Changeset 777


Ignore:
Timestamp:
Apr 16, 2006, 8:28:47 PM (15 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
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca.h

    r773 r777  
    8888#endif
    8989
    90 /** \brief User event types.
    91  *
    92  *  Event types returned by caca_get_event().
    93  */
    94 enum caca_event_type
    95 {
    96     CACA_EVENT_NONE =          0x0000, /**< No event. */
    97 
    98     CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
    99     CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
    100     CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
    101     CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
    102     CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
    103     CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
    104 
    105     CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
    106 };
     90/** \e libcaca context */
     91typedef struct caca caca_t;
     92/** event structure */
     93typedef struct caca_event caca_event_t;
    10794
    10895/** \brief User events.
     
    139126struct caca_event
    140127{
    141     enum caca_event_type type;
     128    enum caca_event_type
     129    {
     130        CACA_EVENT_NONE =          0x0000, /**< No event. */
     131
     132        CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
     133        CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
     134        CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
     135        CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
     136        CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
     137        CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
     138
     139        CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
     140    } type;
     141
    142142    union
    143143    {
     
    195195};
    196196
    197 typedef struct caca_context caca_t;
    198 
    199 /** \defgroup basic Basic functions
     197/** \defgroup caca Basic libcaca functions
    200198 *
    201199 *  These functions provide the basic \e libcaca routines for driver
     
    219217 *
    220218 *  @{ */
    221 int caca_get_event(caca_t *kk, unsigned int, struct caca_event *, int);
     219int caca_get_event(caca_t *kk, unsigned int, caca_event_t *, int);
    222220unsigned int caca_get_mouse_x(caca_t *kk);
    223221unsigned int caca_get_mouse_y(caca_t *kk);
  • libcaca/trunk/caca/caca_internals.h

    r775 r777  
    2525typedef long unsigned int uintptr_t;
    2626#endif
     27
     28typedef struct caca_timer caca_timer_t;
    2729
    2830#if !defined(_DOXYGEN_SKIP_ME)
     
    8991
    9092/* Internal caca context */
    91 struct caca_context
     93struct caca
    9294{
    9395    /* A link to our cucul canvas */
     
    107109        void (* display) (caca_t *);
    108110        void (* handle_resize) (caca_t *);
    109         int (* get_event) (caca_t *, struct caca_event *);
     111        int (* get_event) (caca_t *, caca_event_t *);
    110112        void (* set_mouse) (caca_t *, int);
    111113    } drv;
     
    126128    /* Framerate handling */
    127129    unsigned int delay, rendertime;
    128     struct caca_timer timer;
     130    caca_timer_t timer;
    129131    int lastticks;
    130132
     
    132134    {
    133135#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
    134         struct caca_event buf[EVENTBUF_LEN];
     136        caca_event_t buf[EVENTBUF_LEN];
    135137        int queue;
    136138#endif
    137139#if defined(USE_SLANG) || defined(USE_NCURSES)
    138         struct caca_timer key_timer;
     140        caca_timer_t key_timer;
    139141        unsigned int last_key_ticks;
    140142        unsigned int autorepeat_ticks;
    141         struct caca_event last_key_event;
     143        caca_event_t last_key_event;
    142144#endif
    143145#if defined(USE_WIN32)
     
    149151/* Internal timer functions */
    150152extern void _caca_sleep(unsigned int);
    151 extern unsigned int _caca_getticks(struct caca_timer *);
     153extern unsigned int _caca_getticks(caca_timer_t *);
    152154
    153155/* Internal event functions */
    154156extern void _caca_handle_resize(caca_t *);
    155157#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
    156 extern void _push_event(caca_t *, struct caca_event *);
    157 extern int _pop_event(caca_t *, struct caca_event *);
     158extern void _push_event(caca_t *, caca_event_t *);
     159extern int _pop_event(caca_t *, caca_event_t *);
    158160#endif
    159161
  • libcaca/trunk/caca/driver_conio.c

    r769 r777  
    120120}
    121121
    122 static int conio_get_event(caca_t *kk, struct caca_event *ev)
     122static int conio_get_event(caca_t *kk, caca_event_t *ev)
    123123{
    124124    unsigned char ch;
    125     struct caca_event release;
     125    caca_event_t release;
    126126
    127127    if(!_conio_kbhit())
  • libcaca/trunk/caca/driver_gl.c

    r769 r777  
    324324}
    325325
    326 static int gl_get_event(caca_t *kk, struct caca_event *ev)
     326static int gl_get_event(caca_t *kk, caca_event_t *ev)
    327327{
    328328#ifdef HAVE_GLUTCHECKLOOP
  • libcaca/trunk/caca/driver_ncurses.c

    r769 r777  
    225225}
    226226
    227 static int ncurses_get_event(caca_t *kk, struct caca_event *ev)
     227static int ncurses_get_event(caca_t *kk, caca_event_t *ev)
    228228{
    229229    int intkey;
  • libcaca/trunk/caca/driver_raw.c

    r769 r777  
    8585}
    8686
    87 static int raw_get_event(caca_t *kk, struct caca_event *ev)
     87static int raw_get_event(caca_t *kk, caca_event_t *ev)
    8888{
    8989    ev->type = CACA_EVENT_NONE;
  • libcaca/trunk/caca/driver_slang.c

    r769 r777  
    253253}
    254254
    255 static int slang_get_event(caca_t *kk, struct caca_event *ev)
     255static int slang_get_event(caca_t *kk, caca_event_t *ev)
    256256{
    257257    int intkey;
  • libcaca/trunk/caca/driver_vga.c

    r769 r777  
    133133}
    134134
    135 static int vga_get_event(caca_t *kk, struct caca_event *ev)
     135static int vga_get_event(caca_t *kk, caca_event-t *ev)
    136136{
    137137    /* FIXME */
  • libcaca/trunk/caca/driver_win32.c

    r769 r777  
    234234}
    235235
    236 static int win32_get_event(caca_t *kk, struct caca_event *ev)
     236static int win32_get_event(caca_t *kk, caca_event_t *ev)
    237237{
    238238    INPUT_RECORD rec;
  • libcaca/trunk/caca/driver_x11.c

    r769 r777  
    405405}
    406406
    407 static int x11_get_event(caca_t *kk, struct caca_event *ev)
     407static int x11_get_event(caca_t *kk, caca_event_t *ev)
    408408{
    409409    XEvent xevent;
  • libcaca/trunk/caca/event.c

    r773 r777  
    2727#include "caca_internals.h"
    2828
    29 static int _get_next_event(caca_t *, struct caca_event *);
    30 static int _lowlevel_event(caca_t *, struct caca_event *);
     29static int _get_next_event(caca_t *, caca_event_t *);
     30static int _lowlevel_event(caca_t *, caca_event_t *);
    3131
    3232#if !defined(_DOXYGEN_SKIP_ME)
     
    5858 */
    5959int caca_get_event(caca_t *kk, unsigned int event_mask,
    60                    struct caca_event *ev, int timeout)
    61 {
    62     struct caca_timer timer;
     60                   caca_event_t *ev, int timeout)
     61{
     62    caca_timer_t timer;
    6363    int usec = 0;
    6464
     
    142142 */
    143143
    144 static int _get_next_event(caca_t *kk, struct caca_event *ev)
     144static int _get_next_event(caca_t *kk, caca_event_t *ev)
    145145{
    146146#if defined(USE_SLANG) || defined(USE_NCURSES)
     
    224224}
    225225
    226 static int _lowlevel_event(caca_t *kk, struct caca_event *ev)
     226static int _lowlevel_event(caca_t *kk, caca_event_t *ev)
    227227{
    228228#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
     
    237237
    238238#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO) || defined(USE_GL)
    239 void _push_event(caca_t *kk, struct caca_event *ev)
     239void _push_event(caca_t *kk, caca_event_t *ev)
    240240{
    241241    if(!ev->type || kk->events.queue == EVENTBUF_LEN)
     
    245245}
    246246
    247 int _pop_event(caca_t *kk, struct caca_event *ev)
     247int _pop_event(caca_t *kk, caca_event_t *ev)
    248248{
    249249    int i;
  • libcaca/trunk/caca/time.c

    r769 r777  
    4646}
    4747
    48 unsigned int _caca_getticks(struct caca_timer *timer)
     48unsigned int _caca_getticks(caca_timer_t *timer)
    4949{
    5050#if defined(HAVE_GETTIMEOFDAY)
  • libcaca/trunk/cucul/cucul.c

    r773 r777  
    7373}
    7474
     75/** \brief Load a memory area into a canvas.
     76 *
     77 *  This function loads a memory area containing an exported canvas into
     78 *  a new \e libcucul canvas.
     79 *
     80 *  \param data The memory area to be loaded into a canvas.
     81 *  \param size The length of the memory area.
     82 *  \return A libcucul canvas, or NULL in case of error.
     83 */
    7584cucul_t *cucul_load(void *data, unsigned int size)
    7685{
     
    228237}
    229238
    230 struct cucul_buffer * cucul_create_export(cucul_t *qq, char const *format)
    231 {
    232     struct cucul_buffer *ex;
    233 
    234     ex = malloc(sizeof(struct cucul_buffer));
     239/** \brief Export a canvas into a foreign format.
     240 *
     241 *  This function exports a libcucul canvas into various foreign formats such
     242 *  as ANSI art, HTML, IRC colours, etc. One should use cucul_get_buffer_data()
     243 *  and cucul_get_buffer_size() to access the buffer contents. The allocated
     244 *  data is valid until cucul_free_buffer() is called.
     245 *
     246 *  Valid values for \e format are:
     247 *
     248 *  \li \e "ansi": export ANSI art (CP437 charset with ANSI colour codes).
     249 *
     250 *  \li \e "html": export an HTML page with CSS information.
     251 *
     252 *  \li \e "html3": export an HTML table that should be compatible with
     253 *      most navigators, including textmode ones.
     254 *
     255 *  \li \e "irc": export UTF-8 text with mIRC colour codes.
     256 *
     257 *  \li \e "ps": export a PostScript document.
     258 *
     259 *  \li \e "svg": export an SVG document.
     260 *
     261 *  \param qq A libcucul canvas
     262 *  \param format A string describing the requested output format.
     263 */
     264cucul_buffer_t * cucul_create_export(cucul_t *qq, char const *format)
     265{
     266    cucul_buffer_t *ex;
     267
     268    ex = malloc(sizeof(cucul_buffer_t));
    235269
    236270    if(!strcasecmp("ansi", format))
     
    280314}
    281315
    282 void cucul_free_export(struct cucul_buffer *ex)
    283 {
    284     free(ex->data);
    285     free(ex);
     316/** \brief Get the buffer size.
     317 *
     318 *  This function returns the length (in bytes) of the memory area stored
     319 *  in the given \e libcucul buffer.
     320 *
     321 *  \param buf A \e libcucul buffer
     322 *  \return The buffer data length.
     323 */
     324unsigned long int cucul_get_buffer_size(cucul_buffer_t *buf)
     325{
     326    return buf->size;
     327}
     328
     329/** \brief Get the buffer data.
     330 *
     331 *  This function returns a pointer to the memory area stored in the given
     332 *  \e libcucul buffer.
     333 *
     334 *  \param buf A \e libcucul buffer
     335 *  \return A pointer to the buffer memory area.
     336 */
     337void * cucul_get_buffer_data(cucul_buffer_t *buf)
     338{
     339    return buf->data;
     340}
     341
     342/** \brief Free a buffer.
     343 *
     344 *  This function frees the structures associated with the given
     345 *  \e libcucul buffer.
     346 *
     347 *  \param buf A \e libcucul buffer
     348 */
     349void cucul_free_buffer(cucul_buffer_t *buf)
     350{
     351    free(buf->data);
     352    free(buf);
    286353}
    287354
  • libcaca/trunk/cucul/cucul.h

    r773 r777  
    3232#endif
    3333
    34 typedef struct cucul_context cucul_t;
    35 
    36 struct cucul_buffer
    37 {
    38     unsigned int size;
    39     char *data;
    40 };
     34/** \e libcucul context */
     35typedef struct cucul cucul_t;
     36/** sprite structure */
     37typedef struct cucul_sprite cucul_sprite_t;
     38/** dither structure */
     39typedef struct cucul_dither cucul_dither_t;
     40/** data buffer structure */
     41typedef struct cucul_buffer cucul_buffer_t;
     42/** font structure */
     43typedef struct cucul_font cucul_font_t;
    4144
    4245/** \defgroup colour Colour definitions
     
    6568/*  @} */
    6669
    67 /** \defgroup basic Basic functions
     70/** \defgroup cucul Basic libcucul functions
    6871 *
    6972 *  These functions provide the basic \e libcaca routines for library
     
    7780unsigned int cucul_get_height(cucul_t *);
    7881void cucul_free(cucul_t *);
     82/*  @} */
     83
     84/** \defgroup buffer Buffer handling
     85 *
     86 *  These functions provide methods to handle libcucul buffers.
     87 *
     88 *  @{ */
     89unsigned long int cucul_get_buffer_size(cucul_buffer_t *);
     90void * cucul_get_buffer_data(cucul_buffer_t *);
     91void cucul_free_buffer(cucul_buffer_t *);
    7992/*  @} */
    8093
     
    145158 *
    146159 *  @{ */
    147 struct cucul_sprite;
    148 struct cucul_sprite * cucul_load_sprite(char const *);
    149 int cucul_get_sprite_frames(struct cucul_sprite const *);
    150 int cucul_get_sprite_width(struct cucul_sprite const *, int);
    151 int cucul_get_sprite_height(struct cucul_sprite const *, int);
    152 int cucul_get_sprite_dx(struct cucul_sprite const *, int);
    153 int cucul_get_sprite_dy(struct cucul_sprite const *, int);
    154 void cucul_draw_sprite(cucul_t *, int, int, struct cucul_sprite const *, int);
    155 void cucul_free_sprite(struct cucul_sprite *);
     160cucul_sprite_t * cucul_load_sprite(char const *);
     161int cucul_get_sprite_frames(cucul_sprite_t const *);
     162int cucul_get_sprite_width(cucul_sprite_t const *, int);
     163int cucul_get_sprite_height(cucul_sprite_t const *, int);
     164int cucul_get_sprite_dx(cucul_sprite_t const *, int);
     165int cucul_get_sprite_dy(cucul_sprite_t const *, int);
     166void cucul_draw_sprite(cucul_t *, int, int, cucul_sprite_t const *, int);
     167void cucul_free_sprite(cucul_sprite_t *);
    156168/*  @} */
    157169
     
    162174 *
    163175 *  @{ */
    164 struct cucul_dither;
    165 struct cucul_dither *cucul_create_dither(unsigned int, unsigned int,
     176cucul_dither_t *cucul_create_dither(unsigned int, unsigned int,
    166177                                         unsigned int, unsigned int,
    167178                                         unsigned int, unsigned int,
    168179                                         unsigned int, unsigned int);
    169 void cucul_set_dither_palette(struct cucul_dither *,
     180void cucul_set_dither_palette(cucul_dither_t *,
    170181                              unsigned int r[], unsigned int g[],
    171182                              unsigned int b[], unsigned int a[]);
    172 void cucul_set_dither_brightness(struct cucul_dither *, float);
    173 void cucul_set_dither_gamma(struct cucul_dither *, float);
    174 void cucul_set_dither_contrast(struct cucul_dither *, float);
    175 void cucul_set_dither_invert(struct cucul_dither *, int);
    176 void cucul_set_dither_antialias(struct cucul_dither *, char const *);
    177 char const * const * cucul_get_dither_antialias_list(struct cucul_dither const *);
    178 void cucul_set_dither_color(struct cucul_dither *, char const *);
    179 char const * const * cucul_get_dither_color_list(struct cucul_dither const *);
    180 void cucul_set_dither_charset(struct cucul_dither *, char const *);
    181 char const * const * cucul_get_dither_charset_list(struct cucul_dither const *);
    182 void cucul_set_dither_mode(struct cucul_dither *, char const *);
    183 char const * const * cucul_get_dither_mode_list(struct cucul_dither const *);
     183void cucul_set_dither_brightness(cucul_dither_t *, float);
     184void cucul_set_dither_gamma(cucul_dither_t *, float);
     185void cucul_set_dither_contrast(cucul_dither_t *, float);
     186void cucul_set_dither_invert(cucul_dither_t *, int);
     187void cucul_set_dither_antialias(cucul_dither_t *, char const *);
     188char const * const * cucul_get_dither_antialias_list(cucul_dither_t const *);
     189void cucul_set_dither_color(cucul_dither_t *, char const *);
     190char const * const * cucul_get_dither_color_list(cucul_dither_t const *);
     191void cucul_set_dither_charset(cucul_dither_t *, char const *);
     192char const * const * cucul_get_dither_charset_list(cucul_dither_t const *);
     193void cucul_set_dither_mode(cucul_dither_t *, char const *);
     194char const * const * cucul_get_dither_mode_list(cucul_dither_t const *);
    184195void cucul_dither_bitmap(cucul_t *, int, int, int, int,
    185                          struct cucul_dither const *, void *);
    186 void cucul_free_dither(struct cucul_dither *);
     196                         cucul_dither_t const *, void *);
     197void cucul_free_dither(cucul_dither_t *);
    187198/*  @} */
    188199
     
    193204 *
    194205 *  @{ */
    195 struct cucul_font;
    196 struct cucul_font *cucul_load_font(void const *, unsigned int);
     206cucul_font_t *cucul_load_font(void const *, unsigned int);
    197207char const * const * cucul_get_font_list(void);
    198 unsigned int cucul_get_font_width(struct cucul_font *);
    199 unsigned int cucul_get_font_height(struct cucul_font *);
    200 void cucul_render_canvas(cucul_t *, struct cucul_font *, unsigned char *,
     208unsigned int cucul_get_font_width(cucul_font_t *);
     209unsigned int cucul_get_font_height(cucul_font_t *);
     210void cucul_render_canvas(cucul_t *, cucul_font_t *, unsigned char *,
    201211                         unsigned int, unsigned int, unsigned int);
    202 void cucul_free_font(struct cucul_font *);
     212void cucul_free_font(cucul_font_t *);
    203213/*  @} */
    204214
     
    206216 *
    207217 *  These functions export the current canvas to various text formats. It
    208  *  is necessary to call cucul_free_export() to dispose of the data.
    209  *
    210  *  @{ */
    211 struct cucul_buffer * cucul_create_export(cucul_t *, char const *);
     218 *  is necessary to call cucul_free_buffer() to dispose of the data.
     219 *
     220 *  @{ */
     221cucul_buffer_t * cucul_create_export(cucul_t *, char const *);
    212222char const * const * cucul_get_export_list(void);
    213 void cucul_free_export(struct cucul_buffer *);
    214223/*  @} */
    215224
  • libcaca/trunk/cucul/cucul_internals.h

    r769 r777  
    2626#endif
    2727
    28 struct cucul_context
     28struct cucul
    2929{
    3030    /* Context size */
     
    3939
    4040    unsigned int refcount;
     41};
     42
     43struct cucul_buffer
     44{
     45    unsigned long int size;
     46    char *data;
    4147};
    4248
     
    6369
    6470/* Export functions */
    65 extern void _cucul_get_ansi(cucul_t *, struct cucul_buffer *);
    66 extern void _cucul_get_html(cucul_t *, struct cucul_buffer *);
    67 extern void _cucul_get_html3(cucul_t *, struct cucul_buffer *);
    68 extern void _cucul_get_irc(cucul_t *, struct cucul_buffer *);
    69 extern void _cucul_get_ps(cucul_t *, struct cucul_buffer *);
    70 extern void _cucul_get_svg(cucul_t *, struct cucul_buffer *);
     71extern void _cucul_get_ansi(cucul_t *, cucul_buffer_t *);
     72extern void _cucul_get_html(cucul_t *, cucul_buffer_t *);
     73extern void _cucul_get_html3(cucul_t *, cucul_buffer_t *);
     74extern void _cucul_get_irc(cucul_t *, cucul_buffer_t *);
     75extern void _cucul_get_ps(cucul_t *, cucul_buffer_t *);
     76extern void _cucul_get_svg(cucul_t *, cucul_buffer_t *);
    7177
    7278#endif /* __CUCUL_INTERNALS_H__ */
  • libcaca/trunk/cucul/dither.c

    r773 r777  
    119119    int rright, gright, bright, aright;
    120120    int rleft, gleft, bleft, aleft;
    121     void (*get_hsv)(struct cucul_dither *, char *, int, int);
     121    void (*get_hsv)(cucul_dither_t *, char *, int, int);
    122122    int red[256], green[256], blue[256], alpha[256];
    123123    float gamma;
     
    164164static float gammapow(float x, float y);
    165165
    166 static void get_rgba_default(struct cucul_dither const *, uint8_t *, int, int,
     166static void get_rgba_default(cucul_dither_t const *, uint8_t *, int, int,
    167167                             unsigned int *);
    168168
     
    246246 *  \return Dither object, or NULL upon error.
    247247 */
    248 struct cucul_dither *cucul_create_dither(unsigned int bpp, unsigned int w,
    249                                          unsigned int h, unsigned int pitch,
    250                                          unsigned int rmask, unsigned int gmask,
    251                                          unsigned int bmask, unsigned int amask)
    252 {
    253     struct cucul_dither *d;
     248cucul_dither_t *cucul_create_dither(unsigned int bpp, unsigned int w,
     249                                    unsigned int h, unsigned int pitch,
     250                                    unsigned int rmask, unsigned int gmask,
     251                                    unsigned int bmask, unsigned int amask)
     252{
     253    cucul_dither_t *d;
    254254    int i;
    255255
     
    258258        return NULL;
    259259
    260     d = malloc(sizeof(struct cucul_dither));
     260    d = malloc(sizeof(cucul_dither_t));
    261261    if(!d)
    262262        return NULL;
     
    331331 *  \param alpha Array of 256 alpha values.
    332332 */
    333 void cucul_set_dither_palette(struct cucul_dither *d,
     333void cucul_set_dither_palette(cucul_dither_t *d,
    334334                              unsigned int red[], unsigned int green[],
    335335                              unsigned int blue[], unsigned int alpha[])
     
    368368 *  \param brightness brightness value.
    369369 */
    370 void cucul_set_dither_brightness(struct cucul_dither *d, float brightness)
     370void cucul_set_dither_brightness(cucul_dither_t *d, float brightness)
    371371{
    372372    /* FIXME */
     
    380380 *  \param gamma Gamma value.
    381381 */
    382 void cucul_set_dither_gamma(struct cucul_dither *d, float gamma)
     382void cucul_set_dither_gamma(cucul_dither_t *d, float gamma)
    383383{
    384384    /* FIXME: we don't need 4096 calls to gammapow(), we can just compute
     
    403403 *  \param value 0 for normal behaviour, 1 for invert
    404404 */
    405 void cucul_set_dither_invert(struct cucul_dither *d, int value)
     405void cucul_set_dither_invert(cucul_dither_t *d, int value)
    406406{
    407407    d->invert = value ? 1 : 0;
     
    415415 *  \param contrast contrast value.
    416416 */
    417 void cucul_set_dither_contrast(struct cucul_dither *d, float contrast)
     417void cucul_set_dither_contrast(cucul_dither_t *d, float contrast)
    418418{
    419419    /* FIXME */
     
    434434 *         for the dithering.
    435435 */
    436 void cucul_set_dither_antialias(struct cucul_dither *d, char const *str)
     436void cucul_set_dither_antialias(cucul_dither_t *d, char const *str)
    437437{
    438438    if(!strcasecmp(str, "none"))
     
    454454 */
    455455char const * const *
    456     cucul_get_dither_antialias_list(struct cucul_dither const *d)
     456    cucul_get_dither_antialias_list(cucul_dither_t const *d)
    457457{
    458458    static char const * const list[] =
     
    492492 *         for the dithering.
    493493 */
    494 void cucul_set_dither_color(struct cucul_dither *d, char const *str)
     494void cucul_set_dither_color(cucul_dither_t *d, char const *str)
    495495{
    496496    if(!strcasecmp(str, "mono"))
     
    522522 */
    523523char const * const *
    524     cucul_get_dither_color_list(struct cucul_dither const *d)
     524    cucul_get_dither_color_list(cucul_dither_t const *d)
    525525{
    526526    static char const * const list[] =
     
    557557 *         for the dithering.
    558558 */
    559 void cucul_set_dither_charset(struct cucul_dither *d, char const *str)
     559void cucul_set_dither_charset(cucul_dither_t *d, char const *str)
    560560{
    561561    if(!strcasecmp(str, "shades"))
     
    587587 *  \return An array of strings.
    588588 */
    589 char const * const *
    590     cucul_get_dither_charset_list(struct cucul_dither const *d)
     589char const * const * cucul_get_dither_charset_list(cucul_dither_t const *d)
    591590{
    592591    static char const * const list[] =
     
    623622 *         for the dithering.
    624623 */
    625 void cucul_set_dither_mode(struct cucul_dither *d, char const *str)
     624void cucul_set_dither_mode(cucul_dither_t *d, char const *str)
    626625{
    627626    if(!strcasecmp(str, "none"))
     
    674673 *  \return An array of strings.
    675674 */
    676 char const * const *
    677     cucul_get_dither_mode_list(struct cucul_dither const *d)
     675char const * const * cucul_get_dither_mode_list(cucul_dither_t const *d)
    678676{
    679677    static char const * const list[] =
     
    705703 */
    706704void cucul_dither_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2,
    707                          struct cucul_dither const *d, void *pixels)
     705                         cucul_dither_t const *d, void *pixels)
    708706{
    709707    int *floyd_steinberg, *fs_r, *fs_g, *fs_b;
     
    956954 *  \param d Dither object.
    957955 */
    958 void cucul_free_dither(struct cucul_dither *d)
     956void cucul_free_dither(cucul_dither_t *d)
    959957{
    960958    if(!d)
     
    10571055}
    10581056
    1059 static void get_rgba_default(struct cucul_dither const *d, uint8_t *pixels,
     1057static void get_rgba_default(cucul_dither_t const *d, uint8_t *pixels,
    10601058                             int x, int y, unsigned int *rgba)
    10611059{
  • libcaca/trunk/cucul/export_ansi.c

    r769 r777  
    3636 *  \return buffer containing generated ANSI codes as a big string
    3737 */
    38 void _cucul_get_ansi(cucul_t *qq, struct cucul_buffer *ex)
     38void _cucul_get_ansi(cucul_t *qq, cucul_buffer_t *ex)
    3939{
    4040    static int const palette[] =
  • libcaca/trunk/cucul/export_html.c

    r769 r777  
    3333 *  the current image.
    3434 */
    35 void _cucul_get_html(cucul_t *qq, struct cucul_buffer *ex)
     35void _cucul_get_html(cucul_t *qq, cucul_buffer_t *ex)
    3636{
    3737    static int const palette[] =
     
    112112 *  a correct header.
    113113 */
    114 void _cucul_get_html3(cucul_t *qq, struct cucul_buffer *ex)
     114void _cucul_get_html3(cucul_t *qq, cucul_buffer_t *ex)
    115115{
    116116    static int const palette[] =
  • libcaca/trunk/cucul/export_irc.c

    r769 r777  
    3333 *  the current image.
    3434 */
    35 void _cucul_get_irc(cucul_t *qq, struct cucul_buffer *ex)
     35void _cucul_get_irc(cucul_t *qq, cucul_buffer_t *ex)
    3636{
    3737    static int const palette[] =
  • libcaca/trunk/cucul/export_ps.c

    r769 r777  
    5858 *  the current image.
    5959 */
    60 void _cucul_get_ps(cucul_t *qq, struct cucul_buffer *ex)
     60void _cucul_get_ps(cucul_t *qq, cucul_buffer_t *ex)
    6161{
    6262    static char const * const palette[] =
  • libcaca/trunk/cucul/export_svg.c

    r769 r777  
    4343 *  the current image.
    4444 */
    45 void _cucul_get_svg(cucul_t *qq, struct cucul_buffer *ex)
     45void _cucul_get_svg(cucul_t *qq, cucul_buffer_t *ex)
    4646{
    4747    static int const palette[] =
  • libcaca/trunk/cucul/font.c

    r775 r777  
    107107 *  \return A font handle or NULL in case of error.
    108108 */
    109 struct cucul_font *cucul_load_font(void const *data, unsigned int size)
    110 {
    111     struct cucul_font *f;
     109cucul_font_t *cucul_load_font(void const *data, unsigned int size)
     110{
     111    cucul_font_t *f;
    112112    unsigned int i;
    113113
     
    125125        return NULL;
    126126
    127     f = malloc(sizeof(struct cucul_font));
     127    f = malloc(sizeof(cucul_font_t));
    128128    f->private = (void *)(uintptr_t)data;
    129129
     
    222222 *  \return The maximum glyph width.
    223223 */
    224 unsigned int cucul_get_font_width(struct cucul_font *f)
     224unsigned int cucul_get_font_width(cucul_font_t *f)
    225225{
    226226    return f->header.width;
     
    234234 *  \return The maximum glyph height.
    235235 */
    236 unsigned int cucul_get_font_height(struct cucul_font *f)
     236unsigned int cucul_get_font_height(cucul_font_t *f)
    237237{
    238238    return f->header.height;
     
    248248 *  \param f The font, as returned by \e cucul_load_font()
    249249 */
    250 void cucul_free_font(struct cucul_font *f)
     250void cucul_free_font(cucul_font_t *f)
    251251{
    252252    free(f->glyph_list);
     
    274274 *  \param pitch The pitch (in bytes) of an image buffer line.
    275275 */
    276 void cucul_render_canvas(cucul_t *qq, struct cucul_font *f,
     276void cucul_render_canvas(cucul_t *qq, cucul_font_t *f,
    277277                         unsigned char *buf, unsigned int width,
    278278                         unsigned int height, unsigned int pitch)
  • libcaca/trunk/cucul/sprite.c

    r773 r777  
    4848 *  \return The sprite, or NULL if an error occured.
    4949 */
    50 struct cucul_sprite *cucul_load_sprite(char const *file)
     50cucul_sprite_t *cucul_load_sprite(char const *file)
    5151{
    5252    char buf[BUFSIZ];
    53     struct cucul_sprite *sprite;
     53    cucul_sprite_t *sprite;
    5454    FILE *fd;
    5555
     
    5858        return NULL;
    5959
    60     sprite = malloc(sizeof(struct cucul_sprite));
     60    sprite = malloc(sizeof(cucul_sprite_t));
    6161    if(sprite == NULL)
    6262        goto sprite_alloc_failed;
     
    168168 *  \return The number of frames.
    169169 */
    170 int cucul_get_sprite_frames(struct cucul_sprite const *sprite)
     170int cucul_get_sprite_frames(cucul_sprite_t const *sprite)
    171171{
    172172    if(sprite == NULL)
     
    182182 *  \return The width of the given frame of the sprite.
    183183 */
    184 int cucul_get_sprite_width(struct cucul_sprite const *sprite, int f)
     184int cucul_get_sprite_width(cucul_sprite_t const *sprite, int f)
    185185{
    186186    if(sprite == NULL)
     
    199199 *  \return The height of the given frame of the sprite.
    200200 */
    201 int cucul_get_sprite_height(struct cucul_sprite const *sprite, int f)
     201int cucul_get_sprite_height(cucul_sprite_t const *sprite, int f)
    202202{
    203203    if(sprite == NULL)
     
    216216 *  \return The X coordinate of the given frame's handle.
    217217 */
    218 int cucul_get_sprite_dx(struct cucul_sprite const *sprite, int f)
     218int cucul_get_sprite_dx(cucul_sprite_t const *sprite, int f)
    219219{
    220220    if(sprite == NULL)
     
    233233 *  \return The Y coordinate of the given frame's handle.
    234234 */
    235 int cucul_get_sprite_dy(struct cucul_sprite const *sprite, int f)
     235int cucul_get_sprite_dy(cucul_sprite_t const *sprite, int f)
    236236{
    237237    if(sprite == NULL)
     
    254254 *  \return void
    255255 */
    256 void cucul_draw_sprite(cucul_t *qq, int x, int y, struct cucul_sprite const *sprite, int f)
     256void cucul_draw_sprite(cucul_t *qq, int x, int y, cucul_sprite_t const *sprite, int f)
    257257{
    258258    int i, j;
     
    293293 *  \return void
    294294 */
    295 void cucul_free_sprite(struct cucul_sprite *sprite)
     295void cucul_free_sprite(cucul_sprite_t *sprite)
    296296{
    297297    int i;
  • 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);
  • libcaca/trunk/test/colors.c

    r710 r777  
    2525    cucul_t *qq;
    2626    caca_t *kk;
    27     struct caca_event ev;
     27    caca_event_t ev;
    2828    int i, j;
    2929
  • libcaca/trunk/test/demo.c

    r774 r777  
    3636int outline = 0;
    3737int dithering = 0;
    38 struct cucul_sprite *sprite = NULL;
     38cucul_sprite_t *sprite = NULL;
    3939
    4040cucul_t *qq;
     
    7272    while(!quit)
    7373    {
    74         struct caca_event ev;
     74        caca_event_t ev;
    7575        int menu = 0, mouse = 0, xmouse = 0, ymouse = 0;
    7676
     
    484484static void demo_render(void)
    485485{
    486     struct cucul_dither *dither;
     486    cucul_dither_t *dither;
    487487    //short buffer[256*256];
    488488    //short *dest = buffer;
     
    514514static void demo_render(void)
    515515{
    516     struct cucul_dither *dither;
     516    cucul_dither_t *dither;
    517517    int buffer[256*256];
    518518    int *dest;
  • libcaca/trunk/test/dithering.c

    r733 r777  
    3535int main(void)
    3636{
    37     struct caca_event ev;
     37    caca_event_t ev;
    3838    cucul_t *qq;
    3939    caca_t *kk;
  • libcaca/trunk/test/event.c

    r710 r777  
    2424static caca_t *kk;
    2525
    26 static void print_event(int, int, struct caca_event *);
     26static void print_event(int, int, caca_event_t *);
    2727
    2828int main(int argc, char **argv)
    2929{
    30     struct caca_event *events;
     30    caca_event_t *events;
    3131    int i, h, quit;
    3232
     
    4848    caca_display(kk);
    4949
    50     events = malloc(h * sizeof(struct caca_event));
    51     memset(events, 0, h * sizeof(struct caca_event));
     50    events = malloc(h * sizeof(caca_event_t));
     51    memset(events, 0, h * sizeof(caca_event_t));
    5252
    5353    for(quit = 0; quit < 4; )
    5454    {
    55         struct caca_event ev;
     55        caca_event_t ev;
    5656        static char const * quit_string[] = { "", "q", "qu", "qui", "quit" };
    5757        int ret = caca_get_event(kk, CACA_EVENT_ANY, &ev, -1);
     
    7575            }
    7676
    77             memmove(events + 1, events, (h - 1) * sizeof(struct caca_event));
     77            memmove(events + 1, events, (h - 1) * sizeof(caca_event_t));
    7878            events[0] = ev;
    7979
     
    107107}
    108108
    109 static void print_event(int x, int y, struct caca_event *ev)
     109static void print_event(int x, int y, caca_event_t *ev)
    110110{
    111111    int character;
  • libcaca/trunk/test/export.c

    r757 r777  
    3636{
    3737    cucul_t *qq;
    38     struct cucul_dither *dither;
    39     struct cucul_buffer *buffer;
     38    cucul_dither_t *dither;
     39    cucul_buffer_t *buffer;
    4040    int x, y;
    4141
     
    9191
    9292    buffer = cucul_create_export(qq, argv[1]);
    93     fwrite(buffer->data, buffer->size, 1, stdout);
    94     cucul_free_export(buffer);
     93    fwrite(cucul_get_buffer_data(buffer),
     94           cucul_get_buffer_size(buffer), 1, stdout);
     95    cucul_free_buffer(buffer);
    9596
    9697    cucul_free(qq);
  • libcaca/trunk/test/font.c

    r767 r777  
    3737    cucul_t *qq;
    3838    caca_t *kk;
    39     struct cucul_font *f;
    40     struct cucul_dither *d;
    41     struct caca_event ev;
     39    cucul_font_t *f;
     40    cucul_dither_t *d;
     41    caca_event_t ev;
    4242    unsigned char *buf;
    4343    unsigned int w, h;
  • libcaca/trunk/test/gamma.c

    r734 r777  
    3434int main(void)
    3535{
    36     struct caca_event ev;
     36    caca_event_t ev;
    3737    cucul_t *qq, *gg, *mask;
    3838    caca_t *kk;
    39     struct cucul_dither *left, *right;
     39    cucul_dither_t *left, *right;
    4040    float gam = 1.0;
    4141    int x;
  • libcaca/trunk/test/hsv.c

    r766 r777  
    2929int main(void)
    3030{
    31     struct caca_event ev;
     31    caca_event_t ev;
    3232    cucul_t *qq;
    3333    caca_t *kk;
    3434
    35     struct cucul_dither *dither;
     35    cucul_dither_t *dither;
    3636    int x, y;
    3737
  • libcaca/trunk/test/spritedit.c

    r774 r777  
    2727
    2828    int quit = 0;
    29     struct cucul_sprite *sprite;
     29    cucul_sprite_t *sprite;
    3030    int frame = 0;
    3131    unsigned char play = 0;
     
    5858    while(!quit)
    5959    {
    60         struct caca_event ev;
     60        caca_event_t ev;
    6161        int xa, ya, xb, yb;
    6262        char buf[BUFSIZ];
  • libcaca/trunk/test/transform.c

    r710 r777  
    5050int main(void)
    5151{
    52     struct caca_event ev;
     52    caca_event_t ev;
    5353    cucul_t *qq, *normal, *flip, *flop, *rotate;
    5454    caca_t *kk;
  • libcaca/trunk/test/unicode.c

    r710 r777  
    2727int main(void)
    2828{
    29     struct caca_event ev;
     29    caca_event_t ev;
    3030    cucul_t *qq;
    3131    caca_t *kk;
Note: See TracChangeset for help on using the changeset viewer.