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.
 
 
 
 
 
 

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