summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2005-12-21 23:15:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:55 -0500
commit107fe91d2b93a34be9fe056da46810dec66aa343 (patch)
tree2f015595a39b984b4d59c560fe49009060b730c1 /source3
parent25f13bb0f1b51704a64d9014121402ef1a1e5e84 (diff)
downloadsamba-107fe91d2b93a34be9fe056da46810dec66aa343.tar.gz
samba-107fe91d2b93a34be9fe056da46810dec66aa343.tar.bz2
samba-107fe91d2b93a34be9fe056da46810dec66aa343.zip
r12414: Remove the unnecessary SMB_STRDUP in server_role_str() + reuse the role
translation elsewhere. Guenther (This used to be commit 6c4a6da3dc7cecce09890a0da7d97b9d1bb47827)
Diffstat (limited to 'source3')
-rw-r--r--source3/param/loadparm.c39
-rw-r--r--source3/rpcclient/cmd_samr.c21
-rw-r--r--source3/utils/testparm.c19
3 files changed, 24 insertions, 55 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ca47e48d8c..fa61a8aedb 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 2050f2a779..e711cc7d1c 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 0ce838e5c7..8490c85009 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) {