Move the remnants of rpc_parse code under registry/
authorSimo Sorce <idra@samba.org>
Thu, 15 Jul 2010 21:45:29 +0000 (17:45 -0400)
committerGünther Deschner <gd@samba.org>
Thu, 15 Jul 2010 23:51:18 +0000 (01:51 +0200)
The registry code is the only last user of this code.
Move everything under registry/ and hope someone will get rid od
it completely from there in the future.

Signed-off-by: Günther Deschner <gd@samba.org>
source3/Makefile.in
source3/include/ntdomain.h
source3/include/proto.h
source3/include/regfio.h
source3/include/rpc_dce.h
source3/registry/reg_parse_prs.c [moved from source3/rpc_parse/parse_prs.c with 99% similarity]
source3/registry/reg_parse_prs.h [new file with mode: 0644]
source3/registry/reg_perfcount.h
source3/registry/regfio.c
source3/rpc_server/srv_winreg_nt.c

index 08d629a7545c87c8e0f4abfff263ec5512a5b33d..9676b379270b1aaaf9fe51f227caf6292f339722 100644 (file)
@@ -354,7 +354,7 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \
 
 # this includes only the low level parse code, not stuff
 # that requires knowledge of security contexts
-RPC_PARSE_OBJ1 = rpc_parse/parse_prs.o
+REG_PARSE_PRS_OBJ = registry/reg_parse_prs.o
 
 RPC_PARSE_OBJ2 = rpc_client/init_netlogon.o \
                 rpc_client/init_lsa.o
@@ -487,7 +487,7 @@ LIBSMB_ERR_OBJ0 = $(NTERR_OBJ) $(DOSERR_OBJ) $(ERRORMAP_OBJ) $(DCE_RPC_ERR_OBJ)
 LIBSMB_ERR_OBJ1 = ../libcli/auth/smbdes.o ../libcli/auth/smbencrypt.o ../libcli/auth/msrpc_parse.o ../libcli/auth/session.o
 
 LIBSMB_ERR_OBJ = $(LIBSMB_ERR_OBJ0) $(LIBSMB_ERR_OBJ1) \
-                $(RPC_PARSE_OBJ1) \
+                $(REG_PARSE_PRS_OBJ) \
                 $(SECRETS_OBJ)
 
 LIBSMB_OBJ0 = \
index 524c9ecc9b2d46d192043322eddc4ed55fe8a5f6..629e51cea3a0cc52609080b791493eb41d628480 100644 (file)
  * in the NTDOM branch - it didn't belong there.
  */
 
-#define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
-
-typedef struct _prs_struct {
-       bool io; /* parsing in or out of data stream */
-       /* 
-        * If the (incoming) data is big-endian. On output we are
-        * always little-endian.
-        */ 
-       bool bigendian_data;
-       uint8 align; /* data alignment */
-       bool is_dynamic; /* Do we own this memory or not ? */
-       uint32 data_offset; /* Current working offset into data. */
-       uint32 buffer_size; /* Current allocated size of the buffer. */
-       uint32 grow_size; /* size requested via prs_grow() calls */
-       /* The buffer itself. If "is_dynamic" is true this
-        * MUST BE TALLOC'ed off mem_ctx. */
-       char *data_p;
-       TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
-} prs_struct;
-
-/*
- * Defines for io member of prs_struct.
- */
-
-#define MARSHALL 0
-#define UNMARSHALL 1
-
-#define MARSHALLING(ps) (!(ps)->io)
-#define UNMARSHALLING(ps) ((ps)->io)
-
-#define RPC_BIG_ENDIAN                 1
-#define RPC_LITTLE_ENDIAN      0
-
-#define RPC_PARSE_ALIGN 4
-
 typedef struct _output_data {
        /*
         * Raw RPC output data. This does not include RPC headers or footers.
index abb498ce4d82de0ab3e2f548e3dadb250cb3ba42..ad16e7e52f7740a2682f1c0903320319e05c88e1 100644 (file)
@@ -5018,50 +5018,6 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
                        const struct ndr_interface_table *table,
                        uint32 opnum, void *r);
 
-/* The following definitions come from rpc_parse/parse_prs.c  */
-
-void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
-bool prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, bool io);
-void prs_mem_free(prs_struct *ps);
-void prs_mem_clear(prs_struct *ps);
-char *prs_alloc_mem_(prs_struct *ps, size_t size, unsigned int count);
-char *prs_alloc_mem(prs_struct *ps, size_t size, unsigned int count);
-TALLOC_CTX *prs_get_mem_context(prs_struct *ps);
-void prs_give_memory(prs_struct *ps, char *buf, uint32 size, bool is_dynamic);
-bool prs_set_buffer_size(prs_struct *ps, uint32 newsize);
-bool prs_grow(prs_struct *ps, uint32 extra_space);
-bool prs_force_grow(prs_struct *ps, uint32 extra_space);
-char *prs_data_p(prs_struct *ps);
-uint32 prs_data_size(prs_struct *ps);
-uint32 prs_offset(prs_struct *ps);
-bool prs_set_offset(prs_struct *ps, uint32 offset);
-bool prs_append_prs_data(prs_struct *dst, prs_struct *src);
-bool prs_append_some_data(prs_struct *dst, void *src_base, uint32_t start,
-                         uint32_t len);
-bool prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
-bool prs_copy_data_in(prs_struct *dst, const char *src, uint32 len);
-bool prs_copy_data_out(char *dst, prs_struct *src, uint32 len);
-bool prs_copy_all_data_out(char *dst, prs_struct *src);
-void prs_set_endian_data(prs_struct *ps, bool endian);
-bool prs_align(prs_struct *ps);
-bool prs_align_uint16(prs_struct *ps);
-bool prs_align_uint64(prs_struct *ps);
-bool prs_align_custom(prs_struct *ps, uint8 boundary);
-bool prs_align_needed(prs_struct *ps, uint32 needed);
-char *prs_mem_get(prs_struct *ps, uint32 extra_size);
-void prs_switch_type(prs_struct *ps, bool io);
-bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
-bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16);
-bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32);
-bool prs_int32(const char *name, prs_struct *ps, int depth, int32 *data32);
-bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64);
-bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status);
-bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
-bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
-bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
-bool prs_init_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
-bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
-
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
 /* The following definitions come from rpc_server/rpc_handles.c  */
