Ignore:
Timestamp:
Nov 5, 2006, 11:20:51 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Updated the caca export format so that it supports multiple frames.
  • Updated the caca importer to reflect that; only one frame is read at the moment.
  • Added an "utf8cr" export format for UTF-8 + CRLF exports.
  • Updated cacaserver to reflect file format changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/cacaserver.c

    r950 r1283  
    143143    server = malloc(sizeof(struct server));
    144144
    145     server->input = malloc(16);
     145    server->input = malloc(12);
    146146    server->read = 0;
    147147
     
    207207        cucul_buffer_t *b;
    208208        uint8_t *buf = server->input;
    209         uint32_t width, height;
     209        uint32_t control_size, data_size;
    210210        unsigned int size;
    211211
     
    215215
    216216        /* Read data from stdin */
    217         read(0, buf, 16);
    218 
    219         while(buf[0] != 'C' || buf[1] != 'A' || buf[2] != 'C' || buf[3] != 'A')
    220         {
    221             memmove(buf, buf + 1, 15);
    222             read(0, buf + 15, 1);
    223         }
    224 
    225         width = ((uint32_t)buf[8] << 24) | ((uint32_t)buf[9] << 16)
     217        read(0, buf, 12);
     218
     219        while(buf[0] != 0xca || buf[1] != 0xca
     220               || buf[2] != 'C' || buf[3] != 'V')
     221        {
     222            memmove(buf, buf + 1, 11);
     223            read(0, buf + 11, 1);
     224        }
     225
     226        control_size = ((uint32_t)buf[4] << 24) | ((uint32_t)buf[5] << 16)
     227               | ((uint32_t)buf[6] << 8) | (uint32_t)buf[7];
     228        data_size = ((uint32_t)buf[8] << 24) | ((uint32_t)buf[9] << 16)
    226229               | ((uint32_t)buf[10] << 8) | (uint32_t)buf[11];
    227         height = ((uint32_t)buf[12] << 24) | ((uint32_t)buf[13] << 16)
    228                 | ((uint32_t)buf[14] << 8) | (uint32_t)buf[15];
    229 
    230         size = 16 + width * height * 8;
     230
     231        size = 4 + control_size + data_size;
    231232        buf = server->input = realloc(server->input, size);
    232         read(0, buf + 16, size - 16);
     233        read(0, buf + 12, size - 12);
    233234
    234235        /* Free the previous canvas, if any */
     
    251252
    252253        /* Get ANSI representation of the image and skip the end-of buffer
    253          * linefeed ("\r\n", 2 bytes) */
    254         server->buffer = cucul_export_canvas(server->canvas, "utf8");
     254         * linefeed ("\r\n", 2 byte) */
     255        server->buffer = cucul_export_canvas(server->canvas, "utf8cr");
    255256        server->bufdata = cucul_get_buffer_data(server->buffer);
    256257        server->buflen = cucul_get_buffer_size(server->buffer);
Note: See TracChangeset for help on using the changeset viewer.