You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/php5
  2. <?php
  3. /*
  4. * import libcaca importers test program
  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:
  9. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  10. * All Rights Reserved
  11. *
  12. * $Id$
  13. *
  14. * This program is free software. It comes without any warranty, to
  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
  18. * http://sam.zoy.org/wtfpl/COPYING for more details.
  19. */
  20. if (php_sapi_name() != "cli") {
  21. die("You have to run this program with php-cli!\n");
  22. }
  23. $imports = caca_get_import_list();
  24. if($argc < 2 || $argc > 3)
  25. {
  26. $msg = ($argv[0] . ": wrong argument count\n" .
  27. "usage: " . $argv[0] . " file [<format>]\n" .
  28. "where <format> is one of:\n");
  29. foreach($imports as $format => $name)
  30. $msg .= " \"" . $name . "\" (" . $format . ")\n";
  31. die($msg);
  32. }
  33. $cv = caca_create_canvas(0, 0);
  34. if(! $cv)
  35. {
  36. die("Can't create canvas\n");
  37. }
  38. if(caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0)
  39. {
  40. die($argv[0] . ": could not open `" . $argv[1] . "'.\n");
  41. }
  42. $dp = caca_create_display($cv);
  43. if(! $dp)
  44. {
  45. die("Can't create display\n");
  46. }
  47. caca_refresh_display($dp);
  48. caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
  49. ?>