index 840fbcd89a5fe13eb381ca8042592090368012d8..f2d952b169212a0f8c837618692a1b8b1ce5f9b0 100644 (file)
@@ -23,6 +23,7 @@
  * Thanks Nigel!
  ***********************************************************/
 
+#include "registry/reg_parse_prs.h"
 
 #ifndef _REGFIO_H
 #define _REGFIO_H
index 4a4068be6fde8e4f4f050e04d60b5cbe00924f07..7be8a8a6f74fd68605e56de88f6eb7af557d61ce 100644 (file)
@@ -33,4 +33,7 @@
 
 #define RPC_HEADER_LEN 16
 
+#define RPC_BIG_ENDIAN                 1
+#define RPC_LITTLE_ENDIAN      0
+
 #endif /* _DCE_RPC_H */
similarity index 99%
rename from source3/rpc_parse/parse_prs.c
rename to source3/registry/reg_parse_prs.c
index 0eecc4c69817a53f9a48f8193c2531d6d3e8913e..c1b941bbae4728b59e74dbbc5a8efb62de8d703d 100644 (file)
@@ -1,26 +1,27 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba memory buffer functions
    Copyright (C) Andrew Tridgell              1992-1997
    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
    Copyright (C) Jeremy Allison               1999
    Copyright (C) Andrew Bartlett              2003.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
+#include "reg_parse_prs.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_PARSE
@@ -207,7 +208,7 @@ bool prs_grow(prs_struct *ps, uint32 extra_space)
                                (unsigned int)extra_space));
                return False;
        }
-       
+
        /*
         * Decide how much extra space we really need.
         */
@@ -455,7 +456,7 @@ bool prs_align(prs_struct *ps)
 /******************************************************************
  Align on a 2 byte boundary
  *****************************************************************/
+
 bool prs_align_uint16(prs_struct *ps)
 {
        bool ret;
@@ -464,14 +465,14 @@ bool prs_align_uint16(prs_struct *ps)
        ps->align = 2;
        ret = prs_align(ps);
        ps->align = old_align;
-       
+
        return ret;
 }
 
 /******************************************************************
  Align on a 8 byte boundary
  *****************************************************************/
+
 bool prs_align_uint64(prs_struct *ps)
 {
        bool ret;
@@ -480,14 +481,14 @@ bool prs_align_uint64(prs_struct *ps)
        ps->align = 8;
        ret = prs_align(ps);
        ps->align = old_align;
-       
+
        return ret;
 }
 
 /******************************************************************
  Align on a specific byte boundary
  *****************************************************************/
+
 bool prs_align_custom(prs_struct *ps, uint8 boundary)
 {
        bool ret;
@@ -496,7 +497,7 @@ bool prs_align_custom(prs_struct *ps, uint8 boundary)
        ps->align = boundary;
        ret = prs_align(ps);
        ps->align = old_align;
-       
+
        return ret;
 }
 
@@ -855,12 +856,12 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
 {
        blob->length = prs_data_size(prs);
        blob->data = (uint8 *)TALLOC_ZERO_SIZE(mem_ctx, blob->length);
-       
+
        /* set the pointer at the end of the buffer */
        prs_set_offset( prs, prs_data_size(prs) );
 
        if (!prs_copy_all_data_out((char *)blob->data, prs))
                return False;
-       
+
        return True;
 }
