MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
getarg.h
1 /*
2  Copyright (C) 2003-2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 /*
20  * Copyright (c) 1997, 1999 Kungliga Tekniska Högskolan
21  * (Royal Institute of Technology, Stockholm, Sweden).
22  * All rights reserved.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  *
31  * 2. Redistributions in binary form must reproduce the above copyright
32  * notice, this list of conditions and the following disclaimer in the
33  * documentation and/or other materials provided with the distribution.
34  *
35  * 3. Neither the name of the Institute nor the names of its contributors
36  * may be used to endorse or promote products derived from this software
37  * without specific prior written permission.
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
40  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
43  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  */
51 
52 /* $KTH: getarg.h,v 1.9 2000/09/01 21:25:55 lha Exp $ */
53 
54 #ifndef __GETARG_H__
55 #define __GETARG_H__
56 
57 #include <ndb_global.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 typedef enum {
64  arg_integer,
65  arg_string,
66  arg_flag,
67  arg_negative_flag,
68  arg_strings,
69  arg_double,
70  arg_collect,
71  arg_counter
72 } arg_type;
73 
74 struct getargs{
75  const char *long_name;
76  char short_name;
77  arg_type type;
78  void *value;
79  const char *help;
80  const char *arg_help;
81 };
82 
83 enum {
84  ARG_ERR_NO_MATCH = 1,
85  ARG_ERR_BAD_ARG,
86  ARG_ERR_NO_ARG
87 };
88 
89 typedef struct getarg_strings {
90  int num_strings;
91  char **strings;
93 
94 typedef int (*getarg_collect_func)(int short_opt,
95  int argc,
96  const char **argv,
97  int *optind,
98  int *optarg,
99  void *data);
100 
101 typedef struct getarg_collect_info {
102  getarg_collect_func func;
103  void *data;
105 
106 int getarg(struct getargs *args, size_t num_args,
107  int argc, const char **argv, int *optind);
108 
109 void arg_printusage (struct getargs *args,
110  size_t num_args,
111  const char *progname,
112  const char *extra_string);
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif /* __GETARG_H__ */