diff --git a/configure.ac b/configure.ac index 3470cc8..92be79c 100644 --- a/configure.ac +++ b/configure.ac @@ -19,8 +19,8 @@ AS_CASE([$host_os], [cygwin], [PLATFORM="cygwin"], [PLATFORM="nix"]) -#PACKAGE_STATUS="development" -PACKAGE_STATUS="release" +PACKAGE_STATUS="development" +#PACKAGE_STATUS="release" AM_CFLAGS="-Wall -Wno-deprecated-declarations -pedantic -std=c11" AS_IF([test "x$PACKAGE_STATUS" = xdevelopment], diff --git a/src/main.c b/src/main.c index fa2798d..7f1dcd2 100644 --- a/src/main.c +++ b/src/main.c @@ -358,6 +358,13 @@ int main(int argc, char *argv[]) { {"mode", required_argument, 0, 'm'}, {"file", required_argument, 0, 'f'}, {0, 0, 0, 0}}; + + // No arguments provided + if (argc == 1) { + _show_help(); + return EXIT_SUCCESS; + } + while (c > -1) { int option_index = 0; @@ -484,7 +491,7 @@ int main(int argc, char *argv[]) { } if( handler == NULL ) { - logError(&xmppc, "Unbekannter mode\n"); + logError(&xmppc, "Unknown mode\n"); return -1; } diff --git a/src/mode/roster.c b/src/mode/roster.c index 16da191..8a00bcc 100644 --- a/src/mode/roster.c +++ b/src/mode/roster.c @@ -59,11 +59,20 @@ static void _roster_send_query(xmppc_t *xmppc,command_t *command); static int _handle_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata); +static void _teardown(xmppc_t *xmppc); + void roster_execute_command(xmppc_t *xmppc, int argc, char *argv[]) { command_t *command = malloc(sizeof(command_t)); command->type = UNKOWN; - _roster_parse_command(command, argc, argv); - _roster_send_query(xmppc, command); + + if (argc == 0) { + logError(xmppc, "No subcommand provided\n"); + } else { + _roster_parse_command(command, argc, argv); + _roster_send_query(xmppc, command); + } + + _teardown(xmppc); } static void _roster_parse_command(command_t *command, int argc, char *argv[]) { @@ -115,7 +124,11 @@ int _handle_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, } } } - xmpp_disconnect(conn); - xmpp_stop(xmpp_conn_get_context(conn)); return 0; } + +static void _teardown(xmppc_t *xmppc) { + xmpp_conn_t *conn = xmppc->conn; + xmpp_disconnect(conn); + xmpp_stop(xmpp_conn_get_context(conn)); +}