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

Last change on this file since 896 was 896, checked in by Sam Hocevar, 15 years ago
  • Implemented cucul_load_file() and cucul_load_memory() to load respectively a file and a memory area into a libcucul buffer.
  • Changed the cucul_import_canvas() prototype so that it uses libcucul buffers instead of simple memory areas.
  • Property svn:keywords set to Id
File size: 1.3 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 896 2006-04-26 11:54:26Z 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#if defined(HAVE_INTTYPES_H)
18#   include <inttypes.h>
19#endif
20
21#include <stdio.h>
22#include <stdlib.h>
23
24#include "cucul.h"
25#include "caca.h"
26
27int main(int argc, char *argv[])
28{
29    cucul_canvas_t *cv;
30    cucul_buffer_t *b;
31    caca_display_t *dp;
32
33    if(argc < 2)
34    {
35        fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
36        return 1;
37    }
38
39    b = cucul_load_file(argv[1]);
40    if(!b)
41    {
42        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
43        return 1;
44    }
45
46    cv = cucul_import_canvas(b, "");
47    if(!cv)
48    {
49        fprintf(stderr, "%s: Can't load %s, unknow reason.\n", argv[0], argv[1]);
50        return 1;
51    }
52
53    cucul_free_buffer(b);
54
55    dp = caca_create_display(cv);
56
57    caca_refresh_display(dp);
58
59    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
60
61    caca_free_display(dp);
62    cucul_free_canvas(cv);
63
64    return 0;
65}
66
Note: See TracBrowser for help on using the repository browser.