1 /* @(#)getopt.h 1.4 19/12/14 Copyright 2018-2019 J. Schilling */ 2 /* 3 * Definitions for the enhanced getopt() from libgetopt 4 * 5 * Copyright (c) 2018-2019 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * When distributing Covered Code, include this CDDL HEADER in each 18 * file and include the License file CDDL.Schily.txt from this distribution. 19 */ 20 21 #ifndef _SCHILY_GETOPT_H 22 #define _SCHILY_GETOPT_H 23 24 #ifndef _SCHILY_MCONFIG_H 25 #include <schily/mconfig.h> 26 #endif 27 #ifndef _SCHILY_UNISTD_H 28 #include <schily/unistd.h> /* This is where the standard puts getopt() */ 29 #endif 30 31 #ifdef HAVE_GETOPT_H 32 #ifndef _INCL_GETOPT_H 33 #define _INCL_GETOPT_H 34 #include <getopt.h> /* This may deliver getopt_long() */ 35 #endif 36 #endif /* HAVE_GETOPT_H */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * The POSIX variables for getopt(): 44 * 45 * Init value name explanation 46 * 1 optind Next argv[] index to scan, argv index of failing option 47 * 1 opterr If 0, do not print error messages from within getopt() 48 * 0 optopt The option character that caused the error. 49 * NULL optarg Pointer to the option argument. 50 */ 51 extern int optind; 52 extern int opterr; 53 extern int optopt; 54 extern char *optarg; 55 56 /* 57 * Additional external variables defined by the AT&T getopt(). 58 * 59 * The original from AT&T used _sp, but we changed that to opt_sp to make sure 60 * that nobody is able to link an updated Solaris program with getopt() from 61 * the old Solaris libc variants. 62 * 63 * The initial value is 1, since that is the first option character after '-'. 64 */ 65 extern int opt_sp; /* Current index for combined option strings */ 66 67 /* 68 * Additional external variables defined by Schily getopt() extensions. 69 * 70 * The initial value is 0. 71 */ 72 extern int optflg; 73 74 /* 75 * Definitions for optflg... 76 */ 77 #if !defined(sun) || !defined(GETOPT_PLUS_FL) 78 #define GETOPT_PLUS_FL 1 /* The current option is of type +o, not -o */ 79 #endif 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif /* _SCHILY_GETOPT_H */ 86