summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>2014-08-29 12:47:57 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-08 00:40:51 +0200
commit77a4e1dbad6b272a2339de2082cae6dc30ce4d12 (patch)
tree705b376dc2076abc9f8dc5523039e54db61fa79c
parentc919296a3085668d5d6134211d82677a57690815 (diff)
downloadneardal-77a4e1dbad6b272a2339de2082cae6dc30ce4d12.tar.gz
neardal-77a4e1dbad6b272a2339de2082cae6dc30ce4d12.tar.bz2
neardal-77a4e1dbad6b272a2339de2082cae6dc30ce4d12.zip
Minor cleanup.
-rw-r--r--ncl/ncl.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/ncl/ncl.c b/ncl/ncl.c
index 8c0a4cf..e285f93 100644
--- a/ncl/ncl.c
+++ b/ncl/ncl.c
@@ -164,34 +164,31 @@ static ncl_cmd_func ncl_prv_find_func(char *cmd)
return NULL;
}
-NCLError ncl_exec(char *cmdName)
+NCLError ncl_exec(char *cmd)
{
NCLError ret = NCLERR_PARSING_PARAMETERS;
- GError *gerror = NULL;
- ncl_cmd_func funcList = NULL;
+ GError *gerr = NULL;
+ ncl_cmd_func func = NULL;
int argc;
char **argv = NULL;
- if (!g_shell_parse_argv(g_strstrip(cmdName), &argc, &argv, &gerror))
+ if (!g_shell_parse_argv(g_strstrip(cmd), &argc, &argv, &gerr))
goto exit;
- funcList = ncl_prv_find_func(argv[0]);
- if (funcList != NULL) {
- ret = (*funcList)(argc, argv);
- if (ret < NCLERR_NOERROR)
- NCL_CMD_PRINTERR(
- "Error command '%s' return err %d (%s)\n",
- argv[0], ret, ncl_error_get_text(ret));
- } else {
- NCL_CMD_PRINTERR("Unknow NCL function '%s', trying shell...\n",
- cmdName);
- g_spawn_command_line_async(cmdName, &gerror);
+ func = ncl_prv_find_func(argv[0]);
+ if (!func) {
+ NCL_CMD_PRINTERR("'%s': Not NCL command, trying shell\n", cmd);
+ g_spawn_command_line_async(cmd, &gerr);
+ goto exit;
}
+
+ if ((ret = func(argc, argv)) != NCLERR_NOERROR)
+ NCL_CMD_PRINTERR("'%s': %s\n", cmd, ncl_error_get_text(ret));
exit:
- if (gerror) {
- if (gerror->code != G_SHELL_ERROR_EMPTY_STRING)
- NCL_CMD_PRINTERR("%s\n", gerror->message);
- g_error_free(gerror);
+ if (gerr) {
+ if (gerr->code != G_SHELL_ERROR_EMPTY_STRING)
+ NCL_CMD_PRINTERR("%s\n", gerr->message);
+ g_error_free(gerr);
}
g_strfreev(argv);
return ret;