#include <stdlib.h>\r
#include <string.h>\r
#include <time.h>\r
+#ifndef _MSC_VER\r
#include <sys/time.h>\r
+#endif\r
\r
#include "main.h"\r
#include "util.h"\r
\r
+// macros\r
+\r
+#define StringSize 4096\r
+\r
// variables\r
\r
static bool Error;\r
//line buffering doesn't work too well in MSVC and/or windows \r
if (LogFile != NULL) setvbuf(LogFile,NULL,_IOLBF,0); // line buffering\r
#endif\r
+ if(LogFile!=NULL){\r
+ my_log("POLYGLOT *** LOGFILE OPENED ***\n");\r
+ }\r
+\r
}\r
\r
// my_log_close()\r
CONSTRUCT_ARG_STRING(format,string);\r
\r
fprintf(stderr,"%s",string);\r
- if (LogFile != NULL) fprintf(LogFile,"%s",string);\r
+ my_log("POLYGLOT %s",string);\r
\r
if (Error) { // recursive error\r
my_log("POLYGLOT *** RECURSIVE ERROR ***\n");\r
return TRUE;\r
}\r
\r
+// my_file_join()\r
+\r
+void my_path_join(char *join_path, const char *path, const char *file){\r
+ char separator;\r
+#ifdef _WIN32\r
+ separator='\\';\r
+#else\r
+ separator='/';\r
+#endif\r
+ snprintf(join_path,StringSize,"%s%c%s",path,separator,file);\r
+ join_path[StringSize-1]='\0';\r
+}\r
+\r
+// my_mkdir()\r
+\r
+int my_mkdir(const char *path){\r
+ int ret;\r
+#ifdef _WIN32\r
+ ret=_mkdir(path);\r
+#else\r
+ ret=mkdir(path,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);\r
+#endif\r
+ return ret;\r
+}\r
+\r
+\r
// my_string_empty()\r
\r
bool my_string_empty(const char string[]) {\r
return FALSE;\r
}\r
\r
+// my_strtolower()\r
+\r
+void my_string_tolower(char *dst, const char *src){\r
+ int c;\r
+ ASSERT(src!=NULL);\r
+ ASSERT(dst!=NULL);\r
+ while((c=*(src++))){\r
+ *dst=tolower(c);\r
+ dst++;\r
+ }\r
+ *(dst++)='\0';\r
+}\r
+\r
+// my_string_case_contains()\r
+\r
+const char* my_string_case_contains(const char string_1[], const char string_2[]){\r
+ \r
+ char tmp1[StringSize];\r
+ char tmp2[StringSize];\r
+ char *where;\r
+\r
+\r
+ ASSERT(string_1!=NULL);\r
+ ASSERT(string_2!=NULL);\r
+\r
+ my_string_tolower(tmp1,string_1);\r
+ my_string_tolower(tmp2,string_2);\r
+\r
+ where=strstr(tmp1,tmp2);\r
+ if(where){\r
+ return string_1+(where-tmp1);\r
+ }\r
+ return NULL;\r
+\r
+ \r
+}\r
+\r
+\r
// my_strdup()\r
\r
char * my_strdup(const char string[]) {\r
*variable = my_strdup(string);\r
}\r
\r
+// now_real()\r
+\r
double now_real() {\r
#ifndef _WIN32\r
struct timeval tv[1];\r
\r
return tv->tv_sec + tv->tv_usec * 1E-6;\r
#else\r
- return (double) GetTickCount() / 1000.0; // we can do better here:-)\r
+ struct _timeb timeptr;\r
+ _ftime(&timeptr);\r
+ return(timeptr.time+((double)timeptr.millitm)/1000.0);\r
+// return (double) GetTickCount() / 1000.0; // we can do better here:-)\r
#endif\r
}\r
\r