Rev 5354: refactoring: Move initialization of regdb into a function of its in http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/

Michael Adam ma at sernet.de
Fri Apr 13 15:57:37 GMT 2007


At http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/

------------------------------------------------------------
revno: 5354
revision-id: ma at sernet.de-20070413155735-bcd3cd2c2e57f281
parent: ma at sernet.de-20070412141700-8ecb2c6ec62e1b2b
committer: Michael Adam <ma at sernet.de>
branch nick: SAMBA_3_0-registry.bzr
timestamp: Fri 2007-04-13 17:57:35 +0200
message:
  refactoring: Move initialization of regdb into a function of its
  own. (peparation for use of registry in loadparm.c)
modified:
  source/lib/util_reg.c          util_reg.c-20060711181331-c2d45d0e1f4a8648
  source/utils/net_conf.c        net_conf.c-20070409110216-64p0zt0mes4j6yoe-1
=== modified file 'source/lib/util_reg.c'
--- a/source/lib/util_reg.c	2007-04-12 12:27:43 +0000
+++ b/source/lib/util_reg.c	2007-04-13 15:57:35 +0000
@@ -20,6 +20,8 @@
 
 #include "includes.h"
 
+extern REGISTRY_OPS smbconf_reg_ops;
+
 const char *reg_type_lookup(enum winreg_Type type)
 {
 	const char *result;
@@ -246,3 +248,29 @@
 	return token;
 }
 
+BOOL registry_init_regdb(void)
+{
+	BOOL ret = False;
+	int saved_errno = 0;
+	REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops};
+
+	if (!regdb_init()) {
+		saved_errno = errno;
+		DEBUG(1, ("Can't open the registry"));
+		if (saved_errno) {
+			DEBUGADD(1, (": %s", strerror(saved_errno)));
+		}
+		DEBUGADD(1, (".\n"));
+		goto done;
+	}
+	reghook_cache_init();
+	if (!reghook_cache_add(&smbconf_reg_hook)) {
+		DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n"));
+		goto done;
+	}
+
+	ret = True;
+
+done:
+	return ret;
+}

=== modified file 'source/utils/net_conf.c'
--- a/source/utils/net_conf.c	2007-04-12 12:27:43 +0000
+++ b/source/utils/net_conf.c	2007-04-13 15:57:35 +0000
@@ -1075,7 +1075,6 @@
 int net_conf(int argc, const char **argv)
 {
 	int ret = -1;
-	int saved_errno = 0;
 	struct functable2 func[] = {
 		{"list", net_conf_list, 
 		 "Dump the complete configuration in smb.conf like format."},
@@ -1098,21 +1097,10 @@
 		{NULL, NULL, NULL}
 	};
 
-	REGISTRY_HOOK smbconf_reg_hook = {KEY_SMBCONF, &smbconf_reg_ops};
-	
-	if (!regdb_init()) {
-		saved_errno = errno;
-		d_fprintf(stderr, "Can't open the registry");
-		if (saved_errno) {
-			d_fprintf(stderr, ": %s\n", strerror(saved_errno));
-		}
-		else {
-			d_fprintf(stderr, "!\n");
-		}
+	if (!registry_init_regdb()) {
+		d_fprintf(stderr, "Error initializing the registry!\n");
 		goto done;
 	}
-	reghook_cache_init();
-	reghook_cache_add(&smbconf_reg_hook);
 
 	ret = net_run_function2(argc, argv, "net conf", func);
 



More information about the samba-cvs mailing list