Ignore:
Timestamp:
Apr 26, 2006, 1:54:26 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Implemented cucul_load_file() and cucul_load_memory() to load respectively a file and a memory area into a libcucul buffer.
  • Changed the cucul_import_canvas() prototype so that it uses libcucul buffers instead of simple memory areas.
Location:
libcaca/trunk/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test

    • Property svn:ignore
      •  

        old new  
        1212gamma
        1313hsv
         14import
        1415spritedit
        1516text
  • libcaca/trunk/test/import.c

    r873 r896  
    2828{
    2929    cucul_canvas_t *cv;
     30    cucul_buffer_t *b;
    3031    caca_display_t *dp;
    31     FILE *fp;
    32     unsigned char *buffer;
    33     int size=0;
    3432
    3533    if(argc < 2)
     
    3937    }
    4038
    41     fp = fopen(argv[1], "rb");
    42 
    43     if(!fp)
     39    b = cucul_load_file(argv[1]);
     40    if(!b)
    4441    {
    4542        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
    4643        return 1;
    4744    }
    48     fseek(fp, 0, SEEK_END);
    49     size = ftell(fp);
    50     fseek(fp, 0, SEEK_SET);
    51     buffer = malloc(sizeof(unsigned char) * size);
    52     if(!buffer)
    53     {
    54         fprintf(stderr, "%s: Can't allocate memory (%d bytes)\n", argv[0], size);
    55         return 1;
    56     }
    5745
    58     if(!fread(buffer, size, 1, fp))
    59     {
    60         fprintf(stderr, "%s: Can't read %s\n", argv[0], argv[1]);
    61         return 1;
    62     }
    63 
    64     cv = cucul_import_canvas(buffer, size, "");
    65 
    66     if(cv == NULL)
     46    cv = cucul_import_canvas(b, "");
     47    if(!cv)
    6748    {
    6849        fprintf(stderr, "%s: Can't load %s, unknow reason.\n", argv[0], argv[1]);
    6950        return 1;
    7051    }
     52
     53    cucul_free_buffer(b);
    7154
    7255    dp = caca_create_display(cv);
  • libcaca/trunk/test/text.c

    r858 r896  
    3737    cucul_buffer_t *buffer;
    3838
    39     cv = cucul_import_canvas(STRING, strlen(STRING), "text");
     39    buffer = cucul_load_memory(STRING, strlen(STRING));
     40    cv = cucul_import_canvas(buffer, "text");
     41    cucul_free_buffer(buffer);
    4042
    4143    buffer = cucul_export_canvas(cv, "ansi");
Note: See TracChangeset for help on using the changeset viewer.