From 665f0c98bfd20d2885759f55e9c749f4e887b501 Mon Sep 17 00:00:00 2001 From: Ben Wiley Sittler Date: Tue, 4 Nov 2008 03:37:12 +0000 Subject: [PATCH] copy import.php to www in preparation for htmlizing --- caca-php/examples/www/import.php | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 caca-php/examples/www/import.php diff --git a/caca-php/examples/www/import.php b/caca-php/examples/www/import.php new file mode 100755 index 0000000..4f0e5be --- /dev/null +++ b/caca-php/examples/www/import.php @@ -0,0 +1,54 @@ +#!/usr/bin/php5 + + * + * This file is a Php port of "examples/import.c" + * which is: + * Copyright (c) 2006 Jean-Yves Lamoureux + * All Rights Reserved + * + * $Id$ + * + * This program is free software. It comes without any warranty, to + * the extent permitted by applicable law. You can redistribute it + * and/or modify it under the terms of the Do What The Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +$imports = caca_get_import_list(); + +if($argc < 2 || $argc > 3) +{ + $msg = ($argv[0] . ": wrong argument count\n" . + "usage: " . $argv[0] . " file []\n" . + "where is one of:\n"); + foreach($imports as $format => $name) + $msg .= " \"" . $name . "\" (" . $format . ")\n"; + die($msg); +} + +$cv = caca_create_canvas(0, 0); +if(! $cv) +{ + die("Can't create canvas\n"); +} + +if(caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0) +{ + die($argv[0] . ": could not open `" . $argv[1] . "'.\n"); +} + +$dp = caca_create_display($cv); +if(! $dp) +{ + die("Can't create display\n"); +} + +caca_refresh_display($dp); + +caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); + +?>