xref: /minix/minix/include/minix/optset.h (revision 433d6423)
1 #ifndef _MINIX_OPTSET_H
2 #define _MINIX_OPTSET_H
3 
4 typedef enum {
5   OPT_BOOL,
6   OPT_STRING,
7   OPT_INT
8 } optset_type;
9 
10 /* An entry for the parser of an options set. The 'os_name' field must point
11  * to a string, which is treated case-insensitively; the last entry of a table
12  * must have NULL name. The 'os_type' field must be set to one of the OPT_
13  * values defined above. The 'os_ptr' field must point to the field that is to
14  * receive the value of a recognized option. For OPT_STRING, it must point to a
15  * string of a size set in 'os_val'; the resulting string may be truncated, but
16  * will always be null-terminated. For OPT_BOOL, it must point to an int which
17  * will be set to the value in 'os_val' if the option is present. For OPT_INT,
18  * it must point to an int which will be set to the provided option value;
19  * 'os_val' is then a base passed to strtol().
20  */
21 struct optset {
22   const char *os_name;
23   optset_type os_type;
24   void *os_ptr;
25   int os_val;
26 };
27 
28 void optset_parse(struct optset *table, char *string);
29 
30 #endif /* _MINIX_OPTSET_H */
31