summaryrefslogtreecommitdiff
path: root/source3/libads/ldap_printer.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-05-24 13:57:35 +0200
committerMichael Adam <obnox@samba.org>2010-05-25 10:35:29 +0200
commit53ba74ecee5ac0cb75f51f3af9f0c62119ed5367 (patch)
tree656b31336ec4cd53ff806a289ad2e33328b26474 /source3/libads/ldap_printer.c
parent5fbf935ffce6204843fc498afd02dc3ba1dd9ff5 (diff)
downloadsamba-53ba74ecee5ac0cb75f51f3af9f0c62119ed5367.tar.gz
samba-53ba74ecee5ac0cb75f51f3af9f0c62119ed5367.tar.bz2
samba-53ba74ecee5ac0cb75f51f3af9f0c62119ed5367.zip
s3:libads:use regval_ctr/blob accessor functions in ldap_printer.c
Diffstat (limited to 'source3/libads/ldap_printer.c')
-rw-r--r--source3/libads/ldap_printer.c76
1 files changed, 42 insertions, 34 deletions
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index cff11bda2a..b5321abbf0 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -127,17 +127,17 @@ static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
size_t converted_size;
ADS_STATUS status;
- if (value->type != REG_SZ)
+ if (regval_type(value) != REG_SZ)
return false;
- if (value->size && *((smb_ucs2_t *) value->data_p)) {
+ if (regval_size(value) && *((smb_ucs2_t *) regval_data_p(value))) {
if (!pull_ucs2_talloc(ctx, &str_value,
- (const smb_ucs2_t *) value->data_p,
+ (const smb_ucs2_t *) regval_data_p(value),
&converted_size))
{
return false;
}
- status = ads_mod_str(ctx, mods, value->valuename, str_value);
+ status = ads_mod_str(ctx, mods, regval_name(value), str_value);
return ADS_ERR_OK(status);
}
return true;
@@ -153,13 +153,13 @@ static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods,
char *str_value = NULL;
ADS_STATUS status;
- if (value->type != REG_DWORD)
+ if (regval_type(value) != REG_DWORD)
return False;
- str_value = talloc_asprintf(ctx, "%d", *((uint32 *) value->data_p));
+ str_value = talloc_asprintf(ctx, "%d", *((uint32 *) regval_data_p(value)));
if (!str_value) {
return False;
}
- status = ads_mod_str(ctx, mods, value->valuename, str_value);
+ status = ads_mod_str(ctx, mods, regval_name(value), str_value);
return ADS_ERR_OK(status);
}
@@ -172,14 +172,14 @@ static bool map_bool(TALLOC_CTX *ctx, ADS_MODLIST *mods,
char *str_value;
ADS_STATUS status;
- if ((value->type != REG_BINARY) || (value->size != 1))
+ if ((regval_type(value) != REG_BINARY) || (regval_size(value) != 1))
return False;
str_value = talloc_asprintf(ctx, "%s",
- *(value->data_p) ? "TRUE" : "FALSE");
+ *(regval_data_p(value)) ? "TRUE" : "FALSE");
if (!str_value) {
return False;
}
- status = ads_mod_str(ctx, mods, value->valuename, str_value);
+ status = ads_mod_str(ctx, mods, regval_name(value), str_value);
return ADS_ERR_OK(status);
}
@@ -191,14 +191,14 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
{
char **str_values = NULL;
size_t converted_size;
- smb_ucs2_t *cur_str = (smb_ucs2_t *) value->data_p;
+ smb_ucs2_t *cur_str = (smb_ucs2_t *) regval_data_p(value);
uint32 size = 0, num_vals = 0, i=0;
ADS_STATUS status;
- if (value->type != REG_MULTI_SZ)
+ if (regval_type(value) != REG_MULTI_SZ)
return False;
- while(cur_str && *cur_str && (size < value->size)) {
+ while(cur_str && *cur_str && (size < regval_size(value))) {
size += 2 * (strlen_w(cur_str) + 1);
cur_str += strlen_w(cur_str) + 1;
num_vals++;
@@ -212,14 +212,14 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
memset(str_values, '\0',
(num_vals + 1) * sizeof(char *));
- cur_str = (smb_ucs2_t *) value->data_p;
+ cur_str = (smb_ucs2_t *) regval_data_p(value);
for (i=0; i < num_vals; i++) {
cur_str += pull_ucs2_talloc(ctx, &str_values[i],
cur_str, &converted_size) ?
converted_size : (size_t)-1;
}
- status = ads_mod_strlist(ctx, mods, value->valuename,
+ status = ads_mod_strlist(ctx, mods, regval_name(value),
(const char **) str_values);
return ADS_ERR_OK(status);
}
@@ -295,11 +295,11 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods,
int i;
for (i=0; map[i].valname; i++) {
- if (StrCaseCmp(map[i].valname, value->valuename) == 0) {
+ if (StrCaseCmp(map[i].valname, regval_name(value)) == 0) {
if (!map[i].fn(ctx, mods, value)) {
- DEBUG(5, ("Add of value %s to modlist failed\n", value->valuename));
+ DEBUG(5, ("Add of value %s to modlist failed\n", regval_name(value)));
} else {
- DEBUG(7, ("Mapped value %s\n", value->valuename));
+ DEBUG(7, ("Mapped value %s\n", regval_name(value)));
}
}
@@ -347,14 +347,18 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
} else {
/* Have the data we need now, so start building */
for (i=0; i < count; i++) {
- struct regval_blob v;
-
- fstrcpy(v.valuename, info[i].value_name);
- v.type = info[i].type;
- v.data_p = info[i].data->data;
- v.size = info[i].data->length;
+ struct regval_blob *v;
+
+ v = regval_compose(mem_ctx, info[i].value_name,
+ info[i].type,
+ info[i].data->data,
+ info[i].data->length);
+ if (v == NULL) {
+ return WERR_NOMEM;
+ }
- map_regval_to_ads(mem_ctx, mods, &v);
+ map_regval_to_ads(mem_ctx, mods, v);
+ talloc_free(v);
}
}
@@ -368,14 +372,18 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
printername, win_errstr(result)));
} else {
for (i=0; i < count; i++) {
- struct regval_blob v;
-
- fstrcpy(v.valuename, info[i].value_name);
- v.type = info[i].type;
- v.data_p = info[i].data->data;
- v.size = info[i].data->length;
+ struct regval_blob *v;
+
+ v = regval_compose(mem_ctx, info[i].value_name,
+ info[i].type,
+ info[i].data->data,
+ info[i].data->length);
+ if (v == NULL) {
+ return WERR_NOMEM;
+ }
- map_regval_to_ads(mem_ctx, mods, &v);
+ map_regval_to_ads(mem_ctx, mods, v);
+ talloc_free(v);
}
}
@@ -395,8 +403,8 @@ bool get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
for (key=0; key < data->num_keys; key++) {
struct regval_ctr *ctr = data->keys[key].values;
- for (val=0; val < ctr->num_values; val++)
- map_regval_to_ads(mem_ctx, mods, ctr->values[val]);
+ for (val=0; val < regval_ctr_numvals(ctr); val++)
+ map_regval_to_ads(mem_ctx, mods, regval_ctr_specific_value(ctr, val));
}
return True;
}