net: Move net_run_function/net_run_function2 to net_util.c
authorKai Blin <kai@samba.org>
Sun, 18 May 2008 08:56:32 +0000 (10:56 +0200)
committerKai Blin <kai@samba.org>
Tue, 10 Jun 2008 07:45:14 +0000 (09:45 +0200)
(This used to be commit 73fb5f392dbc1966ec34217e39d565200e071aaf)

source3/utils/net.c
source3/utils/net_proto.h
source3/utils/net_util.c

index 91070a5da9dd2ec711f5c2bc365317b4dcb44adc..e0edeef61008827ad27c4de45af109266b9a44e9 100644 (file)
@@ -85,52 +85,6 @@ uint32 get_sec_channel_type(const char *param)
        }
 }
 
-/*
-  run a function from a function table. If not found then
-  call the specified usage function
-*/
-int net_run_function(struct net_context *c, int argc, const char **argv,
-                    struct functable *table,
-                    int (*usage_fn)(struct net_context *c,
-                                    int argc, const char **argv))
-{
-       int i;
-
-       if (argc < 1) {
-               d_printf("\nUsage: \n");
-               return usage_fn(c, argc, argv);
-       }
-       for (i=0; table[i].funcname; i++) {
-               if (StrCaseCmp(argv[0], table[i].funcname) == 0)
-                       return table[i].fn(c, argc-1, argv+1);
-       }
-       d_fprintf(stderr, "No command: %s\n", argv[0]);
-       return usage_fn(c, argc, argv);
-}
-
-/*
- * run a function from a function table.
- */
-int net_run_function2(struct net_context *c, int argc, const char **argv,
-                     const char *whoami, struct functable2 *table)
-{
-       int i;
-
-       if (argc != 0) {
-               for (i=0; table[i].funcname; i++) {
-                       if (StrCaseCmp(argv[0], table[i].funcname) == 0)
-                               return table[i].fn(c, argc-1, argv+1);
-               }
-       }
-
-       for (i=0; table[i].funcname != NULL; i++) {
-               d_printf("%s %-15s %s\n", whoami, table[i].funcname,
-                        table[i].helptext);
-       }
-
-       return -1;
-}
-
 static int net_changetrustpw(struct net_context *c, int argc, const char **argv)
 {
        if (net_ads_check_our_domain(c) == 0)
index 7606ba7e082c6ee6a79175d6095bb873fdd4b1b2..5af9d9e2cddc091c2d9cd31f705caf3b0454ff7c 100644 (file)
@@ -43,12 +43,6 @@ void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
 /* The following definitions come from utils/net.c  */
 
 uint32 get_sec_channel_type(const char *param);
-int net_run_function(struct net_context *c, int argc, const char **argv,
-                    struct functable *table,
-                    int (*usage_fn)(struct net_context *c,
-                                    int argc, const char **argv));
-int net_run_function2(struct net_context *c, int argc, const char **argv,
-                     const char *whoami, struct functable2 *table);
 
 /* The following definitions come from utils/net_ads.c  */
 
@@ -460,6 +454,12 @@ NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain,
                                    struct sockaddr_storage *pss,
                                    unsigned flags, struct cli_state **pcli);
 const char *net_prompt_pass(struct net_context *c, const char *user);
+int net_run_function(struct net_context *c, int argc, const char **argv,
+                    struct functable *table,
+                    int (*usage_fn)(struct net_context *c,
+                                    int argc, const char **argv));
+int net_run_function2(struct net_context *c, int argc, const char **argv,
+                     const char *whoami, struct functable2 *table);
 
 /* The following definitions come from utils/netlookup.c  */
 
index 771c7e4f4646ca691b44756939fcfa07667ec8c7..20f004b790b02c527efeca16532fa5c71a456510 100644 (file)
@@ -546,3 +546,49 @@ const char *net_prompt_pass(struct net_context *c, const char *user)
        return pass;
 }
 
+/*
+  run a function from a function table. If not found then
+  call the specified usage function
+*/
+int net_run_function(struct net_context *c, int argc, const char **argv,
+                    struct functable *table,
+                    int (*usage_fn)(struct net_context *c,
+                                    int argc, const char **argv))
+{
+       int i;
+
+       if (argc < 1) {
+               d_printf("\nUsage: \n");
+               return usage_fn(c, argc, argv);
+       }
+       for (i=0; table[i].funcname; i++) {
+               if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+                       return table[i].fn(c, argc-1, argv+1);
+       }
+       d_fprintf(stderr, "No command: %s\n", argv[0]);
+       return usage_fn(c, argc, argv);
+}
+
+/*
+ * run a function from a function table.
+ */
+int net_run_function2(struct net_context *c, int argc, const char **argv,
+                     const char *whoami, struct functable2 *table)
+{
+       int i;
+
+       if (argc != 0) {
+               for (i=0; table[i].funcname; i++) {
+                       if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+                               return table[i].fn(c, argc-1, argv+1);
+               }
+       }
+
+       for (i=0; table[i].funcname != NULL; i++) {
+               d_printf("%s %-15s %s\n", whoami, table[i].funcname,
+                        table[i].helptext);
+       }
+
+       return -1;
+}
+