[libvirt] [PATCH 11/13] vsh: Make separated generic methods public

Erik Skultety eskultet at redhat.com
Mon Jun 29 15:43:18 UTC 2015


Earlier, we have moved virsh generic methods into vsh module, but to
make them really usable by other clients, they cannot be defined as
static.
---
 tools/vsh.c | 22 +++++++++++-----------
 tools/vsh.h | 16 ++++++++++++++--
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index ed1fdb9..9b810c9 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1128,7 +1128,7 @@ vshCommandOptArgv(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
 /*
  * Executes command(s) and returns return code from last command
  */
-static bool
+bool
 vshCommandRun(vshControl *ctl, const vshCmd *cmd)
 {
     bool ret = true;
@@ -1415,7 +1415,7 @@ vshCommandArgvGetArg(vshControl *ctl, vshCommandParser *parser, char **res)
     return VSH_TK_ARG;
 }
 
-static bool
+bool
 vshCommandArgvParse(vshControl *ctl, int nargs, char **argv)
 {
     vshCommandParser parser;
@@ -1494,7 +1494,7 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res)
     return VSH_TK_ARG;
 }
 
-static bool
+bool
 vshCommandStringParse(vshControl *ctl, char *cmdstr)
 {
     vshCommandParser parser;
@@ -1745,7 +1745,7 @@ vshError(vshControl *ctl, const char *format, ...)
 }
 
 
-static void
+void
 vshEventLoop(void *opaque)
 {
     vshControl *ctl = opaque;
@@ -1788,7 +1788,7 @@ vshEventInt(int sig ATTRIBUTE_UNUSED,
 
 
 /* Event loop handler used to limit length of waiting for any other event. */
-static void
+void
 vshEventTimeout(int timer ATTRIBUTE_UNUSED,
                 void *opaque)
 {
@@ -1911,7 +1911,7 @@ vshEventCleanup(vshControl *ctl)
 /*
  * Initialize debug settings.
  */
-static void
+void
 vshInitDebug(vshControl *ctl)
 {
     const char *debugEnv;
@@ -2213,7 +2213,7 @@ vshReadlineCompletion(const char *text, int start,
 
 # define VIRSH_HISTSIZE_MAX 500000
 
-static int
+int
 vshReadlineInit(vshControl *ctl)
 {
     char *userdir = NULL;
@@ -2271,7 +2271,7 @@ vshReadlineInit(vshControl *ctl)
     return 0;
 }
 
-static void
+void
 vshReadlineDeinit(vshControl *ctl)
 {
     if (ctl->historyfile != NULL) {
@@ -2289,7 +2289,7 @@ vshReadlineDeinit(vshControl *ctl)
     VIR_FREE(ctl->historyfile);
 }
 
-static char *
+char *
 vshReadline(vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt)
 {
     return readline(prompt);
@@ -2297,14 +2297,14 @@ vshReadline(vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt)
 
 #else /* !WITH_READLINE */
 
-static int
+int
 vshReadlineInit(vshControl *ctl ATTRIBUTE_UNUSED)
 {
     /* empty */
     return 0;
 }
 
-static void
+void
 vshReadlineDeinit(vshControl *ctl ATTRIBUTE_UNUSED)
 {
     /* empty */
diff --git a/tools/vsh.h b/tools/vsh.h
index 6bf742d..1ad0287 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -287,8 +287,12 @@ int vshCommandOptScaledInt(vshControl *ctl, const vshCmd *cmd,
                            int scale, unsigned long long max)
     ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
 bool vshCommandOptBool(const vshCmd *cmd, const char *name);
+bool vshCommandRun(vshControl *ctl, const vshCmd *cmd);
+bool vshCommandStringParse(vshControl *ctl, char *cmdstr);
+
 const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, const vshCmd *cmd,
                                    const vshCmdOpt *opt);
+bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv);
 
 /* Filter flags for various vshCommandOpt*By() functions */
 typedef enum {
@@ -303,6 +307,7 @@ void vshPrintExtra(vshControl *ctl, const char *format, ...)
 int vshInit(vshControl *ctl, const vshClientHooks *clhooks,
             const vshCmdGrp *clgrps)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+void vshInitDebug(vshControl *ctl);
 void vshDebug(vshControl *ctl, int level, const char *format, ...)
     ATTRIBUTE_FMT_PRINTF(3, 4);
 
@@ -341,10 +346,17 @@ enum {
     VSH_EVENT_TIMEOUT,
     VSH_EVENT_DONE,
 };
-int vshEventStart(vshControl *ctl, int timeout_ms);
+void vshEventCleanup(vshControl *ctl);
 void vshEventDone(vshControl *ctl);
+void vshEventLoop(void *opaque);
+int vshEventStart(vshControl *ctl, int timeout_ms);
+void vshEventTimeout(int timer, void *opaque);
 int vshEventWait(vshControl *ctl);
-void vshEventCleanup(vshControl *ctl);
+
+/* readline */
+char * vshReadline(vshControl *ctl, const char *prompt);
+int vshReadlineInit(vshControl *ctl);
+void vshReadlineDeinit(vshControl *ctl);
 
 /* allocation wrappers */
 void *_vshMalloc(vshControl *ctl, size_t sz, const char *filename, int line);
-- 
1.9.3




More information about the libvir-list mailing list