diff --git a/source3/registry/reg_parse_prs.h b/source3/registry/reg_parse_prs.h
new file mode 100644 (file)
index 0000000..0dd475a
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+   Unix SMB/CIFS implementation.
+   SMB parameters and setup
+   Copyright (C) Andrew Tridgell 1992-1997
+   Copyright (C) Luke Kenneth Casson Leighton 1996-1997
+   Copyright (C) Paul Ashton 1997
+   Copyright (C) Jeremy Allison 2000-2004
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _REG_PARSE_PRS_H_
+#define _REG_PARSE_PRS_H_
+
+
+#define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
+
+typedef struct _prs_struct {
+       bool io; /* parsing in or out of data stream */
+       /*
+        * If the (incoming) data is big-endian. On output we are
+        * always little-endian.
+        */
+       bool bigendian_data;
+       uint8 align; /* data alignment */
+       bool is_dynamic; /* Do we own this memory or not ? */
+       uint32 data_offset; /* Current working offset into data. */
+       uint32 buffer_size; /* Current allocated size of the buffer. */
+       uint32 grow_size; /* size requested via prs_grow() calls */
+       /* The buffer itself. If "is_dynamic" is true this
+        * MUST BE TALLOC'ed off mem_ctx. */
+       char *data_p;
+       TALLOC_CTX *mem_ctx; /* When unmarshalling, use this.... */
+} prs_struct;
+
+/*
+ * Defines for io member of prs_struct.
+ */
+
+#define MARSHALL 0
+#define UNMARSHALL 1
+
+#define MARSHALLING(ps) (!(ps)->io)
+#define UNMARSHALLING(ps) ((ps)->io)
+
+#define RPC_PARSE_ALIGN 4
+
+void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
+bool prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, bool io);
+void prs_mem_free(prs_struct *ps);
+void prs_mem_clear(prs_struct *ps);
+char *prs_alloc_mem_(prs_struct *ps, size_t size, unsigned int count);
+char *prs_alloc_mem(prs_struct *ps, size_t size, unsigned int count);
+TALLOC_CTX *prs_get_mem_context(prs_struct *ps);
+void prs_give_memory(prs_struct *ps, char *buf, uint32 size, bool is_dynamic);
+bool prs_set_buffer_size(prs_struct *ps, uint32 newsize);
+bool prs_grow(prs_struct *ps, uint32 extra_space);
+bool prs_force_grow(prs_struct *ps, uint32 extra_space);
+char *prs_data_p(prs_struct *ps);
+uint32 prs_data_size(prs_struct *ps);
+uint32 prs_offset(prs_struct *ps);
+bool prs_set_offset(prs_struct *ps, uint32 offset);
+bool prs_append_prs_data(prs_struct *dst, prs_struct *src);
+bool prs_append_some_data(prs_struct *dst, void *src_base, uint32_t start,
+                         uint32_t len);
+bool prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
+bool prs_copy_data_in(prs_struct *dst, const char *src, uint32 len);
+bool prs_copy_data_out(char *dst, prs_struct *src, uint32 len);
+bool prs_copy_all_data_out(char *dst, prs_struct *src);
+void prs_set_endian_data(prs_struct *ps, bool endian);
+bool prs_align(prs_struct *ps);
+bool prs_align_uint16(prs_struct *ps);
+bool prs_align_uint64(prs_struct *ps);
+bool prs_align_custom(prs_struct *ps, uint8 boundary);
+bool prs_align_needed(prs_struct *ps, uint32 needed);
+char *prs_mem_get(prs_struct *ps, uint32 extra_size);
+void prs_switch_type(prs_struct *ps, bool io);
+bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
+bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16);
+bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32);
+bool prs_int32(const char *name, prs_struct *ps, int depth, int32 *data32);
+bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64);
+bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status);
+bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
+bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
+bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
+bool prs_init_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
+bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx);
+
+#endif
index c6b76a53606bdbd72879a43d96885e4860946a39..671153f21c71866f171b13c4935f1420b9869735 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef _REG_PERFCOUNT_H
 #define _REG_PERFCOUNT_H
 
+#include "reg_parse_prs.h"
+
 void perfcount_init_keys( void );
 uint32 reg_perfcount_get_base_index(void);
 uint32 reg_perfcount_get_last_counter(uint32 base_index);
index 5ba936273d51734e00c87afa32b8e89977cf2334..7a362d205e8cd5f505ddc76becf56bb6faeb9929 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "includes.h"
+#include "reg_parse_prs.h"
 #include "regfio.h"
 #include "reg_objects.h"
 #include "../librpc/gen_ndr/ndr_security.h"
index 209deadd70c89b31781906728b4ab3e4b13a74bd..73d2775b16dedec4ea694f2fd5c1001c264f657f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "../librpc/gen_ndr/srv_winreg.h"
+#include "registry/reg_parse_prs.h"
 #include "registry.h"
 #include "registry/reg_perfcount.h"