Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

options default and destination combo fix #41

Merged
merged 1 commit into from

2 participants

@ploxiln

destinations, if specified, would not be set with defaults specified

Pierce Lopez options: fix combination of default and destination
destinations, if specified, would not be set with defaults specified
d9a637f
@ploxiln

fixed check for null default_str

@mreiferson
Collaborator

sweet

@mreiferson mreiferson merged commit 424c5f4 into bitly:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 5, 2012
  1. options: fix combination of default and destination

    Pierce Lopez authored
    destinations, if specified, would not be set with defaults specified
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 5 deletions.
  1. +15 −4 simplehttp/options.c
  2. +1 −1  simplehttp/simplehttp.h
View
19 simplehttp/options.c
@@ -178,10 +178,21 @@ int option_parse_command_line(int argc, char **argv)
// check for not found entries
HASH_ITER(hh, option_list, option, tmp_option) {
- if (option->required == OPT_REQUIRED && option->found == 0) {
- fprintf(stderr, "ERROR: required option --%s not present\n", option->option_name);
- fprintf(stderr, " for a complete list of options use --help\n");
- return 0;
+ if (option->found == 0) {
+ if (option->required == OPT_REQUIRED) {
+ fprintf(stderr, "ERROR: required option --%s not present\n", option->option_name);
+ fprintf(stderr, " for a complete list of options use --help\n");
+ return 0;
+ }
+ if (option->dest_int) {
+ *(option->dest_int) = option->default_int;
+ } else if (option->dest_str) {
+ if (option->default_str) {
+ *(option->dest_str) = strdup(option->default_str);
+ }
+ } else if (option->dest_char) {
+ *(option->dest_char) = option->default_char;
+ }
}
}
return 1;
View
2  simplehttp/simplehttp.h
@@ -6,7 +6,7 @@
#include <event.h>
#include <evhttp.h>
-#define SIMPLEHTTP_VERSION "0.1.2"
+#define SIMPLEHTTP_VERSION "0.1.3"
#ifndef DUPE_N_TERMINATE
#define DUPE_N_TERMINATE(buf, len, tmp) \
tmp = malloc((len) + 1); \
Something went wrong with that request. Please try again.