Ignore:
Timestamp:
Aug 2, 2006, 3:12:43 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Fixed libcaca prototypes so that all functions use the errno mechanism and return a value.
File:
1 edited

Legend:

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

    r984 r1006  
    2424#   include <stdlib.h>
    2525#   include <string.h>
     26#   if defined(HAVE_ERRNO_H)
     27#       include <errno.h>
     28#   endif
    2629#endif
    2730
     
    3134#include "caca_internals.h"
    3235
    33 static int caca_init_driver(caca_display_t *dp);
     36static int caca_select_driver(caca_display_t *dp);
    3437
    3538/** \brief Attach a caca graphical context to a cucul canvas.
     
    4043 *  then be displayed by the libcaca driver.
    4144 *
     45 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     46 *  - \c ENOMEM Not enough memory.
     47 *  - \c ENODEV Graphical device could not be initialised.
     48 *
    4249 *  \param cv The cucul cavas.
    4350 *  \return The caca graphical context or NULL if an error occurred.
     
    4754    caca_display_t *dp = malloc(sizeof(caca_display_t));
    4855
     56    if(!dp)
     57    {
     58#if defined(HAVE_ERRNO_H)
     59        errno = ENOMEM;
     60#endif
     61        return NULL;
     62    }
     63
    4964    dp->cv = cv;
    5065
    51     if(caca_init_driver(dp))
     66    if(caca_select_driver(dp))
    5267    {
    5368        free(dp);
     69#if defined(HAVE_ERRNO_H)
     70        errno = ENODEV;
     71#endif
    5472        return NULL;
    5573    }
     
    5876    {
    5977        free(dp);
     78#if defined(HAVE_ERRNO_H)
     79        errno = ENODEV;
     80#endif
    6081        return NULL;
    6182    }
     
    100121 *  attached to it afterwards.
    101122 *
     123 *  This function never fails.
     124 *
    102125 *  \param dp The libcaca graphical context.
    103  */
    104 void caca_free_display(caca_display_t *dp)
     126 *  \return This function always returns 0.
     127 */
     128int caca_free_display(caca_display_t *dp)
    105129{
    106130    dp->drv.end_graphics(dp);
    107131    dp->cv->refcount--;
    108132    free(dp);
     133
     134    return 0;
    109135}
    110136
     
    113139 */
    114140
    115 static int caca_init_driver(caca_display_t *dp)
     141static int caca_select_driver(caca_display_t *dp)
    116142{
    117143#if defined(HAVE_GETENV) && defined(HAVE_STRCASECMP)
Note: See TracChangeset for help on using the changeset viewer.