Changeset 2304


Ignore:
Timestamp:
Apr 19, 2008, 9:25:47 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Get rid of the last long types in the API.
  • Use size_t and ssize_t where appropriate.
Location:
libcaca/trunk
Files:
13 edited

Legend:

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

    r2299 r2304  
    421421        char utf8[7];
    422422        uint32_t utf32;
    423         unsigned int i, bytes = 0;
     423        unsigned int i;
     424        size_t bytes = 0;
    424425
    425426        keys[0] = intkey;
  • libcaca/trunk/caca/driver_slang.c

    r2299 r2304  
    329329        char utf8[7];
    330330        uint32_t utf32;
    331         unsigned int i, bytes = 0;
     331        unsigned int i;
     332        size_t bytes = 0;
    332333
    333334        keys[0] = intkey;
  • libcaca/trunk/cucul/canvas.c

    r2303 r2304  
    220220int cucul_put_str(cucul_canvas_t *cv, int x, int y, char const *s)
    221221{
    222     unsigned int rd;
     222    size_t rd;
    223223
    224224    if(y < 0 || y >= (int)cv->height || x >= (int)cv->width)
  • libcaca/trunk/cucul/charset.c

    r2303 r2304  
    112112 *  is incomplete.
    113113 */
    114 uint32_t cucul_utf8_to_utf32(char const *s, unsigned int *read)
    115 {
    116     unsigned int bytes = trailing[(int)(unsigned char)*s];
     114uint32_t cucul_utf8_to_utf32(char const *s, size_t *bytes)
     115{
     116    unsigned int todo = trailing[(int)(unsigned char)*s];
    117117    unsigned int i = 0;
    118118    uint32_t ret = 0;
     
    122122        if(!*s)
    123123        {
    124             if(read)
    125                 *read = 0;
     124            if(bytes)
     125                *bytes = 0;
    126126            return 0;
    127127        }
    128128
    129         ret += ((uint32_t)(unsigned char)*s++) << (6 * (bytes - i));
    130 
    131         if(bytes == i++)
     129        ret += ((uint32_t)(unsigned char)*s++) << (6 * (todo - i));
     130
     131        if(todo == i++)
    132132        {
    133             if(read)
    134                 *read = i;
    135             return ret - offsets[bytes];
     133            if(bytes)
     134                *bytes = i;
     135            return ret - offsets[todo];
    136136        }
    137137    }
     
    151151 *  \return The number of bytes written.
    152152 */
    153 unsigned int cucul_utf32_to_utf8(char *buf, uint32_t ch)
     153size_t cucul_utf32_to_utf8(char *buf, uint32_t ch)
    154154{
    155155    static const uint8_t mark[7] =
     
    159159
    160160    char *parser = buf;
    161     int bytes;
     161    size_t bytes;
    162162
    163163    if(ch < 0x80)
  • libcaca/trunk/cucul/cucul.h

    r2303 r2304  
    163163 *
    164164 *  @{ */
    165 __extern uint32_t cucul_utf8_to_utf32(char const *, unsigned int *);
    166 __extern unsigned int cucul_utf32_to_utf8(char *, uint32_t);
     165__extern uint32_t cucul_utf8_to_utf32(char const *, size_t *);
     166__extern size_t cucul_utf32_to_utf8(char *, uint32_t);
    167167__extern uint8_t cucul_utf32_to_cp437(uint32_t);
    168168__extern uint32_t cucul_cp437_to_utf32(uint8_t);
     
    289289 *
    290290 *  @{ */
    291 __extern long int cucul_import_memory(cucul_canvas_t *, void const *,
    292                                       unsigned long int, char const *);
    293 __extern long int cucul_import_file(cucul_canvas_t *, char const *,
    294                                     char const *);
     291__extern ssize_t cucul_import_memory(cucul_canvas_t *, void const *,
     292                                     size_t, char const *);
     293__extern ssize_t cucul_import_file(cucul_canvas_t *, char const *,
     294                                   char const *);
    295295__extern char const * const * cucul_get_import_list(void);
    296296__extern void *cucul_export_memory(cucul_canvas_t const *, char const *,
    297                                    unsigned long int *);
     297                                   size_t *);
    298298__extern char const * const * cucul_get_export_list(void);
    299299/*  @} */
  • libcaca/trunk/cucul/cucul_types.h.in

    r2299 r2304  
    3838typedef signed short int16_t;
    3939typedef signed long int int32_t;
     40typedef signed long long int int64_t;
    4041
    4142typedef unsigned char uint8_t;
    4243typedef unsigned short uint16_t;
    4344typedef unsigned long int uint32_t;
     45typedef unsigned long long int uint64_t;
    4446
    4547typedef long int intptr_t;
  • libcaca/trunk/cucul/export.c

    r2300 r2304  
    4545}
    4646
    47 static void *export_caca(cucul_canvas_t const *, unsigned long int *);
    48 static void *export_ansi(cucul_canvas_t const *, unsigned long int *);
    49 static void *export_utf8(cucul_canvas_t const *, unsigned long int *, int);
    50 static void *export_html(cucul_canvas_t const *, unsigned long int *);
    51 static void *export_html3(cucul_canvas_t const *, unsigned long int *);
    52 static void *export_bbfr(cucul_canvas_t const *, unsigned long int *);
    53 static void *export_irc(cucul_canvas_t const *, unsigned long int *);
    54 static void *export_ps(cucul_canvas_t const *, unsigned long int *);
    55 static void *export_svg(cucul_canvas_t const *, unsigned long int *);
    56 static void *export_tga(cucul_canvas_t const *, unsigned long int *);
     47static void *export_caca(cucul_canvas_t const *, size_t *);
     48static void *export_ansi(cucul_canvas_t const *, size_t *);
     49static void *export_utf8(cucul_canvas_t const *, size_t *, int);
     50static void *export_html(cucul_canvas_t const *, size_t *);
     51static void *export_html3(cucul_canvas_t const *, size_t *);
     52static void *export_bbfr(cucul_canvas_t const *, size_t *);
     53static void *export_irc(cucul_canvas_t const *, size_t *);
     54static void *export_ps(cucul_canvas_t const *, size_t *);
     55static void *export_svg(cucul_canvas_t const *, size_t *);
     56static void *export_tga(cucul_canvas_t const *, size_t *);
    5757
    5858/** \brief Export a canvas into a foreign format.
     
    7979 *  \param cv A libcucul canvas
    8080 *  \param format A string describing the requested output format.
    81  *  \param bytes A pointer to an unsigned long integer where the number of
    82  *         allocated bytes will be written.
     81 *  \param bytes A pointer to a size_t where the number of allocated bytes
     82 *         will be written.
    8383 *  \return A pointer to the exported memory area, or NULL in case of error.
    8484 */
    8585void *cucul_export_memory(cucul_canvas_t const *cv, char const *format,
    86                           unsigned long int *bytes)
     86                          size_t *bytes)
    8787{
    8888    if(!strcasecmp("caca", format))
     
    160160
    161161/* Generate a native libcaca canvas file. */
    162 static void *export_caca(cucul_canvas_t const *cv, unsigned long int *bytes)
     162static void *export_caca(cucul_canvas_t const *cv, size_t *bytes)
    163163{
    164164    char *data, *cur;
     
    213213
    214214/* Generate UTF-8 representation of current canvas. */
    215 static void *export_utf8(cucul_canvas_t const *cv, unsigned long int *bytes,
     215static void *export_utf8(cucul_canvas_t const *cv, size_t *bytes,
    216216                         int cr)
    217217{
     
    294294
    295295/* Generate ANSI representation of current canvas. */
    296 static void *export_ansi(cucul_canvas_t const *cv, unsigned long int *bytes)
     296static void *export_ansi(cucul_canvas_t const *cv, size_t *bytes)
    297297{
    298298    static uint8_t const palette[] =
     
    374374
    375375/* Generate HTML representation of current canvas. */
    376 static void *export_html(cucul_canvas_t const *cv, unsigned long int *bytes)
     376static void *export_html(cucul_canvas_t const *cv, size_t *bytes)
    377377{
    378378    char *data, *cur;
     
    456456 * will not work under gecko (mozilla rendering engine) unless you set a
    457457 * correct header. */
    458 static void *export_html3(cucul_canvas_t const *cv, unsigned long int *bytes)
     458static void *export_html3(cucul_canvas_t const *cv, size_t *bytes)
    459459{
    460460    char *data, *cur;
     
    557557}
    558558
    559 static void *export_bbfr(cucul_canvas_t const *cv, unsigned long int *bytes)
     559static void *export_bbfr(cucul_canvas_t const *cv, size_t *bytes)
    560560{
    561561    char *data, *cur;
     
    658658
    659659/* Export a text file with IRC colours */
    660 static void *export_irc(cucul_canvas_t const *cv, unsigned long int *bytes)
     660static void *export_irc(cucul_canvas_t const *cv, size_t *bytes)
    661661{
    662662    static uint8_t const palette[] =
     
    765765
    766766/* Export a PostScript document. */
    767 static void *export_ps(cucul_canvas_t const *cv, unsigned long int *bytes)
     767static void *export_ps(cucul_canvas_t const *cv, size_t *bytes)
    768768{
    769769    static char const *ps_header =
     
    874874
    875875/* Export an SVG vector image */
    876 static void *export_svg(cucul_canvas_t const *cv, unsigned long int *bytes)
     876static void *export_svg(cucul_canvas_t const *cv, size_t *bytes)
    877877{
    878878    static char const svg_header[] =
     
    960960
    961961/* Export a TGA image */
    962 static void *export_tga(cucul_canvas_t const *cv, unsigned long int *bytes)
     962static void *export_tga(cucul_canvas_t const *cv, size_t *bytes)
    963963{
    964964    char const * const *fontlist;
  • libcaca/trunk/cucul/import.c

    r2299 r2304  
    5353};
    5454
    55 static long int import_caca(cucul_canvas_t *, void const *, unsigned int);
    56 static long int import_text(cucul_canvas_t *, void const *, unsigned int);
    57 static long int import_ansi(cucul_canvas_t *, void const *, unsigned int, int);
     55static ssize_t import_caca(cucul_canvas_t *, void const *, size_t);
     56static ssize_t import_text(cucul_canvas_t *, void const *, size_t);
     57static ssize_t import_ansi(cucul_canvas_t *, void const *, size_t, int);
    5858
    5959static void ansi_parse_grcm(cucul_canvas_t *, struct import *,
     
    8787 *  or -1 if an error occurred.
    8888 */
    89 long int cucul_import_memory(cucul_canvas_t *cv, void const *data,
    90                              unsigned long int len, char const *format)
     89ssize_t cucul_import_memory(cucul_canvas_t *cv, void const *data,
     90                            size_t len, char const *format)
    9191{
    9292    if(!strcasecmp("caca", format))
     
    152152 *  or -1 if an error occurred.
    153153 */
    154 long int cucul_import_file(cucul_canvas_t *cv, char const *filename,
    155                            char const *format)
     154ssize_t cucul_import_file(cucul_canvas_t *cv, char const *filename,
     155                          char const *format)
    156156{
    157157#if defined __KERNEL__
     
    161161    FILE *fp;
    162162    void *data;
    163     long int size;
     163    ssize_t size;
    164164    int ret;
    165165
     
    220220 */
    221221
    222 static long int import_caca(cucul_canvas_t *cv,
    223                             void const *data, unsigned int size)
     222static ssize_t import_caca(cucul_canvas_t *cv, void const *data, size_t size)
    224223{
    225224    uint8_t const *buf = (uint8_t const *)data;
     
    338337}
    339338
    340 static long int import_text(cucul_canvas_t *cv,
    341                             void const *data, unsigned int size)
     339static ssize_t import_text(cucul_canvas_t *cv, void const *data, size_t size)
    342340{
    343341    char const *text = (char const *)data;
     
    381379}
    382380
    383 static long int import_ansi(cucul_canvas_t *cv,
    384                             void const *data, unsigned int size, int utf8)
     381static ssize_t import_ansi(cucul_canvas_t *cv, void const *data,
     382                           size_t size, int utf8)
    385383{
    386384    struct import im;
     
    683681        else if(utf8)
    684682        {
    685             unsigned int bytes;
     683            size_t bytes;
    686684
    687685            if(i + 6 < size)
  • libcaca/trunk/cxx/cucul++.cpp

    r2303 r2304  
    2626
    2727
    28 uint32_t Charset::utf8ToUtf32(char const *s, unsigned int *read)
     28uint32_t Charset::utf8ToUtf32(char const *s, size_t *read)
    2929{
    3030    return cucul_utf8_to_utf32(s, read);
    3131}
    32 unsigned int Charset::utf32ToUtf8(char *buf, uint32_t ch)
     32size_t Charset::utf32ToUtf8(char *buf, uint32_t ch)
    3333{
    3434    return cucul_utf32_to_utf8(buf, ch);
  • libcaca/trunk/cxx/cucul++.h

    r2303 r2304  
    3939{
    4040 public:
    41     uint32_t utf8ToUtf32(char const *, unsigned int *);
    42     unsigned int utf32ToUtf8(char *, uint32_t);
     41    uint32_t utf8ToUtf32(char const *, size_t *);
     42    size_t utf32ToUtf8(char *, uint32_t);
    4343    uint8_t utf32ToCp437(uint32_t);
    4444    uint32_t cp437ToUtf32(uint8_t);
  • libcaca/trunk/examples/font2tga.c

    r2299 r2304  
    2424int main(int argc, char *argv[])
    2525{
    26     unsigned long int const *blocks;
     26    uint32_t const *blocks;
    2727    cucul_font_t *f;
    2828    char const * const * fonts;
    2929    cucul_canvas_t *cv;
    3030    void *buffer;
    31     unsigned long int len;
     31    size_t len;
    3232    unsigned int i, j, x, y, cells, width;
    3333
  • libcaca/trunk/src/aafire.c

    r2299 r2304  
    4646static cucul_dither_t *cucul_dither;
    4747static char *bitmap;
    48 static int pause = 0;
     48static int paused = 0;
    4949#else
    5050static aa_context *context;
     
    213213  char *bitmap = aa_image (context);
    214214#else
    215   if(pause)
    216     goto paused;
     215  if(paused)
     216    goto _paused;
    217217#endif
    218218
     
    238238  firemain ();
    239239#ifdef LIBCACA
    240 paused:
     240_paused:
    241241  cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv),
    242242                      cucul_get_canvas_height(cv), cucul_dither, bitmap);
     
    280280                case CACA_KEY_CTRL_Z:
    281281                case CACA_KEY_ESCAPE: return;
    282                 case ' ': pause = !pause;
     282                case ' ': paused = !paused;
    283283            }
    284284        }
  • libcaca/trunk/src/cacademo.c

    r2299 r2304  
    7373    static cucul_canvas_t *frontcv, *backcv, *mask;
    7474
    75     int demo, next = -1, pause = 0, next_transition = DEMO_FRAMES;
     75    int demo, next = -1, paused = 0, next_transition = DEMO_FRAMES;
    7676    unsigned int i;
    7777    int tmode = cucul_rand(0, TRANSITION_COUNT);
     
    118118                    goto end;
    119119                case ' ':
    120                     pause = !pause;
     120                    paused = !paused;
    121121                    break;
    122122                case '\r':
     
    133133                                    cucul_get_canvas_height(frontcv));
    134134
    135         if(pause)
    136             goto paused;
     135        if(paused)
     136            goto _paused;
    137137
    138138        /* Update demo's data */
     
    160160
    161161        frame++;
    162 paused:
     162_paused:
    163163        /* Render main demo's canvas */
    164164        fn[demo](RENDER, frontcv);
Note: See TracChangeset for help on using the changeset viewer.