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.

преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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; 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(HAVE_INTTYPES_H)
  16. # include <inttypes.h>
  17. #endif
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include "cucul.h"
  21. #include "caca.h"
  22. int main(int argc, char *argv[])
  23. {
  24. cucul_canvas_t *cv;
  25. caca_display_t *dp;
  26. FILE *fp;
  27. unsigned char *buffer;
  28. int size=0;
  29. if(argc < 2)
  30. {
  31. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  32. return 1;
  33. }
  34. fp = fopen(argv[1], "rb");
  35. if(!fp)
  36. {
  37. fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  38. return 1;
  39. }
  40. fseek(fp, 0, SEEK_END);
  41. size = ftell(fp);
  42. fseek(fp, 0, SEEK_SET);
  43. buffer = malloc(sizeof(unsigned char) * size);
  44. if(!buffer)
  45. {
  46. fprintf(stderr, "%s: Can't allocate memory (%d bytes)\n", argv[0], size);
  47. return 1;
  48. }
  49. if(!fread(buffer, size, 1, fp))
  50. {
  51. fprintf(stderr, "%s: Can't read %s\n", argv[0], argv[1]);
  52. return 1;
  53. }
  54. cv = cucul_import_canvas(buffer, size, "");
  55. if(cv == NULL)
  56. {
  57. fprintf(stderr, "%s: Can't load %s, unknow reason.\n", argv[0], argv[1]);
  58. return 1;
  59. }
  60. dp = caca_create_display(cv);
  61. caca_refresh_display(dp);
  62. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  63. caca_free_display(dp);
  64. cucul_free_canvas(cv);
  65. return 0;
  66. }