X-Git-Url: http://git.jankratochvil.net/?p=vblib.git;a=blobdiff_plain;f=vblib.h;h=c40f47d89373657cb87ec97a31848a2c4688cbd3;hp=8ee18bcc64766b4f9d5b51884c04cfe92cf70ab3;hb=2855398ad0fd631f11c2395da59bc3941fa75e5f;hpb=568dfce1d3c4b7b3bc4fc1503469a35b5e21734f diff --git a/vblib.h b/vblib.h index 8ee18bc..c40f47d 100644 --- a/vblib.h +++ b/vblib.h @@ -14,19 +14,71 @@ * Configuration section follows */ +/* + * PSTR_16BIT: whether PSTR strings should be preceded + * by 16-bit or 8-bit length (thus also limiting the maximum + * allowed length of PSTR string) + */ //#define PSTR_16BIT + +/* + * INLINE_PUTGETCHAR: inline vb{put,get}char() + */ #define INLINE_PUTGETCHAR + +/* + * FATALSIG_INSANE: if defined, no vbcheck()s are done after some fatal + * signal has been caught as the data structures may be corrupted + * already thereafter + */ //#define FATALSIG_INSANE +/* + * HAVE_PTHREAD: vbcheck() serialization between threds + * Please note that VB library in general is NOT multithreading safe. + */ +//#define HAVE_PTHREAD + +/* + * VB_DEFSIZE: Default size of buffer of "vb" object. Large sizes may + * slow down vbcopy() significantly. + */ #define VB_DEFSIZE 256 //>=min of n in vsnprintf() + +/* + * LOGF_FGETS_BUF: Buffer size for vbgetlinef(), doesn't hard limit anything, + * it has only performance impact. + */ +#define LOGF_FGETS_BUF VB_DEFSIZE + +/* + * VB_MAXSIZE: Maximum size of one "vbn" segment to prevent circular + * use of "vb" to eat up the whole memory. It doesn't limit the maximum + * data storage of "vb" object in no way, it has only performance impact. + */ #define VB_MAXSIZE 128*1024 //recommended limit, not hard (probably) +/* + * CHAT_CMD_MAXPARS: Size of chat_cmdpars[] array, maximum # of parameters + * a user command can have during chat_proccmd() parse. + */ #define CHAT_CMD_MAXPARS 10 /* * Configuration section ends ****************************/ +#ifndef VB_LOG +#define VB_LOG(lev,msg,args...) fprintf(stderr,VB_LOG_##lev msg "\n", ##args) +#endif +#ifndef VB_FATAL +#define VB_FATAL(lev,msg,args...) do { VB_LOG(lev,msg , ##args); exit(EXIT_FAILURE); } while (0) +#endif + +#define VB_LOG_DEBUG "VB_Debug: " +#define VB_LOG_ERR "VB_Error: " +#define VB_LOG_CRIT "VB_Critical: " + #define strncpydst(d,s) strncpy(d,s,sizeof(d)) #ifdef NDEBUG #undef DEBUG @@ -46,6 +98,10 @@ #ifndef __NORETURN #define __NORETURN __attribute__((__noreturn__)) #endif +/* for chat_cmdtable: */ +#ifndef __WEAK +#define __WEAK __attribute__((__weak__)) +#endif #define NELEM(a) (sizeof((a))/sizeof(*(a))) #define XRAWDIGITI(n) ((n)-'0'-((n)>='A'?'A'-('9'+1):0))