svn commit: samba r12182 - branches/SAMBA_3_0/source/groupdb branches/SAMBA_3_0/source/utils trunk/source/groupdb trunk/source/utils

vlendec at samba.org vlendec at samba.org
Sun Dec 11 16:55:29 GMT 2005


Author: vlendec
Date: 2005-12-11 16:55:28 +0000 (Sun, 11 Dec 2005)
New Revision: 12182

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12182

Log:
Cosmetic cleanup
Modified:
   branches/SAMBA_3_0/source/groupdb/mapping.c
   branches/SAMBA_3_0/source/utils/net_groupmap.c
   trunk/source/groupdb/mapping.c
   trunk/source/utils/net_groupmap.c


Changeset:
Modified: branches/SAMBA_3_0/source/groupdb/mapping.c
===================================================================
--- branches/SAMBA_3_0/source/groupdb/mapping.c	2005-12-11 14:44:38 UTC (rev 12181)
+++ branches/SAMBA_3_0/source/groupdb/mapping.c	2005-12-11 16:55:28 UTC (rev 12182)
@@ -35,43 +35,34 @@
  */
 #define MEMBEROF_PREFIX "MEMBEROF/"
 
+static struct sid_name_mapping {
+	enum SID_NAME_USE type;
+	const char *name;
+} sid_name_use_strings[] = {
+	{ SID_NAME_USE_NONE, "Not initialized" },
+	{ SID_NAME_USER,     "User" },
+	{ SID_NAME_DOM_GRP,  "Domain group" },
+	{ SID_NAME_DOMAIN,   "Domain" },
+	{ SID_NAME_ALIAS,    "Local group" },
+	{ SID_NAME_WKN_GRP,  "Builtin group" },
+	{ SID_NAME_DELETED,  "Deleted" },
+	{ SID_NAME_INVALID,  "Invalid" },
+	{ 0, NULL }
+};
+
 /****************************************************************************
 dump the mapping group mapping to a text file
 ****************************************************************************/
