Parcourir la source

* Added basis for an errno-like mechanism.

tags/v0.99.beta14
Sam Hocevar sam il y a 19 ans
Parent
révision
fc6d86d835
3 fichiers modifiés avec 59 ajouts et 1 suppressions
  1. +1
    -0
      cucul/Makefile.am
  2. +13
    -1
      cucul/cucul.h
  3. +45
    -0
      cucul/error.c

+ 1
- 0
cucul/Makefile.am Voir le fichier

@@ -16,6 +16,7 @@ libcucul_la_SOURCES = \
cucul_internals.h \
buffer.c \
canvas.c \
error.c \
transform.c \
charset.c \
colour.c \


+ 13
- 1
cucul/cucul.h Voir le fichier

@@ -31,7 +31,7 @@ extern "C"
{
#endif

/** \e libcucul context */
/** \e libcucul canvas */
typedef struct cucul_canvas cucul_canvas_t;
/** dither structure */
typedef struct cucul_dither cucul_dither_t;
@@ -79,6 +79,18 @@ void cucul_free_canvas(cucul_canvas_t *);
int cucul_rand(int, int);
/* @} */

/** \defgroup error libcucul error management
*
* These functions provide simple error management routines.
*
* @{ */
#define ECUCUL_NOMEM (100)
#define ECUCUL_INVAL (101)
#define ECUCUL_RANGE (102)
int cucul_errno(void);
char const *cucul_strerr(int);
/* @} */

/** \defgroup buffer libcucul buffer handling
*
* These functions provide methods to handle libcucul buffers.


+ 45
- 0
cucul/error.c Voir le fichier

@@ -0,0 +1,45 @@
/*
* libcucul Canvas for ultrafast compositing of Unicode letters
* Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Do What The Fuck You Want To
* Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* This file contains error management functions.
*/

#include "config.h"
#include "common.h"

#include "cucul.h"
#include "cucul_internals.h"

int cucul_errno(void)
{
return _cucul_errno;
}

char const *cucul_strerror(int error)
{
switch(error)
{
case 0:
return "no error";
case ECUCUL_NOMEM:
return "not enough memory";
case ECUCUL_INVAL:
return "invalid argument";
case ECUCUL_RANGE:
return "argument out of bounds";
default:
return "unknown error";
}
}


Chargement…
Annuler
Enregistrer