diff options
-rw-r--r-- | source3/include/proto.h | 4 | ||||
-rw-r--r-- | source3/rpc_parse/parse_prs.c | 28 | ||||
-rw-r--r-- | source3/tdb/tdbutil.c | 30 |
3 files changed, 30 insertions, 32 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 65b84398c2..fdd3282307 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2100,6 +2100,8 @@ BOOL prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16, BOOL prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset); BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32, uint32 ptr_uint32, uint32 data_size); +int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps); +int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps); /*The following definitions come from rpc_parse/parse_reg.c */ @@ -3631,8 +3633,6 @@ int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, void *buffer, int len); TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, char *keystr); size_t tdb_pack(char *buf, int bufsize, char *fmt, ...); int tdb_unpack(char *buf, int bufsize, char *fmt, ...); -int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps); -int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps); /*The following definitions come from utils/nbio.c */ diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index b7fe19f9ab..b6bedac536 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -807,3 +807,31 @@ BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32, } return True; } + +/* useful function to store a structure in rpc wire format */ +int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) +{ + TDB_DATA kbuf, dbuf; + kbuf.dptr = keystr; + kbuf.dsize = strlen(keystr)+1; + dbuf.dptr = prs_data_p(ps); + dbuf.dsize = prs_offset(ps); + return tdb_store(tdb, kbuf, dbuf, TDB_REPLACE); +} + +/* useful function to fetch a structure into rpc wire format */ +int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) +{ + TDB_DATA kbuf, dbuf; + kbuf.dptr = keystr; + kbuf.dsize = strlen(keystr)+1; + + dbuf = tdb_fetch(tdb, kbuf); + if (!dbuf.dptr) return -1; + + ZERO_STRUCTP(ps); + prs_init(ps, 0, 4, UNMARSHALL); + prs_give_memory(ps, dbuf.dptr, dbuf.dsize, True); + + return 0; +} diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c index d2eb6b5ec7..3e973337b9 100644 --- a/source3/tdb/tdbutil.c +++ b/source3/tdb/tdbutil.c @@ -250,33 +250,3 @@ int tdb_unpack(char *buf, int bufsize, char *fmt, ...) no_space: return -1; } - - -/* useful function to store a structure in rpc wire format */ -int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) -{ - TDB_DATA kbuf, dbuf; - kbuf.dptr = keystr; - kbuf.dsize = strlen(keystr)+1; - dbuf.dptr = prs_data_p(ps); - dbuf.dsize = prs_offset(ps); - - return tdb_store(tdb, kbuf, dbuf, TDB_REPLACE); -} - -/* useful function to fetch a structure into rpc wire format */ -int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) -{ - TDB_DATA kbuf, dbuf; - kbuf.dptr = keystr; - kbuf.dsize = strlen(keystr)+1; - - dbuf = tdb_fetch(tdb, kbuf); - if (!dbuf.dptr) return -1; - - ZERO_STRUCTP(ps); - prs_init(ps, 0, 4, UNMARSHALL); - prs_give_memory(ps, dbuf.dptr, dbuf.dsize, True); - - return 0; -} |