*/
#include "includes.h"
+#include "registry.h"
+#include "reg_backend_db.h"
+#include "reg_eventlog.h"
+#include "reg_objects.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
TALLOC_FREE( subkeys );
/* now add the values to the KEY_EVENTLOG/Application form key */
- if (!(values = TALLOC_ZERO_P(ctx, struct regval_ctr))) {
+
+ werr = regval_ctr_init(ctx, &values);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
uiRetention = 0x93A80;
regval_ctr_addvalue(values, "MaxSize", REG_DWORD,
- (char *)&uiMaxSize,
+ (uint8 *)&uiMaxSize,
sizeof(uint32));
regval_ctr_addvalue(values, "Retention", REG_DWORD,
- (char *)&uiRetention,
+ (uint8 *)&uiRetention,
sizeof(uint32));
regval_ctr_addvalue_sz(values, "PrimaryModule", *elogs);
push_reg_sz(talloc_tos(), &data, *elogs);
regval_ctr_addvalue(values, "Sources", REG_MULTI_SZ,
- (char *)data.data,
+ data.data,
data.length);
evtfilepath = talloc_asprintf(ctx,
TALLOC_FREE(values);
}
push_reg_sz(talloc_tos(), &data, evtfilepath);
- regval_ctr_addvalue(values, "File", REG_EXPAND_SZ, (char *)data.data,
+ regval_ctr_addvalue(values, "File", REG_EXPAND_SZ, data.data,
data.length);
regdb_store_values(evtlogpath, values);
if (!evtlogpath) {
return false;
}
- if (!(values = TALLOC_ZERO_P(ctx, struct regval_ctr))) {
+
+ werr = regval_ctr_init(ctx, &values);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
uiCategoryCount = 0x00000007;
regval_ctr_addvalue( values, "CategoryCount",
REG_DWORD,
- ( char * ) &uiCategoryCount,
+ (uint8 *) &uiCategoryCount,
sizeof( uint32 ) );
push_reg_sz(talloc_tos(), &data,
"%SystemRoot%\\system32\\eventlog.dll");
regval_ctr_addvalue( values, "CategoryMessageFile",
REG_EXPAND_SZ,
- ( char * ) data.data,
+ data.data,
data.length);
regdb_store_values( evtlogpath, values );
}
need to add KEY of source to KEY_EVENTLOG/<eventlog>/<source> */
const char **elogs = lp_eventlog_list( );
- char **wrklist, **wp;
+ const char **wrklist, **wp;
char *evtlogpath = NULL;
struct regsubkey_ctr *subkeys;
struct regval_ctr *values;
struct regval_blob *rval;
- uint16 *msz_wp;
- int mbytes, ii;
+ int ii = 0;
bool already_in;
int i;
- int numsources;
+ int numsources = 0;
TALLOC_CTX *ctx = talloc_tos();
WERROR werr;
+ DATA_BLOB blob;
if (!elogs) {
return False;
/* todo add to Sources */
- if (!( values = TALLOC_ZERO_P(ctx, struct regval_ctr))) {
+ werr = regval_ctr_init(ctx, &values);
+ if(!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ));
return false;
}
/* perhaps this adding a new string to a multi_sz should be a fn? */
/* check to see if it's there already */
- if ( rval->type != REG_MULTI_SZ ) {
+ if ( regval_type(rval) != REG_MULTI_SZ ) {
DEBUG( 0,
( "Wrong type for Sources, should be REG_MULTI_SZ\n" ) );
return False;
already_in = False;
wrklist = NULL;
- dump_data( 1, rval->data_p, rval->size );
- if ( ( numsources =
- regval_convert_multi_sz( ( uint16 * ) rval->data_p, rval->size,
- &wrklist ) ) > 0 ) {
+ dump_data(1, regval_data_p(rval), regval_size(rval));
+
+ blob = data_blob_const(regval_data_p(rval), regval_size(rval));
+ if (!pull_reg_multi_sz(talloc_tos(), &blob, &wrklist)) {
+ return false;
+ }
- ii = numsources;
+ for (ii=0; wrklist[ii]; ii++) {
+ numsources++;
+ }
+
+ if (numsources > 0) {
/* see if it's in there already */
wp = wrklist;
- while ( ii && wp && *wp ) {
+ while (wp && *wp ) {
if ( strequal( *wp, sourcename ) ) {
DEBUG( 5,
( "Source name [%s] already in list for [%s] \n",
break;
}
wp++;
- ii--;
}
} else {
- if ( numsources < 0 ) {
- DEBUG( 3, ( "problem in getting the sources\n" ) );
- return False;
- }
DEBUG( 3,
( "Nothing in the sources list, this might be a problem\n" ) );
}
if ( !already_in ) {
/* make a new list with an additional entry; copy values, add another */
- wp = TALLOC_ARRAY(ctx, char *, numsources + 2 );
+ wp = TALLOC_ARRAY(ctx, const char *, numsources + 2 );
if ( !wp ) {
DEBUG( 0, ( "talloc() failed \n" ) );
memcpy( wp, wrklist, sizeof( char * ) * numsources );
*( wp + numsources ) = ( char * ) sourcename;
*( wp + numsources + 1 ) = NULL;
- mbytes = regval_build_multi_sz( wp, &msz_wp );
- dump_data( 1, ( uint8 * ) msz_wp, mbytes );
+ if (!push_reg_multi_sz(ctx, &blob, wp)) {
+ return false;
+ }
+ dump_data( 1, blob.data, blob.length);
regval_ctr_addvalue( values, "Sources", REG_MULTI_SZ,
- ( char * ) msz_wp, mbytes );
+ blob.data, blob.length);
regdb_store_values( evtlogpath, values );
- TALLOC_FREE(msz_wp);
+ data_blob_free(&blob);
} else {
DEBUG( 3,
( "Source name [%s] found in existing list of sources\n",
regdb_fetch_keys( evtlogpath, subkeys );
/* now add the values to the KEY_EVENTLOG/Application form key */
- if ( !( values = TALLOC_ZERO_P(ctx, struct regval_ctr ) ) ) {
+ werr = regval_ctr_init(ctx, &values);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}