files that help getting that native windows port going -- Philippe.Simonet with swiss...
[rrdtool.git] / src / win32comp.c
1 // compatibility routines, non reentrant ....\r
2 \r
3 #include <string.h> \r
4 #include <time.h>\r
5 \r
6 struct tm* localtime_r(const time_t* t, struct tm* r) {\r
7   struct tm * temp;\r
8   temp = localtime(t);\r
9   memcpy(r,temp,sizeof(struct tm));\r
10   return(r);\r
11 }\r
12 \r
13 struct tm* gmtime_r(const time_t* t, struct tm* r) {\r
14   struct tm * temp;\r
15   temp = gmtime(t);\r
16   memcpy(r,temp,sizeof(struct tm));\r
17   return r;\r
18 }\r
19 \r
20 char* ctime_r (const time_t* t, char* buf) {\r
21   char * temp;\r
22   temp = asctime(localtime(t));\r
23   strcpy(buf,temp);\r
24   return(buf);\r
25 }\r
26 \r
27 /*\r
28         s  \r
29         Points to the string from which to extract tokens. \r
30 \r
31         delim  \r
32         Points to a null-terminated set of delimiter characters. \r
33 \r
34         save_ptr\r
35         Is a value-return parameter used by strtok_r() to record its progress through s1. \r
36 */\r
37 \r
38 \r
39 char * strtok_r (char *s, const char *delim, char **save_ptr) {\r
40   char *token;\r
41 \r
42   if (s == NULL)  s = *save_ptr;\r
43 \r
44   /* Scan leading delimiters.  */\r
45   s += strspn(s, delim);\r
46   if (*s == '\0')\r
47     {\r
48       *save_ptr = s;\r
49       return NULL;\r
50     }\r
51 \r
52   /* Find the end of the token.  */\r
53   token = s;\r
54   s = strpbrk (token, delim);\r
55   if (s == NULL) {\r
56     /* This token finishes the string.  */\r
57           *save_ptr = token;\r
58           while (**save_ptr != '\0') (*save_ptr)++;\r
59   }  else\r
60     {\r
61       /* Terminate the token and make *SAVE_PTR point past it.  */\r
62       *s = '\0';\r
63       *save_ptr = s + 1;\r
64     }\r
65   return token;\r
66 }\r
67 \r