diff options
| author | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:56:41 -0800 | 
|---|---|---|
| committer | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:59:33 -0800 | 
| commit | d577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch) | |
| tree | 590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/src/iup_assert.c | |
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/src/iup_assert.c')
| -rwxr-xr-x | iup/src/iup_assert.c | 54 | 
1 files changed, 54 insertions, 0 deletions
| diff --git a/iup/src/iup_assert.c b/iup/src/iup_assert.c new file mode 100755 index 0000000..11de909 --- /dev/null +++ b/iup/src/iup_assert.c @@ -0,0 +1,54 @@ +/** \file + * \brief String Utilities + * + * See Copyright Notice in "iup.h" + */ + +  +#include <string.h>   +#include <stdlib.h>   +#include <stdio.h>   +#include <limits.h>   +#include <stdarg.h> + +#include "iup.h" + +#include "iup_assert.h" +#include "iup_attrib.h" +#include "iup_str.h" +#include "iup_strmessage.h" + +/* from iup_open, but it is not exported, used only here */ +int iupIsOpened(void); + +void iupError(const char* format, ...) +{ +  static char msg[SHRT_MAX]; +  va_list arglist; +  va_start(arglist, format); +  vsprintf(msg, format, arglist); +  va_end(arglist); +#if IUP_ASSERT_CONSOLE  +  fprintf(stderr, msg); +#else +  if (iupIsOpened()) +    iupStrMessageShowError(NULL, msg); +  else +    fprintf(stderr, msg); +#endif +} + +void iupAssert(const char* expr, const char* file, int line, const char* func) +{ +  if (func) +    iupError("File: %s\n" +             "Line: %d\n" +             "Function: %s\n" +             "Assertive: (%s)",  +             file, line, func, expr); +  else +    iupError("File: %s\n" +             "Line: %d\n" +             "Assertive: (%s)",  +             file, line, expr); +} | 
