Changeset 2305 for libcaca


Ignore:
Timestamp:
Apr 19, 2008, 9:25:52 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Remove all unsigned ints from exported functions. Signed arithmetic is far better for error checking.
Location:
libcaca/trunk
Files:
25 edited

Legend:

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

    r2303 r2305  
    2828
    2929#undef __extern
    30 #if defined(_WIN32) && defined(__LIBCACA__)
     30#if defined(_DOXYGEN_SKIP_ME)
     31#elif defined(_WIN32) && defined(__LIBCACA__)
    3132#   define __extern extern __declspec(dllexport)
    3233#else
     
    8081    union
    8182    {
    82         struct { unsigned int x, y, button; } mouse;
    83         struct { unsigned int w, h; } resize;
    84         struct { unsigned int ch; uint32_t utf32; char utf8[8]; } key;
     83        struct { int x, y, button; } mouse;
     84        struct { int w, h; } resize;
     85        struct { int ch; uint32_t utf32; char utf8[8]; } key;
    8586    } data;
    8687    uint8_t padding[16];
     
    171172__extern cucul_canvas_t * caca_get_canvas(caca_display_t *);
    172173__extern int caca_refresh_display(caca_display_t *);
    173 __extern int caca_set_display_time(caca_display_t *, unsigned int);
    174 __extern unsigned int caca_get_display_time(caca_display_t const *);
    175 __extern unsigned int caca_get_display_width(caca_display_t const *);
    176 __extern unsigned int caca_get_display_height(caca_display_t const *);
     174__extern int caca_set_display_time(caca_display_t *, int);
     175__extern int caca_get_display_time(caca_display_t const *);
     176__extern int caca_get_display_width(caca_display_t const *);
     177__extern int caca_get_display_height(caca_display_t const *);
    177178__extern int caca_set_display_title(caca_display_t *, char const *);
    178179__extern int caca_set_mouse(caca_display_t *, int);
     
    187188 *
    188189 *  @{ */
    189 __extern int caca_get_event(caca_display_t *, unsigned int,
    190                             caca_event_t *, int);
    191 __extern unsigned int caca_get_mouse_x(caca_display_t const *);
    192 __extern unsigned int caca_get_mouse_y(caca_display_t const *);
     190__extern int caca_get_event(caca_display_t *, int, caca_event_t *, int);
     191__extern int caca_get_mouse_x(caca_display_t const *);
     192__extern int caca_get_mouse_y(caca_display_t const *);
    193193__extern enum caca_event_type caca_get_event_type(caca_event_t const *);
    194 __extern unsigned int caca_get_event_key_ch(caca_event_t const *);
     194__extern int caca_get_event_key_ch(caca_event_t const *);
    195195__extern uint32_t caca_get_event_key_utf32(caca_event_t const *);
    196196__extern int caca_get_event_key_utf8(caca_event_t const *, char *);
    197 __extern unsigned int caca_get_event_mouse_button(caca_event_t const *);
    198 __extern unsigned int caca_get_event_mouse_x(caca_event_t const *);
    199 __extern unsigned int caca_get_event_mouse_y(caca_event_t const *);
    200 __extern unsigned int caca_get_event_resize_width(caca_event_t const *);
    201 __extern unsigned int caca_get_event_resize_height(caca_event_t const *);
     197__extern int caca_get_event_mouse_button(caca_event_t const *);
     198__extern int caca_get_event_mouse_x(caca_event_t const *);
     199__extern int caca_get_event_mouse_y(caca_event_t const *);
     200__extern int caca_get_event_resize_width(caca_event_t const *);
     201__extern int caca_get_event_resize_height(caca_event_t const *);
    202202/*  @} */
    203203
     
    206206#endif
    207207
    208 #if !defined(_DOXYGEN_SKIP_ME)
    209 #   undef __extern
    210 #endif
     208#undef __extern
    211209
    212210#endif /* __CACA_H__ */
  • libcaca/trunk/caca/caca_internals.h

    r2299 r2305  
    9696    union
    9797    {
    98         struct { unsigned int x, y, button; } mouse;
    99         struct { unsigned int w, h; } resize;
    100         struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
     98        struct { int x, y, button; } mouse;
     99        struct { int w, h; } resize;
     100        struct { int ch; uint32_t utf32; char utf8[8]; } key;
    101101    } data;
    102102};
     
    123123        int (* end_graphics) (caca_display_t *);
    124124        int (* set_display_title) (caca_display_t *, char const *);
    125         unsigned int (* get_display_width) (caca_display_t const *);
    126         unsigned int (* get_display_height) (caca_display_t const *);
     125        int (* get_display_width) (caca_display_t const *);
     126        int (* get_display_height) (caca_display_t const *);
    127127        void (* display) (caca_display_t *);
    128128        void (* handle_resize) (caca_display_t *);
     
    135135    struct mouse
    136136    {
    137         unsigned int x, y;
     137        int x, y;
    138138    } mouse;
    139139
     
    143143        int resized;   /* A resize event was requested */
    144144        int allow;     /* The display driver allows resizing */
    145         unsigned w, h; /* Requested width and height */
     145        int w, h; /* Requested width and height */
    146146    } resize;
    147147
    148148    /* Framerate handling */
    149     unsigned int delay, rendertime;
     149    int delay, rendertime;
    150150    caca_timer_t timer;
    151151    int lastticks;
     
    159159#if defined(USE_SLANG) || defined(USE_NCURSES)
    160160        caca_timer_t key_timer;
    161         unsigned int last_key_ticks;
    162         unsigned int autorepeat_ticks;
     161        int last_key_ticks;
     162        int autorepeat_ticks;
    163163        caca_privevent_t last_key_event;
    164164#endif
    165165#if defined(USE_WIN32)
    166         unsigned char not_empty_struct;
     166        uint8_t not_empty_struct;
    167167#endif
    168168    } events;
     
    170170
    171171/* Internal timer functions */
    172 extern void _caca_sleep(unsigned int);
    173 extern unsigned int _caca_getticks(caca_timer_t *);
     172extern void _caca_sleep(int);
     173extern int _caca_getticks(caca_timer_t *);
    174174
    175175/* Internal event functions */
  • libcaca/trunk/caca/driver_cocoa.m

    r2138 r2305  
    6363    //NSFont* _font;
    6464    NSRect _font_rect;
    65     unsigned int _h, _w;
     65    int _h, _w;
    6666    uint32_t* _attrs;
    6767    uint32_t* _chars;
     
    100100
    101101#ifdef PRECACHE_WHOLE_COLOR_TABLE
    102     unsigned int i;
     102    int i;
    103103    for(i = 0; i < NCOLORS; i++)
    104104        _colorCache[i] = [[NSColor colorFromRgb12:i] retain];
     
    126126    //[_font release];
    127127#ifdef PRECACHE_WHOLE_COLOR_TABLE
    128     unsigned short i;
     128    short i;
    129129    for(i = 0; i < NCOLORS; i++)
    130130        [_colorCache[i] release];
     
    249249    }
    250250
    251     unsigned int x, y;
     251    int x, y;
    252252    float fw = _font_rect.size.width;
    253253    float fh = _font_rect.size.height;
     
    259259    NSRectFill(rect);
    260260
    261     unsigned int arrayLength = 0;
     261    int arrayLength = 0;
    262262    for(y = 0; y < _h; y++)
    263263    {
    264         unsigned int yoff = y * fh;
     264        int yoff = y * fh;
    265265        for(x = 0; x < _w; x++)
    266266        {
     
    308308    for(y = 0; y < _h; y++)
    309309    {
    310         unsigned int yoff = y * fh;
     310        int yoff = y * fh;
    311311        for(x = 0; x < _w; x++, chars++)
    312312        {
     
    598598}
    599599
    600 static unsigned int get_caca_keycode(NSEvent* event)
    601 {
    602     unsigned int caca_keycode = 0;
     600static int get_caca_keycode(NSEvent* event)
     601{
     602    int caca_keycode = 0;
    603603    /*
    604604    unsigned short mac_keycode = [event keyCode];
     
    748748    }
    749749
    750     unsigned int caca_keycode = get_caca_keycode(event);
     750    int caca_keycode = get_caca_keycode(event);
    751751    if(caca_keycode)
    752752    {
     
    801801        {
    802802            NSPoint mouseLoc = [NSEvent mouseLocation];
    803             unsigned int mouse_x = round(mouseLoc.x);
    804             unsigned int mouse_y = round(mouseLoc.y);
     803            int mouse_x = round(mouseLoc.x);
     804            int mouse_y = round(mouseLoc.y);
    805805            if(dp->mouse.x == mouse_x && dp->mouse.y == mouse_y)
    806806                break;
     
    827827static int cocoa_init_graphics(caca_display_t *dp)
    828828{
    829     unsigned int width = cucul_get_canvas_width(dp->cv);
    830     unsigned int height = cucul_get_canvas_height(dp->cv);
     829    int width = cucul_get_canvas_width(dp->cv);
     830    int height = cucul_get_canvas_height(dp->cv);
    831831
    832832    debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, width, height);
     
    971971}
    972972
    973 static unsigned int cocoa_get_display_width(caca_display_t const *dp)
     973static int cocoa_get_display_width(caca_display_t const *dp)
    974974{
    975975    return [dp->drv.p->window frame].size.width;
    976976}
    977977
    978 static unsigned int cocoa_get_display_height(caca_display_t const *dp)
     978static int cocoa_get_display_height(caca_display_t const *dp)
    979979{
    980980    return [dp->drv.p->window frame].size.height;
  • libcaca/trunk/caca/driver_conio.c

    r2300 r2305  
    8585}
    8686
    87 static unsigned int conio_get_display_width(caca_display_t const *dp)
     87static int conio_get_display_width(caca_display_t const *dp)
    8888{
    8989    /* Fallback to a 6x10 font */
     
    9191}
    9292
    93 static unsigned int conio_get_display_height(caca_display_t const *dp)
     93static int conio_get_display_height(caca_display_t const *dp)
    9494{
    9595    /* Fallback to a 6x10 font */
     
    102102    uint32_t const *chars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    103103    uint32_t const *attrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    104     unsigned int width = cucul_get_canvas_width(dp->cv);
    105     unsigned int height = cucul_get_canvas_height(dp->cv);
    106     unsigned int n;
     104    int width = cucul_get_canvas_width(dp->cv);
     105    int height = cucul_get_canvas_height(dp->cv);
     106    int n;
    107107
    108108    for(n = height * width; n--; )
  • libcaca/trunk/caca/driver_gl.c

    r2303 r2305  
    6464{
    6565    int window;
    66     unsigned int width, height;
    67     unsigned int new_width, new_height;
     66    int width, height;
     67    int new_width, new_height;
    6868    cucul_font_t *f;
    6969    float font_width, font_height;
     
    7474    uint8_t bit;
    7575    uint8_t mouse_changed, mouse_clicked;
    76     unsigned int mouse_x, mouse_y;
    77     unsigned int mouse_button, mouse_state;
     76    int mouse_x, mouse_y;
     77    int mouse_button, mouse_state;
    7878
    7979    uint8_t key;
     
    8888    char *argv[2] = { "", NULL };
    8989    char const * const * fonts;
    90     unsigned int width = cucul_get_canvas_width(dp->cv);
    91     unsigned int height = cucul_get_canvas_height(dp->cv);
     90    int width = cucul_get_canvas_width(dp->cv);
     91    int height = cucul_get_canvas_height(dp->cv);
    9292    int argc = 1;
    9393
     
    205205}
    206206
    207 static unsigned int gl_get_display_width(caca_display_t const *dp)
     207static int gl_get_display_width(caca_display_t const *dp)
    208208{
    209209    return dp->drv.p->width;
    210210}
    211211
    212 static unsigned int gl_get_display_height(caca_display_t const *dp)
     212static int gl_get_display_height(caca_display_t const *dp)
    213213{
    214214    return dp->drv.p->height;
     
    219219    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    220220    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    221     unsigned int width = cucul_get_canvas_width(dp->cv);
    222     unsigned int x, y, line;
     221    int width = cucul_get_canvas_width(dp->cv);
     222    int x, y, line;
    223223
    224224    glClear(GL_COLOR_BUFFER_BIT);
  • libcaca/trunk/caca/driver_ncurses.c

    r2304 r2305  
    333333}
    334334
    335 static unsigned int ncurses_get_display_width(caca_display_t const *dp)
     335static int ncurses_get_display_width(caca_display_t const *dp)
    336336{
    337337    /* Fallback to a 6x10 font */
     
    339339}
    340340
    341 static unsigned int ncurses_get_display_height(caca_display_t const *dp)
     341static int ncurses_get_display_height(caca_display_t const *dp)
    342342{
    343343    /* Fallback to a 6x10 font */
     
    349349    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    350350    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    351     unsigned int width = cucul_get_canvas_width(dp->cv);
    352     unsigned int height = cucul_get_canvas_height(dp->cv);
     351    int width = cucul_get_canvas_width(dp->cv);
     352    int height = cucul_get_canvas_height(dp->cv);
    353353    int x, y;
    354354
     
    421421        char utf8[7];
    422422        uint32_t utf32;
    423         unsigned int i;
    424         size_t bytes = 0;
     423        size_t i, bytes = 0;
    425424
    426425        keys[0] = intkey;
     
    496495        }
    497496
    498         if(dp->mouse.x == (unsigned int)mevent.x &&
    499            dp->mouse.y == (unsigned int)mevent.y)
     497        if(dp->mouse.x == mevent.x && dp->mouse.y == mevent.y)
    500498            return _pop_event(dp, ev);
    501499
  • libcaca/trunk/caca/driver_raw.c

    r2299 r2305  
    3030static int raw_init_graphics(caca_display_t *dp)
    3131{
    32     unsigned int width = cucul_get_canvas_width(dp->cv);
    33     unsigned int height = cucul_get_canvas_height(dp->cv);
     32    int width = cucul_get_canvas_width(dp->cv);
     33    int height = cucul_get_canvas_height(dp->cv);
    3434    char const *geometry;
    3535
     
    5757}
    5858
    59 static unsigned int raw_get_display_width(caca_display_t const *dp)
     59static int raw_get_display_width(caca_display_t const *dp)
    6060{
    6161    return 0;
    6262}
    6363
    64 static unsigned int raw_get_display_height(caca_display_t const *dp)
     64static int raw_get_display_height(caca_display_t const *dp)
    6565{
    6666    return 0;
     
    7070{
    7171    void *buffer;
    72     unsigned long int len;
     72    size_t len;
    7373
    7474    buffer = cucul_export_memory(dp->cv, "caca", &len);
  • libcaca/trunk/caca/driver_slang.c

    r2304 r2305  
    208208}
    209209
    210 static unsigned int slang_get_display_width(caca_display_t const *dp)
     210static int slang_get_display_width(caca_display_t const *dp)
    211211{
    212212    /* Fallback to a 6x10 font */
     
    214214}
    215215
    216 static unsigned int slang_get_display_height(caca_display_t const *dp)
     216static int slang_get_display_height(caca_display_t const *dp)
    217217{
    218218    /* Fallback to a 6x10 font */
     
    224224    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    225225    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    226     unsigned int width = cucul_get_canvas_width(dp->cv);
    227     unsigned int height = cucul_get_canvas_height(dp->cv);
     226    int width = cucul_get_canvas_width(dp->cv);
     227    int height = cucul_get_canvas_height(dp->cv);
    228228    int x, y;
    229229
     
    329329        char utf8[7];
    330330        uint32_t utf32;
    331         unsigned int i;
    332         size_t bytes = 0;
     331        size_t i, bytes = 0;
    333332
    334333        keys[0] = intkey;
     
    362361    {
    363362        int button = (SLang_getkey() - ' ' + 1) & 0xf;
    364         unsigned int x = SLang_getkey() - '!';
    365         unsigned int y = SLang_getkey() - '!';
     363        int x = SLang_getkey() - '!';
     364        int y = SLang_getkey() - '!';
    366365
    367366        ev->data.mouse.button = button;
  • libcaca/trunk/caca/driver_vga.c

    r2299 r2305  
    102102}
    103103
    104 static unsigned int vga_get_display_width(caca_display_t const *dp)
     104static int vga_get_display_width(caca_display_t const *dp)
    105105{
    106106    /* Fallback to a 320x200 screen */
     
    108108}
    109109
    110 static unsigned int vga_get_display_height(caca_display_t const *dp)
     110static int vga_get_display_height(caca_display_t const *dp)
    111111{
    112112    /* Fallback to a 320x200 screen */
     
    119119    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    120120    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    121     unsigned int width = cucul_get_canvas_width(dp->cv);
    122     unsigned int height = cucul_get_canvas_height(dp->cv);
     121    int width = cucul_get_canvas_width(dp->cv);
     122    int height = cucul_get_canvas_height(dp->cv);
    123123    int n;
    124124
  • libcaca/trunk/caca/driver_win32.c

    r2299 r2305  
    8383static int win32_init_graphics(caca_display_t *dp)
    8484{
    85     unsigned int width = cucul_get_canvas_width(dp->cv);
    86     unsigned int height = cucul_get_canvas_height(dp->cv);
     85    int width = cucul_get_canvas_width(dp->cv);
     86    int height = cucul_get_canvas_height(dp->cv);
    8787    CONSOLE_SCREEN_BUFFER_INFO csbi;
    8888    SMALL_RECT rect;
     
    176176}
    177177
    178 static unsigned int win32_get_display_width(caca_display_t const *dp)
     178static int win32_get_display_width(caca_display_t const *dp)
    179179{
    180180    /* FIXME */
     
    184184}
    185185
    186 static unsigned int win32_get_display_height(caca_display_t const *dp)
     186static int win32_get_display_height(caca_display_t const *dp)
    187187{
    188188    /* FIXME */
     
    199199    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    200200    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    201     unsigned int width = cucul_get_canvas_width(dp->cv);
    202     unsigned int height = cucul_get_canvas_height(dp->cv);
    203     unsigned int n;
     201    int width = cucul_get_canvas_width(dp->cv);
     202    int height = cucul_get_canvas_height(dp->cv);
     203    int n;
    204204
    205205    /* Render everything to our screen buffer */
     
    303303                COORD pos = rec.Event.MouseEvent.dwMousePosition;
    304304
    305                 if(dp->mouse.x == (unsigned int)pos.X &&
    306                    dp->mouse.y == (unsigned int)pos.Y)
     305                if(dp->mouse.x == pos.X && dp->mouse.y == pos.Y)
    307306                    continue;
    308307
  • libcaca/trunk/caca/driver_x11.c

    r2299 r2305  
    7676    char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser;
    7777    char const *geometry;
    78     unsigned int width = cucul_get_canvas_width(dp->cv);
    79     unsigned int height = cucul_get_canvas_height(dp->cv);
     78    int width = cucul_get_canvas_width(dp->cv);
     79    int height = cucul_get_canvas_height(dp->cv);
    8080    int i;
    8181
     
    112112    for( ; ; parser++)
    113113    {
    114         unsigned int font_max_char;
     114        uint32_t font_max_char;
    115115
    116116        if(!*parser)
     
    144144
    145145        font_max_char =
    146             (((unsigned int)dp->drv.p->font_struct->max_byte1) << 8)
     146            (dp->drv.p->font_struct->max_byte1 << 8)
    147147             | dp->drv.p->font_struct->max_char_or_byte2;
    148148        if(font_max_char && (font_max_char < dp->drv.p->max_char))
     
    278278}
    279279
    280 static unsigned int x11_get_display_width(caca_display_t const *dp)
     280static int x11_get_display_width(caca_display_t const *dp)
    281281{
    282282    return cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width;
    283283}
    284284
    285 static unsigned int x11_get_display_height(caca_display_t const *dp)
     285static int x11_get_display_height(caca_display_t const *dp)
    286286{
    287287    return cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height;
     
    292292    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
    293293    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
    294     unsigned int width = cucul_get_canvas_width(dp->cv);
    295     unsigned int height = cucul_get_canvas_height(dp->cv);
    296     unsigned int x, y, len;
     294    int width = cucul_get_canvas_width(dp->cv);
     295    int height = cucul_get_canvas_height(dp->cv);
     296    int x, y, len;
    297297
    298298    /* First draw the background colours. Splitting the process in two
     
    323323    for(y = 0; y < height; y++)
    324324    {
    325         unsigned int yoff = (y + 1) * dp->drv.p->font_height
     325        int yoff = (y + 1) * dp->drv.p->font_height
    326326                                    - dp->drv.p->font_offset;
    327327        uint32_t const *chars = cvchars + y * width;
     
    379379static int x11_get_event(caca_display_t *dp, caca_privevent_t *ev)
    380380{
    381     unsigned int width = cucul_get_canvas_width(dp->cv);
    382     unsigned int height = cucul_get_canvas_height(dp->cv);
     381    int width = cucul_get_canvas_width(dp->cv);
     382    int height = cucul_get_canvas_height(dp->cv);
    383383    XEvent xevent;
    384384    char key;
     
    402402        if(xevent.type == ConfigureNotify)
    403403        {
    404             unsigned int w, h;
     404            int w, h;
    405405
    406406            w = (xevent.xconfigure.width + dp->drv.p->font_width / 3)
     
    422422        if(xevent.type == MotionNotify)
    423423        {
    424             unsigned int newx = xevent.xmotion.x / dp->drv.p->font_width;
    425             unsigned int newy = xevent.xmotion.y / dp->drv.p->font_height;
     424            int newx = xevent.xmotion.x / dp->drv.p->font_width;
     425            int newy = xevent.xmotion.y / dp->drv.p->font_height;
    426426
    427427            if(newx >= width)
  • libcaca/trunk/caca/event.c

    r2303 r2305  
    6464 *  \return 1 if a matching event was received, or 0 if the wait timeouted.
    6565 */
    66 int caca_get_event(caca_display_t *dp, unsigned int event_mask,
     66int caca_get_event(caca_display_t *dp, int event_mask,
    6767                   caca_event_t *ev, int timeout)
    6868{
     
    128128 *  \return The X mouse coordinate.
    129129 */
    130 unsigned int caca_get_mouse_x(caca_display_t const *dp)
    131 {
    132     unsigned int width = cucul_get_canvas_width(dp->cv);
     130int caca_get_mouse_x(caca_display_t const *dp)
     131{
     132    int width = cucul_get_canvas_width(dp->cv);
    133133
    134134    if(dp->mouse.x >= width)
     
    150150 *  \return The Y mouse coordinate.
    151151 */
    152 unsigned int caca_get_mouse_y(caca_display_t const *dp)
    153 {
    154     unsigned int height = cucul_get_canvas_height(dp->cv);
     152int caca_get_mouse_y(caca_display_t const *dp)
     153{
     154    int height = cucul_get_canvas_height(dp->cv);
    155155
    156156    if(dp->mouse.y >= height)
     
    199199 *  \return The key value.
    200200 */
    201 unsigned int caca_get_event_key_ch(caca_event_t const *ev)
     201int caca_get_event_key_ch(caca_event_t const *ev)
    202202{
    203203    return ((caca_privevent_t const *)ev)->data.key.ch;
     
    250250 *  \return The event's mouse button.
    251251 */
    252 unsigned int caca_get_event_mouse_button(caca_event_t const *ev)
     252int caca_get_event_mouse_button(caca_event_t const *ev)
    253253{
    254254    return ((caca_privevent_t const *)ev)->data.mouse.button;
     
    266266 *  \return The event's X mouse coordinate.
    267267 */
    268 unsigned int caca_get_event_mouse_x(caca_event_t const *ev)
     268int caca_get_event_mouse_x(caca_event_t const *ev)
    269269{
    270270    return ((caca_privevent_t const *)ev)->data.mouse.x;
     
    282282 *  \return The event's Y mouse coordinate.
    283283 */
    284 unsigned int caca_get_event_mouse_y(caca_event_t const *ev)
     284int caca_get_event_mouse_y(caca_event_t const *ev)
    285285{
    286286    return ((caca_privevent_t const *)ev)->data.mouse.y;
     
    298298 *  \return The event's new display width value.
    299299 */
    300 unsigned int caca_get_event_resize_width(caca_event_t const *ev)
     300int caca_get_event_resize_width(caca_event_t const *ev)
    301301{
    302302    return ((caca_privevent_t const *)ev)->data.resize.w;
     
    314314 *  \return The event's new display height value.
    315315 */
    316 unsigned int caca_get_event_resize_height(caca_event_t const *ev)
     316int caca_get_event_resize_height(caca_event_t const *ev)
    317317{
    318318    return ((caca_privevent_t const *)ev)->data.resize.h;
     
    326326{
    327327#if defined(USE_SLANG) || defined(USE_NCURSES)
    328     unsigned int ticks;
     328    int ticks;
    329329#endif
    330330    int ret;
  • libcaca/trunk/caca/graphics.c

    r2299 r2305  
    6363 *  \return The display width.
    6464 */
    65 unsigned int caca_get_display_width(caca_display_t const *dp)
     65int caca_get_display_width(caca_display_t const *dp)
    6666{
    6767    return dp->drv.get_display_width(dp);
     
    8080 *  \return The display height.
    8181 */
    82 unsigned int caca_get_display_height(caca_display_t const *dp)
     82int caca_get_display_height(caca_display_t const *dp)
    8383{
    8484    return dp->drv.get_display_height(dp);
     
    9494 *  default behaviour.
    9595 *
    96  *  This function never fails.
     96 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     97 *  - \c EINVAL Refresh delay value is invalid.
    9798 *
    9899 *  \param dp The libcaca display context.
    99100 *  \param usec The refresh delay in microseconds.
    100  *  \return This function always returns 0.
    101  */
    102 int caca_set_display_time(caca_display_t *dp, unsigned int usec)
    103 {
     101 *  \return 0 upon success, -1 if an error occurred.
     102 */
     103int caca_set_display_time(caca_display_t *dp, int usec)
     104{
     105    if(usec < 0)
     106    {
     107        seterrno(EINVAL);
     108        return -1;
     109    }
     110
    104111    dp->delay = usec;
    105112    return 0;
     
    119126 *  \return The render time in microseconds.
    120127 */
    121 unsigned int caca_get_display_time(caca_display_t const *dp)
     128int caca_get_display_time(caca_display_t const *dp)
    122129{
    123130    return dp->rendertime;
  • libcaca/trunk/caca/time.c

    r2299 r2305  
    3636#include "caca_internals.h"
    3737
    38 void _caca_sleep(unsigned int usec)
     38void _caca_sleep(int usec)
    3939{
    4040#if defined(HAVE_USLEEP)
     
    4747}
    4848
    49 unsigned int _caca_getticks(caca_timer_t *timer)
     49int _caca_getticks(caca_timer_t *timer)
    5050{
    5151#if defined(HAVE_GETTIMEOFDAY)
     
    5353#elif defined(USE_WIN32)
    5454    static __int64 freq = -1; /* FIXME: can this move to caca_context? */
    55     unsigned __int64 usec;
     55    __int64 usec;
    5656#endif
    57     unsigned int ticks = 0;
     57    int ticks = 0;
    5858    int new_sec, new_usec;
    5959
  • libcaca/trunk/cucul/canvas.c

    r2304 r2305  
    300300{
    301301    uint32_t attr = cv->curattr;
    302     unsigned int n;
     302    int n;
    303303
    304304    for(n = cv->width * cv->height; n--; )
     
    394394    endj = (y + src->height >= dst->height) ? dst->height - y : src->height;
    395395
    396     if((unsigned int)starti > src->width || (unsigned int)startj > src->height
     396    if(starti > src->width || startj > src->height
    397397        || starti >= endi || startj >= endj)
    398398        return 0;
     
    400400    for(j = startj; j < endj; j++)
    401401    {
    402         unsigned int dstix = (j + y) * dst->width + starti + x;
    403         unsigned int srcix = j * src->width + starti;
     402        int dstix = (j + y) * dst->width + starti + x;
     403        int srcix = j * src->width + starti;
    404404        int stride = endi - starti;
    405405
     
    408408            dst->chars[dstix - 1] = ' ';
    409409
    410         if((unsigned int)(endi + x) < dst->width
     410        if(endi + x < dst->width
    411411                && dst->chars[dstix + stride] == CUCUL_MAGIC_FULLWIDTH)
    412412            dst->chars[dstix + stride] = ' ';
     
    433433            dst->chars[dstix] = ' ';
    434434
    435         if((unsigned int)endi < src->width
    436                 && src->chars[endi] == CUCUL_MAGIC_FULLWIDTH)
     435        if(endi < src->width && src->chars[endi] == CUCUL_MAGIC_FULLWIDTH)
    437436            dst->chars[dstix + stride - 1] = ' ';
    438437    }
     
    448447 *
    449448 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     449 *  - \c EINVAL Specified width or height is invalid.
    450450 *  - \c EBUSY The canvas is in use by a display driver and cannot be resized.
    451451 *  - \c ENOMEM Not enough memory for the requested canvas size. If this
     
    459459 *  \return 0 in case of success, -1 if an error occurred.
    460460 */
    461 int cucul_set_canvas_boundaries(cucul_canvas_t *cv, int x, int y,
    462                                 unsigned int w, unsigned int h)
     461int cucul_set_canvas_boundaries(cucul_canvas_t *cv, int x, int y, int w, int h)
    463462{
    464463    cucul_canvas_t *new;
    465     unsigned int f, saved_f, framecount;
     464    int f, saved_f, framecount;
    466465
    467466    if(cv->refcount)
    468467    {
    469468        seterrno(EBUSY);
     469        return -1;
     470    }
     471
     472    if(w < 0 || h < 0)
     473    {
     474        seterrno(EINVAL);
    470475        return -1;
    471476    }
  • libcaca/trunk/cucul/cucul.c

    r2300 r2305  
    3434#include "cucul_internals.h"
    3535
    36 static int cucul_resize(cucul_canvas_t *, unsigned int, unsigned int);
     36static int cucul_resize(cucul_canvas_t *, int, int);
    3737
    3838/** \brief Initialise a \e libcucul canvas.
     
    4747 *
    4848 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     49 *  - \c EINVAL Specified width or height is invalid.
    4950 *  - \c ENOMEM Not enough memory for the requested canvas size.
    5051 *
     
    5354 *  \return A libcucul canvas handle upon success, NULL if an error occurred.
    5455 */
    55 cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
    56 {
    57     cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t));
     56cucul_canvas_t * cucul_create_canvas(int width, int height)
     57{
     58    cucul_canvas_t *cv;
     59
     60    if(width < 0 || height < 0)
     61    {
     62        seterrno(EINVAL);
     63        return NULL;
     64    }
     65
     66    cv = malloc(sizeof(cucul_canvas_t));
    5867
    5968    if(!cv)
     
    191200 *
    192201 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     202 *  - \c EINVAL Specified width or height is invalid.
    193203 *  - \c EBUSY The canvas is in use by a display driver and cannot be resized.
    194204 *  - \c ENOMEM Not enough memory for the requested canvas size. If this
     
    200210 *  \return 0 in case of success, -1 if an error occurred.
    201211 */
    202 int cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
    203                                               unsigned int height)
    204 {
     212int cucul_set_canvas_size(cucul_canvas_t *cv, int width, int height)
     213{
     214    if(width < 0 || height < 0)
     215    {
     216        seterrno(EINVAL);
     217        return -1;
     218    }
     219
    205220    if(cv->refcount && cv->resize_callback
    206221        && !cv->resize_callback(cv->resize_data))
     
    222237 *  \return The canvas width.
    223238 */
    224 unsigned int cucul_get_canvas_width(cucul_canvas_t const *cv)
     239int cucul_get_canvas_width(cucul_canvas_t const *cv)
    225240{
    226241    return cv->width;
     
    236251 *  \return The canvas height.
    237252 */
    238 unsigned int cucul_get_canvas_height(cucul_canvas_t const *cv)
     253int cucul_get_canvas_height(cucul_canvas_t const *cv)
    239254{
    240255    return cv->height;
     
    293308int cucul_free_canvas(cucul_canvas_t *cv)
    294309{
    295     unsigned int f;
     310    int f;
    296311
    297312    if(cv->refcount)
     
    357372 */
    358373
    359 int cucul_resize(cucul_canvas_t *cv, unsigned int width, unsigned int height)
    360 {
    361     unsigned int x, y, f, old_width, old_height, new_size, old_size;
     374int cucul_resize(cucul_canvas_t *cv, int width, int height)
     375{
     376    int x, y, f, old_width, old_height, new_size, old_size;
    362377
    363378    old_width = cv->width;
     
    427442        /* New width is smaller. Copy as many lines as possible. Ignore
    428443         * the first line, it is already in place. */
    429         unsigned int lines = height < old_height ? height : old_height;
     444        int lines = height < old_height ? height : old_height;
    430445
    431446        for(f = 0; f < cv->framecount; f++)
  • libcaca/trunk/cucul/cucul.h

    r2304 r2305  
    2828
    2929#undef __extern
    30 #if defined(_WIN32) && defined(__LIBCUCUL__)
     30#if defined(_DOXYGEN_SKIP_ME)
     31#elif defined(_WIN32) && defined(__LIBCUCUL__)
    3132#   define __extern extern __declspec(dllexport)
    3233#else
     
    8788 *
    8889 *  @{ */
    89 __extern cucul_canvas_t * cucul_create_canvas(unsigned int, unsigned int);
     90__extern cucul_canvas_t * cucul_create_canvas(int, int);
    9091__extern int cucul_manage_canvas(cucul_canvas_t *, int (*)(void *), void *);
    9192__extern int cucul_unmanage_canvas(cucul_canvas_t *, int (*)(void *), void *);
    92 __extern int cucul_set_canvas_size(cucul_canvas_t *, unsigned int,
    93                                    unsigned int);
    94 __extern unsigned int cucul_get_canvas_width(cucul_canvas_t const *);
    95 __extern unsigned int cucul_get_canvas_height(cucul_canvas_t const *);
     93__extern int cucul_set_canvas_size(cucul_canvas_t *, int, int);
     94__extern int cucul_get_canvas_width(cucul_canvas_t const *);
     95__extern int cucul_get_canvas_height(cucul_canvas_t const *);
    9696__extern uint8_t const * cucul_get_canvas_chars(cucul_canvas_t const *);
    9797__extern uint8_t const * cucul_get_canvas_attrs(cucul_canvas_t const *);
     
    126126__extern int cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *,
    127127                        cucul_canvas_t const *);
    128 __extern int cucul_set_canvas_boundaries(cucul_canvas_t *, int, int,
    129                                          unsigned int, unsigned int);
     128__extern int cucul_set_canvas_boundaries(cucul_canvas_t *, int, int, int, int);
    130129/*  @} */
    131130
     
    208207 *
    209208 *  @{ */
    210 __extern unsigned int cucul_get_frame_count(cucul_canvas_t const *);
    211 __extern int cucul_set_frame(cucul_canvas_t *, unsigned int);
     209__extern int cucul_get_frame_count(cucul_canvas_t const *);
     210__extern int cucul_set_frame(cucul_canvas_t *, int);
    212211__extern char const *cucul_get_frame_name(cucul_canvas_t const *);
    213212__extern int cucul_set_frame_name(cucul_canvas_t *, char const *);
    214 __extern int cucul_create_frame(cucul_canvas_t *, unsigned int);
    215 __extern int cucul_free_frame(cucul_canvas_t *, unsigned int);
     213__extern int cucul_create_frame(cucul_canvas_t *, int);
     214__extern int cucul_free_frame(cucul_canvas_t *, int);
    216215/*  @} */
    217216
     
    222221 *
    223222 *  @{ */
    224 __extern cucul_dither_t *cucul_create_dither(unsigned int, unsigned int,
    225                                              unsigned int, unsigned int,
     223__extern cucul_dither_t *cucul_create_dither(int, int, int, int,
    226224                                             uint32_t, uint32_t,
    227225                                             uint32_t, uint32_t);
    228226__extern int cucul_set_dither_palette(cucul_dither_t *,
    229                                       unsigned int r[], unsigned int g[],
    230                                       unsigned int b[], unsigned int a[]);
     227                                      uint32_t r[], uint32_t g[],
     228                                      uint32_t b[], uint32_t a[]);
    231229__extern int cucul_set_dither_brightness(cucul_dither_t *, float);
    232230__extern float cucul_get_dither_brightness(cucul_dither_t const *);
     
    262260 *
    263261 *  @{ */
    264 __extern cucul_font_t *cucul_load_font(void const *, unsigned int);
     262__extern cucul_font_t *cucul_load_font(void const *, size_t);
    265263__extern char const * const * cucul_get_font_list(void);
    266 __extern unsigned int cucul_get_font_width(cucul_font_t const *);
    267 __extern unsigned int cucul_get_font_height(cucul_font_t const *);
    268 __extern unsigned int const *cucul_get_font_blocks(cucul_font_t const *);
     264__extern int cucul_get_font_width(cucul_font_t const *);
     265__extern int cucul_get_font_height(cucul_font_t const *);
     266__extern uint32_t const *cucul_get_font_blocks(cucul_font_t const *);
    269267__extern int cucul_render_canvas(cucul_canvas_t const *, cucul_font_t const *,
    270                                  void *, unsigned int, unsigned int,
    271                                  unsigned int);
     268                                 void *, int, int, int);
    272269__extern int cucul_free_font(cucul_font_t *);
    273270/*  @} */
     
    367364#endif
    368365
    369 #if !defined(_DOXYGEN_SKIP_ME)
    370 #   undef __extern
    371 #endif
     366#undef __extern
    372367
    373368#endif /* __CUCUL_H__ */
  • libcaca/trunk/cucul/cucul_internals.h

    r2299 r2305  
    2323{
    2424    /* Frame size */
    25     unsigned int width, height;
     25    int width, height;
    2626
    2727    /* Cell information */
     
    4444
    4545    /* Frame information */
    46     unsigned int frame, framecount;
     46    int frame, framecount;
    4747    struct cucul_frame *frames;
    4848
    4949    /* Canvas management */
    50     unsigned int refcount;
    51     unsigned int autoinc;
     50    int refcount;
     51    int autoinc;
    5252    int (*resize_callback)(void *);
    5353    void *resize_data;
    5454
    5555    /* Shortcut to the active frame information */
    56     unsigned int width, height;
     56    int width, height;
    5757    uint32_t *chars;
    5858    uint32_t *attrs;
     
    6565struct cucul_buffer
    6666{
    67     unsigned long int size;
     67    size_t size;
    6868    char *data;
    6969    int user_data;
  • libcaca/trunk/cucul/dither.c

    r2303 r2305  
    139139    char const *algo_name;
    140140    void (*init_dither) (int);
    141     unsigned int (*get_dither) (void);
     141    int (*get_dither) (void);
    142142    void (*increment_dither) (void);
    143143
    144144    char const *glyph_name;
    145145    uint32_t const * glyphs;
    146     unsigned glyph_count;
     146    int glyph_count;
    147147
    148148    int invert;
     
    179179/* Dithering algorithms */
    180180static void init_no_dither(int);
    181 static unsigned int get_no_dither(void);
     181static int get_no_dither(void);
    182182static void increment_no_dither(void);
    183183
    184184static void init_fstein_dither(int);
    185 static unsigned int get_fstein_dither(void);
     185static int get_fstein_dither(void);
    186186static void increment_fstein_dither(void);
    187187
    188188static void init_ordered2_dither(int);
    189 static unsigned int get_ordered2_dither(void);
     189static int get_ordered2_dither(void);
    190190static void increment_ordered2_dither(void);
    191191
    192192static void init_ordered4_dither(int);
    193 static unsigned int get_ordered4_dither(void);
     193static int get_ordered4_dither(void);
    194194static void increment_ordered4_dither(void);
    195195
    196196static void init_ordered8_dither(int);
    197 static unsigned int get_ordered8_dither(void);
     197static int get_ordered8_dither(void);
    198198static void increment_ordered8_dither(void);
    199199
    200200static void init_random_dither(int);
    201 static unsigned int get_random_dither(void);
     201static int get_random_dither(void);
    202202static void increment_random_dither(void);
    203203
     
    261261 *  \return Dither object upon success, NULL if an error occurred.
    262262 */
    263 cucul_dither_t *cucul_create_dither(unsigned int bpp, unsigned int w,
    264                                     unsigned int h, unsigned int pitch,
     263cucul_dither_t *cucul_create_dither(int bpp, int w, int h, int pitch,
    265264                                    uint32_t rmask, uint32_t gmask,
    266265                                    uint32_t bmask, uint32_t amask)
     
    270269
    271270    /* Minor sanity test */
    272     if(!w || !h || !pitch || bpp > 32 || bpp < 8)
     271    if(w < 0 || h < 0 || pitch < 0 || bpp > 32 || bpp < 8)
    273272    {
    274273        seterrno(EINVAL);
     
    374373 */
    375374int cucul_set_dither_palette(cucul_dither_t *d,
    376                              unsigned int red[], unsigned int green[],
    377                              unsigned int blue[], unsigned int alpha[])
     375                             uint32_t red[], uint32_t green[],
     376                             uint32_t blue[], uint32_t alpha[])
    378377{
    379378    int i, has_alpha = 0;
     
    947946    uint32_t savedattr;
    948947    int fs_length;
    949     int x1, y1, x2, y2, pitch, deltax, deltay;
    950     unsigned int dchmax;
     948    int x1, y1, x2, y2, pitch, deltax, deltay, dchmax;
    951949
    952950    if(!d || !pixels)
     
    982980            x++)
    983981    {
    984         unsigned int i;
    985         int ch = 0, distmin;
    986982        unsigned int rgba[4];
     983        int error[3];
     984        int i, ch = 0, distmin;
    987985        int fg_r = 0, fg_g = 0, fg_b = 0, bg_r, bg_g, bg_b;
    988986        int fromx, fromy, tox, toy, myx, myy, dots, dist;
    989         int error[3];
    990 
    991         unsigned int outfg = 0, outbg = 0;
     987
     988        int outfg = 0, outbg = 0;
    992989        uint32_t outch;
    993990
     
    13631360}
    13641361
    1365 static unsigned int get_no_dither(void)
     1362static int get_no_dither(void)
    13661363{
    13671364    return 0x80;
     
    13811378}
    13821379
    1383 static unsigned int get_fstein_dither(void)
     1380static int get_fstein_dither(void)
    13841381{
    13851382    return 0x80;
     
    13941391 * Ordered 2 dithering
    13951392 */
    1396 static unsigned int const *ordered2_table;
    1397 static unsigned int ordered2_index;
     1393static int const *ordered2_table;
     1394static int ordered2_index;
    13981395
    13991396static void init_ordered2_dither(int line)
    14001397{
    1401     static unsigned int const dither2x2[] =
     1398    static int const dither2x2[] =
    14021399    {
    14031400        0x00, 0x80,
     
    14091406}
    14101407
    1411 static unsigned int get_ordered2_dither(void)
     1408static int get_ordered2_dither(void)
    14121409{
    14131410    return ordered2_table[ordered2_index];
     
    14261423                          -2, -7, -8,  3,
    14271424                           4, -3, -4, -7};*/
    1428 static unsigned int const *ordered4_table;
    1429 static unsigned int ordered4_index;
     1425static int const *ordered4_table;
     1426static int ordered4_index;
    14301427
    14311428static void init_ordered4_dither(int line)
    14321429{
    1433     static unsigned int const dither4x4[] =
     1430    static int const dither4x4[] =
    14341431    {
    14351432        0x00, 0x80, 0x20, 0xa0,
     
    14431440}
    14441441
    1445 static unsigned int get_ordered4_dither(void)
     1442static int get_ordered4_dither(void)
    14461443{
    14471444    return ordered4_table[ordered4_index];
     
    14561453 * Ordered 8 dithering
    14571454 */
    1458 static unsigned int const *ordered8_table;
    1459 static unsigned int ordered8_index;
     1455static int const *ordered8_table;
     1456static int ordered8_index;
    14601457
    14611458static void init_ordered8_dither(int line)
    14621459{
    1463     static unsigned int const dither8x8[] =
     1460    static int const dither8x8[] =
    14641461    {
    14651462        0x00, 0x80, 0x20, 0xa0, 0x08, 0x88, 0x28, 0xa8,
     
    14771474}
    14781475
    1479 static unsigned int get_ordered8_dither(void)
     1476static int get_ordered8_dither(void)
    14801477{
    14811478    return ordered8_table[ordered8_index];
     
    14951492}
    14961493
    1497 static unsigned int get_random_dither(void)
     1494static int get_random_dither(void)
    14981495{
    14991496    return cucul_rand(0x00, 0x100);
     
    15101507static int init_lookup(void)
    15111508{
    1512     unsigned int v, s, h;
     1509    int v, s, h;
    15131510
    15141511    /* These ones are constant */
  • libcaca/trunk/cucul/export.c

    r2304 r2305  
    163163{
    164164    char *data, *cur;
    165     unsigned int f, n;
     165    int f, n;
    166166
    167167    /* 52 bytes for the header:
     
    223223
    224224    char *data, *cur;
    225     unsigned int x, y;
     225    int x, y;
    226226
    227227    /* 23 bytes assumed for max length per pixel ('\e[5;1;3x;4y;9x;10ym' plus
     
    303303
    304304    char *data, *cur;
    305     unsigned int x, y;
     305    int x, y;
    306306
    307307    uint8_t prevfg = -1;
     
    377377{
    378378    char *data, *cur;
    379     unsigned int x, y, len;
     379    int x, y, len;
    380380
    381381    /* The HTML header: less than 1000 bytes
     
    459459{
    460460    char *data, *cur;
    461     unsigned int x, y, len;
     461    int x, y, len;
    462462
    463463    /* The HTML table markup: less than 1000 bytes
     
    483483        for(x = 0; x < cv->width; x += len)
    484484        {
    485             unsigned int i, needfont;
     485            int i, needfont;
    486486
    487487            /* Use colspan option to factor cells with same attributes
     
    560560{
    561561    char *data, *cur;
    562     unsigned int x, y, len;
     562    int x, y, len;
    563563
    564564    /* The font markup: less than 100 bytes
     
    581581        for(x = 0; x < cv->width; x += len)
    582582        {
    583             unsigned int i, needback, needfront;
     583            int i, needback, needfront;
    584584
    585585            /* Use colspan option to factor cells with same attributes
     
    667667
    668668    char *data, *cur;
    669     unsigned int x, y;
     669    int x, y;
    670670
    671671    /* 14 bytes assumed for max length per pixel. Worst case scenario:
     
    793793
    794794    char *data, *cur;
    795     unsigned int x, y;
     795    int x, y;
    796796
    797797    /* 200 is arbitrary but should be ok */
     
    884884
    885885    char *data, *cur;
    886     unsigned int x, y;
     886    int x, y;
    887887
    888888    /* 200 is arbitrary but should be ok */
     
    965965    char *data, *cur;
    966966    cucul_font_t *f;
    967     unsigned int i, w, h;
     967    int i, w, h;
    968968
    969969    fontlist = cucul_get_font_list();
  • libcaca/trunk/cucul/figfont.c

    r2303 r2305  
    3434struct cucul_figfont
    3535{
    36     unsigned int term_width;
     36    int term_width;
    3737    int x, y, w, h, lines;
    3838
    3939    enum { H_DEFAULT, H_KERN, H_SMUSH, H_NONE, H_OVERLAP } hmode;
    40     unsigned int hsmushrule;
     40    int hsmushrule;
    4141    uint32_t hardblank;
    42     unsigned int height, baseline, max_length;
     42    int height, baseline, max_length;
    4343    int old_layout;
    44     unsigned int print_direction, full_layout, codetag_count;
    45     unsigned int glyphs;
     44    int print_direction, full_layout, codetag_count;
     45    int glyphs;
    4646    cucul_canvas_t *fontcv, *charcv;
    4747    int *left, *right; /* Unused yet */
    48     unsigned int *lookup;
     48    uint32_t *lookup;
    4949};
    5050
    51 static uint32_t hsmush(uint32_t ch1, uint32_t ch2, unsigned int rule);
     51static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule);
    5252static cucul_figfont_t * open_figfont(char const *);
    5353static int free_figfont(cucul_figfont_t *);
     
    131131{
    132132    cucul_figfont_t *ff = cv->ff;
    133     unsigned int c, w, h, x, y, overlap, extra, xleft, xright;
     133    int c, w, h, x, y, overlap, extra, xleft, xright;
    134134
    135135    switch(ch)
     
    254254{
    255255    cucul_figfont_t *ff = cv->ff;
    256     unsigned int x, y;
     256    int x, y;
    257257
    258258    //ff->torender = cv;
     
    292292    char *data = NULL;
    293293    cucul_file_t *f;
    294     unsigned int i, j, size, comment_lines;
     294    int i, j, size, comment_lines;
    295295
    296296    ff = malloc(sizeof(cucul_figfont_t));
     
    488488}
    489489
    490 static uint32_t hsmush(uint32_t ch1, uint32_t ch2, unsigned int rule)
     490static uint32_t hsmush(uint32_t ch1, uint32_t ch2, int rule)
    491491{
    492492    /* Rule 1 */
  • libcaca/trunk/cucul/font.c

    r2303 r2305  
    7171#define DECLARE_UNPACKGLYPH(bpp) \
    7272    static inline void \
    73       unpack_glyph ## bpp(uint8_t *glyph, uint8_t *packed_data, \
    74                           unsigned int n) \
     73      unpack_glyph ## bpp(uint8_t *glyph, uint8_t *packed_data, int n) \
    7574{ \
    76     unsigned int i; \
     75    int i; \
    7776    \
    7877    for(i = 0; i < n; i++) \
     
    112111 *  \return A font handle or NULL in case of error.
    113112 */
    114 cucul_font_t *cucul_load_font(void const *data, unsigned int size)
     113cucul_font_t *cucul_load_font(void const *data, size_t size)
    115114{
    116115    cucul_font_t *f;
    117     unsigned int i;
     116    int i;
    118117
    119118    if(size == 0)
     
    248247                + f->header.blocks * sizeof(struct block_info),
    249248           f->header.glyphs * sizeof(struct glyph_info));
    250     for(i = 0; i < f->header.glyphs; i++)
     249    for(i = 0; i < (int)f->header.glyphs; i++)
    251250    {
    252251        f->glyph_list[i].width = hton16(f->glyph_list[i].width);
     
    325324 *  \return The standard glyph width.
    326325 */
    327 unsigned int cucul_get_font_width(cucul_font_t const *f)
     326int cucul_get_font_width(cucul_font_t const *f)
    328327{
    329328    return f->header.width;
     
    340339 *  \return The standard glyph height.
    341340 */
    342 unsigned int cucul_get_font_height(cucul_font_t const *f)
     341int cucul_get_font_height(cucul_font_t const *f)
    343342{
    344343    return f->header.height;
     
    405404 *  all. They may be cropped instead in future versions.
    406405 *
    407  *  This function never fails.
     406 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     407 *  - \c EINVAL Specified width, height or pitch is invalid.
    408408 *
    409409 *  \param cv The canvas to render
     
    413413 *  \param height The height (in pixels) of the image buffer
    414414 *  \param pitch The pitch (in bytes) of an image buffer line.
    415  *  \return This function always returns 0.
     415 *  \return 0 in case of success, -1 if an error occurred.
    416416 */
    417417int cucul_render_canvas(cucul_canvas_t const *cv, cucul_font_t const *f,
    418                         void *buf, unsigned int width,
    419                         unsigned int height, unsigned int pitch)
     418                        void *buf, int width, int height, int pitch)
    420419{
    421420    uint8_t *glyph = NULL;
    422     unsigned int x, y, xmax, ymax;
     421    int x, y, xmax, ymax;
     422
     423    if(width < 0 || height < 0 || pitch < 0)
     424    {
     425        seterrno(EINVAL);
     426        return -1;
     427    }
    423428
    424429    if(f->header.bpp != 8)
     
    440445        {
    441446            uint8_t argb[8];
    442             unsigned int starty = y * f->header.height;
    443             unsigned int startx = x * f->header.width;
     447            int starty = y * f->header.height;
     448            int startx = x * f->header.width;
    444449            uint32_t ch = cv->chars[y * cv->width + x];
    445450            uint32_t attr = cv->attrs[y * cv->width + x];
    446             unsigned int b, i, j;
     451            int b, i, j;
    447452            struct glyph_info *g;
    448453
  • libcaca/trunk/cucul/frame.c

    r2299 r2305  
    3737 *  \return The frame count
    3838 */
    39 unsigned int cucul_get_frame_count(cucul_canvas_t const *cv)
     39int cucul_get_frame_count(cucul_canvas_t const *cv)
    4040{
    4141    return cv->framecount;
     
    5757 *  \return 0 in case of success, -1 if an error occurred.
    5858 */
    59 int cucul_set_frame(cucul_canvas_t *cv, unsigned int id)
    60 {
    61     if(id >= cv->framecount)
     59int cucul_set_frame(cucul_canvas_t *cv, int id)
     60{
     61    if(id < 0 || id >= cv->framecount)
    6262    {
    6363        seterrno(EINVAL);
     
    125125 *  values range from 0 to the current canvas frame count. If the frame
    126126 *  index is greater than or equals the current canvas frame count, the new
    127  *  frame is appended at the end of the canvas.
     127 *  frame is appended at the end of the canvas. If the frame index is less
     128 *  than zero, the new frame is inserted at index 0.
    128129 *
    129130 *  The active frame does not change, but its index may be renumbered due
     
    137138 *  \return 0 in case of success, -1 if an error occurred.
    138139 */
    139 int cucul_create_frame(cucul_canvas_t *cv, unsigned int id)
    140 {
    141     unsigned int size = cv->width * cv->height;
    142     unsigned int f;
    143 
    144     if(id > cv->framecount)
     140int cucul_create_frame(cucul_canvas_t *cv, int id)
     141{
     142    int size = cv->width * cv->height;
     143    int f;
     144
     145    if(id < 0)
     146        id = 0;
     147    else if(id > cv->framecount)
    145148        id = cv->framecount;
    146149
     
    195198 *  \return 0 in case of success, -1 if an error occurred.
    196199 */
    197 int cucul_free_frame(cucul_canvas_t *cv, unsigned int id)
    198 {
    199     unsigned int f;
    200 
    201     if(id >= cv->framecount)
     200int cucul_free_frame(cucul_canvas_t *cv, int id)
     201{
     202    int f;
     203
     204    if(id < 0 || id >= cv->framecount)
    202205    {
    203206        seterrno(EINVAL);
  • libcaca/trunk/cucul/transform.c

    r2299 r2305  
    4747{
    4848    uint32_t *attrs = cv->attrs;
    49     unsigned int i;
     49    int i;
    5050
    5151    for(i = cv->height * cv->width; i--; )
     
    7272int cucul_flip(cucul_canvas_t *cv)
    7373{
    74     unsigned int y;
     74    int y;
    7575
    7676    for(y = 0; y < cv->height; y++)
     
    131131int cucul_flop(cucul_canvas_t *cv)
    132132{
    133     unsigned int x;
     133    int x;
    134134
    135135    for(x = 0; x < cv->width; x++)
     
    181181    uint32_t *abegin = cv->attrs;
    182182    uint32_t *aend = abegin + cv->width * cv->height - 1;
    183     unsigned int y;
     183    int y;
    184184
    185185    while(cbegin < cend)
     
    243243{
    244244    uint32_t *newchars, *newattrs;
    245     unsigned int x, y, w2, h2;
     245    int x, y, w2, h2;
    246246
    247247    if(cv->refcount)
     
    360360{
    361361    uint32_t *newchars, *newattrs;
    362     unsigned int x, y, w2, h2;
     362    int x, y, w2, h2;
    363363
    364364    if(cv->refcount)
     
    475475{
    476476    uint32_t *newchars, *newattrs;
    477     unsigned int x, y;
     477    int x, y;
    478478
    479479    if(cv->refcount)
     
    566566{
    567567    uint32_t *newchars, *newattrs;
    568     unsigned int x, y;
     568    int x, y;
    569569
    570570    if(cv->refcount)
  • libcaca/trunk/examples/text.c

    r2299 r2305  
    3838    cucul_canvas_t *cv, *pig;
    3939    void *buffer;
    40     unsigned long int len;
    41     unsigned int i, j;
     40    size_t len;
     41    int i, j;
    4242
    4343    pig = cucul_create_canvas(0, 0);
Note: See TracChangeset for help on using the changeset viewer.