Changeset 777 for libcaca/trunk/src


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.
Location:
libcaca/trunk/src
Files:
8 edited

Legend:

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

    r734 r777  
    4343static caca_t *kk;
    4444static int XSIZ, YSIZ;
    45 static struct cucul_dither *cucul_dither;
     45static cucul_dither_t *cucul_dither;
    4646static char *bitmap;
    4747static int pause = 0;
     
    266266    {
    267267#ifdef LIBCACA
    268       struct caca_event ev;
     268      caca_event_t ev;
    269269      if(caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, 0))
    270270        {
  • libcaca/trunk/src/cacaball.c

    r734 r777  
    4747    float d[METABALLS], di[METABALLS], dj[METABALLS], dk[METABALLS];
    4848    unsigned int x[METABALLS], y[METABALLS];
    49     struct cucul_dither *cucul_dither;
     49    cucul_dither_t *cucul_dither;
    5050    float i = 10.0, j = 17.0, k = 11.0;
    5151    int p, frame = 0, pause = 0;
     
    9393    for(;;)
    9494    {
    95         struct caca_event ev;
     95        caca_event_t ev;
    9696        if(caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, 0))
    9797        {
  • libcaca/trunk/src/cacamoir.c

    r734 r777  
    4040    cucul_t *qq; caca_t *kk;
    4141    unsigned int red[256], green[256], blue[256], alpha[256];
    42     struct cucul_dither *dither;
     42    cucul_dither_t *dither;
    4343    int i, x, y, frame = 0, pause = 0;
    4444
     
    6969    for(;;)
    7070    {
    71         struct caca_event ev;
     71        caca_event_t ev;
    7272        if(caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, 0))
    7373        {
  • libcaca/trunk/src/cacaplas.c

    r769 r777  
    4444    unsigned int red[256], green[256], blue[256], alpha[256];
    4545    double r[3], R[6];
    46     struct cucul_dither *dither;
     46    cucul_dither_t *dither;
    4747    int i, x, y, frame = 0, pause = 0;
    4848
     
    8585    for(;;)
    8686    {
    87         struct caca_event ev;
     87        caca_event_t ev;
    8888        if(caca_get_event(kk, CACA_EVENT_KEY_PRESS, &ev, 0))
    8989        {
  • libcaca/trunk/src/cacaplay.c

    r710 r777  
    2727{
    2828    struct stat statbuf;
    29     struct caca_event ev;
     29    caca_event_t ev;
    3030    cucul_t *qq;
    3131    caca_t *kk;
  • 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;
  • libcaca/trunk/src/cacaview.c

    r769 r777  
    124124    while(!quit)
    125125    {
    126         struct caca_event ev;
     126        caca_event_t ev;
    127127        unsigned int const event_mask = CACA_EVENT_KEY_PRESS
    128128                                      | CACA_EVENT_RESIZE
  • libcaca/trunk/src/img2irc.c

    r757 r777  
    2525    /* libcucul context */
    2626    cucul_t *qq;
    27     struct cucul_buffer *export;
     27    cucul_buffer_t *export;
    2828    struct image *i;
    2929    int cols = 56, lines;
     
    6060
    6161    export = cucul_create_export(qq, "irc");
    62     fwrite(export->data, export->size, 1, stdout);
    63     cucul_free_export(export);
     62    fwrite(cucul_get_buffer_data(export),
     63           cucul_get_buffer_size(export), 1, stdout);
     64    cucul_free_buffer(export);
    6465
    6566    cucul_free(qq);
Note: See TracChangeset for help on using the changeset viewer.