--- pcprofiledump.c.org Fri May 3 05:07:17 2002 +++ pcprofiledump.c Fri May 3 05:08:18 2002 @@ -18,7 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -/* This is mainly and example. It shows how programs which want to use +/* This is mainly an example. It shows how programs which want to use the information should read the file. */ #ifdef HAVE_CONFIG_H # include @@ -49,6 +49,7 @@ /* Definitions of arguments for argp functions. */ static const struct argp_option options[] = { + { "unbuffered", 'u', NULL, 0, N_("Make stdout unbuffered") }, { NULL, 0, NULL, 0, NULL } }; @@ -61,10 +62,13 @@ /* Function to print some extra text in the help message. */ static char *more_help (int key, const char *text, void *input); +/* Prototype for option handler. */ +static error_t parse_opt (int key, char *arg, struct argp_state *state); + /* Data structure to communicate with argp functions. */ static struct argp argp = { - options, NULL, args_doc, doc, NULL, more_help + options, parse_opt, args_doc, doc, NULL, more_help }; @@ -171,6 +175,20 @@ return 0; } +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case 'u': + setbuf(stdout,NULL); + break; + default: + return ARGP_ERR_UNKNOWN; + } + return 0; +} + static char * more_help (int key, const char *text, void *input) {