[multipathd] move show_{paths,maps} in cli_handlers.c
authorChristophe Varoqui <root@xa-s05.(none)>
Wed, 30 Nov 2005 08:52:12 +0000 (09:52 +0100)
committerChristophe Varoqui <root@xa-s05.(none)>
Wed, 30 Nov 2005 08:52:12 +0000 (09:52 +0100)
Near their users.

multipathd/cli_handlers.c
multipathd/main.c
multipathd/main.h

index 0fb1cfb..1b2b789 100644 (file)
 #include "cli.h"
 
 int
+show_paths (char ** r, int * len, struct vectors * vecs, char * style)
+{
+       int i;
+       struct path * pp;
+       char * c;
+       char * reply;
+       int maxlen = INITIAL_REPLY_LEN;
+       int again = 1;
+
+       get_path_layout(vecs->pathvec);
+       reply = MALLOC(maxlen);
+
+       while (again) {
+               if (!reply)
+                       return 1;
+
+               c = reply;
+
+               if (VECTOR_SIZE(vecs->pathvec) > 0)
+                       c += snprint_path_header(c, reply + maxlen - c,
+                                                style);
+
+               vector_foreach_slot(vecs->pathvec, pp, i)
+                       c += snprint_path(c, reply + maxlen - c,
+                                         style, pp);
+
+               again = ((c - reply) == (maxlen - 1));
+
+               if (again)
+                       reply = REALLOC(reply, maxlen *= 2);
+
+       }
+       *r = reply;
+       *len = (int)(c - reply + 1);
+       return 0;
+}
+
+int
 cli_list_paths (void * v, char ** reply, int * len, void * data)
 {
        struct vectors * vecs = (struct vectors *)data;
@@ -27,6 +65,42 @@ cli_list_paths (void * v, char ** reply, int * len, void * data)
 }
 
 int
+show_maps (char ** r, int *len, struct vectors * vecs, char * style)
+{
+       int i;
+       struct multipath * mpp;
+       char * c;
+       char * reply;
+       int maxlen = INITIAL_REPLY_LEN;
+       int again = 1;
+
+       get_multipath_layout(vecs->mpvec);
+       reply = MALLOC(maxlen);
+
+       while (again) {
+               if (!reply)
+                       return 1;
+
+               c = reply;
+               if (VECTOR_SIZE(vecs->mpvec) > 0)
+                       c += snprint_multipath_header(c, reply + maxlen - c,
+                                                     style);
+
+               vector_foreach_slot(vecs->mpvec, mpp, i)
+                       c += snprint_multipath(c, reply + maxlen - c,
+                                              style, mpp);
+
+               again = ((c - reply) == (maxlen - 1));
+
+               if (again)
+                       reply = REALLOC(reply, maxlen *= 2);
+       }
+       *r = reply;
+       *len = (int)(c - reply + 1);
+       return 0;
+}
+
+int
 cli_list_maps (void * v, char ** reply, int * len, void * data)
 {
        struct vectors * vecs = (struct vectors *)data;
index 48fae6a..cef6fc2 100644 (file)
@@ -860,80 +860,6 @@ out:
        return 1;
 }
 
-int
-show_paths (char ** r, int * len, struct vectors * vecs, char * style)
-{
-       int i;
-       struct path * pp;
-       char * c;
-       char * reply;
-       int maxlen = INITIAL_REPLY_LEN;
-       int again = 1;
-
-       get_path_layout(vecs->pathvec);
-       reply = MALLOC(maxlen);
-
-       while (again) {
-               if (!reply)
-                       return 1;
-
-               c = reply;
-
-               if (VECTOR_SIZE(vecs->pathvec) > 0)
-                       c += snprint_path_header(c, reply + maxlen - c,
-                                                style);
-
-               vector_foreach_slot(vecs->pathvec, pp, i)
-                       c += snprint_path(c, reply + maxlen - c,
-                                         style, pp);
-
-               again = ((c - reply) == (maxlen - 1));
-
-               if (again)
-                       reply = REALLOC(reply, maxlen *= 2);
-
-       }
-       *r = reply;
-       *len = (int)(c - reply + 1);
-       return 0;
-}
-
-int
-show_maps (char ** r, int *len, struct vectors * vecs, char * style)
-{
-       int i;
-       struct multipath * mpp;
-       char * c;
-       char * reply;
-       int maxlen = INITIAL_REPLY_LEN;
-       int again = 1;
-
-       get_multipath_layout(vecs->mpvec);
-       reply = MALLOC(maxlen);
-
-       while (again) {
-               if (!reply)
-                       return 1;
-
-               c = reply;
-               if (VECTOR_SIZE(vecs->mpvec) > 0)
-                       c += snprint_multipath_header(c, reply + maxlen - c,
-                                                     style);
-
-               vector_foreach_slot(vecs->mpvec, mpp, i)
-                       c += snprint_multipath(c, reply + maxlen - c,
-                                              style, mpp);
-
-               again = ((c - reply) == (maxlen - 1));
-
-               if (again)
-                       reply = REALLOC(reply, maxlen *= 2);
-       }
-       *r = reply;
-       *len = (int)(c - reply + 1);
-       return 0;
-}
-
 static int
 map_discovery (struct vectors * vecs)
 {
index c9a4886..a623656 100644 (file)
@@ -7,8 +7,6 @@
 #define MAX_CHECKINT CHECKINT << 2
 
 int reconfigure (struct vectors *);
-int show_paths (char **, int *, struct vectors *, char *);
-int show_maps (char **, int *, struct vectors *, char *);
 int ev_add_path (char *, struct vectors *);
 int ev_remove_path (char *, struct vectors *);
 int ev_add_map (char *, struct vectors *);