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/graphics.c

    r985 r1006  
    1919#include "common.h"
    2020
     21#if !defined(__KERNEL__)
     22#   if defined(HAVE_ERRNO_H)
     23#       include <errno.h>
     24#   endif
     25#endif
     26
    2127#include "caca.h"
    2228#include "caca_internals.h"
     
    2733 *
    2834 *  If libcaca runs in a window, try to change its title. This works with
    29  *  the X11 and Win32 drivers.
     35 *  the OpenGL, X11 and Win32 drivers.
     36 *
     37 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     38 *  - \c ENOSYS Display driver does not support setting the window title.
    3039 *
    3140 *  \param dp The libcaca display context.
    3241 *  \param title The desired display title.
    33  *  \return 0 upon success, a non-zero value if an error occurs.
     42 *  \return 0 upon success, -1 if an error occurred.
    3443 */
    3544int caca_set_display_title(caca_display_t *dp, char const *title)
    3645{
    37     return dp->drv.set_display_title(dp, title);
     46    int ret = dp->drv.set_display_title(dp, title);
     47
     48#if defined(HAVE_ERRNO_H)
     49    if(ret)
     50        errno = ENOSYS;
     51#endif
     52
     53    return ret;
    3854}
    3955
     
    4561 *  6x10 font is being used. Note that the units are not necessarily pixels.
    4662 *
     63 *  This function never fails.
     64 *
    4765 *  \param dp The libcaca display context.
    4866 *  \return The display width.
     
    6078 *  used. Note that the units are not necessarily pixels.
    6179 *
     80 *  This function never fails.
     81 *
    6282 *  \param dp The libcaca display context.
    6383 *  \return The display height.
     
    7797 *  default behaviour.
    7898 *
     99 *  This function never fails.
     100 *
    79101 *  \param dp The libcaca display context.
    80102 *  \param usec The refresh delay in microseconds.
    81  */
    82 void caca_set_display_time(caca_display_t *dp, unsigned int usec)
     103 *  \return This function always returns 0.
     104 */
     105int caca_set_display_time(caca_display_t *dp, unsigned int usec)
    83106{
    84107    dp->delay = usec;
     108    return 0;
    85109}
    86110
     
    93117 *  delay even if the real rendering time was shorter.
    94118 *
     119 *  This function never fails.
     120 *
    95121 *  \param dp The libcaca display context.
    96122 *  \return The render time in microseconds.
     
    113139 *  the second call will be delayed before performing the screen refresh.
    114140 *
    115  *  \param dp The libcaca display context.
    116  */
    117 void caca_refresh_display(caca_display_t *dp)
     141 *  This function never fails.
     142 *
     143 *  \param dp The libcaca display context.
     144 *  \return This function always returns 0.
     145 */
     146int caca_refresh_display(caca_display_t *dp)
    118147{
    119148#if !defined(_DOXYGEN_SKIP_ME)
     
    148177    if(dp->lastticks > (int)dp->delay)
    149178        dp->lastticks = 0;
     179
     180    return 0;
    150181}
    151182
     
    155186 *  support it.
    156187 *
     188 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     189 *  - \c ENOSYS Display driver does not support hiding the mouse pointer.
     190 *
    157191 *  \param dp The libcaca display context.
    158192 *  \param flag 0 hides the pointer, 1 shows the system's default pointer
    159193 *              (usually an arrow). Other values are reserved for future use.
    160  */
    161 void caca_set_mouse(caca_display_t *dp, int flag)
    162 {
    163     if(dp->drv.set_mouse)
    164         dp->drv.set_mouse(dp, flag);
     194 *  \return 0 upon success, -1 if an error occurred.
     195 */
     196int caca_set_mouse(caca_display_t *dp, int flag)
     197{
     198    if(!dp->drv.set_mouse)
     199    {
     200#if defined(HAVE_ERRNO_H)
     201        errno = ENOSYS;
     202#endif
     203        return -1;
     204    }
     205
     206    dp->drv.set_mouse(dp, flag);
     207    return 0;
    165208}
    166209
Note: See TracChangeset for help on using the changeset viewer.