]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add os_gmtime() as wrapper for gmtime()
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 17 Oct 2011 21:23:42 +0000 (00:23 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 17 Oct 2011 21:23:42 +0000 (00:23 +0300)
src/utils/os.h
src/utils/os_internal.c
src/utils/os_none.c
src/utils/os_unix.c
src/utils/os_win32.c

index f4723d87525d7c37ee63ec48057ef12a29b757cb..f69478ade43718fc96f508ad4f5fac36b64a65cf 100644 (file)
@@ -70,6 +70,16 @@ int os_get_time(struct os_time *t);
 int os_mktime(int year, int month, int day, int hour, int min, int sec,
              os_time_t *t);
 
+struct os_tm {
+       int sec; /* 0..59 or 60 for leap seconds */
+       int min; /* 0..59 */
+       int hour; /* 0..23 */
+       int day; /* 1..31 */
+       int month; /* 1..12 */
+       int year; /* Four digit year */
+};
+
+int os_gmtime(os_time_t t, struct os_tm *tm);
 
 /**
  * os_daemonize - Run in the background (detach from the controlling terminal)
index 5260e232101f2a15302c68b749dde021796854fe..59d078924de6003a5b64cd846c5fb70e87bb59af 100644 (file)
@@ -70,6 +70,25 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
 }
 
 
+int os_gmtime(os_time_t t, struct os_tm *tm)
+{
+       time_t t2;
+       struct tm *tm2;
+
+       t2 = t;
+       tm2 = gmtime(&t);
+       if (tm2 == NULL)
+               return -1;
+       tm->sec = tm2->tm_sec;
+       tm->min = tm2->tm_min;
+       tm->hour = tm2->tm_hour;
+       tm->day = tm2->tm_mday;
+       tm->month = tm2->tm_mon + 1;
+       tm->year = tm2->tm_year + 1900;
+       return 0;
+}
+
+
 int os_daemonize(const char *pid_file)
 {
        if (daemon(0, 0)) {
index bab8f178c05af60c69caf7e2888c7b13d6a760bf..3fbb777a2d0c3ef66c2c380a590048a9d5a27afd 100644 (file)
@@ -38,6 +38,11 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
        return -1;
 }
 
+int os_gmtime(os_time_t t, struct os_tm *tm)
+{
+       return -1;
+}
+
 
 int os_daemonize(const char *pid_file)
 {
index cb3a0240a7f0d6f99872c5c6a1c1455aa03a5318..bb88c5c63999dd3e26fcdebd7f971aa729616351 100644 (file)
@@ -106,6 +106,25 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
 }
 
 
+int os_gmtime(os_time_t t, struct os_tm *tm)
+{
+       time_t t2;
+       struct tm *tm2;
+
+       t2 = t;
+       tm2 = gmtime(&t);
+       if (tm2 == NULL)
+               return -1;
+       tm->sec = tm2->tm_sec;
+       tm->min = tm2->tm_min;
+       tm->hour = tm2->tm_hour;
+       tm->day = tm2->tm_mday;
+       tm->month = tm2->tm_mon + 1;
+       tm->year = tm2->tm_year + 1900;
+       return 0;
+}
+
+
 #ifdef __APPLE__
 #include <fcntl.h>
 static int os_daemon(int nochdir, int noclose)
index 074096480a405f54efa93f82c02d199434ba17c1..f9ba8c2726dd5d19c9bdc04912e3a94f5d8b0697 100644 (file)
@@ -92,6 +92,25 @@ int os_mktime(int year, int month, int day, int hour, int min, int sec,
 }
 
 
+int os_gmtime(os_time_t t, struct os_tm *tm)
+{
+       time_t t2;
+       struct tm *tm2;
+
+       t2 = t;
+       tm2 = gmtime(&t);
+       if (tm2 == NULL)
+               return -1;
+       tm->sec = tm2->tm_sec;
+       tm->min = tm2->tm_min;
+       tm->hour = tm2->tm_hour;
+       tm->day = tm2->tm_mday;
+       tm->month = tm2->tm_mon + 1;
+       tm->year = tm2->tm_year + 1900;
+       return 0;
+}
+
+
 int os_daemonize(const char *pid_file)
 {
        /* TODO */