2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1997-09-01 08:54:13 adam
8 * New windows NT/95 port using MSV5.0. Made prefix query handling
9 * thread safe. The function options ignores empty arguments when met.
11 * Revision 1.5 1995/12/06 13:00:19 adam
12 * Minus alone not treated as an option.
14 * Revision 1.4 1995/09/29 17:12:35 quinn
17 * Revision 1.3 1995/09/27 15:03:03 quinn
18 * Modified function heads & prototypes.
20 * Revision 1.2 1995/05/16 08:51:13 quinn
21 * License, documentation, and memory fixes
23 * Revision 1.1 1995/03/27 08:35:18 quinn
24 * Created util library
25 * Added memory debugging module. Imported options-manager
27 * Revision 1.2 1994/10/04 17:47:10 adam
28 * Function options now returns arg with error option.
30 * Revision 1.1 1994/08/16 15:57:22 adam
31 * The first utility modules.
38 static int arg_no = 1;
39 static int arg_off = 0;
41 int options (const char *desc, char **argv, int argc, char **arg)
49 while (argv[arg_no][0] == '\0')
55 if (argv[arg_no][0] != '-' || argv[arg_no][1] == '\0')
57 *arg = argv[arg_no++];
62 ch = argv[arg_no][arg_off++];
65 int desc_char = desc[i++];
68 { /* string argument */
72 { /* option with argument */
75 if (argv[arg_no][arg_off])
77 *arg = argv[arg_no]+arg_off;
86 *arg = argv[arg_no++];
91 else /* option with no argument */
93 if (argv[arg_no][arg_off])
104 *arg = argv[arg_no]+arg_off-1;