3 * $Id: traceopt.c,v 1.1 1999/10/22 22:40:08 mdw Exp $
5 * Parsing tracing options
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
32 * $Log: traceopt.c,v $
33 * Revision 1.1 1999/10/22 22:40:08 mdw
34 * Separate function for parsing user trace specs.
38 /*----- Header files ------------------------------------------------------*/
47 /*----- Main code ---------------------------------------------------------*/
49 /* --- @traceopt@ --- *
51 * Arguments: @trace_opt *t@ = pointer to trace options table
52 * @const char *p@ = option string supplied by user
53 * @unsigned f@ = initial tracing flags
54 * @unsigned bad@ = forbidden tracing flags
56 * Returns: Trace flags as set by user.
58 * Use: Parses an option string from the user and sets the
59 * appropriate trace flags. If the argument is null or a single
60 * `?' character, a help message is displayed.
63 unsigned traceopt(trace_opt
*t
, const char *p
, unsigned f
, unsigned bad
)
67 /* --- Dump out help text --- */
69 if (!p
|| strcmp(p
, "?")) {
70 puts("Trace options:");
72 if (t
->f
& bad
|| !t
->help
)
74 printf(" `%c': %s\n", t
->ch
, t
->help
);
79 /* --- Parse the string properly --- */
92 for (tt
= t
; tt
->ch
; tt
++) {
103 moan("unknown trace option `%c'", *p
);
113 /*----- That's all, folks -------------------------------------------------*/