r5351: Add wrapper for nt_errstr and array functions for samr_ConnectInfo.
[samba.git] / source4 / libads / ldap_printer.c
index 1448074ea022d53333b38c42c2c215013b717866..7ae19219b4f1e29936514a2daa737b2787174d80 100644 (file)
@@ -98,8 +98,8 @@ static BOOL map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
        if (value->type != REG_SZ)
                return False;
 
-       if (value->size && *((smb_ucs2_t *) value->data_p)) {
-               pull_ucs2_talloc(ctx, &str_value, (const smb_ucs2_t *) value->data_p);
+       if (value->size && SVAL(value->data_p, 0)) {
+               pull_ucs2_talloc(ctx, &str_value, value->data_p);
                status = ads_mod_str(ctx, mods, value->valuename, str_value);
                return ADS_ERR_OK(status);
        }
@@ -118,7 +118,7 @@ static BOOL map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods,
 
        if (value->type != REG_DWORD)
                return False;
-       str_value = talloc_asprintf(ctx, "%d", *((uint32 *) value->data_p));
+       str_value = talloc_asprintf(ctx, "%d", *((uint32_t *) value->data_p));
        status = ads_mod_str(ctx, mods, value->valuename, str_value);
        return ADS_ERR_OK(status);
 }
@@ -147,29 +147,28 @@ static BOOL map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
                         const REGISTRY_VALUE *value)
 {
        char **str_values = NULL;
-       smb_ucs2_t *cur_str = (smb_ucs2_t *) value->data_p;
-        uint32 size = 0, num_vals = 0, i=0;
+       char *cur_str = value->data_p;
+        uint32_t size = 0, num_vals = 0, i=0;
        ADS_STATUS status;
 
        if (value->type != REG_MULTI_SZ)
                return False;
 
-       while(cur_str && *cur_str && (size < value->size)) {            
-               size += 2 * (strlen_w(cur_str) + 1);
-               cur_str += strlen_w(cur_str) + 1;
+       while (cur_str && *cur_str && (size < value->size)) {           
+               size_t this_size = utf16_len(cur_str);
+               cur_str += this_size;
+               size += this_size;
                num_vals++;
        };
 
        if (num_vals) {
-               str_values = talloc(ctx, 
-                                   (num_vals + 1) * sizeof(smb_ucs2_t *));
-               memset(str_values, '\0', 
-                      (num_vals + 1) * sizeof(smb_ucs2_t *));
-
-               cur_str = (smb_ucs2_t *) value->data_p;
-               for (i=0; i < num_vals; i++)
-                       cur_str += pull_ucs2_talloc(ctx, &str_values[i],
-                                                   cur_str);
+               str_values = talloc_array(ctx, char *, num_vals + 1);
+               cur_str = value->data_p;
+               for (i=0; i < num_vals; i++) {
+                       pull_ucs2_talloc(ctx, &str_values[i], cur_str);
+                       cur_str += utf16_len(cur_str);
+               }
+               str_values[i] = NULL;
 
                status = ads_mod_strlist(ctx, mods, value->valuename, 
                                         (const char **) str_values);
@@ -259,7 +258,7 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods,
 }
 
 
-WERROR get_remote_printer_publishing_data(struct cli_state *cli, 
+WERROR get_remote_printer_publishing_data(struct smbcli_state *cli, 
                                          TALLOC_CTX *mem_ctx,
                                          ADS_MODLIST *mods,
                                          const char *printer)
@@ -268,7 +267,7 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
        char *printername, *servername;
        REGVAL_CTR dsdriver_ctr, dsspooler_ctr;
        BOOL got_dsdriver = False, got_dsspooler = False;
-       uint32 needed, i;
+       uint32_t needed, i;
        POLICY_HND pol;
 
        asprintf(&servername, "\\\\%s", cli->desthost);
@@ -278,7 +277,7 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
                return WERR_NOMEM;
        }
        
-       result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, 
+       result = smbcli_spoolss_open_printer_ex(cli, mem_ctx, printername, 
                                             "", MAXIMUM_ALLOWED_ACCESS, 
                                             servername, cli->user_name, &pol);
        if (!W_ERROR_IS_OK(result)) {
@@ -287,11 +286,11 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
                return result;
        }
        
-       result = cli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed, 
+       result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed, 
                                               &pol, SPOOL_DSDRIVER_KEY, NULL);
 
        if (W_ERROR_V(result) == ERRmoredata)
-               result = cli_spoolss_enumprinterdataex(cli, mem_ctx, needed, 
+               result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, needed, 
                                                       NULL, &pol, 
                                                       SPOOL_DSDRIVER_KEY,
                                                       &dsdriver_ctr);
@@ -308,12 +307,12 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
                                          dsdriver_ctr.values[i]);
        }
        
-       result = cli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed, 
+       result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, 0, &needed, 
                                               &pol, SPOOL_DSSPOOLER_KEY, 
                                               NULL);
 
        if (W_ERROR_V(result) == ERRmoredata)
-               result = cli_spoolss_enumprinterdataex(cli, mem_ctx, needed, 
+               result = smbcli_spoolss_enumprinterdataex(cli, mem_ctx, needed, 
                                                       NULL, &pol, 
                                                       SPOOL_DSSPOOLER_KEY,
                                                       &dsspooler_ctr);
@@ -332,7 +331,7 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
 
        if (got_dsdriver) regval_ctr_destroy(&dsdriver_ctr);
        if (got_dsspooler) regval_ctr_destroy(&dsspooler_ctr);
-       cli_spoolss_close_printer(cli, mem_ctx, &pol);
+       smbcli_spoolss_close_printer(cli, mem_ctx, &pol);
 
        return result;
 }
@@ -341,7 +340,7 @@ BOOL get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
                                       ADS_MODLIST *mods,
                                       NT_PRINTER_DATA *data)
 {
-       uint32 key,val;
+       uint32_t key,val;
 
        for (key=0; key < data->num_keys; key++) {
                REGVAL_CTR ctr = data->keys[key].values;