Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

57 řádky
1.4 KiB

  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. * This program is free software. It comes without any warranty, to
  13. * the extent permitted by applicable law. You can redistribute it
  14. * and/or modify it under the terms of the Do What The Fuck You Want
  15. * To Public License, Version 2, as published by Sam Hocevar. See
  16. * http://sam.zoy.org/wtfpl/COPYING for more details.
  17. */
  18. if (php_sapi_name() != "cli") {
  19. die("You have to run this program with php-cli!\n");
  20. }
  21. $imports = caca_get_import_list();
  22. if($argc < 2 || $argc > 3)
  23. {
  24. $msg = ($argv[0] . ": wrong argument count\n" .
  25. "usage: " . $argv[0] . " file [<format>]\n" .
  26. "where <format> is one of:\n");
  27. foreach($imports as $format => $name)
  28. $msg .= " \"" . $name . "\" (" . $format . ")\n";
  29. die($msg);
  30. }
  31. $cv = caca_create_canvas(0, 0);
  32. if(! $cv)
  33. {
  34. die("Can't create canvas\n");
  35. }
  36. if(caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0)
  37. {
  38. die($argv[0] . ": could not open `" . $argv[1] . "'.\n");
  39. }
  40. $dp = caca_create_display($cv);
  41. if(! $dp)
  42. {
  43. die("Can't create display\n");
  44. }
  45. caca_refresh_display($dp);
  46. caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
  47. ?>