Skip to content

Commit

Permalink
added TWOPTTYPE_FLAG. value is 1 if present, else 0 (set by model). c…
Browse files Browse the repository at this point in the history
…loses #17
  • Loading branch information
gonsie committed Jan 23, 2015
1 parent 7c6ca8c commit 3829d22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/tw-opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ show_help(void)
fprintf(stderr, " (default %s)", (char *) def->value);
break;

case TWOPTTYPE_FLAG:
fprintf(stderr, " (default off)");
break;

default:
break;
}
Expand Down Expand Up @@ -152,6 +156,10 @@ tw_opt_print(void)
fprintf(f, "%s,", (char *)def->value);
break;

case TWOPTTYPE_FLAG:
fprintf(f, "%s,", (char *)def->name);
break;

default:
break;
}
Expand Down Expand Up @@ -228,6 +236,10 @@ apply_opt(const tw_optdef *def, const char *value)
break;
}

case TWOPTTYPE_FLAG:
*((unsigned int*)def->value) = 1;
break;

case TWOPTTYPE_SHOWHELP:
if (tw_ismaster())
show_help();
Expand Down
2 changes: 2 additions & 0 deletions core/tw-opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum tw_opttype
TWOPTTYPE_UINT, /* value must be an "unsigned int*" */
TWOPTTYPE_STIME, /* value must be an "tw_stime*" */
TWOPTTYPE_CHAR, /* value must be a char * */
TWOPTTYPE_FLAG, /* value must be at "unsigned int*" */
TWOPTTYPE_SHOWHELP
};
typedef enum tw_opttype tw_opttype;
Expand All @@ -26,6 +27,7 @@ struct tw_optdef
#define TWOPT_UINT(n,v,h) { TWOPTTYPE_UINT, (n), (h), &(v) }
#define TWOPT_STIME(n,v,h) { TWOPTTYPE_STIME, (n), (h), &(v) }
#define TWOPT_CHAR(n,v,h) { TWOPTTYPE_CHAR, (n), (h), &(v) }
#define TWOPT_FLAG(n,v,h) { TWOPTTYPE_FLAG, (n), (h), &(v) }
#define TWOPT_END() (tw_opttype)0

/** Remove options from the command line arguments. */
Expand Down

0 comments on commit 3829d22

Please sign in to comment.