[3264] | 1 | #!/usr/bin/php5 |
---|
| 2 | <?php |
---|
[872] | 3 | /* |
---|
[873] | 4 | * import libcaca importers test program |
---|
[3264] | 5 | * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com> |
---|
| 6 | * |
---|
| 7 | * This file is a Php port of "examples/import.c" |
---|
| 8 | * which is: |
---|
[873] | 9 | * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> |
---|
[872] | 10 | * All Rights Reserved |
---|
| 11 | * |
---|
| 12 | * $Id: import.php 3267 2008-11-04 03:39:20Z bsittler $ |
---|
| 13 | * |
---|
[1462] | 14 | * This program is free software. It comes without any warranty, to |
---|
[1452] | 15 | * the extent permitted by applicable law. You can redistribute it |
---|
| 16 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
| 17 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
[872] | 18 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 19 | */ |
---|
| 20 | |
---|
[3267] | 21 | if (php_sapi_name() != "cli") { |
---|
| 22 | die("You have to run this program with php-cli!\n"); |
---|
| 23 | } |
---|
| 24 | |
---|
[3265] | 25 | $imports = caca_get_import_list(); |
---|
| 26 | |
---|
| 27 | if($argc < 2 || $argc > 3) |
---|
[3264] | 28 | { |
---|
[3265] | 29 | $msg = ($argv[0] . ": wrong argument count\n" . |
---|
| 30 | "usage: " . $argv[0] . " file [<format>]\n" . |
---|
| 31 | "where <format> is one of:\n"); |
---|
| 32 | foreach($imports as $format => $name) |
---|
| 33 | $msg .= " \"" . $name . "\" (" . $format . ")\n"; |
---|
| 34 | die($msg); |
---|
[3264] | 35 | } |
---|
[872] | 36 | |
---|
[3264] | 37 | $cv = caca_create_canvas(0, 0); |
---|
| 38 | if(! $cv) |
---|
| 39 | { |
---|
| 40 | die("Can't create canvas\n"); |
---|
| 41 | } |
---|
[872] | 42 | |
---|
[3264] | 43 | if(caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0) |
---|
| 44 | { |
---|
| 45 | die($argv[0] . ": could not open `" . $argv[1] . "'.\n"); |
---|
| 46 | } |
---|
[872] | 47 | |
---|
[3264] | 48 | $dp = caca_create_display($cv); |
---|
| 49 | if(! $dp) |
---|
[872] | 50 | { |
---|
[3264] | 51 | die("Can't create display\n"); |
---|
| 52 | } |
---|
[872] | 53 | |
---|
[3264] | 54 | caca_refresh_display($dp); |
---|
[872] | 55 | |
---|
[3264] | 56 | caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
---|
[1753] | 57 | |
---|
[3264] | 58 | ?> |
---|