Skip to content
This repository

options default and destination combo fix #41

Merged
merged 1 commit into from over 2 years ago

2 participants

Pierce Lopez Matt Reiferson
Pierce Lopez
Owner

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

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

fixed check for null default_str

Matt Reiferson
Collaborator

sweet

Matt Reiferson mreiferson merged commit 424c5f4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 05, 2012
Pierce Lopez ploxiln options: fix combination of default and destination
destinations, if specified, would not be set with defaults specified
d9a637f
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. +15 4 simplehttp/options.c
  2. +1 1  simplehttp/simplehttp.h
19 simplehttp/options.c
@@ -178,10 +178,21 @@ int option_parse_command_line(int argc, char **argv)
178 178
179 179 // check for not found entries
180 180 HASH_ITER(hh, option_list, option, tmp_option) {
181   - if (option->required == OPT_REQUIRED && option->found == 0) {
182   - fprintf(stderr, "ERROR: required option --%s not present\n", option->option_name);
183   - fprintf(stderr, " for a complete list of options use --help\n");
184   - return 0;
  181 + if (option->found == 0) {
  182 + if (option->required == OPT_REQUIRED) {
  183 + fprintf(stderr, "ERROR: required option --%s not present\n", option->option_name);
  184 + fprintf(stderr, " for a complete list of options use --help\n");
  185 + return 0;
  186 + }
  187 + if (option->dest_int) {
  188 + *(option->dest_int) = option->default_int;
  189 + } else if (option->dest_str) {
  190 + if (option->default_str) {
  191 + *(option->dest_str) = strdup(option->default_str);
  192 + }
  193 + } else if (option->dest_char) {
  194 + *(option->dest_char) = option->default_char;
  195 + }
185 196 }
186 197 }
187 198 return 1;
2  simplehttp/simplehttp.h
@@ -6,7 +6,7 @@
6 6 #include <event.h>
7 7 #include <evhttp.h>
8 8
9   -#define SIMPLEHTTP_VERSION "0.1.2"
  9 +#define SIMPLEHTTP_VERSION "0.1.3"
10 10 #ifndef DUPE_N_TERMINATE
11 11 #define DUPE_N_TERMINATE(buf, len, tmp) \
12 12 tmp = malloc((len) + 1); \

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.