Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (47 sloc) 1.081 kB
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "options.h"
options_t options_parse(int argc, char *argv[]) {
assert(argc > 1);
options_t opts;
opts.outfile = NULL;
opts.errfile = NULL;
opts.target = NULL;
opts.json = 0;
opts.child_args = NULL;
int i;
for (i = 1; i < argc; i++) {
switch((int)argv[i][0]) {
case '-':
switch((int)argv[i][1]) {
case 'o':
if (argv[i + 1][0] != '-') {
opts.outfile = &argv[i + 1][0];
}
break;
case 'e':
if (argv[i + 1][0] != '-') {
opts.errfile = &argv[i + 1][0];
}
break;
case 'j':
opts.json = 1;
break;
case '-':
if (argv[i + 1] != NULL) {
opts.target = &argv[i + 1][0];
opts.child_args = &argv[i + 1];
return opts;
}
break;
default:
break;
}
break;
default:
break;
}
}
return opts;
}
Jump to Line
Something went wrong with that request. Please try again.