diff options
author | Günther Deschner <gd@samba.org> | 2009-09-24 15:01:32 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-09-30 00:30:12 +0200 |
commit | 1b0f3b7e3a3eadb1c9997b38dd41aa4c09c41a46 (patch) | |
tree | 0a0286fc31ccba857497fae5131e6b7561c69f9a /source3/registry | |
parent | a50cc61ee6bc973f913a8c26a082ae99f63091db (diff) | |
download | samba-1b0f3b7e3a3eadb1c9997b38dd41aa4c09c41a46.tar.gz samba-1b0f3b7e3a3eadb1c9997b38dd41aa4c09c41a46.tar.bz2 samba-1b0f3b7e3a3eadb1c9997b38dd41aa4c09c41a46.zip |
s3-registry: use regval_ctr_addvalue_sz().
Greatly simplifies and cleanes up the code.
Guenther
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_backend_current_version.c | 12 | ||||
-rw-r--r-- | source3/registry/reg_backend_db.c | 8 | ||||
-rw-r--r-- | source3/registry/reg_backend_printing.c | 60 | ||||
-rw-r--r-- | source3/registry/reg_backend_prod_options.c | 7 | ||||
-rw-r--r-- | source3/registry/reg_backend_tcpip_params.c | 19 | ||||
-rw-r--r-- | source3/registry/reg_eventlog.c | 12 |
6 files changed, 25 insertions, 93 deletions
diff --git a/source3/registry/reg_backend_current_version.c b/source3/registry/reg_backend_current_version.c index 1a3b2819a6..386c580965 100644 --- a/source3/registry/reg_backend_current_version.c +++ b/source3/registry/reg_backend_current_version.c @@ -37,8 +37,6 @@ static int current_version_fetch_values(const char *key, struct regval_ctr *valu { const char *sysroot_string = "c:\\Windows"; fstring sysversion; - fstring value; - uint32 value_length; char *path = NULL; TALLOC_CTX *ctx = talloc_tos(); @@ -55,16 +53,12 @@ static int current_version_fetch_values(const char *key, struct regval_ctr *valu return regdb_ops.fetch_values(key, values); } - value_length = push_ucs2(value, value, sysroot_string, sizeof(value), - STR_TERMINATE|STR_NOALIGN ); - regval_ctr_addvalue(values, "SystemRoot", REG_SZ, value, value_length); + regval_ctr_addvalue_sz(values, "SystemRoot", sysroot_string); fstr_sprintf(sysversion, "%d.%d", lp_major_announce_version(), lp_minor_announce_version()); - value_length = push_ucs2(value, value, sysversion, sizeof(value), - STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue(values, "CurrentVersion", REG_SZ, value, - value_length); + + regval_ctr_addvalue_sz(values, "CurrentVersion", sysversion); return regval_ctr_numvals(values); } diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index b9ff5dc7fc..2b6259c03a 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -250,8 +250,6 @@ WERROR init_registry_key(const char *add_path) static void regdb_ctr_add_value(struct regval_ctr *ctr, struct builtin_regkey_value *value) { - DATA_BLOB data; - switch(value->type) { case REG_DWORD: regval_ctr_addvalue(ctr, value->valuename, REG_DWORD, @@ -260,10 +258,8 @@ static void regdb_ctr_add_value(struct regval_ctr *ctr, break; case REG_SZ: - push_reg_sz(talloc_tos(), &data, value->data.string); - regval_ctr_addvalue(ctr, value->valuename, REG_SZ, - (char*)data.data, - data.length); + regval_ctr_addvalue_sz(ctr, value->valuename, + value->data.string); break; default: diff --git a/source3/registry/reg_backend_printing.c b/source3/registry/reg_backend_printing.c index 2dc5d84215..cc44f877bb 100644 --- a/source3/registry/reg_backend_printing.c +++ b/source3/registry/reg_backend_printing.c @@ -386,7 +386,6 @@ static bool key_printers_store_keys( const char *key, struct regsubkey_ctr *subk static void fill_in_printer_values(NT_PRINTER_INFO_LEVEL_2 *info2, struct regval_ctr *values) { struct spoolss_DeviceMode *devmode; - DATA_BLOB data; char *p; uint32 printer_status = PRINTER_STATUS_OK; @@ -407,35 +406,16 @@ static void fill_in_printer_values(NT_PRINTER_INFO_LEVEL_2 *info2, struct regval else p++; - push_reg_sz(talloc_tos(), &data, p); - regval_ctr_addvalue( values, "Name", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->location); - regval_ctr_addvalue( values, "Location", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->comment); - regval_ctr_addvalue( values, "Description", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->parameters); - regval_ctr_addvalue( values, "Parameters", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->portname); - regval_ctr_addvalue( values, "Port", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->sharename); - regval_ctr_addvalue( values, "Share Name", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->drivername); - regval_ctr_addvalue( values, "Printer Driver", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, info2->sepfile); - regval_ctr_addvalue( values, "Separator File", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, "WinPrint"); - regval_ctr_addvalue( values, "Print Processor", REG_SZ, (char*)data.data, data.length); - - push_reg_sz(talloc_tos(), &data, "RAW"); - regval_ctr_addvalue( values, "Datatype", REG_SZ, (char*)data.data, data.length); + regval_ctr_addvalue_sz(values, "Name", p); + regval_ctr_addvalue_sz(values, "Location", info2->location); + regval_ctr_addvalue_sz(values, "Description", info2->comment); + regval_ctr_addvalue_sz(values, "Parameters", info2->parameters); + regval_ctr_addvalue_sz(values, "Port", info2->portname); + regval_ctr_addvalue_sz(values, "Share Name", info2->sharename); + regval_ctr_addvalue_sz(values, "Printer Driver", info2->drivername); + regval_ctr_addvalue_sz(values, "Separator File", info2->sepfile); + regval_ctr_addvalue_sz(values, "Print Processor", "WinPrint"); + regval_ctr_addvalue_sz(values, "Datatype", "RAW"); /* stream the device mode */ @@ -898,28 +878,18 @@ static void fill_in_driver_values(NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, struct DATA_BLOB data; filename = dos_basename( info3->driverpath ); - push_reg_sz(talloc_tos(), &data, filename); - regval_ctr_addvalue( values, "Driver", REG_SZ, - (char *)data.data, data.length); + regval_ctr_addvalue_sz(values, "Driver", filename); filename = dos_basename( info3->configfile ); - push_reg_sz(talloc_tos(), &data, filename); - regval_ctr_addvalue( values, "Configuration File", REG_SZ, - (char *)data.data, data.length); + regval_ctr_addvalue_sz(values, "Configuration File", filename); filename = dos_basename( info3->datafile ); - push_reg_sz(talloc_tos(), &data, filename); - regval_ctr_addvalue( values, "Data File", REG_SZ, - (char *)data.data, data.length); + regval_ctr_addvalue_sz(values, "Data File", filename); filename = dos_basename( info3->helpfile ); - push_reg_sz(talloc_tos(), &data, filename); - regval_ctr_addvalue( values, "Help File", REG_SZ, - (char *)data.data, data.length); + regval_ctr_addvalue_sz(values, "Help File", filename); - push_reg_sz(talloc_tos(), &data, info3->defaultdatatype); - regval_ctr_addvalue( values, "Data Type", REG_SZ, - (char *)data.data, data.length); + regval_ctr_addvalue_sz(values, "Data Type", info3->defaultdatatype); regval_ctr_addvalue( values, "Version", REG_DWORD, (char*)&info3->cversion, sizeof(info3->cversion) ); diff --git a/source3/registry/reg_backend_prod_options.c b/source3/registry/reg_backend_prod_options.c index cdc1f37e72..786bc99eb1 100644 --- a/source3/registry/reg_backend_prod_options.c +++ b/source3/registry/reg_backend_prod_options.c @@ -34,8 +34,6 @@ extern struct registry_ops regdb_ops; static int prod_options_fetch_values(const char *key, struct regval_ctr *regvals) { const char *value_ascii = ""; - fstring value; - int value_length; switch (lp_server_role()) { case ROLE_DOMAIN_PDC: @@ -50,10 +48,7 @@ static int prod_options_fetch_values(const char *key, struct regval_ctr *regvals break; } - value_length = push_ucs2(value, value, value_ascii, sizeof(value), - STR_TERMINATE|STR_NOALIGN ); - regval_ctr_addvalue(regvals, "ProductType", REG_SZ, value, - value_length); + regval_ctr_addvalue_sz(regvals, "ProductType", value_ascii); return regval_ctr_numvals( regvals ); } diff --git a/source3/registry/reg_backend_tcpip_params.c b/source3/registry/reg_backend_tcpip_params.c index 30f7f71938..fbad0436b6 100644 --- a/source3/registry/reg_backend_tcpip_params.c +++ b/source3/registry/reg_backend_tcpip_params.c @@ -33,24 +33,9 @@ extern struct registry_ops regdb_ops; static int tcpip_params_fetch_values(const char *key, struct regval_ctr *regvals) { - fstring value; - int value_length; - char *hname; - char *mydomainname = NULL; + regval_ctr_addvalue_sz(regvals, "Hostname", myhostname()); - hname = myhostname(); - value_length = push_ucs2(value, value, hname, sizeof(value), - STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue(regvals, "Hostname",REG_SZ, value, value_length); - - mydomainname = get_mydnsdomname(talloc_tos()); - if (!mydomainname) { - return -1; - } - - value_length = push_ucs2(value, value, mydomainname, sizeof(value), - STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue(regvals, "Domain", REG_SZ, value, value_length); + regval_ctr_addvalue_sz(regvals, "Domain", get_mydnsdomname(talloc_tos())); return regval_ctr_numvals(regvals); } diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c index c0d5b95b0b..4d395eddb1 100644 --- a/source3/registry/reg_eventlog.c +++ b/source3/registry/reg_eventlog.c @@ -114,11 +114,8 @@ bool eventlog_init_keys(void) regval_ctr_addvalue(values, "Retention", REG_DWORD, (char *)&uiRetention, sizeof(uint32)); - push_reg_sz(talloc_tos(), &data, *elogs); - regval_ctr_addvalue(values, "PrimaryModule", REG_SZ, - (char *)data.data, - data.length); + regval_ctr_addvalue_sz(values, "PrimaryModule", *elogs); push_reg_sz(talloc_tos(), &data, *elogs); regval_ctr_addvalue(values, "Sources", REG_MULTI_SZ, @@ -199,7 +196,6 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, struct regsubkey_ctr *subkeys; struct regval_ctr *values; struct regval_blob *rval; - DATA_BLOB data; uint16 *msz_wp; int mbytes, ii; bool already_in; @@ -369,11 +365,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename, regdb_fetch_values( evtlogpath, values ); - push_reg_sz(talloc_tos(), &data, messagefile); - - regval_ctr_addvalue( values, "EventMessageFile", REG_SZ, - ( char * ) data.data, - data.length); + regval_ctr_addvalue_sz(values, "EventMessageFile", messagefile); regdb_store_values( evtlogpath, values ); TALLOC_FREE(values); |