Changeset 870


Ignore:
Timestamp:
Apr 25, 2006, 11:59:58 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Check for <errno.h>.
  • Started changing function prototypes so that they return an integer instead of void, just in case they might fail.
Location:
libcaca/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/configure.ac

    r867 r870  
    6666  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
    6767
    68 AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h)
     68AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h)
    6969AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
    7070AC_CHECK_FUNCS(usleep gettimeofday)
  • libcaca/trunk/cucul/box.c

    r859 r870  
    2828/** \brief Draw a box on the canvas using the given character.
    2929 *
     30 *  This function never fails.
     31 *
    3032 *  \param cv The handle to the libcucul canvas.
    3133 *  \param x1 X coordinate of the upper-left corner of the box.
     
    3436 *  \param y2 Y coordinate of the lower-right corner of the box.
    3537 *  \param str UTF-8 string containing the character to use to draw the box.
    36  *  \return void
     38 *  \return This function always returns 0.
    3739 */
    38 void cucul_draw_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
    39                     char const *str)
     40int cucul_draw_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     41                   char const *str)
    4042{
    4143    cucul_draw_line(cv, x1, y1, x1, y2, str);
     
    4345    cucul_draw_line(cv, x2, y2, x2, y1, str);
    4446    cucul_draw_line(cv, x2, y1, x1, y1, str);
     47
     48    return 0;
    4549}
    4650
    4751/** \brief Draw a thin box on the canvas.
     52 *
     53 *  This function never fails.
    4854 *
    4955 *  \param cv The handle to the libcucul canvas.
     
    5258 *  \param x2 X coordinate of the lower-right corner of the box.
    5359 *  \param y2 Y coordinate of the lower-right corner of the box.
    54  *  \return void
     60 *  \return This function always returns 0.
    5561 */
    56 void cucul_draw_thin_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
     62int cucul_draw_thin_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
    5763{
    5864    int x, y, xmax, ymax;
     
    7480
    7581    if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax)
    76         return;
     82        return 0;
    7783
    7884    /* Draw edges */
     
    105111    if(x2 <= xmax && y2 <= ymax)
    106112        _cucul_putchar32(cv, x2, y2, (uint32_t)'\'');
     113
     114    return 0;
    107115}
    108116
    109117/** \brief Fill a box on the canvas using the given character.
     118 *
     119 *  This function never fails.
    110120 *
    111121 *  \param cv The handle to the libcucul canvas.
     
    115125 *  \param y2 Y coordinate of the lower-right corner of the box.
    116126 *  \param str UTF-8 string containing the character to fill the box with.
    117  *  \return void
     127 *  \return This function always returns 0.
    118128 */
    119 void cucul_fill_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
    120                     char const *str)
     129int cucul_fill_box(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     130                   char const *str)
    121131{
    122132    int x, y, xmax, ymax;
     
    139149
    140150    if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax)
    141         return;
     151        return 0;
    142152
    143153    if(x1 < 0) x1 = 0;
     
    151161        for(x = x1; x <= x2; x++)
    152162            _cucul_putchar32(cv, x, y, ch);
     163
     164    return 0;
    153165}
    154166
  • libcaca/trunk/cucul/buffer.c

    r859 r870  
    3333 *  in the given \e libcucul buffer.
    3434 *
     35 *  This function never fails.
     36 *
    3537 *  \param buf A \e libcucul buffer
    3638 *  \return The buffer data length.
     
    4547 *  This function returns a pointer to the memory area stored in the given
    4648 *  \e libcucul buffer.
     49 *
     50 *  This function never fails.
    4751 *
    4852 *  \param buf A \e libcucul buffer
     
    5963 *  \e libcucul buffer.
    6064 *
     65 *  This function never fails.
     66 *
    6167 *  \param buf A \e libcucul buffer
     68 *  \return This function always returns 0.
    6269 */
    63 void cucul_free_buffer(cucul_buffer_t *buf)
     70int cucul_free_buffer(cucul_buffer_t *buf)
    6471{
    6572    free(buf->data);
    6673    free(buf);
     74
     75    return 0;
    6776}
    6877
  • libcaca/trunk/cucul/canvas.c

    r859 r870  
    2525#   include <stdlib.h>
    2626#   include <stdarg.h>
     27#   if defined(HAVE_ERRNO_H)
     28#       include <errno.h>
     29#   endif
    2730#   if defined(HAVE_UNISTD_H)
    2831#       include <unistd.h>
     
    4851 *  character, use cucul_putstr() instead.
    4952 *
     53 *  This function never fails.
     54 *
    5055 *  \param cv A handle to the libcucul canvas.
    5156 *  \param x X coordinate.
    5257 *  \param y Y coordinate.
    5358 *  \param ch The character to print.
     59 *  \return This function always returns 0.
    5460 */
    5561void cucul_putchar(cucul_canvas_t *cv, int x, int y, char ch)
     
    7379 *  be cropped accordingly if it is too long.
    7480 *
     81 *  This function never fails.
     82 *
    7583 *  \param cv A handle to the libcucul canvas.
    7684 *  \param x X coordinate.
    7785 *  \param y Y coordinate.
    7886 *  \param s The string to print.
     87 *  \return This function always returns 0.
    7988 */
    8089void cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
     
    121130 *  string is the same as for the C printf() function.
    122131 *
     132 *  This function never fails.
     133 *
    123134 *  \param cv A handle to the libcucul canvas.
    124135 *  \param x X coordinate.
     
    126137 *  \param format The format string to print.
    127138 *  \param ... Arguments to the format string.
     139 *  \return This function always returns 0.
    128140 */
    129141void cucul_printf(cucul_canvas_t *cv, int x, int y, char const *format, ...)
     
    158170 *  This function clears the canvas using the current background colour.
    159171 *
     172 *  This function never fails.
     173 *
    160174 *  \param cv The canvas to clear.
     175 *  \return This function always returns 0.
    161176 */
    162177void cucul_clear_canvas(cucul_canvas_t *cv)
     
    183198 *  \param src The source canvas.
    184199 *  \param mask The mask canvas.
    185  */
    186 void cucul_blit(cucul_canvas_t *dst, int x, int y,
    187                 cucul_canvas_t const *src, cucul_canvas_t const *mask)
     200 *  \return 0 in case of success, -1 otherwise.
     201 */
     202int cucul_blit(cucul_canvas_t *dst, int x, int y,
     203               cucul_canvas_t const *src, cucul_canvas_t const *mask)
    188204{
    189205    int i, j, starti, startj, endi, endj;
    190206
    191207    if(mask && (src->width != mask->width || src->height != mask->height))
    192         return;
     208    {
     209#if defined(HAVE_ERRNO_H)
     210        errno = EINVAL;
     211#endif
     212        return -1;
     213    }
    193214
    194215    starti = x < 0 ? -x : 0;
     
    198219
    199220    if(starti >= endi || startj >= endj)
    200         return;
     221        return 0;
    201222
    202223    for(j = startj; j < endj; j++)
     
    225246        }
    226247    }
     248
     249    return 0;
    227250}
    228251
  • libcaca/trunk/cucul/conic.c

    r859 r870  
    3030
    3131/** \brief Draw a circle on the canvas using the given character.
     32 *
     33 *  This function never fails.
    3234 *
    3335 *  \param cv The handle to the libcucul canvas.
     
    3739 *  \param str UTF-8 string representing the character that should be used
    3840 *         to draw the circle outline.
    39  *  \return void
    40  */
    41 void cucul_draw_circle(cucul_canvas_t *cv, int x, int y, int r, char const *str)
     41 *  \return This function always returns 0.
     42 */
     43int cucul_draw_circle(cucul_canvas_t *cv, int x, int y, int r, char const *str)
    4244{
    4345    int test, dx, dy;
     
    5254        test += test > 0 ? dx - dy-- : dx;
    5355    }
     56
     57    return 0;
    5458}
    5559
    5660/** \brief Fill an ellipse on the canvas using the given character.
     61 *
     62 *  This function never fails.
    5763 *
    5864 *  \param cv The handle to the libcucul canvas.
     
    6369 *  \param str UTF-8 string representing the character that should be used
    6470 *         to fill the ellipse.
    65  *  \return void
    66  */
    67 void cucul_fill_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
    68                         char const *str)
     71 *  \return This function always returns 0.
     72 */
     73int cucul_fill_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
     74                       char const *str)
    6975{
    7076    int d2;
     
    109115        cucul_draw_line(cv, xo - x, yo + y, xo + x, yo + y, str);
    110116    }
     117
     118    return 0;
    111119}
    112120
    113121/** \brief Draw an ellipse on the canvas using the given character.
     122 *
     123 *  This function never fails.
    114124 *
    115125 *  \param cv The handle to the libcucul canvas.
     
    120130 *  \param str UTF-8 string representing the character that should be used
    121131 *         to draw the ellipse outline.
    122  *  \return void
    123  */
    124 void cucul_draw_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
    125                         char const *str)
     132 *  \return This function always returns 0.
     133 */
     134int cucul_draw_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b,
     135                       char const *str)
    126136{
    127137    int d2;
     
    164174        ellipsepoints(cv, xo, yo, x, y, ch);
    165175    }
     176
     177    return 0;
    166178}
    167179
    168180/** \brief Draw a thin ellipse on the canvas.
     181 *
     182 *  This function never fails.
    169183 *
    170184 *  \param cv The handle to the libcucul canvas.
     
    173187 *  \param a Ellipse X radius.
    174188 *  \param b Ellipse Y radius.
    175  *  \return void
    176  */
    177 void cucul_draw_thin_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b)
     189 *  \return This function always returns 0.
     190 */
     191int cucul_draw_thin_ellipse(cucul_canvas_t *cv, int xo, int yo, int a, int b)
    178192{
    179193    /* FIXME: this is not correct */
     
    216230        ellipsepoints(cv, xo, yo, x, y, '|');
    217231    }
     232
     233    return 0;
    218234}
    219235
  • libcaca/trunk/cucul/cucul.h

    r869 r870  
    8787unsigned long int cucul_get_buffer_size(cucul_buffer_t *);
    8888void * cucul_get_buffer_data(cucul_buffer_t *);
    89 void cucul_free_buffer(cucul_buffer_t *);
     89int cucul_free_buffer(cucul_buffer_t *);
    9090/*  @} */
    9191
     
    103103void cucul_printf(cucul_canvas_t *, int, int, char const *, ...);
    104104void cucul_clear_canvas(cucul_canvas_t *);
    105 void cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *);
     105int cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *);
    106106/*  @} */
    107107
     
    123123 *
    124124 *  @{ */
    125 void cucul_draw_line(cucul_canvas_t *, int, int, int, int, char const *);
    126 void cucul_draw_polyline(cucul_canvas_t *, int const x[], int const y[], int, char const *);
    127 void cucul_draw_thin_line(cucul_canvas_t *, int, int, int, int);
    128 void cucul_draw_thin_polyline(cucul_canvas_t *, int const x[], int const y[], int);
    129 
    130 void cucul_draw_circle(cucul_canvas_t *, int, int, int, char const *);
    131 void cucul_draw_ellipse(cucul_canvas_t *, int, int, int, int, char const *);
    132 void cucul_draw_thin_ellipse(cucul_canvas_t *, int, int, int, int);
    133 void cucul_fill_ellipse(cucul_canvas_t *, int, int, int, int, char const *);
    134 
    135 void cucul_draw_box(cucul_canvas_t *, int, int, int, int, char const *);
    136 void cucul_draw_thin_box(cucul_canvas_t *, int, int, int, int);
    137 void cucul_fill_box(cucul_canvas_t *, int, int, int, int, char const *);
    138 
    139 void cucul_draw_triangle(cucul_canvas_t *, int, int, int, int, int, int, char const *);
    140 void cucul_draw_thin_triangle(cucul_canvas_t *, int, int, int, int, int, int);
    141 void cucul_fill_triangle(cucul_canvas_t *, int, int, int, int, int, int, char const *);
     125int cucul_draw_line(cucul_canvas_t *, int, int, int, int, char const *);
     126int cucul_draw_polyline(cucul_canvas_t *, int const x[], int const y[], int, char const *);
     127int cucul_draw_thin_line(cucul_canvas_t *, int, int, int, int);
     128int cucul_draw_thin_polyline(cucul_canvas_t *, int const x[], int const y[], int);
     129
     130int cucul_draw_circle(cucul_canvas_t *, int, int, int, char const *);
     131int cucul_draw_ellipse(cucul_canvas_t *, int, int, int, int, char const *);
     132int cucul_draw_thin_ellipse(cucul_canvas_t *, int, int, int, int);
     133int cucul_fill_ellipse(cucul_canvas_t *, int, int, int, int, char const *);
     134
     135int cucul_draw_box(cucul_canvas_t *, int, int, int, int, char const *);
     136int cucul_draw_thin_box(cucul_canvas_t *, int, int, int, int);
     137int cucul_fill_box(cucul_canvas_t *, int, int, int, int, char const *);
     138
     139int cucul_draw_triangle(cucul_canvas_t *, int, int, int, int, int, int, char const *);
     140int cucul_draw_thin_triangle(cucul_canvas_t *, int, int, int, int, int, int);
     141int cucul_fill_triangle(cucul_canvas_t *, int, int, int, int, int, int, char const *);
    142142/*  @} */
    143143
  • libcaca/trunk/cucul/line.c

    r859 r870  
    4444/** \brief Draw a line on the canvas using the given character.
    4545 *
     46 *  This function never fails.
     47 *
    4648 *  \param cv The handle to the libcucul canvas.
    4749 *  \param x1 X coordinate of the first point.
     
    5052 *  \param y2 Y coordinate of the second point.
    5153 *  \param str UTF-8 string containing the character to use to draw the line.
    52  *  \return void
    53  */
    54 void cucul_draw_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
    55                      char const *str)
     54 *  \return This function always returns 0.
     55 */
     56int cucul_draw_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     57                    char const *str)
    5658{
    5759    struct line s;
     
    6365    s.draw = draw_solid_line;
    6466    clip_line(cv, &s);
     67
     68    return 0;
    6569}
    6670
     
    7175 *  draw a polygon you need to specify the starting point at the end of the
    7276 *  list as well.
     77 *
     78 *  This function never fails.
    7379 *
    7480 *  \param cv The handle to the libcucul canvas.
     
    7783 *  \param n Number of lines to draw.
    7884 *  \param str UTF-8 string containing the character to use to draw the lines.
    79  *  \return void
    80  */
    81 void cucul_draw_polyline(cucul_canvas_t *cv, int const x[], int const y[],
    82                          int n, char const *str)
     85 *  \return This function always returns 0.
     86 */
     87int cucul_draw_polyline(cucul_canvas_t *cv, int const x[], int const y[],
     88                        int n, char const *str)
    8389{
    8490    int i;
     
    95101        clip_line(cv, &s);
    96102    }
     103
     104    return 0;
    97105}
    98106
    99107/** \brief Draw a thin line on the canvas, using ASCII art.
     108 *
     109 *  This function never fails.
    100110 *
    101111 *  \param cv The handle to the libcucul canvas.
     
    104114 *  \param x2 X coordinate of the second point.
    105115 *  \param y2 Y coordinate of the second point.
    106  *  \return void
    107  */
    108 void cucul_draw_thin_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
     116 *  \return This function always returns 0.
     117 */
     118int cucul_draw_thin_line(cucul_canvas_t *cv, int x1, int y1, int x2, int y2)
    109119{
    110120    struct line s;
     
    115125    s.draw = draw_thin_line;
    116126    clip_line(cv, &s);
     127
     128    return 0;
    117129}
    118130
     
    124136 *  the list as well.
    125137 *
     138 *  This function never fails.
     139 *
    126140 *  \param cv The handle to the libcucul canvas.
    127141 *  \param x Array of X coordinates. Must have \p n + 1 elements.
    128142 *  \param y Array of Y coordinates. Must have \p n + 1 elements.
    129143 *  \param n Number of lines to draw.
    130  *  \return void
    131  */
    132 void cucul_draw_thin_polyline(cucul_canvas_t *cv, int const x[], int const y[],
    133                               int n)
     144 *  \return This function always returns 0.
     145 */
     146int cucul_draw_thin_polyline(cucul_canvas_t *cv, int const x[], int const y[],
     147                             int n)
    134148{
    135149    int i;
     
    145159        clip_line(cv, &s);
    146160    }
     161
     162    return 0;
    147163}
    148164
  • libcaca/trunk/cucul/triangle.c

    r859 r870  
    2828/** \brief Draw a triangle on the canvas using the given character.
    2929 *
     30 *  This function never fails.
     31 *
    3032 *  \param cv The handle to the libcucul canvas.
    3133 *  \param x1 X coordinate of the first point.
     
    3739 *  \param str UTF-8 string representing the character that should be used
    3840 *         to draw the triangle outline.
    39  *  \return void
     41 *  \return This function always returns 0.
    4042 */
    41 void cucul_draw_triangle(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
    42                          int x3, int y3, char const *str)
     43int cucul_draw_triangle(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     44                        int x3, int y3, char const *str)
    4345{
    4446    cucul_draw_line(cv, x1, y1, x2, y2, str);
    4547    cucul_draw_line(cv, x2, y2, x3, y3, str);
    4648    cucul_draw_line(cv, x3, y3, x1, y1, str);
     49
     50    return 0;
    4751}
    4852
    4953/** \brief Draw a thin triangle on the canvas.
     54 *
     55 *  This function never fails.
    5056 *
    5157 *  \param cv The handle to the libcucul canvas.
     
    5662 *  \param x3 X coordinate of the third point.
    5763 *  \param y3 Y coordinate of the third point.
    58  *  \return void
     64 *  \return This function always returns 0.
    5965 */
    60 void cucul_draw_thin_triangle(cucul_canvas_t *cv, int x1, int y1,
    61                               int x2, int y2, int x3, int y3)
     66int cucul_draw_thin_triangle(cucul_canvas_t *cv, int x1, int y1,
     67                             int x2, int y2, int x3, int y3)
    6268{
    6369    cucul_draw_thin_line(cv, x1, y1, x2, y2);
    6470    cucul_draw_thin_line(cv, x2, y2, x3, y3);
    6571    cucul_draw_thin_line(cv, x3, y3, x1, y1);
     72
     73    return 0;
    6674}
    6775
    6876/** \brief Fill a triangle on the canvas using the given character.
     77 *
     78 *  This function never fails.
    6979 *
    7080 *  \param cv The handle to the libcucul canvas.
     
    7787 *  \param str UTF-8 string representing the character that should be used
    7888 *         to fill the triangle.
    79  *  \return void
     89 *  \return This function always returns 0.
    8090 */
    81 void cucul_fill_triangle(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
    82                          int x3, int y3, char const *str)
     91int cucul_fill_triangle(cucul_canvas_t *cv, int x1, int y1, int x2, int y2,
     92                        int x3, int y3, char const *str)
    8393{
    8494    int x, y, xa, xb, xmax, ymax;
     
    8797    /* Bubble-sort y1 <= y2 <= y3 */
    8898    if(y1 > y2)
    89     {
    90         cucul_fill_triangle(cv, x2, y2, x1, y1, x3, y3, str);
    91         return;
    92     }
     99        return cucul_fill_triangle(cv, x2, y2, x1, y1, x3, y3, str);
    93100
    94101    if(y2 > y3)
    95     {
    96         cucul_fill_triangle(cv, x1, y1, x3, y3, x2, y2, str);
    97         return;
    98     }
     102        return cucul_fill_triangle(cv, x1, y1, x3, y3, x2, y2, str);
    99103
    100104    /* Promote precision */
     
    140144            _cucul_putchar32(cv, x, y, ch);
    141145    }
     146
     147    return 0;
    142148}
    143149
Note: See TracChangeset for help on using the changeset viewer.