Last change
on this file since 1042 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.4 KB
|
Line | |
---|
1 | /* |
---|
2 | * cacaplay caca file player |
---|
3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: cacaplay.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 | #include <stdio.h> |
---|
18 | #include <stdlib.h> |
---|
19 | |
---|
20 | #include "cucul.h" |
---|
21 | #include "caca.h" |
---|
22 | |
---|
23 | int main(int argc, char **argv) |
---|
24 | { |
---|
25 | caca_event_t ev; |
---|
26 | cucul_buffer_t *b; |
---|
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]); |
---|
33 | return 1; |
---|
34 | } |
---|
35 | |
---|
36 | b = cucul_load_file(argv[1]); |
---|
37 | if(!b) |
---|
38 | { |
---|
39 | fprintf(stderr, "%s: could not open %s.\n", argv[0], argv[1]); |
---|
40 | return 1; |
---|
41 | } |
---|
42 | |
---|
43 | cv = cucul_import_canvas(b, "caca"); |
---|
44 | if(!cv) |
---|
45 | { |
---|
46 | fprintf(stderr, "%s: invalid caca file %s.\n", argv[0], argv[1]); |
---|
47 | cucul_free_buffer(b); |
---|
48 | return 1; |
---|
49 | } |
---|
50 | |
---|
51 | cucul_free_buffer(b); |
---|
52 | |
---|
53 | dp = caca_create_display(cv); |
---|
54 | |
---|
55 | caca_refresh_display(dp); |
---|
56 | |
---|
57 | while(caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1)) |
---|
58 | { |
---|
59 | if(ev.data.key.ch == CACA_KEY_ESCAPE) |
---|
60 | break; |
---|
61 | } |
---|
62 | |
---|
63 | /* Clean up */ |
---|
64 | caca_free_display(dp); |
---|
65 | cucul_free_canvas(cv); |
---|
66 | |
---|
67 | return 0; |
---|
68 | } |
---|
69 | |
---|
Note: See
TracBrowser
for help on using the repository browser.