Ignore:
Timestamp:
Apr 16, 2006, 8:28:47 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Replaced "struct cucul_*" and "struct caca_*" types with opaque typedefs such as cucul_dither_t instead of struct cucul_dither.
  • Made cucul_buffer_t an opaque structure and implemented the two getters cucul_get_buffer_data() and cucul_get_buffer_size().
  • Documented all missing functions and function parameters.
File:
1 edited

Legend:

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

    r769 r777  
    106106
    107107    cucul_t *qq;
    108     struct cucul_buffer *ex;
     108    cucul_buffer_t *buffer;
     109    unsigned long int buflen;
     110    void *bufdata;
    109111
    110112    int client_count;
     
    184186
    185187    server->qq = NULL;
    186     server->ex = NULL;
     188    server->buffer = NULL;
    187189
    188190    /* Ignore SIGPIPE */
     
    231233
    232234        /* Free the previous export buffer, if any */
    233         if(server->ex)
    234         {
    235             cucul_free_export(server->ex);
    236             server->ex = NULL;
     235        if(server->buffer)
     236        {
     237            cucul_free_buffer(server->buffer);
     238            server->buffer = NULL;
    237239        }
    238240
    239241        /* Get ANSI representation of the image and skip the end-of buffer
    240242         * linefeed ("\r\n\0", 3 bytes) */
    241         server->ex = cucul_create_export(server->qq, "ansi");
    242         server->ex->size -= 3;
     243        server->buffer = cucul_create_export(server->qq, "ansi");
     244        server->buflen -= 3;
    243245
    244246        for(i = 0; i < server->client_count; i++)
     
    267269    }
    268270
    269     if(server->ex)
    270         cucul_free_export(server->ex);
     271    if(server->buffer)
     272        cucul_free_buffer(server->buffer);
    271273
    272274    /* Restore SIGPIPE handler */
     
    396398
    397399    /* No error, there's just nothing to send yet */
    398     if(!server->ex)
     400    if(!server->buffer)
    399401        return 0;
    400402
     
    421423            c->start += ret;
    422424
    423             if(c->stop - c->start + strlen(ANSI_PREFIX) + server->ex->size
     425            if(c->stop - c->start + strlen(ANSI_PREFIX) + server->buflen
    424426                > OUTBUFFER)
    425427            {
     
    432434
    433435            /* Need to move? */
    434             if(c->stop + strlen(ANSI_PREFIX) + server->ex->size > OUTBUFFER)
     436            if(c->stop + strlen(ANSI_PREFIX) + server->buflen > OUTBUFFER)
    435437            {
    436438                memmove(c->outbuf, c->outbuf + c->start, c->stop - c->start);
     
    441443            memcpy(c->outbuf + c->stop, ANSI_PREFIX, strlen(ANSI_PREFIX));
    442444            c->stop += strlen(ANSI_PREFIX);
    443             memcpy(c->outbuf + c->stop, server->ex->data, server->ex->size);
    444             c->stop += server->ex->size;
     445            memcpy(c->outbuf + c->stop, server->bufdata, server->buflen);
     446            c->stop += server->buflen;
    445447
    446448            return 0;
     
    462464    if(ret < (ssize_t)strlen(ANSI_PREFIX))
    463465    {
    464         if(strlen(ANSI_PREFIX) + server->ex->size > OUTBUFFER)
     466        if(strlen(ANSI_PREFIX) + server->buflen > OUTBUFFER)
    465467        {
    466468            /* Overflow! Empty buffer and start again */
     
    473475        memcpy(c->outbuf, ANSI_PREFIX, strlen(ANSI_PREFIX) - ret);
    474476        c->stop = strlen(ANSI_PREFIX) - ret;
    475         memcpy(c->outbuf + c->stop, server->ex->data, server->ex->size);
    476         c->stop += server->ex->size;
     477        memcpy(c->outbuf + c->stop, server->bufdata, server->buflen);
     478        c->stop += server->buflen;
    477479
    478480        return 0;
     
    480482
    481483    /* Send actual data */
    482     ret = nonblock_write(c->fd, server->ex->data, server->ex->size);
     484    ret = nonblock_write(c->fd, server->bufdata, server->buflen);
    483485    if(ret == -1)
    484486    {
     
    489491    }
    490492
    491     if(ret < (int)server->ex->size)
    492     {
    493         if(server->ex->size > OUTBUFFER)
     493    if(ret < (int)server->buflen)
     494    {
     495        if(server->buflen > OUTBUFFER)
    494496        {
    495497            /* Overflow! Empty buffer and start again */
     
    500502        }
    501503
    502         memcpy(c->outbuf, server->ex->data, server->ex->size - ret);
    503         c->stop = server->ex->size - ret;
     504        memcpy(c->outbuf, server->bufdata, server->buflen - ret);
     505        c->stop = server->buflen - ret;
    504506
    505507        return 0;
Note: See TracChangeset for help on using the changeset viewer.