Well, we can now add keys and values and delete keys and values ...
authorRichard Sharpe <sharpe@samba.org>
Sun, 20 Apr 2003 21:43:07 +0000 (21:43 +0000)
committerRichard Sharpe <sharpe@samba.org>
Sun, 20 Apr 2003 21:43:07 +0000 (21:43 +0000)
Lots more to do, like handling regular expressions for keys, and input of
the security descriptors, etc. However, I now have to work on writing the
in-memory tree out to a file in a format that Windows can understand.
(This used to be commit 562b36510c704eba84b036aacdb1f984339afafc)

source3/utils/editreg.c

index 5e79df1a149a66d5bee121e4874999132f2da9da..b35e278ab052508c68df58985309f0117cd99e65 100644 (file)
@@ -981,10 +981,10 @@ void *str_to_val(int type, char *val, int *len)
     if (!dwordp) return NULL;
     /* Allow for ddddd and 0xhhhhh and 0ooooo */
     if (strncmp(val, "0x", 2) == 0 || strncmp(val, "0X", 2) == 0) {
-      sscanf(val, "0[xX]%X", dwordp);
+      sscanf(&val[2], "%X", dwordp);
     }
     else if (*val == '0') {
-      sscanf(val, "0%o", dwordp);
+      sscanf(&val[1], "%o", dwordp);
     }
     else { 
       sscanf(val, "%d", dwordp);
@@ -1018,7 +1018,9 @@ VAL_KEY *nt_add_reg_value(REG_KEY *key, char *name, int type, char *value)
   assert(type != REG_TYPE_DELETE); /* We never process deletes here */
 
   for (i = 0; i < key->values->val_count; i++) {
-    if (strcmp(name, key->values->vals[i]->name) == 0){ /* Change the value */
+    if ((!key->values->vals[i]->has_name && !*name) || 
+       (key->values->vals[i]->has_name &&
+        strcmp(name, key->values->vals[i]->name) == 0)){ /* Change the value */
       free(key->values->vals[i]->data_blk);
       key->values->vals[i]->data_blk = str_to_val(type, value, &
                                                  key->values->vals[i]->data_len);
@@ -3272,7 +3274,7 @@ int main(int argc, char *argv[])
            if (reg_val) nt_delete_val_key(reg_val);
          }
          else {
-           reg_val = nt_add_reg_value(tmp, reg_val->name, val->type, 
+           reg_val = nt_add_reg_value(tmp, val->name, val->type, 
                                       val->val);
          }