mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
debug macros
This commit is contained in:
parent
6b6e83db8f
commit
475eeb8121
7 changed files with 178 additions and 18 deletions
10
include/psyc.h
Normal file
10
include/psyc.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PSYC_EPOCH 1440444041 // 2015-08-24 21:20:41 CET (Monday)
|
||||
|
||||
/** @brief Checks if short keyword string matches long keyword string
|
||||
*/
|
||||
int PSYC_matches(uint8_t* sho, unsigned int slen,
|
||||
uint8_t* lon, unsigned int llen);
|
||||
|
95
include/psyc/debug.h
Normal file
95
include/psyc/debug.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
# define PP(args) printf args;
|
||||
#else
|
||||
# define PP(args)
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
# define PT(MSG) PP(MSG);
|
||||
# define DT(CODE) CODE
|
||||
#else
|
||||
# define PT(MSG)
|
||||
# define DT(CODE)
|
||||
#endif
|
||||
|
||||
/* simplified form of conditional compilation */
|
||||
|
||||
#ifndef DEBUG_FLAGS
|
||||
# ifdef DEBUG
|
||||
# if DEBUG == 1
|
||||
# define DEBUG_FLAGS 0x03
|
||||
# else
|
||||
# if DEBUG == 2
|
||||
# define DEBUG_FLAGS 0x07
|
||||
# else
|
||||
# if DEBUG == 3
|
||||
# define DEBUG_FLAGS 0x0f
|
||||
# else
|
||||
# if DEBUG == 4
|
||||
# define DEBUG_FLAGS 0x1f
|
||||
# else
|
||||
# define DEBUG_FLAGS 0x01
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# define DEBUG_FLAGS 0x00 /* no debugging */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if DEBUG_FLAGS & 0x01
|
||||
# define D0(CODE) CODE
|
||||
# define P0(MSG) PP(MSG);
|
||||
#else
|
||||
# define D0(CODE)
|
||||
# define P0(MSG)
|
||||
#endif
|
||||
|
||||
#if DEBUG_FLAGS & 0x02
|
||||
# define D1(CODE) CODE
|
||||
# define P1(MSG) PP(MSG);
|
||||
#else
|
||||
# define D1(CODE)
|
||||
# define P1(MSG)
|
||||
#endif
|
||||
|
||||
#if DEBUG_FLAGS & 0x04
|
||||
# define D2(CODE) CODE
|
||||
# define P2(MSG) PP(MSG);
|
||||
#else
|
||||
# define D2(CODE)
|
||||
# define P2(MSG)
|
||||
#endif
|
||||
|
||||
#if DEBUG_FLAGS & 0x08
|
||||
# define D3(CODE) CODE
|
||||
# define P3(MSG) PP(MSG);
|
||||
#else
|
||||
# define D3(CODE)
|
||||
# define P3(MSG)
|
||||
#endif
|
||||
|
||||
#if DEBUG_FLAGS & 0x10
|
||||
# define D4(CODE) CODE
|
||||
# define P4(MSG) PP(MSG);
|
||||
#else
|
||||
# define D4(CODE)
|
||||
# define P4(MSG)
|
||||
#endif
|
||||
|
||||
// ASSERT() unused as yet
|
||||
#if DEBUG > 0
|
||||
# ifdef STRICT
|
||||
# define ASSERT(NAME,COND,VALUE) { unless (COND) { \
|
||||
PP(("Assertion %s failed in %s: %s\n", NAME, ME, VALUE)); \
|
||||
raise_error("Assertion failed (strict mode).\n"); } }
|
||||
# else
|
||||
# define ASSERT(NAME,COND,VALUE) { unless (COND) \
|
||||
PP(("Assertion %s failed in %s: %s\n", NAME, ME, VALUE)); }
|
||||
# endif
|
||||
#else
|
||||
# define ASSERT(NAME,CONDITION,VALUE)
|
||||
#endif
|
||||
|
9
include/psyc/lib.h
Normal file
9
include/psyc/lib.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* this is needed to compile the library, not to use it */
|
||||
|
||||
#include "../psyc.h"
|
||||
#include "./debug.h"
|
||||
|
||||
/* perlisms for readability */
|
||||
#define unless(COND) if (!(COND))
|
||||
#define until(COND) while (!(COND))
|
||||
|
39
include/psyc/syntax.h
Normal file
39
include/psyc/syntax.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef PSYC_SYNTAX_H
|
||||
#define PSYC_SYNTAX_H
|
||||
|
||||
#ifndef PSYC_LIST_SIZE_LIMIT
|
||||
# define PSYC_LIST_SIZE_LIMIT 404
|
||||
#endif
|
||||
|
||||
/* beyond this a content length must be provided */
|
||||
#ifndef PSYC_CONTENT_SIZE_THRESHOLD
|
||||
# define PSYC_CONTENT_SIZE_THRESHOLD 444
|
||||
#endif
|
||||
|
||||
#define C_GLYPH_PACKET_DELIMITER '.'
|
||||
#define S_GLYPH_PACKET_DELIMITER "."
|
||||
|
||||
#define C_GLYPH_SEPARATOR_KEYWORD '_'
|
||||
#define S_GLYPH_SEPARATOR_KEYWORD "_"
|
||||
|
||||
#define C_GLYPH_MODIFIER_SET ':'
|
||||
#define S_GLYPH_MODIFIER_SET ":"
|
||||
|
||||
#define C_GLYPH_MODIFIER_ASSIGN '='
|
||||
#define S_GLYPH_MODIFIER_ASSIGN "="
|
||||
|
||||
#define C_GLYPH_MODIFIER_AUGMENT '+'
|
||||
#define S_GLYPH_MODIFIER_AUGMENT "+"
|
||||
|
||||
#define C_GLYPH_MODIFIER_DIMINISH '-'
|
||||
#define S_GLYPH_MODIFIER_DIMINISH "-"
|
||||
|
||||
#define C_GLYPH_MODIFIER_QUERY '?'
|
||||
#define S_GLYPH_MODIFIER_QUERY "?"
|
||||
|
||||
/* might move into routing.h or something */
|
||||
#define PSYC_ROUTING 1
|
||||
#define PSYC_ROUTING_MERGE 2
|
||||
#define PSYC_ROUTING_RENDER 4
|
||||
|
||||
#endif /* PSYC_SYNTAX_H */
|
Loading…
Add table
Add a link
Reference in a new issue