diff options
Diffstat (limited to 'src/options.h')
-rw-r--r-- | src/options.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/options.h b/src/options.h new file mode 100644 index 0000000000..033bd4d31d --- /dev/null +++ b/src/options.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011-2012 Free Software Foundation, Inc. + * + * This file is part of GnuTLS. + * + * GnuTLS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GnuTLS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef GNUTLS_SRC_OPTIONS_H +#define GNUTLS_SRC_OPTIONS_H + +// number of elements within an array +#define countof(a) (sizeof(a)/sizeof(*(a))) + +typedef const struct optionw *option_t; // forward declaration + +struct optionw { + const char + *long_name; + void + *var; + int + (*parser)(option_t opt, const char *val, const char invert); + int + nargs; // -1: optional argument, else: number of arguments + char + short_name; + const char + *help_str[4]; +}; + +int parse_command_line(int argc, const char **argv, const struct optionw *options, int noptions); +int parse_integer(option_t opt, const char *val, const char invert); +int parse_bool(option_t opt, const char *val, const char invert); +int parse_string(option_t opt, const char *val, const char invert); +void print_options(const struct optionw *options, int noptions); +int print_version(option_t opt, const char *val, const char invert); +int print_help(option_t opt, const char *val, const char invert); + +#endif /* GNUTLS_SRC_OPTIONS_H */ |