[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Apr 22 10:44:02 MDT 2013


The branch, master has been updated
       via  19242b2 docs-xml: document dbwrap_tool exists
       via  26515c5 s3:utils/dbwrap_tool add exists operation
      from  5512a43 docs: Fix bug 9809 -- missing entry in specfile

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 19242b2916b55d2f1d97855e038395d5c87ca421
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Apr 22 13:56:24 2013 +0200

    docs-xml: document dbwrap_tool exists
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Apr 22 18:43:42 CEST 2013 on sn-devel-104

commit 26515c5d473c12f638e7405a5df3b1e24cd82ec8
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Apr 22 13:51:52 2013 +0200

    s3:utils/dbwrap_tool add exists operation
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages/dbwrap_tool.1.xml |    7 ++++++
 source3/utils/dbwrap_tool.c         |   38 +++++++++++++++++++++++++++++++---
 2 files changed, 41 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/dbwrap_tool.1.xml b/docs-xml/manpages/dbwrap_tool.1.xml
index 59ef968..e2b2cee 100644
--- a/docs-xml/manpages/dbwrap_tool.1.xml
+++ b/docs-xml/manpages/dbwrap_tool.1.xml
@@ -49,6 +49,7 @@
 		<listitem><para>fetch: fetch a record</para></listitem>
 		<listitem><para>store: create or modify a record</para></listitem>
 		<listitem><para>delete: remove a record</para></listitem>
+		<listitem><para>exists: test for existance of a record</para></listitem>
 		<listitem><para>erase: remove all records</para></listitem>
 		<listitem><para>listkeys: list all available records</para></listitem>
 		<listitem><para>listwatchers: list processes, which are waiting for changes in a record</para></listitem>
@@ -101,6 +102,12 @@
 		</cmdsynopsis>
 	</refsect2>
 	<refsect2>
+		<title>exists</title>
+		<cmdsynopsis>
+			<command>dbwrap_tool</command> <database> exists <key>
+		</cmdsynopsis>
+	</refsect2>
+	<refsect2>
 		<title>erase</title>
 		<cmdsynopsis>
 			<command>dbwrap_tool</command> <database> erase </cmdsynopsis>
diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c
index aab5773..79b40d2 100644
--- a/source3/utils/dbwrap_tool.c
+++ b/source3/utils/dbwrap_tool.c
@@ -30,7 +30,7 @@
 #include "util_tdb.h"
 
 enum dbwrap_op { OP_FETCH, OP_STORE, OP_DELETE, OP_ERASE, OP_LISTKEYS,
-		 OP_LISTWATCHERS };
+		 OP_LISTWATCHERS, OP_EXISTS };
 
 enum dbwrap_type { TYPE_INT32, TYPE_UINT32, TYPE_STRING, TYPE_HEX, TYPE_NONE };
 
@@ -263,6 +263,24 @@ static int dbwrap_tool_delete(struct db_context *db,
 	return 0;
 }
 
+static int dbwrap_tool_exists(struct db_context *db,
+			      const char *keyname,
+			      const char *data)
+{
+	bool result;
+
+	result = dbwrap_exists(db, string_term_tdb_data(keyname));
+
+	if (result) {
+		d_fprintf(stdout, "Key %s exists\n", keyname);
+	} else {
+		d_fprintf(stdout, "Key %s does not exist\n", keyname);
+	}
+
+	return (result)?0:1;
+}
+
+
 static int delete_fn(struct db_record *rec, void *priv)
 {
 	dbwrap_record_delete(rec);
@@ -373,6 +391,7 @@ struct dbwrap_op_dispatch_table dispatch_table[] = {
 	{ OP_ERASE,  TYPE_INT32,  dbwrap_tool_erase },
 	{ OP_LISTKEYS, TYPE_INT32, dbwrap_tool_listkeys },
 	{ OP_LISTWATCHERS, TYPE_NONE, dbwrap_tool_listwatchers },
+	{ OP_EXISTS, TYPE_STRING, dbwrap_tool_exists },
 	{ 0, 0, NULL },
 };
 
@@ -437,8 +456,8 @@ int main(int argc, const char **argv)
 		d_fprintf(stderr,
 			  "USAGE: %s [options] <database> <op> [<key> [<type> "
 			  "[<value>]]]\n"
-			  "       ops: fetch, store, delete, erase, listkeys, "
-			  "listwatchers\n"
+			  "       ops: fetch, store, delete, exists, "
+			  "erase, listkeys, listwatchers\n"
 			  "       types: int32, uint32, string, hex\n",
 			 argv[0]);
 		goto done;
@@ -496,10 +515,20 @@ int main(int argc, const char **argv)
 		}
 		op = OP_LISTWATCHERS;
 		keytype = "none";
+	} else if (strcmp(opname, "exists") == 0) {
+		if (extra_argc != 3) {
+			d_fprintf(stderr, "ERROR: operation 'exists' does "
+				  "not allow type nor value argument\n");
+			goto done;
+		}
+		keyname = extra_argv[2];
+		op = OP_EXISTS;
+		keytype = "string";
 	} else {
 		d_fprintf(stderr,
 			  "ERROR: invalid op '%s' specified\n"
-			  "       supported ops: fetch, store, delete\n",
+			  "       supported ops: fetch, store, delete, exists, "
+			  "erase, listkeys, listwatchers\n",
 			  opname);
 		goto done;
 	}
@@ -544,6 +573,7 @@ int main(int argc, const char **argv)
 	case OP_DELETE:
 	case OP_ERASE:
 	case OP_LISTKEYS:
+	case OP_EXISTS:
 		db = db_open(mem_ctx, dbname, 0, tdb_flags, O_RDWR | O_CREAT,
 			     0644, DBWRAP_LOCK_ORDER_1);
 		if (db == NULL) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list