#define N_(x) x
#endif
-/* prototypes for the special type handlers */
-static bool handle_include(struct loadparm_context *lp_ctx, int unused,
- const char *pszParmValue, char **ptr);
-
#include "lib/param/param_table.c"
-/* local variables */
-struct loadparm_context {
- const char *szConfigFile;
- struct loadparm_global *globals;
- struct loadparm_service **services;
- struct loadparm_service *sDefault;
- struct smb_iconv_handle *iconv_handle;
- int iNumServices;
- struct loadparm_service *currentService;
- bool bInGlobalSection;
- struct file_lists *file_lists;
- unsigned int flags[NUMPARAMETERS];
- bool loaded;
- bool refuse_free;
- bool global; /* Is this the global context, which may set
- * global variables such as debug level etc? */
- const struct loadparm_s3_helpers *s3_fns;
-};
-
-
struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
{
if (lp_ctx->s3_fns) {
return NULL;
if (lp_ctx->s3_fns) {
- return lp_ctx->s3_fns->get_parametric(service, type, option);
+ return lp_ctx->s3_fns->get_parametric(service, type, option, NULL);
}
data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
/**
* convenience routine to return int parameters.
*/
-static int lp_int(const char *s)
+int lp_int(const char *s)
{
- if (!s) {
+ if (!s || !*s) {
DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
return -1;
}
/**
* convenience routine to return unsigned long parameters.
*/
-static unsigned long lp_ulong(const char *s)
+unsigned long lp_ulong(const char *s)
{
- if (!s) {
+ if (!s || !*s) {
DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s));
return -1;
}
/**
* convenience routine to return boolean parameters.
*/
-static bool lp_bool(const char *s)
+bool lp_bool(const char *s)
{
bool ret = false;
- if (!s) {
+ if (!s || !*s) {
DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
return false;
}
return ret;
}
-
/**
* Return parametric option from a given service. Type is a part of option before ':'
* Parametric option has following syntax: 'Type: option = value'
* Set a string value, deallocating any existing space, and allocing the space
* for the string
*/
-static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
+bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
talloc_free(*dest);
return false;
}
+/*
+ * set the value for a P_ENUM
+ */
+bool lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
+ int *ptr )
+{
+ int i;
+
+ for (i = 0; parm->enum_list[i].name; i++) {
+ if ( strequal(pszParmValue, parm->enum_list[i].name)) {
+ *ptr = parm->enum_list[i].value;
+ return true;
+ }
+ }
+ DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
+ pszParmValue, parm->label));
+ return false;
+}
+
+
/***************************************************************************
Handle the "realm" parameter
***************************************************************************/
Handle the include operation.
***************************************************************************/
-static bool handle_include(struct loadparm_context *lp_ctx, int unused,
+bool handle_include(struct loadparm_context *lp_ctx, int unused,
const char *pszParmValue, char **ptr)
{
- char *fname = standard_sub_basic(lp_ctx, pszParmValue);
+ char *fname;
+
+ if (lp_ctx->s3_fns) {
+ return lp_ctx->s3_fns->lp_include(lp_ctx, unused, pszParmValue, ptr);
+ }
+
+ fname = standard_sub_basic(lp_ctx, pszParmValue);
add_to_file_list(lp_ctx, &lp_ctx->file_lists, pszParmValue, fname);
break;
case P_ENUM:
- for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
- if (strequal
- (pszParmValue,
- parm_table[parmnum].enum_list[i].name)) {
- *(int *)parm_ptr =
- parm_table[parmnum].
- enum_list[i].value;
- break;
- }
- }
- if (!parm_table[parmnum].enum_list[i].name) {
- DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
- pszParmValue, pszParmName));
+ if (!lp_set_enum_parm(&parm_table[parmnum], pszParmValue, (int*)parm_ptr)) {
return false;
}
break;
int parmnum;
int i;
+ while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
+
if (lp_ctx->s3_fns) {
return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
}
parmnum = lpcfg_map_parameter(pszParmName);
- while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
-
-
if (parmnum < 0 && strchr(pszParmName, ':')) {
/* set a parametric option */
return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
lp_ctx->bInGlobalSection = true;
lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
+ lp_ctx->flags = talloc_zero_array(lp_ctx, unsigned int, NUMPARAMETERS);
lp_ctx->sDefault->iMaxPrintJobs = 1000;
lp_ctx->sDefault->bAvailable = true;