[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 2821 2008-09-27 13:12:46Z 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 "caca.h" |
---|
| 23 | |
---|
| 24 | int main(int argc, char *argv[]) |
---|
| 25 | { |
---|
[2821] | 26 | caca_canvas_t *cv; |
---|
[872] | 27 | caca_display_t *dp; |
---|
| 28 | |
---|
| 29 | if(argc < 2) |
---|
| 30 | { |
---|
| 31 | fprintf(stderr, "%s: missing argument (filename).\n", argv[0]); |
---|
[1153] | 32 | fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]); |
---|
[872] | 33 | return 1; |
---|
| 34 | } |
---|
| 35 | |
---|
[2821] | 36 | cv = caca_create_canvas(0, 0); |
---|
[1753] | 37 | if(cv == NULL) |
---|
| 38 | { |
---|
| 39 | printf("Can't create canvas\n"); |
---|
| 40 | return -1; |
---|
| 41 | } |
---|
| 42 | |
---|
[2821] | 43 | if(caca_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0) |
---|
[872] | 44 | { |
---|
| 45 | fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); |
---|
[2821] | 46 | caca_free_canvas(cv); |
---|
[872] | 47 | return 1; |
---|
| 48 | } |
---|
[873] | 49 | |
---|
[872] | 50 | dp = caca_create_display(cv); |
---|
[1753] | 51 | if(dp == NULL) |
---|
| 52 | { |
---|
| 53 | printf("Can't create display\n"); |
---|
| 54 | return -1; |
---|
| 55 | } |
---|
[872] | 56 | |
---|
| 57 | caca_refresh_display(dp); |
---|
| 58 | |
---|
| 59 | caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); |
---|
| 60 | |
---|
| 61 | caca_free_display(dp); |
---|
[2821] | 62 | caca_free_canvas(cv); |
---|
[872] | 63 | |
---|
| 64 | return 0; |
---|
| 65 | } |
---|
| 66 | |
---|