wscript: Add check for --wrap linker flag
[vlendec/samba-autobuild/.git] / source3 / rpc_client / init_spoolss.c
index 8b66227ce78393d7a0dd0030152a7e7165594c60..9a4dab6d417176cde4626946b5f203036ad76cec 100644 (file)
@@ -48,19 +48,71 @@ bool init_systemtime(struct spoolss_Time *r,
 
 time_t spoolss_Time_to_time_t(const struct spoolss_Time *r)
 {
-       struct tm unixtime;
-
-       unixtime.tm_year        = r->year - 1900;
-       unixtime.tm_mon         = r->month - 1;
-       unixtime.tm_wday        = r->day_of_week;
-       unixtime.tm_mday        = r->day;
-       unixtime.tm_hour        = r->hour;
-       unixtime.tm_min         = r->minute;
-       unixtime.tm_sec         = r->second;
+       struct tm unixtime = {
+               .tm_year        = r->year - 1900,
+               .tm_mon         = r->month - 1,
+               .tm_wday        = r->day_of_week,
+               .tm_mday        = r->day,
+               .tm_hour        = r->hour,
+               .tm_min         = r->minute,
+               .tm_sec         = r->second,
+       };
 
        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;
+}
+
+/*******************************************************************
+ ********************************************************************/
+
+bool spoolss_driver_version_to_qword(const char *str,
+                                    uint64_t *data)
+{
+       unsigned int v1, v2, v3, v4 = 0;
+
+       if ((sscanf(str, "%u.%u.%u.%u", &v1, &v2, &v3, &v4) != 4) &&
+           (sscanf(str, "%u.%u.%u", &v1, &v2, &v3) != 3))
+       {
+               return false;
+       }
+
+       *data = ((uint64_t)(v1 & 0xFFFF) << 48) +
+               ((uint64_t)(v2 & 0xFFFF) << 32) +
+               ((uint64_t)(v3 & 0xFFFF) << 16) +
+               (uint64_t)(v4 & 0xFFFF);
+
+       return true;
+}
+
 /*******************************************************************
  ********************************************************************/
 
@@ -73,7 +125,7 @@ WERROR pull_spoolss_PrinterData(TALLOC_CTX *mem_ctx,
        ndr_err = ndr_pull_union_blob(blob, mem_ctx, data, type,
                        (ndr_pull_flags_fn_t)ndr_pull_spoolss_PrinterData);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               return WERR_GENERAL_FAILURE;
+               return WERR_GEN_FAILURE;
        }
        return WERR_OK;
 }
@@ -89,7 +141,7 @@ WERROR push_spoolss_PrinterData(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
        ndr_err = ndr_push_union_blob(blob, mem_ctx, data, type,
                        (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               return WERR_GENERAL_FAILURE;
+               return WERR_GEN_FAILURE;
        }
        return WERR_OK;
 }
@@ -225,12 +277,12 @@ WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx,
 
        dm = talloc_zero(mem_ctx, struct spoolss_DeviceMode);
        if (dm == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        dname = talloc_asprintf(dm, "%s", devicename);
        if (dname == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
        if (strlen(dname) > MAXDEVICENAME) {
                dname[MAXDEVICENAME] = '\0';
@@ -239,7 +291,7 @@ WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx,
 
        dm->formname = talloc_strdup(dm, "Letter");
        if (dm->formname == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        dm->specversion          = DMSPEC_NT4_AND_ABOVE;
@@ -373,7 +425,7 @@ WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx,
 
        if (psd == NULL) {
                DEBUG(0,("construct_default_printer_sd: Failed to make SEC_DESC.\n"));
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        DEBUG(4,("construct_default_printer_sdb: size = %u.\n",
@@ -383,3 +435,14 @@ WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx,
 
        return WERR_OK;
 }
+
+const char *spoolss_get_short_filesys_environment(const char *environment)
+{
+       if (strequal(environment, SPOOLSS_ARCHITECTURE_x64)) {
+               return "amd64";
+       } else if (strequal(environment, SPOOLSS_ARCHITECTURE_NT_X86)) {
+               return "x86";
+       } else {
+               return NULL;
+       }
+}