Ignore:
Timestamp:
Sep 27, 2008, 3:12:46 PM (12 years ago)
Author:
Sam Hocevar
Message:

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/legacy.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2626#endif
    2727
    28 #include "cucul.h"
    29 #include "cucul_internals.h"
     28#include "caca.h"
     29#include "caca_internals.h"
     30
     31struct cucul_buffer
     32{
     33    size_t size;
     34    char *data;
     35    int user_data;
     36};
    3037
    3138/*
     
    3542int cucul_putchar(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
    3643{
    37     return cucul_put_char(cv, x, y, ch);
     44    return caca_put_char(cv, x, y, ch);
    3845}
    3946
    4047unsigned long int cucul_getchar(cucul_canvas_t *cv, int x, int y)
    4148{
    42     return cucul_get_char(cv, x, y);
     49    return caca_get_char(cv, x, y);
    4350}
    4451
    4552int cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
    4653{
    47     return cucul_put_str(cv, x, y, s);
     54    return caca_put_str(cv, x, y, s);
    4855}
    4956
     
    5461int cucul_set_color(cucul_canvas_t *cv, unsigned char fg, unsigned char bg)
    5562{
    56     return cucul_set_color_ansi(cv, fg, bg);
     63    return caca_set_color_ansi(cv, fg, bg);
    5764}
    5865
    5966int cucul_set_truecolor(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
    6067{
    61     return cucul_set_color_argb(cv, fg, bg);
     68    return caca_set_color_argb(cv, fg, bg);
    6269}
    6370
     
    6774int cucul_set_dither_invert(cucul_dither_t *d, int value)
    6875{
    69     float gamma = cucul_get_dither_gamma(d);
     76    float gamma = caca_get_dither_gamma(d);
    7077
    7178    if(gamma * (value ? -1 : 1) < 0)
    72         cucul_set_dither_gamma(d, -gamma);
     79        caca_set_dither_gamma(d, -gamma);
    7380
    7481    return 0;
     
    7784int cucul_set_dither_mode(cucul_dither_t *d, char const *s)
    7885{
    79     return cucul_set_dither_algorithm(d, s);
     86    return caca_set_dither_algorithm(d, s);
    8087}
    8188
    8289char const * const * cucul_get_dither_mode_list(cucul_dither_t const *d)
    8390{
    84     return cucul_get_dither_algorithm_list(d);
     91    return caca_get_dither_algorithm_list(d);
    8592}
    8693
     
    9198cucul_canvas_t * cucul_import_canvas(cucul_buffer_t *buf, char const *format)
    9299{
    93     cucul_canvas_t *cv = cucul_create_canvas(0, 0);
    94     int ret = cucul_import_memory(cv, (unsigned char const *)buf->data,
     100    caca_canvas_t *cv = caca_create_canvas(0, 0);
     101    int ret = caca_import_memory(cv, (unsigned char const *)buf->data,
    95102                                  buf->size, format);
    96103    if(ret < 0)
    97104    {
    98         cucul_free_canvas(cv);
     105        caca_free_canvas(cv);
    99106        return NULL;
    100107    }
     
    118125    }
    119126
    120     ex->data = cucul_export_memory(cv, format, &ex->size);
     127    ex->data = caca_export_memory(cv, format, &ex->size);
    121128    if(!ex->data)
    122129    {
     
    136143unsigned int cucul_get_canvas_frame_count(cucul_canvas_t *cv)
    137144{
    138     return cucul_get_frame_count(cv);
     145    return caca_get_frame_count(cv);
    139146}
    140147
    141148int cucul_set_canvas_frame(cucul_canvas_t *cv, unsigned int id)
    142149{
    143     return cucul_set_frame(cv, id);
     150    return caca_set_frame(cv, id);
    144151}
    145152
    146153int cucul_create_canvas_frame(cucul_canvas_t *cv, unsigned int id)
    147154{
    148     return cucul_create_frame(cv, id);
     155    return caca_create_frame(cv, id);
    149156}
    150157
    151158int cucul_free_canvas_frame(cucul_canvas_t *cv, unsigned int id)
    152159{
    153     return cucul_free_frame(cv, id);
     160    return caca_free_frame(cv, id);
    154161}
    155162
     
    176183{
    177184    cucul_buffer_t *buf;
    178     cucul_file_t *f;
     185    caca_file_t *f;
    179186    int ret;
    180187
    181     f = cucul_file_open(file, "rb");
     188    f = caca_file_open(file, "rb");
    182189    if(!f)
    183190        return NULL;
     
    186193    if(!buf)
    187194    {
    188         cucul_file_close(f);
     195        caca_file_close(f);
    189196        return NULL;
    190197    }
     
    193200    buf->size = 0;
    194201
    195     while(!cucul_file_eof(f))
     202    while(!caca_file_eof(f))
    196203    {
    197204        buf->data = realloc(buf->data, buf->size + 1024);
     
    200207            int saved_errno = geterrno();
    201208            free(buf);
    202             cucul_file_close(f);
     209            caca_file_close(f);
    203210            seterrno(saved_errno);
    204211            return NULL;
    205212        }
    206213
    207         ret = cucul_file_read(f, buf->data + buf->size, 1024);
     214        ret = caca_file_read(f, buf->data + buf->size, 1024);
    208215        if(ret >= 0)
    209216            buf->size += ret;
    210217    }
    211     cucul_file_close(f);
     218    caca_file_close(f);
    212219
    213220    return buf;
     
    240247int cucul_rotate(cucul_canvas_t *cv)
    241248{
    242     return cucul_rotate_180(cv);
    243 }
    244 
     249    return caca_rotate_180(cv);
     250}
     251
Note: See TracChangeset for help on using the changeset viewer.