source: libcaca/trunk/test/import.c @ 1153

Last change on this file since 1153 was 1153, checked in by Sam Hocevar, 16 years ago
  • Added an optional argument to the import test to select import format.
  • 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 *  $Id: import.c 1153 2006-09-30 18:24:10Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "config.h"
15#include "common.h"
16
17
18#if !defined(__KERNEL__)
19#   if defined(HAVE_INTTYPES_H)
20#      include <inttypes.h>
21#   endif
22#   include <stdio.h>
23#   include <stdlib.h>
24#endif
25
26
27#include "cucul.h"
28#include "caca.h"
29
30int main(int argc, char *argv[])
31{
32    cucul_canvas_t *cv;
33    cucul_buffer_t *b;
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    b = cucul_load_file(argv[1]);
44    if(!b)
45    {
46        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
47        return 1;
48    }
49
50    cv = cucul_import_canvas(b, argc >= 3 ? argv[2] : "");
51    if(!cv)
52    {
53        fprintf(stderr, "%s: could not import `%s'.\n", argv[0], argv[1]);
54        return 1;
55    }
56
57    cucul_free_buffer(b);
58
59    dp = caca_create_display(cv);
60
61    caca_refresh_display(dp);
62
63    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
64
65    caca_free_display(dp);
66    cucul_free_canvas(cv);
67
68    return 0;
69}
70
Note: See TracBrowser for help on using the repository browser.