static void copy_service(struct service *pserviceDest,
struct service *pserviceSource,
struct bitmap *pcopymapDest);
-static bool do_parameter(const char *pszParmName, const char *pszParmValue);
-static bool do_section(const char *pszSectionName);
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+ void *userdata);
+static bool do_section(const char *pszSectionName, void *userdata);
static void init_copymap(struct service *pservice);
static bool hash_a_service(const char *name, int number);
static void free_service_byindex(int iService);
/*
* process_registry_globals
*/
-static bool process_registry_globals(bool (*pfunc)(const char *, const char *))
+static bool process_registry_globals(bool (*pfunc)(const char *, const char *, void *))
{
WERROR werr;
char **param_names;
}
for (count = 0; count < num_params; count++) {
- ret = pfunc(param_names[count], param_values[count]);
+ ret = pfunc(param_names[count], param_values[count], NULL);
if (ret != true) {
goto done;
}
}
- ret = pfunc("registry shares", "yes");
+ ret = pfunc("registry shares", "yes", NULL);
/* store the csn */
smbconf_changed(conf_ctx, &conf_last_csn, NULL, NULL);
string_set(ptr, fname);
if (file_exist(fname, NULL)) {
- bool ret = pm_process(fname, do_section, do_parameter);
+ bool ret = pm_process(fname, do_section, do_parameter, NULL);
SAFE_FREE(fname);
return ret;
}
Process a parameter.
***************************************************************************/
-static bool do_parameter(const char *pszParmName, const char *pszParmValue)
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+ void *userdata)
{
if (!bInGlobalSection && bGlobalOnly)
return (True);
Returns True on success, False on failure.
***************************************************************************/
-static bool do_section(const char *pszSectionName)
+static bool do_section(const char *pszSectionName, void *userdata)
{
bool bRetval;
bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
- bRetval = pm_process(n2, do_section, do_parameter);
+ bRetval = pm_process(n2, do_section, do_parameter, NULL);
SAFE_FREE(n2);
/* finish up the last section */
void lp_copy_service(int snum, const char *new_name)
{
- do_section(new_name);
+ do_section(new_name, NULL);
if (snum >= 0) {
snum = lp_servicenumber(new_name);
if (snum >= 0)
* ------------------------------------------------------------------------ **
*/
-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;
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;
* ------------------------------------------------------------------------ **
*/
-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. */
}
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(). */
}
/* ------------------------------------------------------------------------ **
*/
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;
break;
case '[': /* Section Header. */
- if( !Section( buf, InFile, sfunc ) )
+ if( !Section( buf, InFile, sfunc, userdata ) )
return False;
c = EatWhitespace( InFile );
break;
break;
default: /* Parameter line. */
- if( !Parameter( buf, InFile, pfunc, c ) )
+ if( !Parameter( buf, InFile, pfunc, c, userdata ) )
return False;
c = EatWhitespace( InFile );
break;
*/
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;
return False;
}
- result = Parse( &buf, InFile, sfunc, pfunc );
+ result = Parse( &buf, InFile, sfunc, pfunc, userdata );
data_blob_free(&buf);
myfile_close(InFile);