You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

import.c 1.5 KiB

18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
18 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. # include <stdlib.h>
  18. #endif
  19. #include "caca.h"
  20. int main(int argc, char *argv[])
  21. {
  22. caca_canvas_t *cv;
  23. caca_display_t *dp;
  24. if(argc < 2)
  25. {
  26. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  27. fprintf(stderr, "usage: %s <filename> [<format>]\n", argv[0]);
  28. return 1;
  29. }
  30. cv = caca_create_canvas(0, 0);
  31. if(cv == NULL)
  32. {
  33. printf("Can't create canvas\n");
  34. return -1;
  35. }
  36. if(caca_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
  37. {
  38. fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  39. caca_free_canvas(cv);
  40. return 1;
  41. }
  42. dp = caca_create_display(cv);
  43. if(dp == NULL)
  44. {
  45. printf("Can't create display\n");
  46. return -1;
  47. }
  48. caca_refresh_display(dp);
  49. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  50. caca_free_display(dp);
  51. caca_free_canvas(cv);
  52. return 0;
  53. }