X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=util.h;h=8b670e8134cae4e629ac4be7b66d50cc20d7acec;hb=ac968003c13bde5c86ffa19f8819e436b5bc03e6;hp=cf197fe9d63d4fca0a83dcfe8ce592d800879d52;hpb=e15efca6667b2673b4c1a5879a6917eab6800e58;p=polyglot.git diff --git a/util.h b/util.h index cf197fe..8b670e8 100644 --- a/util.h +++ b/util.h @@ -7,6 +7,8 @@ // includes #include +#include +#include // defines @@ -65,6 +67,31 @@ #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 +119,7 @@ typedef struct { bool running; } my_timer_t; + // functions extern void util_init (); @@ -135,9 +163,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