r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / lib / registry / tools / regshell.c
index 6bcaf42b6cb0513ac63056c34f73cef45fed3143..f431c81bf8dc19fb8f6a4dc9987aff6808d55095 100644 (file)
@@ -6,7 +6,7 @@
 
    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 2 of the License, or
+   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,
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/events/events.h"
-#include "lib/registry/reg_backend_rpc.h"
 #include "system/time.h"
-#include "lib/replace/readline.h"
+#include "lib/smbreadline/smbreadline.h"
 #include "librpc/gen_ndr/ndr_security.h"
 
 /* 
@@ -90,19 +88,23 @@ static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_context
 
 static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv)
 {
+       struct registry_value val;
+       WERROR error;
+
        if (argc < 4) {
                fprintf(stderr, "Usage: set value-name type value\n");
-       } else {
-               struct registry_value val;
-               if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) {
-                       WERROR error = reg_val_set(cur, argv[1], val.data_type, val.data);
-                       if (!W_ERROR_IS_OK(error)) {
-                               fprintf(stderr, "Error setting value: %s\n", win_errstr(error));
-                               return NULL;
-                       }
-               } else {
-                       fprintf(stderr, "Unable to interpret data\n");
-               }
+               return cur;
+       } 
+
+       if (!reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) {
+               fprintf(stderr, "Unable to interpret data\n");
+               return cur;
+       }
+
+       error = reg_val_set(cur, argv[1], val.data_type, val.data);
+       if (!W_ERROR_IS_OK(error)) {
+               fprintf(stderr, "Error setting value: %s\n", win_errstr(error));
+               return NULL;
        }
        return cur;
 }
@@ -415,22 +417,22 @@ static char **reg_completion(const char *text, int start, int end)
                POPT_COMMON_SAMBA
                POPT_COMMON_CREDENTIALS
                POPT_COMMON_VERSION
-               POPT_TABLEEND
+               { NULL }
        };
 
-       registry_init();
-
        pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
        
        while((opt = poptGetNextOpt(pc)) != -1) {
        }
 
+       registry_init();
+
        if (remote) {
                error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); 
        } else if (backend) {
                error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey);
        } else {
-               error = reg_open_local(&h, NULL, cmdline_credentials);
+               error = reg_open_local(NULL, &h, NULL, cmdline_credentials);
        }
 
        if(!W_ERROR_IS_OK(error)) {