summaryrefslogtreecommitdiff
path: root/source3/param/params.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-25 22:53:47 +0100
committerMichael Adam <obnox@samba.org>2008-03-26 14:55:05 +0100
commit2b84aea424410a1c4d5b29849bfe4ee411c78fac (patch)
tree8514071a8f98914429e0be2afbc1391c79bf6bb4 /source3/param/params.c
parent7d2e3aacd922c920326c23cd53997bb3d0c9230e (diff)
downloadsamba-2b84aea424410a1c4d5b29849bfe4ee411c78fac.tar.gz
samba-2b84aea424410a1c4d5b29849bfe4ee411c78fac.tar.bz2
samba-2b84aea424410a1c4d5b29849bfe4ee411c78fac.zip
loadparm: add userdata parameter to do_section() and do_parameter().
The userdata is currently unused. It can be used in the future for passing a context like in samba4 code. Michael (This used to be commit 31b31171bd88c41443268d3300c492e2347b9e73)
Diffstat (limited to 'source3/param/params.c')
-rw-r--r--source3/param/params.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/source3/param/params.c b/source3/param/params.c
index e69715e4a3..478376c9e9 100644
--- a/source3/param/params.c
+++ b/source3/param/params.c
@@ -230,7 +230,7 @@ static int Continuation(uint8_t *line, int pos )
* ------------------------------------------------------------------------ **
*/
-static bool Section( DATA_BLOB *buf, myFILE *InFile, bool (*sfunc)(const char *) )
+static bool Section( DATA_BLOB *buf, myFILE *InFile, bool (*sfunc)(const char *, void *), void *userdata )
{
int c;
int i;
@@ -299,7 +299,7 @@ static bool Section( DATA_BLOB *buf, myFILE *InFile, bool (*sfunc)(const char *)
DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
return False;
}
- if( !sfunc((char *)buf->data) ) /* Got a valid name. Deal with it. */
+ if( !sfunc((char *)buf->data, userdata) ) /* Got a valid name. Deal with it. */
return False;
EatComment( InFile ); /* Finish off the line. */
return True;
@@ -336,7 +336,7 @@ static bool Section( DATA_BLOB *buf, myFILE *InFile, bool (*sfunc)(const char *)
* ------------------------------------------------------------------------ **
*/
-static bool Parameter( DATA_BLOB *buf, myFILE *InFile, bool (*pfunc)(const char *, const char *), int c )
+static bool Parameter( DATA_BLOB *buf, myFILE *InFile, bool (*pfunc)(const char *, const char *, void *), int c, void *userdata )
{
int i = 0; /* Position within bufr. */
int end = 0; /* bufr[end] is current end-of-string. */
@@ -441,7 +441,7 @@ static bool Parameter( DATA_BLOB *buf, myFILE *InFile, bool (*pfunc)(const char
}
buf->data[end] = '\0'; /* End of value. */
- return( pfunc( (char *)buf->data, (char *)&buf->data[vstart] ) ); /* Pass name & value to pfunc(). */
+ return( pfunc( (char *)buf->data, (char *)&buf->data[vstart], userdata ) ); /* Pass name & value to pfunc(). */
}
/* ------------------------------------------------------------------------ **
@@ -467,8 +467,9 @@ static bool Parameter( DATA_BLOB *buf, myFILE *InFile, bool (*pfunc)(const char
*/
static bool Parse( DATA_BLOB *buf, myFILE *InFile,
- bool (*sfunc)(const char *),
- bool (*pfunc)(const char *, const char *) )
+ bool (*sfunc)(const char *, void *),
+ bool (*pfunc)(const char *, const char *, void *),
+ void *userdata)
{
int c;
@@ -485,7 +486,7 @@ static bool Parse( DATA_BLOB *buf, myFILE *InFile,
break;
case '[': /* Section Header. */
- if( !Section( buf, InFile, sfunc ) )
+ if( !Section( buf, InFile, sfunc, userdata ) )
return False;
c = EatWhitespace( InFile );
break;
@@ -495,7 +496,7 @@ static bool Parse( DATA_BLOB *buf, myFILE *InFile,
break;
default: /* Parameter line. */
- if( !Parameter( buf, InFile, pfunc, c ) )
+ if( !Parameter( buf, InFile, pfunc, c, userdata ) )
return False;
c = EatWhitespace( InFile );
break;
@@ -552,8 +553,9 @@ static myFILE *OpenConfFile( const char *FileName )
*/
bool pm_process( const char *FileName,
- bool (*sfunc)(const char *),
- bool (*pfunc)(const char *, const char *) )
+ bool (*sfunc)(const char *, void *),
+ bool (*pfunc)(const char *, const char *, void *),
+ void *userdata)
{
int result;
myFILE *InFile;
@@ -574,7 +576,7 @@ bool pm_process( const char *FileName,
return False;
}
- result = Parse( &buf, InFile, sfunc, pfunc );
+ result = Parse( &buf, InFile, sfunc, pfunc, userdata );
data_blob_free(&buf);
myfile_close(InFile);