source: libcaca/trunk/examples/import.c @ 2101

Last change on this file since 2101 was 2101, checked in by Sam Hocevar, 12 years ago
  • Rename "test" to "examples". The former will become a real testsuite.
  • Autodetect zzuf in the configure step. It might become handy.
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/*
2 *  import        libcaca importers test program
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  $Id: import.c 2101 2007-11-30 23:48:39Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
16#include "common.h"
17
18
19#if !defined(__KERNEL__)
20#   if defined(HAVE_INTTYPES_H)
21#      include <inttypes.h>
22#   endif
23#   include <stdio.h>
24#   include <stdlib.h>
25#endif
26
27
28#include "cucul.h"
29#include "caca.h"
30
31int main(int argc, char *argv[])
32{
33    cucul_canvas_t *cv;
34    caca_display_t *dp;
35
36    if(argc < 2)
37    {
38        fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
39        fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
40        return 1;
41    }
42
43    cv = cucul_create_canvas(0, 0);
44    if(cv == NULL)
45    {
46        printf("Can't create canvas\n");
47        return -1;
48    }
49
50    if(cucul_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
51    {
52        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
53        cucul_free_canvas(cv);
54        return 1;
55    }
56
57    dp = caca_create_display(cv);
58    if(dp == NULL)
59    {
60        printf("Can't create display\n");
61        return -1;
62    }
63
64    caca_refresh_display(dp);
65
66    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
67
68    caca_free_display(dp);
69    cucul_free_canvas(cv);
70
71    return 0;
72}
73
Note: See TracBrowser for help on using the repository browser.