summaryrefslogtreecommitdiff
path: root/source/rpc_parse/parse_prs.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-01-31 06:00:43 +0000
committerLuke Leighton <lkcl@samba.org>2000-01-31 06:00:43 +0000
commitd350e1fae1027f9aff738406c2ba99afbbc1aa91 (patch)
tree9a1d0d929e3327d3c25471970accbe9a9f2ac797 /source/rpc_parse/parse_prs.c
parent6cbdfeb40f8b388d73820d60612b9f000e5fea6d (diff)
downloadsamba-d350e1fae1027f9aff738406c2ba99afbbc1aa91.tar.gz
some ideas are JUST so cool, i can't get over it.
created the following two functions: int prs_tdb_store(TDB_CONTEXT *tdb, int flgs, prs_struct *pk, prs_struct *pd); void prs_tdb_fetch(TDB_CONTEXT *tdb, prs_struct *pk, prs_struct *pd); they are SO cool, it's unbelievable. one prs_struct is used as a key, the other as data. they are used like this, which does a lookup of a UNICODE domain name to look up the SID associated with it. andrew, i'm in love with the tdb database code! the point of using smb_io_unistr2 and smb_io_dom_sid is that these create NDR (network data representation) flattened versions of the two variable-length data structures, uni_domain and sid. so it's an optimal usage of pre-existing functions and also a reasonably optimal use of database space (i cannot be bothered to write better disk-space-saving code because these smb_io_() functions already exist). p.s did i say i love the tdb code, already? static uint32 tdb_lookup_domain(TDB_CONTEXT *tdb, const UNISTR2* uni_domain, DOM_SID *sid) { prs_struct key; prs_struct data; UNISTR2 uni_dom_copy; copy_unistr2(&uni_dom_copy, uni_domain); prs_init(&key, 0, 4, False); if (!smb_io_unistr2("dom", &uni_dom_copy, True, &key, 0)) { return NT_STATUS_NO_MEMORY; } prs_tdb_fetch(tdb, &key, &data); if (!smb_io_dom_sid("sid", sid, &data, 0)) { prs_free_data(&key); prs_free_data(&data); return NT_STATUS_NO_SUCH_DOMAIN; } prs_free_data(&key); prs_free_data(&data); return 0x0; }
Diffstat (limited to 'source/rpc_parse/parse_prs.c')
-rw-r--r--source/rpc_parse/parse_prs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c
index dff3fc8e368..ec8e679bbf9 100644
--- a/source/rpc_parse/parse_prs.c
+++ b/source/rpc_parse/parse_prs.c
@@ -1035,3 +1035,35 @@ BOOL _prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
return True;
}
+/*******************************************************************
+ prs_tdb_store. stores prs_struct data by prs_struct key
+ ********************************************************************/
+int prs_tdb_store(TDB_CONTEXT *tdb, int flgs, prs_struct *pk, prs_struct *pd)
+{
+ TDB_DATA key;
+ TDB_DATA data;
+
+ key.dptr = (char*)prs_data(pk, 0);
+ key.dsize = prs_buf_len(pk);
+
+ data.dptr = prs_data(pd, 0);
+ data.dsize = prs_buf_len(pd);
+
+ return tdb_store(tdb, key, data, flgs);
+}
+
+/*******************************************************************
+ prs_tdb_fetch. fetches prs_struct data by prs_struct key
+ ********************************************************************/
+void prs_tdb_fetch(TDB_CONTEXT *tdb, prs_struct *pk, prs_struct *pd)
+{
+ TDB_DATA key;
+ TDB_DATA data;
+
+ key.dptr = (char*)prs_data(pk, 0);
+ key.dsize = prs_buf_len(pk);
+
+ data = tdb_fetch(tdb, key);
+
+ prs_create(pd, data.dptr, data.dsize, 4, True);
+}