source: libcaca/trunk/examples/import.c @ 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:keywords set to Id
File size: 1.5 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 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#include "config.h"
14
15#if !defined(__KERNEL__)
16#   include <stdio.h>
17#   include <stdlib.h>
18#endif
19
20#include "caca.h"
21
22int main(int argc, char *argv[])
23{
24    caca_canvas_t *cv;
25    caca_display_t *dp;
26
27    if(argc < 2)
28    {
29        fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
30        fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
31        return 1;
32    }
33
34    cv = caca_create_canvas(0, 0);
35    if(cv == NULL)
36    {
37        printf("Can't create canvas\n");
38        return -1;
39    }
40
41    if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
42    {
43        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
44        caca_free_canvas(cv);
45        return 1;
46    }
47
48    dp = caca_create_display(cv);
49    if(dp == NULL)
50    {
51        printf("Can't create display\n");
52        return -1;
53    }
54
55    caca_refresh_display(dp);
56
57    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
58
59    caca_free_display(dp);
60    caca_free_canvas(cv);
61
62    return 0;
63}
64
Note: See TracBrowser for help on using the repository browser.