Permalink
Browse files

[api] Support short options and aliases

  • Loading branch information...
1 parent 7e6b37a commit 2f5a5eb40799c88220b0ee51be0c060bf39e7889 @mmalecki committed Mar 30, 2013
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/saneopt.c
View
@@ -31,6 +31,21 @@ int saneopt__matches(saneopt_t* opt, char* name, char* arg) {
}
}
}
+ else if (strncmp(arg, "-", 1) == 0) {
+ ++arg;
+
+ if (strcmp(arg, name) == 0) {
+ return 1;
+ }
+
+ for (i = 0; opt->aliases && i < opt->alias_count; i++) {
+ if (strcmp(opt->aliases[i]->option, name) == 0 &&
+ strlen(opt->aliases[i]->alias) == 1 &&
+ strcmp(arg, opt->aliases[i]->alias) == 0) {
+ return 1;
+ }
+ }
+ }
return 0;
}

0 comments on commit 2f5a5eb

Please sign in to comment.