}
/**
- * Handle command line options
+ * Handle command line options, if simple is TRUE only arguments like --help
+ * and --version are handled.
*/
-static void handle_arguments(int argc, char *argv[])
+static void handle_arguments(int argc, char *argv[], bool simple)
{
struct option long_opts[CMD_OPT_COUNT + 1] = {};
int i, opt;
long_opts[i].val = cmd_options[i].id;
long_opts[i].has_arg = cmd_options[i].has_arg;
}
+ /* reset option parser */
+ optind = 1;
while (TRUE)
{
bool handled = FALSE;
printf("%s, strongSwan %s\n", "charon-cmd", VERSION);
exit(0);
default:
+ if (simple)
+ {
+ continue;
+ }
handled |= conn->handle(conn, opt, optarg);
handled |= creds->handle(creds, opt, optarg);
if (handled)
struct utsname utsname;
int group;
+ /* handle simple arguments */
+ handle_arguments(argc, argv, TRUE);
+
dbg = dbg_stderr;
atexit(library_deinit);
if (!library_init(NULL))
creds = cmd_creds_create();
atexit(cleanup_creds);
- handle_arguments(argc, argv);
+ /* handle all arguments */
+ handle_arguments(argc, argv, FALSE);
if (uname(&utsname) != 0)
{