More infrastructure for storing registry
authorRichard Sharpe <sharpe@samba.org>
Tue, 22 Apr 2003 01:57:21 +0000 (01:57 +0000)
committerRichard Sharpe <sharpe@samba.org>
Tue, 22 Apr 2003 01:57:21 +0000 (01:57 +0000)
(This used to be commit de337632c99080f4be73a6e49839d424b49c8cc3)

source3/utils/editreg.c

index c00d9c22cbd6e7f6e8a7f088e9684490b67046ba..8af54ed58a6e5d44581d3f33d9134c15f754c816 100644 (file)
@@ -594,7 +594,26 @@ typedef struct sk_map_s {
   KEY_SEC_DESC *key_sec_desc;
 } SK_MAP;
 
-struct regf_struct_s {
+/*
+ * This structure keeps track of the output format of the registry
+ */
+#define REG_OUTBLK_HDR 1
+#define REG_OUTBLK_HBIN 2
+
+typedef struct hbin_blk_s {
+  int type, size;
+  struct hbin_blk_s *next;
+  char *data;                /* The data block                */
+  unsigned int file_offset;  /* Offset in file                */
+  unsigned int free_space;   /* Amount of free space in block */
+  unsigned int fsp_off;      /* Start of free space in block  */
+  int complete, stored;
+} HBIN_BLK;
+
+/*
+ * This structure keeps all the registry stuff in one place
+ */
+typedef struct regf_struct_s {
   int reg_type;
   char *regfile_name, *outfile_name;
   int fd;
@@ -607,9 +626,12 @@ struct regf_struct_s {
   SK_MAP *sk_map;
   char *owner_sid_str;
   SEC_DESC *def_sec_desc;
-};
-
-typedef struct regf_struct_s REGF;
+  /*
+   * These next pointers point to the blocks used to contain the 
+   * keys when we are preparing to write them to a file
+   */
+  HBIN_BLK *blk_head, *blk_tail, *free_space;
+} REGF;
 
 /*
  * An API for accessing/creating/destroying items above
@@ -2407,17 +2429,6 @@ int nt_load_registry(REGF *regf)
   return 1;
 }
 
-/*
- * These structures keep track of the output format of the registry
- */
-typedef struct hbin_blk_s {
-  struct hbin_blk_s *next;
-  unsigned int file_offset;  /* Offset in file                */
-  unsigned int free_space;   /* Amount of free space in block */
-  unsigned int fsp_off;      /* Start of free space in block  */
-  int complete, stored;
-} HBIN_BLK;
-
 /*
  * Allocate a new hbin block and link it to the others.
  */
@@ -2427,11 +2438,23 @@ int nt_create_hbin_blk(REGF *regf)
   return 0;
 }
 
+/*
+ * Allocate a unit of space ...
+ */
+void *nt_alloc_regf_space(REGF *regf, int size)
+{
+
+  return NULL;
+}
+
 /*
  * Store a KEY in the file ...
  *
  * We store this depth first, and defer storing the lf struct until
  * all the sub-keys have been stored.
+ * 
+ * We store the NK hdr, any SK header, class name, and VK structure, then
+ * recurse down the LF structures ... 
  */
 int nt_store_reg_key(REGF *regf, REG_KEY *key)
 {
@@ -2442,10 +2465,30 @@ int nt_store_reg_key(REGF *regf, REG_KEY *key)
 
 /*
  * Store the registry header ...
+ * We actually create the registry header block and link it to the chain
+ * of output blocks.
  */
-int nt_store_reg_header(REGF *regf){
+REGF_HDR *nt_get_reg_header(REGF *regf)
+{
+  HBIN_BLK *tmp = NULL;
+  
+  tmp = (HBIN_BLK *)malloc(sizeof(HBIN_BLK));
+  if (!tmp) return 0;
 
-  return 0;
+  bzero(tmp, sizeof(HBIN_BLK));
+  tmp->type = REG_OUTBLK_HDR;
+  tmp->size = REGF_HDR_BLKSIZ;
+  tmp->data = malloc(REGF_HDR_BLKSIZ);
+  if (!tmp->data) goto error;
+
+  bzero(tmp->data, REGF_HDR_BLKSIZ);  /* Make it pristine, unlike Windows */
+  regf->blk_head = regf->blk_tail = tmp;
+
+  return (REGF_HDR *)tmp->data;
+
+ error:
+  if (tmp) free(tmp);
+  return NULL;
 }
 
 /*
@@ -2461,6 +2504,9 @@ int nt_store_reg_header(REGF *regf){
  */
 int nt_store_registry(REGF *regf)
 {
+  REGF_HDR *reg;
+
+  reg = nt_get_reg_header(regf);
 
   return 1;
 }