Right now, there's very little to do in global initializer besides
registering client hooks, but there's a potential to have some more
features that will need to be properly initialized beforehand (exporting
vshControl pointer only would definitely make use of this).
---
tools/vsh.c | 24 ++++++++++++++++++++++++
tools/vsh.h | 3 +++
2 files changed, 27 insertions(+)
diff --git a/tools/vsh.c b/tools/vsh.c
index 4eb5de2..ed1fdb9 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1942,6 +1942,30 @@ vshInitDebug(vshControl *ctl)
}
+/*
+ * Initialize global data
+ */
+int
+vshInit(vshControl *ctl,
+ const vshClientHooks *clhooks,
+ const vshCmdGrp *clgrps)
+{
+ if (!clhooks || !clhooks->connHandler) {
+ vshError(ctl, "%s", _("client hooks must not be NULL"));
+ return -1;
+ }
+
+ if (!clgrps) {
+ vshError(ctl, "%s", _("command groups must not be NULL"));
+ return -1;
+ }
+
+ hooks = clhooks;
+ cmdGroups = clgrps;
+ vshInitDebug(ctl);
+ return 0;
+}
+
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
/**
diff --git a/tools/vsh.h b/tools/vsh.h
index eae38d5..6bf742d 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -300,6 +300,9 @@ typedef enum {
void vshPrintExtra(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
+int vshInit(vshControl *ctl, const vshClientHooks *clhooks,
+ const vshCmdGrp *clgrps)
+ ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
void vshDebug(vshControl *ctl, int level, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(3, 4);
--
1.9.3