getopt.h (1738B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 4 * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 5 * 6 * This file is part of GNU Mes. 7 * 8 * GNU Mes is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 3 of the License, or (at 11 * your option) any later version. 12 * 13 * GNU Mes is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 #ifndef __MES_GETOPT_H 22 #define __MES_GETOPT_H 1 23 24 #if SYSTEM_LIBC 25 #ifndef _GNU_SOURCE 26 #define _GNU_SOURCE 27 #endif 28 #undef __MES_GETOPT_H 29 #include_next <getopt.h> 30 31 #else // ! SYSTEM_LIBC 32 #include <endian.h> 33 int isdigit (int); 34 int isxdigit (int); 35 36 char *optarg; 37 int optind; 38 int opterr; 39 struct option 40 { 41 char const *name; 42 int has_arg; 43 int *flag; 44 int val; 45 }; 46 47 enum _argtype 48 { 49 no_argument, 50 required_argument, 51 optional_argument 52 }; 53 54 int getopt (int argc, char *const *argv, char const *options); 55 int getopt_long (int argc, char *const *argv, char const *options, 56 struct option const *long_options, int *opt_index); 57 int getopt_long_only (int argc, char *const *argv, char const *options, 58 struct option const *long_options, int *opt_index); 59 60 #endif // ! SYSTEM_LIBC 61 62 #endif // __MES_GETOPT_H