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