s3-rpc_client: add spoolss_timestr_to_NTTIME()
authorGünther Deschner <gd@samba.org>
Fri, 23 Sep 2016 15:10:22 +0000 (17:10 +0200)
committerUri Simchoni <uri@samba.org>
Mon, 26 Sep 2016 18:24:18 +0000 (20:24 +0200)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/rpc_client/init_spoolss.c
source3/rpc_client/init_spoolss.h

index 7e29cdc7ca166ee7dd274a2b86cf27c2da44bbbb..b4e3daac8fc1f7c3f7047aa78c8d738828f0fde6 100644 (file)
@@ -61,6 +61,36 @@ time_t spoolss_Time_to_time_t(const struct spoolss_Time *r)
        return mktime(&unixtime);
 }
 
+/*******************************************************************
+ ********************************************************************/
+
+bool spoolss_timestr_to_NTTIME(const char *str,
+                              NTTIME *data)
+{
+       struct tm tm;
+       time_t t;
+
+       if (strequal(str, "01/01/1601")) {
+               *data = 0;
+               return true;
+       }
+
+       ZERO_STRUCT(tm);
+
+       if (sscanf(str, "%d/%d/%d",
+                  &tm.tm_mon, &tm.tm_mday, &tm.tm_year) != 3) {
+               return false;
+       }
+       tm.tm_mon -= 1;
+       tm.tm_year -= 1900;
+       tm.tm_isdst = -1;
+
+       t = mktime(&tm);
+       unix_to_nt_time(data, t);
+
+       return true;
+}
+
 /*******************************************************************
  ********************************************************************/
 
index 247f711f760c2509f1fd2ee6228bc211352af9c5..10c899df29e41fb05143fe38ac5b9c18ddb71308 100644 (file)
@@ -25,6 +25,8 @@
 bool init_systemtime(struct spoolss_Time *r,
                     struct tm *unixtime);
 time_t spoolss_Time_to_time_t(const struct spoolss_Time *r);
+bool spoolss_timestr_to_NTTIME(const char *str,
+                              NTTIME *data);
 WERROR pull_spoolss_PrinterData(TALLOC_CTX *mem_ctx,
                                const DATA_BLOB *blob,
                                union spoolss_PrinterData *data,