-char *decode_sid_name_use(fstring group, enum SID_NAME_USE name_use)
-{	
-	static fstring group_type;
+const char *decode_sid_name_use(enum SID_NAME_USE name_use)
+{
+	struct sid_name_mapping *m;
 
-	switch(name_use) {
-		case SID_NAME_USER:
-			fstrcpy(group_type,"User");
-			break;
-		case SID_NAME_DOM_GRP:
-			fstrcpy(group_type,"Domain group");
-			break;
-		case SID_NAME_DOMAIN:
-			fstrcpy(group_type,"Domain");
-			break;
-		case SID_NAME_ALIAS:
-			fstrcpy(group_type,"Local group");
-			break;
-		case SID_NAME_WKN_GRP:
-			fstrcpy(group_type,"Builtin group");
-			break;
-		case SID_NAME_DELETED:
-			fstrcpy(group_type,"Deleted");
-			break;
-		case SID_NAME_INVALID:
-			fstrcpy(group_type,"Invalid");
-			break;
-		case SID_NAME_UNKNOWN:
-		default:
-			fstrcpy(group_type,"Unknown type");
-			break;
+	for (m = sid_name_use_strings; m->name != NULL; m++) {
+		if (m->type == name_use)
+			return m->name;
 	}
-	
-	fstrcpy(group, group_type);
-	return group_type;
+
+	return "Unknown type";
 }
 
 /****************************************************************************
@@ -405,7 +396,6 @@
 {
 	TDB_DATA kbuf, dbuf, newkey;
 	fstring string_sid;
-	fstring group_type;
 	GROUP_MAP map;
 	GROUP_MAP *mapt;
 	int ret;
@@ -455,8 +445,8 @@
 
 		string_to_sid(&map.sid, string_sid);
 		
-		decode_sid_name_use(group_type, map.sid_name_use);
-		DEBUG(11,("enum_group_mapping: returning group %s of type %s\n", map.nt_name ,group_type));
+		DEBUG(11,("enum_group_mapping: returning group %s of type %s\n",
+			  map.nt_name, decode_sid_name_use(map.sid_name_use)));
 
 		mapt= SMB_REALLOC_ARRAY((*pp_rmap), GROUP_MAP, entries+1);
 		if (!mapt) {

Modified: branches/SAMBA_3_0/source/utils/net_groupmap.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_groupmap.c	2005-12-11 14:44:38 UTC (rev 12181)
+++ branches/SAMBA_3_0/source/utils/net_groupmap.c	2005-12-11 16:55:28 UTC (rev 12182)
@@ -87,19 +87,15 @@
 
 static void print_map_entry ( GROUP_MAP map, BOOL long_list )
 {
-	fstring string_sid;
-	fstring group_type;
-	
-	decode_sid_name_use(group_type, map.sid_name_use);
-	sid_to_string(string_sid, &map.sid);
-		
 	if (!long_list)
-		d_printf("%s (%s) -> %s\n", map.nt_name, string_sid, gidtoname(map.gid));
+		d_printf("%s (%s) -> %s\n", map.nt_name,
+			 sid_string_static(&map.sid), gidtoname(map.gid));
 	else {
 		d_printf("%s\n", map.nt_name);
-		d_printf("\tSID       : %s\n", string_sid);
+		d_printf("\tSID       : %s\n", sid_string_static(&map.sid));
 		d_printf("\tUnix group: %s\n", gidtoname(map.gid));
-		d_printf("\tGroup type: %s\n", group_type);
+		d_printf("\tGroup type: %s\n",
+			 decode_sid_name_use(map.sid_name_use));
 		d_printf("\tComment   : %s\n", map.comment);
 	}
 

Modified: trunk/source/groupdb/mapping.c
===================================================================
--- trunk/source/groupdb/mapping.c	2005-12-11 14:44:38 UTC (rev 12181)
+++ trunk/source/groupdb/mapping.c	2005-12-11 16:55:28 UTC (rev 12182)
@@ -35,43 +35,34 @@
  */
 #define MEMBEROF_PREFIX "MEMBEROF/"
 
+static struct sid_name_mapping {
+	enum SID_NAME_USE type;
+	const char *name;
+} sid_name_use_strings[] = {
+	{ SID_NAME_USE_NONE, "Not initialized" },
+	{ SID_NAME_USER,     "User" },
+	{ SID_NAME_DOM_GRP,  "Domain group" },
+	{ SID_NAME_DOMAIN,   "Domain" },
+	{ SID_NAME_ALIAS,    "Local group" },
+	{ SID_NAME_WKN_GRP,  "Builtin group" },
+	{ SID_NAME_DELETED,  "Deleted" },
+	{ SID_NAME_INVALID,  "Invalid" },
+	{ 0, NULL }
+};
+
 /****************************************************************************
 dump the mapping group mapping to a text file
 ****************************************************************************/
-char *decode_sid_name_use(fstring group, enum SID_NAME_USE name_use)
-{	
-	static fstring group_type;
+const char *decode_sid_name_use(enum SID_NAME_USE name_use)
+{
+	struct sid_name_mapping *m;
 
-	switch(name_use) {
-		case SID_NAME_USER:
-			fstrcpy(group_type,"User");
-			break;
-		case SID_NAME_DOM_GRP:
-			fstrcpy(group_type,"Domain group");
-			break;
-		case SID_NAME_DOMAIN:
-			fstrcpy(group_type,"Domain");
-			break;
-		case SID_NAME_ALIAS:
-			fstrcpy(group_type,"Local group");
-			break;
-		case SID_NAME_WKN_GRP:
-			fstrcpy(group_type,"Builtin group");
-			break;
-		case SID_NAME_DELETED:
-			fstrcpy(group_type,"Deleted");
-			break;
-		case SID_NAME_INVALID:
-			fstrcpy(group_type,"Invalid");
-			break;
-		case SID_NAME_UNKNOWN:
-		default:
-			fstrcpy(group_type,"Unknown type");
-			break;
+	for (m = sid_name_use_strings; m->name != NULL; m++) {
+		if (m->type == name_use)
+			return m->name;
 	}
-	
-	fstrcpy(group, group_type);
-	return group_type;
+
+	return "Unknown type";
 }
 
 /****************************************************************************
@@ -405,7 +396,6 @@
 {
 	TDB_DATA kbuf, dbuf, newkey;
 	fstring string_sid;
-	fstring group_type;
 	GROUP_MAP map;
 	GROUP_MAP *mapt;
 	int ret;
@@ -455,8 +445,8 @@
 
 		string_to_sid(&map.sid, string_sid);
 		
-		decode_sid_name_use(group_type, map.sid_name_use);
-		DEBUG(11,("enum_group_mapping: returning group %s of type %s\n", map.nt_name ,group_type));
+		DEBUG(11,("enum_group_mapping: returning group %s of type %s\n",
+			  map.nt_name, decode_sid_name_use(map.sid_name_use)));
 
 		mapt= SMB_REALLOC_ARRAY((*pp_rmap), GROUP_MAP, entries+1);
 		if (!mapt) {

Modified: trunk/source/utils/net_groupmap.c
===================================================================
--- trunk/source/utils/net_groupmap.c	2005-12-11 14:44:38 UTC (rev 12181)
+++ trunk/source/utils/net_groupmap.c	2005-12-11 16:55:28 UTC (rev 12182)
@@ -87,19 +87,15 @@
 
 static void print_map_entry ( GROUP_MAP map, BOOL long_list )
 {
-	fstring string_sid;
-	fstring group_type;
-	
-	decode_sid_name_use(group_type, map.sid_name_use);
-	sid_to_string(string_sid, &map.sid);
-		
 	if (!long_list)
-		d_printf("%s (%s) -> %s\n", map.nt_name, string_sid, gidtoname(map.gid));
+		d_printf("%s (%s) -> %s\n", map.nt_name,
+			 sid_string_static(&map.sid), gidtoname(map.gid));
 	else {
 		d_printf("%s\n", map.nt_name);
-		d_printf("\tSID       : %s\n", string_sid);
+		d_printf("\tSID       : %s\n", sid_string_static(&map.sid));
 		d_printf("\tUnix group: %s\n", gidtoname(map.gid));
-		d_printf("\tGroup type: %s\n", group_type);
+		d_printf("\tGroup type: %s\n",
+			 decode_sid_name_use(map.sid_name_use));
 		d_printf("\tComment   : %s\n", map.comment);
 	}
 



More information about the samba-cvs mailing list