X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=util.h;h=bf45896be8a617c277a1c919dda33ff15931a5e3;hb=5eed4adb3552562329c0b0b460c8851efb1a38bb;hp=cf197fe9d63d4fca0a83dcfe8ce592d800879d52;hpb=e15efca6667b2673b4c1a5879a6917eab6800e58;p=polyglot.git diff --git a/util.h b/util.h index cf197fe..bf45896 100644 --- a/util.h +++ b/util.h @@ -7,6 +7,8 @@ // includes #include +#include +#include // defines @@ -65,6 +67,29 @@ #define snprintf _snprintf #endif +#define FormatBufferSize 4096 + +#ifdef _MSC_VER +#define vsnprintf _vsnprintf +#endif + +#define CONSTRUCT_ARG_STRING(format,buf) \ + { \ + va_list arg_list; \ + int written; \ + va_start(arg_list,format); \ + written=vsnprintf(buf, \ + sizeof(buf), \ + format, \ + arg_list); \ + va_end(arg_list); \ + buf[sizeof(buf)-1]='\0'; \ + if(written>=sizeof(buf) || written<0){ \ + my_fatal("write_buffer overflow: file \"%s\", line %d\n", \ + __FILE__,__LINE__); \ + } \ + } \ + // types typedef signed char sint8; @@ -92,6 +117,7 @@ typedef struct { bool running; } my_timer_t; + // functions extern void util_init (); @@ -135,9 +161,6 @@ extern double my_timer_elapsed_real (const my_timer_t * timer); extern char * my_error(); -extern char * my_getcwd (char *buf, size_t size); -extern int my_chdir (const char *path); - #endif // !defined UTIL_H // end of util.h