\r
// includes\r
\r
-#include <cstdio>\r
+#include <stdio.h>\r
+#include <sys/types.h>\r
+#include <sys/timeb.h>\r
+#include <sys/stat.h>\r
+\r
+// defines\r
+\r
+#ifndef EXIT_SUCCES\r
+#define EXIT_SUCCES 0\r
+#endif\r
+\r
+#ifndef STDIN_FILENO\r
+#define STDIN_FILENO 0\r
+#endif\r
+\r
+#ifndef STDOUT_FILENO\r
+#define STDOUT_FILENO 1\r
+#endif\r
\r
-// constants\r
\r
#undef FALSE\r
#define FALSE 0\r
# define ASSERT(a)\r
#endif\r
\r
+#ifdef _WIN32\r
+#define snprintf _snprintf\r
+#endif\r
+\r
+#define FormatBufferSize 4096\r
+\r
+#ifdef _MSC_VER\r
+#define vsnprintf _vsnprintf\r
+#endif\r
+\r
+#define CONSTRUCT_ARG_STRING(format,buf) \\r
+ { \\r
+ va_list arg_list; \\r
+ int written; \\r
+ va_start(arg_list,format); \\r
+ written=vsnprintf(buf, \\r
+ sizeof(buf), \\r
+ format, \\r
+ arg_list); \\r
+ va_end(arg_list); \\r
+ buf[sizeof(buf)-1]='\0'; \\r
+ if(written>=sizeof(buf) || written<0){ \\r
+ my_fatal("write_buffer overflow: file \"%s\", line %d\n", \\r
+ __FILE__,__LINE__); \\r
+ } \\r
+ } \\r
+\r
+#define TO_BOOL(string) ((my_string_case_equal(string,"false") || \\r
+ my_string_equal(string,"0"))?FALSE:TRUE)\r
+\r
+#define IS_BOOL(string) (my_string_case_equal(string,"false")|| \\r
+ my_string_case_equal(string,"true") || \\r
+ my_string_case_equal(string,"1") || \\r
+ my_string_case_equal(string,"0"))\r
// types\r
\r
typedef signed char sint8;\r
typedef signed int sint32;\r
typedef unsigned int uint32;\r
\r
+typedef int bool;\r
+\r
#ifdef _MSC_VER\r
typedef signed __int64 sint64;\r
typedef unsigned __int64 uint64;\r
typedef unsigned long long int uint64;\r
#endif\r
\r
-struct my_timer_t {\r
+typedef struct {\r
double start_real;\r
double elapsed_real;\r
bool running;\r
-};\r
+} my_timer_t;\r
+\r
\r
// functions\r
\r
-#ifdef _WIN32\r
- #include <windows.h>\r
- inline void Idle(void) {\r
- Sleep(1);\r
- }\r
- inline void Idle500msecs(void){\r
- Sleep(500);\r
- }\r
-#else\r
- #include <unistd.h>\r
- inline void Idle(void) {\r
- usleep(1000);\r
- }\r
-#endif\r
extern void util_init ();\r
\r
extern void my_random_init ();\r
extern void my_fatal (const char format[], ...);\r
\r
extern bool my_file_read_line (FILE * file, char string[], int size);\r
+extern void my_path_join (char *join_path, const char *path, const char *file);\r
+\r
+extern int my_mkdir (const char *path);\r
\r
extern bool my_string_empty (const char string[]);\r
extern bool my_string_whitespace (const char string[]);\r
extern bool my_string_equal (const char string_1[], const char string_2[]);\r
extern bool my_string_case_equal (const char string_1[], const char string_2[]);\r
+extern const char* my_string_case_contains(const char haystack[], \r
+ const char needle[]);\r
+\r
+\r
+extern bool my_string_to_lower (char dst[], const char src[]);\r
+\r
extern char * my_strdup (const char string[]);\r
\r
extern void my_string_clear (const char * * variable);\r
extern void my_string_set (const char * * variable, const char string[]);\r
\r
+extern double now_real ();\r
+\r
extern void my_timer_reset (my_timer_t * timer);\r
extern void my_timer_start (my_timer_t * timer);\r
extern void my_timer_stop (my_timer_t * timer);\r
\r
extern double my_timer_elapsed_real (const my_timer_t * timer);\r
\r
+extern char * my_error();\r
+\r
+extern void my_dequote (char *out, \r
+ const char *in, \r
+ const char *special);\r
+extern void my_quote (char *out, \r
+ const char *in, \r
+ const char *special);\r
+\r
+extern void my_sleep (int msec);\r
\r
#endif // !defined UTIL_H\r
\r