source: libcaca/trunk/caca-php/examples/import.php @ 4333

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
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
19if (php_sapi_name() != "cli") {
20    die("You have to run this program with php-cli!\n");
21}
22
23$imports = caca_get_import_list();
24
25if($argc < 2 || $argc > 3)
26{
27    $msg = ($argv[0] . ": wrong argument count\n" .
28            "usage: " . $argv[0] . " file [<format>]\n" .
29            "where <format> is one of:\n");
30    foreach($imports as $format => $name)
31        $msg .= " \"" . $name . "\" (" . $format . ")\n";
32    die($msg);
33}
34
35$cv = caca_create_canvas(0, 0);
36if(! $cv)
37{
38    die("Can't create canvas\n");
39}
40
41if(caca_import_file($cv, $argv[1], $argc >= 3 ? $argv[2] : "") < 0)
42{
43    die($argv[0] . ": could not open `" . $argv[1] . "'.\n");
44}
45
46$dp = caca_create_display($cv);
47if(! $dp)
48{
49    die("Can't create display\n");
50}
51
52caca_refresh_display($dp);
53
54caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
55
56?>
Note: See TracBrowser for help on using the repository browser.