From 62b20bc8d13242a1d2a4e6f04e2c35286644bfa0 Mon Sep 17 00:00:00 2001 From: Ben Wiley Sittler Date: Tue, 4 Nov 2008 03:22:04 +0000 Subject: [PATCH] copy import.c to import.php in preparation for phpizing --- caca-php/examples/import.php | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 caca-php/examples/import.php diff --git a/caca-php/examples/import.php b/caca-php/examples/import.php new file mode 100644 index 0000000..d235f62 --- /dev/null +++ b/caca-php/examples/import.php @@ -0,0 +1,66 @@ +/* + * import libcaca importers test program + * Copyright (c) 2006 Jean-Yves Lamoureux + * All Rights Reserved + * + * $Id$ + * + * This program is free software. It comes without any warranty, to + * the extent permitted by applicable law. You can redistribute it + * and/or modify it under the terms of the Do What The Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +#include "config.h" + +#if !defined(__KERNEL__) +# include +# include +#endif + +#include "caca.h" + +int main(int argc, char *argv[]) +{ + caca_canvas_t *cv; + caca_display_t *dp; + + if(argc < 2) + { + fprintf(stderr, "%s: missing argument (filename).\n", argv[0]); + fprintf(stderr, "usage: %s []\n", argv[0]); + return 1; + } + + cv = caca_create_canvas(0, 0); + if(cv == NULL) + { + printf("Can't create canvas\n"); + return -1; + } + + if(caca_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0) + { + fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); + caca_free_canvas(cv); + return 1; + } + + dp = caca_create_display(cv); + if(dp == NULL) + { + printf("Can't create display\n"); + return -1; + } + + caca_refresh_display(dp); + + caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); + + caca_free_display(dp); + caca_free_canvas(cv); + + return 0; +} +