diff options
author | Angelo Mantellini <angelo.mantellini@cisco.com> | 2020-06-09 14:48:02 +0200 |
---|---|---|
committer | Angelo Mantellini <angelo.mantellini@cisco.com> | 2020-06-15 11:43:30 +0200 |
commit | 9e2c045d6118ef264d6cf8fc655b72d7c4c403dc (patch) | |
tree | d4156335f5ea69064e817b7c6536e0200c6421af /hicn-light/src/hicn/config/controlRoot.c | |
parent | a84ff82bb37ac53f20639d6e5e7f19d002459f31 (diff) |
[HICN-626] Return output from libhicnlight
Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com>
Change-Id: I2351ce4dcefa1311fa09049f87e8317c8fe449f4
Diffstat (limited to 'hicn-light/src/hicn/config/controlRoot.c')
-rw-r--r-- | hicn-light/src/hicn/config/controlRoot.c | 78 |
1 files changed, 50 insertions, 28 deletions
diff --git a/hicn-light/src/hicn/config/controlRoot.c b/hicn-light/src/hicn/config/controlRoot.c index 8c8cc1804..39a1fa6b5 100644 --- a/hicn-light/src/hicn/config/controlRoot.c +++ b/hicn-light/src/hicn/config/controlRoot.c @@ -37,9 +37,15 @@ static void _controlRoot_Init(CommandParser *parser, CommandOps *ops); static CommandReturn _controlRoot_Execute(CommandParser *parser, - CommandOps *ops, PARCList *args); + CommandOps *ops, + PARCList *args, + char *output, + size_t output_size); static CommandReturn _controlRoot_HelpExecute(CommandParser *parser, - CommandOps *ops, PARCList *args); + CommandOps *ops, + PARCList *args, + char *output, + size_t output_size); static const char *_commandRoot = ""; static const char *_commandRootHelp = "help"; @@ -59,20 +65,21 @@ CommandOps *controlRoot_HelpCreate(ControlState *state) { // =================================================== static CommandReturn _controlRoot_HelpExecute(CommandParser *parser, - CommandOps *ops, PARCList *args) { - printf("Command-line execution:\n"); - printf( - " controller [--server <server-ip>] [--port <server-port>] " - "command\n"); - printf("\n"); - printf("Interactive execution:\n"); - printf(" controller [--server <server-ip>] [--port <server-port>]\n"); - printf("\n"); - printf( - "If the keystore is not specified, the default path is used. Keystore " - "must exist prior to running program.\n"); - printf("If the password is not specified, the user will be prompted.\n"); - printf("\n"); + CommandOps *ops, + PARCList *args, + char *output, + size_t output_size) { + size_t output_offset = snprintf(output, output_size, "Command-line execution:\n" + " controller [--server <server-ip>] [--port <server-port>] " + "command\n" + "\n" + "Interactive execution:\n" + " controller [--server <server-ip>] [--port <server-port>]\n" + "\n" + "If the keystore is not specified, the default path is used. Keystore " + "must exist prior to running program.\n" + "If the password is not specified, the user will be prompted.\n" + "\n"); CommandOps *ops_help_add = controlAdd_CreateHelp(NULL); CommandOps *ops_help_list = controlList_HelpCreate(NULL); @@ -86,19 +93,31 @@ static CommandReturn _controlRoot_HelpExecute(CommandParser *parser, CommandOps *ops_help_update = controlUpdate_HelpCreate(NULL); #endif /* WITH_POLICY */ - printf("Available commands:\n"); - printf(" %s\n", ops_help_add->command); - printf(" %s\n", ops_help_list->command); - printf(" %s\n", ops_help_quit->command); - printf(" %s\n", ops_help_remove->command); - printf(" %s\n", ops_help_set->command); - printf(" %s\n", ops_help_unset->command); - printf(" %s\n", ops_help_cache->command); - printf(" %s\n", ops_help_mapme->command); + snprintf(output + output_offset, output_size - output_offset,"Available commands:\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" #ifdef WITH_POLICY - printf(" %s\n", ops_help_update->command); + " %s\n" #endif /* WITH_POLICY */ - printf("\n"); + "\n", + ops_help_add->command, + ops_help_list->command, + ops_help_quit->command, + ops_help_remove->command, + ops_help_set->command, + ops_help_unset->command, + ops_help_cache->command, + ops_help_mapme->command +#ifdef WITH_POLICY + , ops_help_update->command +#endif /* WITH_POLICY */ + ); commandOps_Destroy(&ops_help_add); commandOps_Destroy(&ops_help_list); @@ -144,7 +163,10 @@ static void _controlRoot_Init(CommandParser *parser, CommandOps *ops) { } static CommandReturn _controlRoot_Execute(CommandParser *parser, - CommandOps *ops, PARCList *args) { + CommandOps *ops, + PARCList *args, + char *output, + size_t output_size) { return CommandReturn_Success; } |