Changeset 757


Ignore:
Timestamp:
Apr 13, 2006, 2:50:41 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Renamed cucul_export into cucul_buffer. We'll use it for other things.
Location:
libcaca/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/cucul.c

    r734 r757  
    225225}
    226226
    227 struct cucul_export * cucul_create_export(cucul_t *qq, char const *format)
    228 {
    229     struct cucul_export *ex;
    230 
    231     ex = malloc(sizeof(struct cucul_export));
     227struct cucul_buffer * cucul_create_export(cucul_t *qq, char const *format)
     228{
     229    struct cucul_buffer *ex;
     230
     231    ex = malloc(sizeof(struct cucul_buffer));
    232232
    233233    if(!strcasecmp("ansi", format))
     
    257257 * Return a list of available export formats. The list is a NULL-terminated
    258258 * array of strings, interleaving a string containing the internal value for
    259  * the export format, to be used with \e cucul_export(), and a string
     259 * the export format, to be used with \e cucul_create_export(), and a string
    260260 * containing the natural language description for that export format.
    261261 *
     
    278278}
    279279
    280 void cucul_free_export(struct cucul_export *ex)
    281 {
    282     free(ex->buffer);
     280void cucul_free_export(struct cucul_buffer *ex)
     281{
     282    free(ex->data);
    283283    free(ex);
    284284}
  • libcaca/trunk/cucul/cucul.h

    r746 r757  
    3030
    3131typedef struct cucul_context cucul_t;
     32
     33struct cucul_buffer
     34{
     35    unsigned int size;
     36    char *data;
     37};
    3238
    3339/** \defgroup colour Colour definitions
     
    195201 *
    196202 *  @{ */
    197 struct cucul_export
    198 {
    199     unsigned int size;
    200     char *buffer;
    201 };
    202 
    203 struct cucul_export * cucul_create_export(cucul_t *, char const *);
     203struct cucul_buffer * cucul_create_export(cucul_t *, char const *);
    204204char const * const * cucul_get_export_list(void);
    205 void cucul_free_export(struct cucul_export *);
     205void cucul_free_export(struct cucul_buffer *);
    206206/*  @} */
    207207
  • libcaca/trunk/cucul/cucul_internals.h

    r753 r757  
    6969
    7070/* Export functions */
    71 extern void _cucul_get_ansi(cucul_t *, struct cucul_export *);
    72 extern void _cucul_get_html(cucul_t *, struct cucul_export *);
    73 extern void _cucul_get_html3(cucul_t *, struct cucul_export *);
    74 extern void _cucul_get_irc(cucul_t *, struct cucul_export *);
    75 extern void _cucul_get_ps(cucul_t *, struct cucul_export *);
    76 extern void _cucul_get_svg(cucul_t *, struct cucul_export *);
     71extern void _cucul_get_ansi(cucul_t *, struct cucul_buffer *);
     72extern void _cucul_get_html(cucul_t *, struct cucul_buffer *);
     73extern void _cucul_get_html3(cucul_t *, struct cucul_buffer *);
     74extern void _cucul_get_irc(cucul_t *, struct cucul_buffer *);
     75extern void _cucul_get_ps(cucul_t *, struct cucul_buffer *);
     76extern void _cucul_get_svg(cucul_t *, struct cucul_buffer *);
    7777
    7878#endif /* __CUCUL_INTERNALS_H__ */
  • libcaca/trunk/cucul/export_ansi.c

    r738 r757  
    3838 *  \return buffer containing generated ANSI codes as a big string
    3939 */
    40 void _cucul_get_ansi(cucul_t *qq, struct cucul_export *ex)
     40void _cucul_get_ansi(cucul_t *qq, struct cucul_buffer *ex)
    4141{
    4242    static int const palette[] =
     
    5353     * Add height*9 to that (zeroes color at the end and jump to next line) */
    5454    ex->size = (qq->height * 9) + (qq->width * qq->height * 23);
    55     ex->buffer = malloc(ex->size);
     55    ex->data = malloc(ex->size);
    5656
    57     cur = ex->buffer;
     57    cur = ex->data;
    5858
    5959    for(y = 0; y < qq->height; y++)
     
    100100
    101101    /* Crop to really used size */
    102     ex->size = (uintptr_t)(cur - ex->buffer);
    103     ex->buffer = realloc(ex->buffer, ex->size);
     102    ex->size = (uintptr_t)(cur - ex->data);
     103    ex->data = realloc(ex->data, ex->size);
    104104}
    105105
  • libcaca/trunk/cucul/export_html.c

    r738 r757  
    3535 *  the current image.
    3636 */
    37 void _cucul_get_html(cucul_t *qq, struct cucul_export *ex)
     37void _cucul_get_html(cucul_t *qq, struct cucul_buffer *ex)
    3838{
    3939    static int const palette[] =
     
    5151     *          7 chars for "</span>" */
    5252    ex->size = 13000 + qq->height * (7 + qq->width * (18 + 9 + 7));
    53     ex->buffer = malloc(ex->size);
     53    ex->data = malloc(ex->size);
    5454
    55     cur = ex->buffer;
     55    cur = ex->data;
    5656
    5757    /* HTML header */
     
    101101
    102102    /* Crop to really used size */
    103     ex->size = strlen(ex->buffer) + 1;
    104     ex->buffer = realloc(ex->buffer, ex->size);
     103    ex->size = strlen(ex->data) + 1;
     104    ex->data = realloc(ex->data, ex->size);
    105105}
    106106
     
    114114 *  a correct header.
    115115 */
    116 void _cucul_get_html3(cucul_t *qq, struct cucul_export *ex)
     116void _cucul_get_html3(cucul_t *qq, struct cucul_buffer *ex)
    117117{
    118118    static int const palette[] =
     
    133133     *          12 chars for "</font></td>" */
    134134    ex->size = 13000 + qq->height * (10 + qq->width * (40 + 9 + 12));
    135     ex->buffer = malloc(ex->size);
     135    ex->data = malloc(ex->size);
    136136
    137     cur = ex->buffer;
     137    cur = ex->data;
    138138
    139139    /* Table */
     
    186186
    187187    /* Crop to really used size */
    188     ex->size = (uintptr_t)(cur - ex->buffer);
    189     ex->buffer = realloc(ex->buffer, ex->size);
     188    ex->size = (uintptr_t)(cur - ex->data);
     189    ex->data = realloc(ex->data, ex->size);
    190190}
    191191
  • libcaca/trunk/cucul/export_irc.c

    r738 r757  
    3535 *  the current image.
    3636 */
    37 void _cucul_get_irc(cucul_t *qq, struct cucul_export *ex)
     37void _cucul_get_irc(cucul_t *qq, struct cucul_buffer *ex)
    3838{
    3939    static int const palette[] =
     
    5555
    5656    ex->size = 2 + (qq->width * qq->height * 11);
    57     ex->buffer = malloc(ex->size);
     57    ex->data = malloc(ex->size);
    5858
    59     cur = ex->buffer;
     59    cur = ex->data;
    6060
    6161    for(y = 0; y < qq->height; y++)
     
    105105
    106106    /* Crop to really used size */
    107     ex->size = (uintptr_t)(cur - ex->buffer);
    108     ex->buffer = realloc(ex->buffer, ex->size);
     107    ex->size = (uintptr_t)(cur - ex->data);
     108    ex->data = realloc(ex->data, ex->size);
    109109}
  • libcaca/trunk/cucul/export_ps.c

    r738 r757  
    6060 *  the current image.
    6161 */
    62 void _cucul_get_ps(cucul_t *qq, struct cucul_export *ex)
     62void _cucul_get_ps(cucul_t *qq, struct cucul_buffer *ex)
    6363{
    6464    static char const * const palette[] =
     
    7676    /* 200 is arbitrary but should be ok */
    7777    ex->size = strlen(ps_header) + (qq->width * qq->height * 200);
    78     ex->buffer = malloc(ex->size);
     78    ex->data = malloc(ex->size);
    7979
    80     cur = ex->buffer;
     80    cur = ex->data;
    8181
    8282    /* Header */
     
    135135
    136136    /* Crop to really used size */
    137     ex->size = (uintptr_t)(cur - ex->buffer);
    138     ex->buffer = realloc(ex->buffer, ex->size);
     137    ex->size = (uintptr_t)(cur - ex->data);
     138    ex->data = realloc(ex->data, ex->size);
    139139}
    140140
  • libcaca/trunk/cucul/export_svg.c

    r738 r757  
    4545 *  the current image.
    4646 */
    47 void _cucul_get_svg(cucul_t *qq, struct cucul_export *ex)
     47void _cucul_get_svg(cucul_t *qq, struct cucul_buffer *ex)
    4848{
    4949    static int const palette[] =
     
    6060    /* 200 is arbitrary but should be ok */
    6161    ex->size = strlen(svg_header) + (qq->width * qq->height * 200);
    62     ex->buffer = malloc(ex->size);
     62    ex->data = malloc(ex->size);
    6363
    64     cur = ex->buffer;
     64    cur = ex->data;
    6565
    6666    /* Header */
     
    147147
    148148    /* Crop to really used size */
    149     ex->size = (uintptr_t)(cur - ex->buffer);
    150     ex->buffer = realloc(ex->buffer, ex->size);
     149    ex->size = (uintptr_t)(cur - ex->data);
     150    ex->data = realloc(ex->data, ex->size);
    151151}
    152152
  • libcaca/trunk/src/cacaserver.c

    r724 r757  
    104104
    105105    cucul_t *qq;
    106     struct cucul_export *ex;
     106    struct cucul_buffer *ex;
    107107
    108108    int client_count;
     
    439439            memcpy(c->outbuf + c->stop, ANSI_PREFIX, strlen(ANSI_PREFIX));
    440440            c->stop += strlen(ANSI_PREFIX);
    441             memcpy(c->outbuf + c->stop, server->ex->buffer, server->ex->size);
     441            memcpy(c->outbuf + c->stop, server->ex->data, server->ex->size);
    442442            c->stop += server->ex->size;
    443443
     
    471471        memcpy(c->outbuf, ANSI_PREFIX, strlen(ANSI_PREFIX) - ret);
    472472        c->stop = strlen(ANSI_PREFIX) - ret;
    473         memcpy(c->outbuf + c->stop, server->ex->buffer, server->ex->size);
     473        memcpy(c->outbuf + c->stop, server->ex->data, server->ex->size);
    474474        c->stop += server->ex->size;
    475475
     
    478478
    479479    /* Send actual data */
    480     ret = nonblock_write(c->fd, server->ex->buffer, server->ex->size);
     480    ret = nonblock_write(c->fd, server->ex->data, server->ex->size);
    481481    if(ret == -1)
    482482    {
     
    498498        }
    499499
    500         memcpy(c->outbuf, server->ex->buffer, server->ex->size - ret);
     500        memcpy(c->outbuf, server->ex->data, server->ex->size - ret);
    501501        c->stop = server->ex->size - ret;
    502502
  • libcaca/trunk/src/img2irc.c

    r739 r757  
    2525    /* libcucul context */
    2626    cucul_t *qq;
    27     struct cucul_export *export;
     27    struct cucul_buffer *export;
    2828    struct image *i;
    2929    int cols = 56, lines;
     
    6060
    6161    export = cucul_create_export(qq, "irc");
    62     fwrite(export->buffer, export->size, 1, stdout);
     62    fwrite(export->data, export->size, 1, stdout);
    6363    cucul_free_export(export);
    6464
  • libcaca/trunk/test/export.c

    r749 r757  
    3737    cucul_t *qq;
    3838    struct cucul_dither *dither;
    39     struct cucul_export *buffer;
     39    struct cucul_buffer *buffer;
    4040    int x, y;
    4141
     
    9191
    9292    buffer = cucul_create_export(qq, argv[1]);
    93     fwrite(buffer->buffer, buffer->size, 1, stdout);
     93    fwrite(buffer->data, buffer->size, 1, stdout);
    9494    cucul_free_export(buffer);
    9595
Note: See TracChangeset for help on using the changeset viewer.