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

Last change on this file since 3266 was 3266, checked in by bsittler, 11 years ago

copy import.php to www in preparation for htmlizing

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