2 * Copyright (c) 1995-2000, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 2003-10-27 12:21:34 adam
8 * Source restructure. yaz-marcdump part of installation
10 * Revision 1.8 2000/02/29 13:44:55 adam
11 * Check for config.h (currently not generated).
13 * Revision 1.7 1999/11/30 13:47:12 adam
14 * Improved installation. Moved header files to include/yaz.
16 * Revision 1.6 1997/09/01 08:54:13 adam
17 * New windows NT/95 port using MSV5.0. Made prefix query handling
18 * thread safe. The function options ignores empty arguments when met.
20 * Revision 1.5 1995/12/06 13:00:19 adam
21 * Minus alone not treated as an option.
23 * Revision 1.4 1995/09/29 17:12:35 quinn
26 * Revision 1.3 1995/09/27 15:03:03 quinn
27 * Modified function heads & prototypes.
29 * Revision 1.2 1995/05/16 08:51:13 quinn
30 * License, documentation, and memory fixes
32 * Revision 1.1 1995/03/27 08:35:18 quinn
33 * Created util library
34 * Added memory debugging module. Imported options-manager
36 * Revision 1.2 1994/10/04 17:47:10 adam
37 * Function options now returns arg with error option.
39 * Revision 1.1 1994/08/16 15:57:22 adam
40 * The first utility modules.
49 #include <yaz/options.h>
51 static int arg_no = 1;
52 static int arg_off = 0;
54 int options (const char *desc, char **argv, int argc, char **arg)
62 while (argv[arg_no][0] == '\0')
68 if (argv[arg_no][0] != '-' || argv[arg_no][1] == '\0')
70 *arg = argv[arg_no++];
75 ch = argv[arg_no][arg_off++];
78 int desc_char = desc[i++];
81 { /* string argument */
85 { /* option with argument */
88 if (argv[arg_no][arg_off])
90 *arg = argv[arg_no]+arg_off;
99 *arg = argv[arg_no++];
104 else /* option with no argument */
106 if (argv[arg_no][arg_off])
117 *arg = argv[arg_no]+arg_off-1;