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.
 
 
 
 
 
 

72 lines
1.4 KiB

  1. /*
  2. * cacaplay caca file player
  3. * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  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. #include "config.h"
  14. #include "common.h"
  15. #if !defined(__KERNEL__)
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #endif
  19. #include "cucul.h"
  20. #include "caca.h"
  21. int main(int argc, char **argv)
  22. {
  23. caca_event_t ev;
  24. cucul_buffer_t *b;
  25. cucul_canvas_t *cv;
  26. caca_display_t *dp;
  27. if(argc < 2)
  28. {
  29. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  30. return 1;
  31. }
  32. b = cucul_load_file(argv[1]);
  33. if(!b)
  34. {
  35. fprintf(stderr, "%s: could not open %s.\n", argv[0], argv[1]);
  36. return 1;
  37. }
  38. cv = cucul_import_canvas(b, "caca");
  39. if(!cv)
  40. {
  41. fprintf(stderr, "%s: invalid caca file %s.\n", argv[0], argv[1]);
  42. cucul_free_buffer(b);
  43. return 1;
  44. }
  45. cucul_free_buffer(b);
  46. dp = caca_create_display(cv);
  47. caca_refresh_display(dp);
  48. while(caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1))
  49. {
  50. if(ev.data.key.ch == CACA_KEY_ESCAPE)
  51. break;
  52. }
  53. /* Clean up */
  54. caca_free_display(dp);
  55. cucul_free_canvas(cv);
  56. return 0;
  57. }