svn commit: samba r3620 - in branches/tmp/ldbPlugins/lib/ldb/tools: .

idra at samba.org idra at samba.org
Mon Nov 8 17:04:37 GMT 2004


Author: idra
Date: 2004-11-08 17:04:37 +0000 (Mon, 08 Nov 2004)
New Revision: 3620

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

Log:

add options support for all the ldb tools


Modified:
   branches/tmp/ldbPlugins/lib/ldb/tools/ldbdel.c
   branches/tmp/ldbPlugins/lib/ldb/tools/ldbedit.c
   branches/tmp/ldbPlugins/lib/ldb/tools/ldbrename.c
   branches/tmp/ldbPlugins/lib/ldb/tools/ldbtest.c


Changeset:
Modified: branches/tmp/ldbPlugins/lib/ldb/tools/ldbdel.c
===================================================================
--- branches/tmp/ldbPlugins/lib/ldb/tools/ldbdel.c	2004-11-08 16:43:36 UTC (rev 3619)
+++ branches/tmp/ldbPlugins/lib/ldb/tools/ldbdel.c	2004-11-08 17:04:37 UTC (rev 3620)
@@ -72,13 +72,16 @@
  int main(int argc, char * const argv[])
 {
 	struct ldb_context *ldb;
+	const char **options = NULL;
+	int ldbopts;
 	int ret, i;
 	const char *ldb_url;
 	int opt, recursive=0;
 
 	ldb_url = getenv("LDB_URL");
 
-	while ((opt = getopt(argc, argv, "hH:r")) != EOF) {
+	ldbopts = 0;
+	while ((opt = getopt(argc, argv, "hH:ro:")) != EOF) {
 		switch (opt) {
 		case 'H':
 			ldb_url = optarg;
@@ -88,6 +91,21 @@
 			recursive=1;
 			break;
 
+		case 'o':
+			ldbopts++;
+			if (options == NULL) {
+				options = (const char **)malloc(sizeof(char *) * (ldbopts + 1));
+			} else {
+				options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1));
+				if (options == NULL) {
+					fprintf(stderr, "Out of memory!\n");
+					exit(-1);
+				}
+			}
+			options[ldbopts - 1] = optarg;
+			options[ldbopts] = NULL;
+			break;
+
 		case 'h':
 		default:
 			usage();
@@ -108,7 +126,7 @@
 		exit(1);
 	}
 
-	ldb = ldb_connect(ldb_url, 0, NULL);
+	ldb = ldb_connect(ldb_url, 0, options);
 	if (!ldb) {
 		perror("ldb_connect");
 		exit(1);

Modified: branches/tmp/ldbPlugins/lib/ldb/tools/ldbedit.c
===================================================================
--- branches/tmp/ldbPlugins/lib/ldb/tools/ldbedit.c	2004-11-08 16:43:36 UTC (rev 3619)
+++ branches/tmp/ldbPlugins/lib/ldb/tools/ldbedit.c	2004-11-08 17:04:37 UTC (rev 3620)
@@ -304,6 +304,8 @@
 	const char *expression = NULL;
 	const char *ldb_url;
 	const char *basedn = NULL;
+	const char **options = NULL;
+	int ldbopts;
 	int opt;
 	enum ldb_scope scope = LDB_SCOPE_SUBTREE;
 	const char *editor;
@@ -321,7 +323,8 @@
 		editor = "vi";
 	}
 
-	while ((opt = getopt(argc, argv, "hab:e:H:s:v")) != EOF) {
+	ldbopts = 0;
+	while ((opt = getopt(argc, argv, "hab:e:H:s:vo:")) != EOF) {
 		switch (opt) {
 		case 'b':
 			basedn = optarg;
@@ -353,6 +356,21 @@
 			verbose++;
 			break;
 
+		case 'o':
+			ldbopts++;
+			if (options == NULL) {
+				options = (const char **)malloc(sizeof(char *) * (ldbopts + 1));
+			} else {
+				options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1));
+				if (options == NULL) {
+					fprintf(stderr, "Out of memory!\n");
+					exit(-1);
+				}
+			}
+			options[ldbopts - 1] = optarg;
+			options[ldbopts] = NULL;
+			break;
+
 		case 'h':
 		default:
 			usage();
@@ -381,7 +399,7 @@
 		attrs = (const char * const *)argv;
 	}
 
-	ldb = ldb_connect(ldb_url, 0, NULL);
+	ldb = ldb_connect(ldb_url, 0, options);
 
 	if (!ldb) {
 		perror("ldb_connect");

Modified: branches/tmp/ldbPlugins/lib/ldb/tools/ldbrename.c
===================================================================
--- branches/tmp/ldbPlugins/lib/ldb/tools/ldbrename.c	2004-11-08 16:43:36 UTC (rev 3619)
+++ branches/tmp/ldbPlugins/lib/ldb/tools/ldbrename.c	2004-11-08 17:04:37 UTC (rev 3620)
@@ -51,16 +51,34 @@
 {
 	struct ldb_context *ldb;
 	const char *ldb_url;
+	const char **options = NULL;
+	int ldbopts;
 	int opt, ret;
 
 	ldb_url = getenv("LDB_URL");
 
-	while ((opt = getopt(argc, argv, "hH:")) != EOF) {
+	ldbopts = 0;
+	while ((opt = getopt(argc, argv, "hH:o:")) != EOF) {
 		switch (opt) {
 		case 'H':
 			ldb_url = optarg;
 			break;
 
+		case 'o':
+			ldbopts++;
+			if (options == NULL) {
+				options = (const char **)malloc(sizeof(char *) * (ldbopts + 1));
+			} else {
+				options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1));
+				if (options == NULL) {
+					fprintf(stderr, "Out of memory!\n");
+					exit(-1);
+				}
+			}
+			options[ldbopts - 1] = optarg;
+			options[ldbopts] = NULL;
+			break;
+
 		case 'h':
 		default:
 			usage();
@@ -76,7 +94,7 @@
 	argc -= optind;
 	argv += optind;
 
-	ldb = ldb_connect(ldb_url, 0, NULL);
+	ldb = ldb_connect(ldb_url, 0, options);
 
 	if (!ldb) {
 		perror("ldb_connect");

Modified: branches/tmp/ldbPlugins/lib/ldb/tools/ldbtest.c
===================================================================
--- branches/tmp/ldbPlugins/lib/ldb/tools/ldbtest.c	2004-11-08 16:43:36 UTC (rev 3619)
+++ branches/tmp/ldbPlugins/lib/ldb/tools/ldbtest.c	2004-11-08 17:04:37 UTC (rev 3620)
@@ -358,13 +358,16 @@
  int main(int argc, char * const argv[])
 {
 	struct ldb_context *ldb;
+	const char **options = NULL;
+	int ldbopts;
 	int opt;
 	int nrecords = 5000;
 	int nsearches = 2000;
 
 	ldb_url = getenv("LDB_URL");
 
-	while ((opt = getopt(argc, argv, "hH:r:s:b:")) != EOF) {
+	ldbopts = 0;
+	while ((opt = getopt(argc, argv, "hH:r:s:b:o:")) != EOF) {
 		switch (opt) {
 		case 'H':
 			ldb_url = optarg;
@@ -382,6 +385,21 @@
 			nsearches = atoi(optarg);
 			break;
 
+		case 'o':
+			ldbopts++;
+			if (options == NULL) {
+				options = (const char **)malloc(sizeof(char *) * (ldbopts + 1));
+			} else {
+				options = (const char **)realloc(options, sizeof(char *) * (ldbopts + 1));
+				if (options == NULL) {
+					fprintf(stderr, "Out of memory!\n");
+					exit(-1);
+				}
+			}
+			options[ldbopts - 1] = optarg;
+			options[ldbopts] = NULL;
+			break;
+
 		case 'h':
 		default:
 			usage();
@@ -397,7 +415,7 @@
 	argc -= optind;
 	argv += optind;
 
-	ldb = ldb_connect(ldb_url, 0, NULL);
+	ldb = ldb_connect(ldb_url, 0, options);
 
 	if (!ldb) {
 		perror("ldb_connect");



More information about the samba-cvs mailing list