mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
lib/param: Make and use lpcfg_dump_a_service() in common
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
412a387357
commit
3d6a0270e4
@ -1949,8 +1949,8 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
|
||||
* Display the contents of a single services record.
|
||||
*/
|
||||
|
||||
static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
|
||||
unsigned int *flags)
|
||||
void lpcfg_dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
|
||||
unsigned int *flags, bool show_defaults)
|
||||
{
|
||||
int i;
|
||||
struct parmlist_entry *data;
|
||||
@ -1967,7 +1967,7 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s
|
||||
if (flags && (flags[i] & FLAG_DEFAULT)) {
|
||||
continue;
|
||||
}
|
||||
if (defaults_saved) {
|
||||
if (!show_defaults) {
|
||||
if (is_default(sDefault, i)) {
|
||||
continue;
|
||||
}
|
||||
@ -2711,11 +2711,9 @@ void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
|
||||
return;
|
||||
}
|
||||
|
||||
defaults_saved = !show_defaults;
|
||||
|
||||
dump_globals(lp_ctx, f, show_defaults);
|
||||
|
||||
dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
|
||||
lpcfg_dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags, show_defaults);
|
||||
|
||||
for (iService = 0; iService < maxtoprint; iService++)
|
||||
lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
|
||||
@ -2729,7 +2727,7 @@ void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *servic
|
||||
if (service != NULL) {
|
||||
if (service->szService[0] == '\0')
|
||||
return;
|
||||
dump_a_service(service, sDefault, f, NULL);
|
||||
lpcfg_dump_a_service(service, sDefault, f, NULL, show_defaults);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3010,46 +3010,9 @@ static void dump_globals(FILE *f)
|
||||
Display the contents of a single services record.
|
||||
***************************************************************************/
|
||||
|
||||
static void dump_a_service(struct loadparm_service *pService, FILE * f)
|
||||
static void dump_a_service(struct loadparm_service *pService, FILE * f, bool show_defaults)
|
||||
{
|
||||
int i;
|
||||
struct parmlist_entry *data;
|
||||
|
||||
if (pService != &sDefault)
|
||||
fprintf(f, "[%s]\n", pService->szService);
|
||||
|
||||
for (i = 0; parm_table[i].label; i++) {
|
||||
|
||||
if (parm_table[i].p_class == P_LOCAL &&
|
||||
!(parm_table[i].flags & FLAG_META) &&
|
||||
(*parm_table[i].label != '-') &&
|
||||
(i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
|
||||
{
|
||||
if (pService == &sDefault) {
|
||||
if (defaults_saved && is_default(i))
|
||||
continue;
|
||||
} else {
|
||||
if (lpcfg_equal_parameter(parm_table[i].type,
|
||||
lp_parm_ptr(pService, &parm_table[i]),
|
||||
lp_parm_ptr(NULL, &parm_table[i])))
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(f, "\t%s = ", parm_table[i].label);
|
||||
lpcfg_print_parameter(&parm_table[i],
|
||||
lp_parm_ptr(pService, &parm_table[i]),
|
||||
f);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (pService->param_opt != NULL) {
|
||||
data = pService->param_opt;
|
||||
while(data) {
|
||||
fprintf(f, "\t%s = %s\n", data->key, data->value);
|
||||
data = data->next;
|
||||
}
|
||||
}
|
||||
return lpcfg_dump_a_service(pService, &sDefault, f, NULL, show_defaults);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -4320,7 +4283,7 @@ void lp_dump(FILE *f, bool show_defaults, int maxtoprint)
|
||||
|
||||
dump_globals(f);
|
||||
|
||||
dump_a_service(&sDefault, f);
|
||||
dump_a_service(&sDefault, f, show_defaults);
|
||||
|
||||
for (iService = 0; iService < maxtoprint; iService++) {
|
||||
fprintf(f,"\n");
|
||||
@ -4337,7 +4300,7 @@ void lp_dump_one(FILE * f, bool show_defaults, int snum)
|
||||
if (VALID(snum)) {
|
||||
if (ServicePtrs[snum]->szService[0] == '\0')
|
||||
return;
|
||||
dump_a_service(ServicePtrs[snum], f);
|
||||
dump_a_service(ServicePtrs[snum], f, show_defaults);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user