Browse Source

Move debugging methods to caca_debug.h.

tags/v0.99.beta17
Sam Hocevar sam 15 years ago
parent
commit
b076ec19b0
5 changed files with 90 additions and 62 deletions
  1. +1
    -0
      caca/Makefile.am
  2. +41
    -0
      caca/caca_debug.h
  3. +1
    -0
      caca/caca_internals.h
  4. +3
    -22
      caca/caca_stubs.h
  5. +44
    -40
      caca/libcaca.vcproj

+ 1
- 0
caca/Makefile.am View File

@@ -19,6 +19,7 @@ libcaca_la_SOURCES = \
caca.h \
caca_types.h \
caca_internals.h \
caca_debug.h \
caca_stubs.h \
caca_conio.c \
caca_conio.h \


+ 41
- 0
caca/caca_debug.h View File

@@ -0,0 +1,41 @@
/*
* libcaca Colour ASCII-Art library
* Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
* 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 debugging functions.
*/

#ifndef __CACA_DEBUG_H__
#define __CACA_DEBUG_H__

/* debug messages */
#if defined DEBUG && !defined __KERNEL__
# include <stdio.h>
# include <stdarg.h>
static inline void debug(const char *format, ...)
{
int saved_errno = geterrno();
va_list args;
va_start(args, format);
fprintf(stderr, "** libcaca debug ** ");
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
va_end(args);
seterrno(saved_errno);
}
#else
# define debug(format, ...) do {} while(0)
#endif

#endif /* __CACA_DEBUG_H__ */


+ 1
- 0
caca/caca_internals.h View File

@@ -16,6 +16,7 @@
#define __CACA_INTERNALS_H__

#include "caca_stubs.h"
#include "caca_debug.h"

typedef struct caca_timer caca_timer_t;
typedef struct caca_privevent caca_privevent_t;


+ 3
- 22
caca/caca_stubs.h View File

@@ -16,8 +16,8 @@
* function prototypes that are sometimes missing.
*/

#ifndef __STUBS_H__
#define __STUBS_H__
#ifndef __CACA_STUBS_H__
#define __CACA_STUBS_H__

/* errno handling */
#if defined HAVE_ERRNO_H && !defined __KERNEL__
@@ -29,25 +29,6 @@ static inline int geterrno(void) { return errno; }
# define geterrno(x) 0
#endif

/* debug messages */
#if defined DEBUG && !defined __KERNEL__
# include <stdio.h>
# include <stdarg.h>
static inline void debug(const char *format, ...)
{
int saved_errno = geterrno();
va_list args;
va_start(args, format);
fprintf(stderr, "** libcaca debug ** ");
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
va_end(args);
seterrno(saved_errno);
}
#else
# define debug(format, ...) do {} while(0)
#endif

/* hton16() and hton32() */
#if defined HAVE_HTONS && !defined __KERNEL__
# if defined HAVE_ARPA_INET_H
@@ -93,5 +74,5 @@ static inline uint32_t hton32(uint32_t x)
}
#endif

#endif /* __STUBS_H__ */
#endif /* __CACA_STUBS_H__ */


+ 44
- 40
caca/libcaca.vcproj View File

