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

Last change on this file since 2300 was 2299, checked in by Sam Hocevar, 13 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 1.5 KB
RevLine 
[872]1/*
[873]2 *  import        libcaca importers test program
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
[872]4 *                All Rights Reserved
5 *
6 *  $Id: import.c 2299 2008-04-19 12:42:50Z sam $
7 *
[1462]8 *  This program is free software. It comes without any warranty, to
[1452]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
[872]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
16
[1048]17#if !defined(__KERNEL__)
18#   include <stdio.h>
19#   include <stdlib.h>
[872]20#endif
21
22#include "cucul.h"
23#include "caca.h"
24
25int main(int argc, char *argv[])
26{
27    cucul_canvas_t *cv;
28    caca_display_t *dp;
29
30    if(argc < 2)
31    {
32        fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
[1153]33        fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
[872]34        return 1;
35    }
36
[1308]37    cv = cucul_create_canvas(0, 0);
[1753]38    if(cv == NULL)
39    {
40        printf("Can't create canvas\n");
41        return -1;
42    }
43
[1308]44    if(cucul_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
[872]45    {
46        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
[1308]47        cucul_free_canvas(cv);
[872]48        return 1;
49    }
[873]50
[872]51    dp = caca_create_display(cv);
[1753]52    if(dp == NULL)
53    {
54        printf("Can't create display\n");
55        return -1;
56    }
[872]57
58    caca_refresh_display(dp);
59
60    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
61
62    caca_free_display(dp);
63    cucul_free_canvas(cv);
64
65    return 0;
66}
67
Note: See TracBrowser for help on using the repository browser.