summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-07-20 13:23:57 +0000
committerGerald Carter <jerry@samba.org>2002-07-20 13:23:57 +0000
commit6dd9f24d05e5db92e15dc53399a0f78ccb69f718 (patch)
tree234454eee6950cf09745f658eebad80756ef6590
parent29075c97d3b7111e2565ede1cd0f000fd2534375 (diff)
downloadsamba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.tar.gz
samba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.tar.bz2
samba-6dd9f24d05e5db92e15dc53399a0f78ccb69f718.zip
another intermediate checkin on the way to enumerating forms
via the registry. There is a seg fault here which shouldn't bother anyone until I can get it fixed. I just need a check point in case I need to roll back to this version later on. (This used to be commit e62ae94823461e142978a786b2860ea97906cfb3)
-rw-r--r--source3/printing/nt_printing.c14
-rw-r--r--source3/registry/reg_frontend.c53
-rw-r--r--source3/registry/reg_printing.c86
-rw-r--r--source3/rpc_server/srv_reg_nt.c19
-rw-r--r--source3/script/mkproto.awk2
5 files changed, 136 insertions, 38 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index ff08b99eb0..76325c2990 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -435,25 +435,29 @@ int get_ntforms(nt_forms_struct **list)
for (kbuf = tdb_firstkey(tdb_forms);
kbuf.dptr;
- newkey = tdb_nextkey(tdb_forms, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
- if (strncmp(kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) != 0) continue;
+ newkey = tdb_nextkey(tdb_forms, kbuf), safe_free(kbuf.dptr), kbuf=newkey)
+ {
+ if (strncmp(kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) != 0)
+ continue;
dbuf = tdb_fetch(tdb_forms, kbuf);
- if (!dbuf.dptr) continue;
+ if (!dbuf.dptr)
+ continue;
fstrcpy(form.name, kbuf.dptr+strlen(FORMS_PREFIX));
ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "dddddddd",
&i, &form.flag, &form.width, &form.length, &form.left,
&form.top, &form.right, &form.bottom);
SAFE_FREE(dbuf.dptr);
- if (ret != dbuf.dsize) continue;
+ if (ret != dbuf.dsize)
+ continue;
tl = Realloc(*list, sizeof(nt_forms_struct)*(n+1));
if (!tl) {
DEBUG(0,("get_ntforms: Realloc fail.\n"));
return 0;
}
- *list = tl;
+ *list = tl;
(*list)[n] = form;
n++;
}
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index 4e3f09fe4e..6e550c1a0d 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -32,7 +32,6 @@ extern REGISTRY_OPS regdb_ops; /* these are the default */
REGISTRY_HOOK reg_hooks[] = {
- { KEY_TREE_ROOT, &regdb_ops },
{ KEY_PRINTING, &printing_ops },
{ NULL, NULL }
};
@@ -283,6 +282,58 @@ int regval_ctr_numvals( REGVAL_CTR *ctr )
return ctr->num_values;
}
+REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx )
+{
+ if ( !(idx < ctr->num_values) )
+ return NULL;
+
+ return ctr->values[idx];
+}
+
+/***********************************************************************
+ Ad a new regostry value to the array
+ **********************************************************************/
+
+int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type,
+ char *data_p, size_t size )
+{
+ REGISTRY_VALUE **ppreg;
+ uint16 len;
+
+ if ( name )
+ {
+ len = strlen( name );
+
+ if ( ctr->num_values == 0 )
+ ctr->values = talloc( ctr->ctx, sizeof(REGISTRY_VALUE*) );
+ else {
+ ppreg = talloc_realloc( ctr->ctx, ctr->values, sizeof(REGISTRY_VALUE*)*(ctr->num_values+1) );
+ if ( ppreg )
+ ctr->values = ppreg;
+ }
+
+ fstrcpy( ctr->values[ctr->num_values]->valuename, name );
+ ctr->values[ctr->num_values]->type = type;
+ switch ( type )
+ {
+ case REG_SZ:
+ ctr->values[ctr->num_values]->data.string = talloc_strdup( ctr->ctx, data_p );
+ break;
+ case REG_DWORD:
+ break;
+ case REG_BINARY:
+ ctr->values[ctr->num_values]->data.binary = talloc_memdup( ctr->ctx, data_p, size );
+ break;
+
+ }
+ ctr->values[ctr->num_values]->size = size;
+
+ ctr->num_values++;
+ }
+
+ return ctr->num_values;
+}
+
/***********************************************************************
free memory held by a REGVAL_CTR structure
**********************************************************************/
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c
index 99bdb4771f..993d793c1e 100644
--- a/source3/registry/reg_printing.c
+++ b/source3/registry/reg_printing.c
@@ -39,6 +39,7 @@ static char *top_level_keys[MAX_TOP_LEVEL_KEYS] = {
"Printers"
};
+
/**********************************************************************
It is safe to assume that every registry path passed into on of
the exported functions here begins with KEY_PRINTING else
@@ -97,12 +98,19 @@ static int print_subpath_environments( char *key, REGSUBKEY_CTR *subkeys )
/**********************************************************************
handle enumeration of subkeys below KEY_PRINTING\Forms
+ Really just a stub function, but left here in case it needs to
+ be expanded later on
*********************************************************************/
static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
{
DEBUG(10,("print_subpath_forms: key=>[%s]\n", key ? key : "NULL" ));
+ /* there are no subkeys */
+
+ if ( key )
+ return -1;
+
return 0;
}
@@ -110,36 +118,74 @@ static int print_subpath_forms( char *key, REGSUBKEY_CTR *subkeys )
handle enumeration of values below KEY_PRINTING\Forms
*********************************************************************/
-static int print_values_forms( char *key, REGVAL_CTR *val )
+static int print_subpath_values_forms( char *key, REGVAL_CTR *val )
{
- int num_values = 0;
+ int num_values = 0;
+ uint32 data[7];
DEBUG(10,("print_values_forms: key=>[%s]\n", key ? key : "NULL" ));
/* handle ..\Forms\ */
-#if 0 /* JERRY */
if ( !key )
{
- nt_forms_struct *forms = NULL;
+ nt_forms_struct *forms_list = NULL;
+ nt_forms_struct *form = NULL;
int i;
- if ( (num_values = get_ntforms( &forms )) == 0 )
+ if ( (num_values = get_ntforms( &forms_list )) == 0 )
return 0;
- if ( !(*values = malloc(sizeof(REGISTRY_VALUE) * num_values)) ) {
- DEBUG(0,("print_values_forms: Failed to malloc memory for [%d] REGISTRY_VALUE structs!\n",
- num_values));
- return -1;
+ DEBUG(10,("print_subpath_values_forms: [%d] user defined forms returned\n",
+ num_values));
+
+ /* handle user defined forms */
+
+ for ( i=0; i<num_values; i++ )
+ {
+ form = &forms_list[i];
+
+ data[0] = form->flag;
+ data[1] = form->width;
+ data[2] = form->length;
+ data[3] = form->left;
+ data[4] = form->top;
+ data[5] = form->right;
+ data[6] = form->bottom;
+
+ regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
+
}
+ SAFE_FREE( forms_list );
+ forms_list = NULL;
+
+ /* handle built-on forms */
+
+ if ( (num_values = get_builtin_ntforms( &forms_list )) == 0 )
+ return 0;
+
+ DEBUG(10,("print_subpath_values_forms: [%d] built-in forms returned\n",
+ num_values));
+
for ( i=0; i<num_values; i++ )
{
+ form = &forms_list[i];
+ data[0] = form->flag;
+ data[1] = form->width;
+ data[2] = form->length;
+ data[3] = form->left;
+ data[4] = form->top;
+ data[5] = form->right;
+ data[6] = form->bottom;
+
+ regval_ctr_addvalue( val, form->name, REG_BINARY, (char*)data, sizeof(data) );
}
+
+ SAFE_FREE( forms_list );
}
-#endif
return num_values;
}
@@ -150,7 +196,7 @@ static int print_values_forms( char *key, REGVAL_CTR *val )
static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys )
{
- int n_services = lp_numservices();
+ int n_services = lp_numservices();
int snum;
fstring sname;
@@ -208,29 +254,25 @@ static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys, REGVAL_CT
if ( !(i < MAX_TOP_LEVEL_KEYS) )
return -1;
-
- /* quick hack for now */
- if ( !subkeys )
- return 0;
-
+
/* Call routine to handle each top level key */
switch ( i )
{
case KEY_INDEX_ENVIR:
if ( subkeys )
print_subpath_environments( p, subkeys );
-#if 0 /* JERRY */
- if ( val )
- print_subpath_values_environments( p, val );
-#endif
break;
case KEY_INDEX_FORMS:
- result = print_subpath_forms( p, subkeys );
+ if ( subkeys )
+ print_subpath_forms( p, subkeys );
+ if ( val )
+ print_subpath_values_forms( p, val );
break;
case KEY_INDEX_PRINTER:
- result = print_subpath_printers( p, subkeys );
+ if ( subkeys )
+ print_subpath_printers( p, subkeys );
break;
/* default case for top level key that has no handler */
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index 580ab78f74..72e0631e8b 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -219,34 +219,35 @@ static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *m
static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum,
uint32 *maxlen, uint32 *maxsize )
{
- REGVAL_CTR val;
+ REGVAL_CTR values;
+ REGISTRY_VALUE *val;
uint32 sizemax, lenmax;
- int num_values;
+ int i, num_values;
if ( !key )
return False;
ZERO_STRUCTP( &val );
- regval_ctr_init( &val );
+ regval_ctr_init( &values );
- if ( fetch_reg_values( key, &val ) == -1 )
+ if ( fetch_reg_values( key, &values ) == -1 )
return False;
lenmax = sizemax = 0;
- num_values = regval_ctr_numvals( &val );
+ num_values = regval_ctr_numvals( &values );
-#if 0 /* JERRY */
- for ( i=0; i<num_values; i++ ) {
+ for ( i=0; i<num_values && val; i++ ) {
+ val = regval_ctr_specific_value( &values, i );
lenmax = MAX(lenmax, strlen(val[i].valuename)+1 );
sizemax = MAX(sizemax, val[i].size );
}
-#endif
+
*maxnum = num_values;
*maxlen = lenmax;
*maxsize = sizemax;
- regval_ctr_destroy( &val );
+ regval_ctr_destroy( &values );
return True;
}
diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk
index eef7180e72..b71d50e95a 100644
--- a/source3/script/mkproto.awk
+++ b/source3/script/mkproto.awk
@@ -142,7 +142,7 @@ END {
gotstart = 1;
}
- if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK/ ) {
+ if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE/ ) {
gotstart = 1;
}