2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1995-12-06 13:00:19 adam
8 * Minus alone not treated as an option.
10 * Revision 1.4 1995/09/29 17:12:35 quinn
13 * Revision 1.3 1995/09/27 15:03:03 quinn
14 * Modified function heads & prototypes.
16 * Revision 1.2 1995/05/16 08:51:13 quinn
17 * License, documentation, and memory fixes
19 * Revision 1.1 1995/03/27 08:35:18 quinn
20 * Created util library
21 * Added memory debugging module. Imported options-manager
23 * Revision 1.2 1994/10/04 17:47:10 adam
24 * Function options now returns arg with error option.
26 * Revision 1.1 1994/08/16 15:57:22 adam
27 * The first utility modules.
34 static int arg_no = 1;
35 static int arg_off = 0;
37 int options (const char *desc, char **argv, int argc, char **arg)
45 if (argv[arg_no][0] != '-' || argv[arg_no][1] == '\0')
47 *arg = argv[arg_no++];
52 ch = argv[arg_no][arg_off++];
55 int desc_char = desc[i++];
58 { /* string argument */
62 { /* option with argument */
65 if (argv[arg_no][arg_off])
67 *arg = argv[arg_no]+arg_off;
76 *arg = argv[arg_no++];
81 else /* option with no argument */
83 if (argv[arg_no][arg_off])
94 *arg = argv[arg_no]+arg_off-1;