25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

import.c 1.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * import libcaca importers test program
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software. It comes without any warranty, to
  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
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #include "common.h"
  16. #if !defined(__KERNEL__)
  17. # if defined(HAVE_INTTYPES_H)
  18. # include <inttypes.h>
  19. # endif
  20. # include <stdio.h>
  21. # include <stdlib.h>
  22. #endif
  23. #include "cucul.h"
  24. #include "caca.h"
  25. int main(int argc, char *argv[])
  26. {
  27. cucul_canvas_t *cv;
  28. caca_display_t *dp;
  29. if(argc < 2)
  30. {
  31. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  32. fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
  33. return 1;
  34. }
  35. cv = cucul_create_canvas(0, 0);
  36. if(cv == NULL)
  37. {
  38. printf("Can't create canvas\n");
  39. return -1;
  40. }
  41. if(cucul_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
  42. {
  43. fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  44. cucul_free_canvas(cv);
  45. return 1;
  46. }
  47. dp = caca_create_display(cv);
  48. if(dp == NULL)
  49. {
  50. printf("Can't create display\n");
  51. return -1;
  52. }
  53. caca_refresh_display(dp);
  54. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  55. caca_free_display(dp);
  56. cucul_free_canvas(cv);
  57. return 0;
  58. }