From 107fe91d2b93a34be9fe056da46810dec66aa343 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Wed, 21 Dec 2005 23:15:57 +0000 Subject: [PATCH] r12414: Remove the unnecessary SMB_STRDUP in server_role_str() + reuse the role translation elsewhere. Guenther (This used to be commit 6c4a6da3dc7cecce09890a0da7d97b9d1bb47827) --- source3/param/loadparm.c | 39 +++++++++++++++++++++++---------------- source3/rpcclient/cmd_samr.c | 21 --------------------- source3/utils/testparm.c | 19 +------------------ 3 files changed, 24 insertions(+), 55 deletions(-) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index ca47e48d8c8..fa61a8aedb4 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4098,6 +4098,28 @@ static void lp_save_defaults(void) Set the server type we will announce as via nmbd. ********************************************************************/ +static const struct srv_role_tab { + uint32 role; + const char *role_str; +} srv_role_tab [] = { + { ROLE_STANDALONE, "ROLE_STANDALONE" }, + { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" }, + { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" }, + { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" }, + { 0, NULL } +}; + +const char* server_role_str(uint32 role) +{ + int i = 0; + for (i=0; srv_role_tab[i].role_str; i++) { + if (role == srv_role_tab[i].role) { + return srv_role_tab[i].role_str; + } + } + return NULL; +} + static void set_server_role(void) { server_role = ROLE_STANDALONE; @@ -4141,22 +4163,7 @@ static void set_server_role(void) break; } - DEBUG(10, ("set_server_role: role = ")); - - switch(server_role) { - case ROLE_STANDALONE: - DEBUGADD(10, ("ROLE_STANDALONE\n")); - break; - case ROLE_DOMAIN_MEMBER: - DEBUGADD(10, ("ROLE_DOMAIN_MEMBER\n")); - break; - case ROLE_DOMAIN_BDC: - DEBUGADD(10, ("ROLE_DOMAIN_BDC\n")); - break; - case ROLE_DOMAIN_PDC: - DEBUGADD(10, ("ROLE_DOMAIN_PDC\n")); - break; - } + DEBUG(10, ("set_server_role: role = %s", server_role_str(server_role))); } /*********************************************************** diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 2050f2a7796..e711cc7d1c0 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -141,27 +141,6 @@ static const char *display_time(NTTIME nttime) return (string); } -static const char* server_role_str(uint32 server_role) -{ - switch(server_role) { - case ROLE_STANDALONE: - return SMB_STRDUP("ROLE_STANDALONE"); - break; - case ROLE_DOMAIN_MEMBER: - return SMB_STRDUP("ROLE_DOMAIN_MEMBER"); - break; - case ROLE_DOMAIN_BDC: - return SMB_STRDUP("ROLE_DOMAIN_BDC"); - break; - case ROLE_DOMAIN_PDC: - return SMB_STRDUP("ROLE_DOMAIN_PDC"); - break; - default: - return SMB_STRDUP("Unknown -- internal error?"); - break; - } -} - static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1) { diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 0ce838e5c76..8490c850091 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -348,24 +348,7 @@ print command parameter is ignored when using CUPS libraries.\n", if (!silent_mode && !section_name && !parameter_name) { - fprintf(stderr,"Server role: "); - switch(lp_server_role()) { - case ROLE_STANDALONE: - fprintf(stderr,"ROLE_STANDALONE\n"); - break; - case ROLE_DOMAIN_MEMBER: - fprintf(stderr,"ROLE_DOMAIN_MEMBER\n"); - break; - case ROLE_DOMAIN_BDC: - fprintf(stderr,"ROLE_DOMAIN_BDC\n"); - break; - case ROLE_DOMAIN_PDC: - fprintf(stderr,"ROLE_DOMAIN_PDC\n"); - break; - default: - fprintf(stderr,"Unknown -- internal error?\n"); - break; - } + fprintf(stderr,"Server role: %s", server_role_str(lp_server_role())); } if (!cname) { -- 2.11.4.GIT