s4:dsdb/common/util.c - provide message set functions for integer types
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 6 Oct 2010 17:11:58 +0000 (19:11 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 7 Oct 2010 06:59:28 +0000 (08:59 +0200)
They will be used by the samldb LDB module

source4/dsdb/common/util.c

index faf2fb5f965e4085f20637b444b234bab356bb5e..71215212fc0fcaf807fa99fabc72c4d2c7c914c9 100644 (file)
@@ -1101,6 +1101,37 @@ int samdb_msg_set_string(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
        return samdb_msg_add_string(sam_ldb, mem_ctx, msg, attr_name, str);
 }
 
+/*
+ * sets a signed integer in a message
+ */
+int samdb_msg_set_int(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
+                     struct ldb_message *msg, const char *attr_name, int v)
+{
+       struct ldb_message_element *el;
+
+       el = ldb_msg_find_element(msg, attr_name);
+       if (el) {
+               el->num_values = 0;
+       }
+       return samdb_msg_add_int(sam_ldb, mem_ctx, msg, attr_name, v);
+}
+
+/*
+ * sets an unsigned integer in a message
+ */
+int samdb_msg_set_uint(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
+                      struct ldb_message *msg, const char *attr_name,
+                      unsigned int v)
+{
+       struct ldb_message_element *el;
+
+       el = ldb_msg_find_element(msg, attr_name);
+       if (el) {
+               el->num_values = 0;
+       }
+       return samdb_msg_add_uint(sam_ldb, mem_ctx, msg, attr_name, v);
+}
+
 /*
  * Handle ldb_request in transaction
  */