2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: options.c,v 1.4 2005-06-25 15:46:04 adam Exp $
9 * \brief Implements command line options parsing
17 #include <yaz/options.h>
19 static int arg_no = 1;
20 static int arg_off = 0;
22 int options (const char *desc, char **argv, int argc, char **arg)
30 while (argv[arg_no][0] == '\0')
36 if (argv[arg_no][0] != '-' || argv[arg_no][1] == '\0')
38 *arg = argv[arg_no++];
43 ch = argv[arg_no][arg_off++];
46 int desc_char = desc[i++];
49 { /* string argument */
53 { /* option with argument */
56 if (argv[arg_no][arg_off])
58 *arg = argv[arg_no]+arg_off;
67 *arg = argv[arg_no++];
72 else /* option with no argument */
74 if (argv[arg_no][arg_off])
85 *arg = argv[arg_no]+arg_off-1;
93 * indent-tabs-mode: nil
95 * vim: shiftwidth=4 tabstop=8 expandtab