diff mbox series

[9/9] suricatta: add help to exported server functions

Message ID 20180906114041.21828-9-sbabic@denx.de
State Accepted
Headers show
Series [1/9] Use provided macro for exit() | expand

Commit Message

Stefano Babic Sept. 6, 2018, 11:40 a.m. UTC
Each server has its own setup and comman line parameters.
Set a general function to be called in suricatta daemon that
references to the server specific help function.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 include/suricatta/server.h | 3 +++
 suricatta/server_hawkbit.c | 4 ++--
 suricatta/suricatta.c      | 5 +++++
 3 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/suricatta/server.h b/include/suricatta/server.h
index 75b93f6..fc65543 100644
--- a/include/suricatta/server.h
+++ b/include/suricatta/server.h
@@ -21,6 +21,7 @@  extern unsigned int server_get_polling_interval(void);
 extern server_op_res_t server_start(const char *cfgfname, int argc, char *argv[]);
 extern server_op_res_t server_stop(void);
 extern server_op_res_t server_ipc(int fd);
+extern void server_print_help(void);
 
 static struct server_t {
 	server_op_res_t (*has_pending_action)(int *action_id);
@@ -30,10 +31,12 @@  static struct server_t {
 	server_op_res_t (*start)(const char *fname, int argc, char *argv[]);
 	server_op_res_t (*stop)(void);
 	server_op_res_t (*ipc)(int fd);
+	void (*help)(void);
 } server = {.has_pending_action = &server_has_pending_action,
 	    .install_update = &server_install_update,
 	    .send_target_data = &server_send_target_data,
 	    .get_polling_interval = &server_get_polling_interval,
+	    .help = &server_print_help,
 	    .ipc = &server_ipc,
 	    .start = &server_start,
 	    .stop = &server_stop};
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 106b535..bc85140 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -108,7 +108,7 @@  server_op_res_t server_process_update_artifact(int action_id,
 						const char *part,
 						const char *version,
 						const char *name);
-void suricatta_print_help(void);
+void server_print_help(void);
 server_op_res_t server_set_polling_interval(json_object *json_root);
 server_op_res_t server_set_config_data(json_object *json_root);
 static update_state_t get_state(void);
@@ -1474,7 +1474,7 @@  cleanup:
 	return result;
 }
 
-void suricatta_print_help(void)
+void server_print_help(void)
 {
 	fprintf(
 	    stderr,
diff --git a/suricatta/suricatta.c b/suricatta/suricatta.c
index 0ca5142..e9718cd 100644
--- a/suricatta/suricatta.c
+++ b/suricatta/suricatta.c
@@ -17,6 +17,11 @@ 
 #include "suricatta/suricatta.h"
 #include "suricatta/server.h"
 
+void suricatta_print_help(void)
+{
+	server.help();
+}
+
 int suricatta_wait(int seconds)
 {
 	fd_set readfds;