@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
ModuleDefinitionFile=".\libcaca.def"
ModuleDefinitionFile="libcaca.def"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@@ -139,7 +139,7 @@
/>
<Tool
Name="VCLinkerTool"
ModuleDefinitionFile=".\libcaca.def"
ModuleDefinitionFile="libcaca.def"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@@ -211,7 +211,7 @@
/>
<Tool
Name="VCLinkerTool"
ModuleDefinitionFile=".\libcaca.def"
ModuleDefinitionFile="libcaca.def"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
@@ -286,7 +286,7 @@
/>
<Tool
Name="VCLinkerTool"
ModuleDefinitionFile=".\libcaca.def"
ModuleDefinitionFile="libcaca.def"
GenerateDebugInformation="true"
OptimizeReferences="2"
EnableCOMDATFolding="2"
@@ -324,39 +324,39 @@
Name="driver"
>
<File
RelativePath=".\driver\conio.c"
RelativePath="driver\conio.c"
>
</File>
<File
RelativePath=".\driver\gl.c"
RelativePath="driver\gl.c"
>
</File>
<File
RelativePath=".\driver\ncurses.c"
RelativePath="driver\ncurses.c"
>
</File>
<File
RelativePath=".\driver\null.c"
RelativePath="driver\null.c"
>
</File>
<File
RelativePath=".\driver\raw.c"
RelativePath="driver\raw.c"
>
</File>
<File
RelativePath=".\driver\slang.c"
RelativePath="driver\slang.c"
>
</File>
<File
RelativePath=".\driver\vga.c"
RelativePath="driver\vga.c"
>
</File>
<File
RelativePath=".\driver\win32.c"
RelativePath="driver\win32.c"
>
</File>
<File
RelativePath=".\driver\x11.c"
RelativePath="driver\x11.c"
>
</File>
</Filter>
@@ -364,32 +364,32 @@
Name="codec"
>
<File
RelativePath=".\codec\codec.h"
RelativePath="codec\codec.h"
>
</File>
<File
RelativePath=".\codec\export.c"
RelativePath="codec\export.c"
>
</File>
<File
RelativePath=".\codec\import.c"
RelativePath="codec\import.c"
>
</File>
<File
RelativePath=".\codec\text.c"
RelativePath="codec\text.c"
>
</File>
</Filter>
<File
RelativePath=".\attr.c"
RelativePath="attr.c"
>
</File>
<File
RelativePath=".\box.c"
RelativePath="box.c"
>
</File>
<File
RelativePath=".\caca.c"
RelativePath="caca.c"
>
</File>
<File
@@ -397,11 +397,15 @@
>
</File>
<File
RelativePath=".\caca_conio.c"
RelativePath="caca_conio.c"
>
</File>
<File
RelativePath=".\caca_conio.h"
RelativePath="caca_conio.h"
>
</File>
<File
RelativePath="caca_debug.h"
>
</File>
<File
@@ -417,11 +421,11 @@
>
</File>
<File
RelativePath=".\canvas.c"
RelativePath="canvas.c"
>
</File>
<File
RelativePath=".\charset.c"
RelativePath="charset.c"
>
</File>
<File
@@ -429,67 +433,67 @@
>
</File>
<File
RelativePath=".\conic.c"
RelativePath="conic.c"
>
</File>
<File
RelativePath=".\dirty.c"
RelativePath="dirty.c"
>
</File>
<File
RelativePath=".\dither.c"
RelativePath="dither.c"
>
</File>
<File
RelativePath=".\event.c"
RelativePath="event.c"
>
</File>
<File
RelativePath=".\figfont.c"
RelativePath="figfont.c"
>
</File>
<File
RelativePath=".\file.c"
RelativePath="file.c"
>
</File>
<File
RelativePath=".\font.c"
RelativePath="font.c"
>
</File>
<File
RelativePath=".\frame.c"
RelativePath="frame.c"
>
</File>
<File
RelativePath=".\graphics.c"
RelativePath="graphics.c"
>
</File>
<File
RelativePath=".\legacy.c"
RelativePath="legacy.c"
>
</File>
<File
RelativePath=".\libcaca.def"
RelativePath="libcaca.def"
>
</File>
<File
RelativePath=".\line.c"
RelativePath="line.c"
>
</File>
<File
RelativePath=".\string.c"
RelativePath="string.c"
>
</File>
<File
RelativePath=".\time.c"
RelativePath="time.c"
>
</File>
<File
RelativePath=".\transform.c"
RelativePath="transform.c"
>
</File>
<File
RelativePath=".\triangle.c"
RelativePath="triangle.c"
>
</File>
</Files>


Loading…
Cancel
Save