mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-22 18:28:52 -05:00
Replaced Free Getopt with getopt_port.
This commit is contained in:
parent
af78508488
commit
18c635f474
|
@ -38,7 +38,7 @@ The following dependencies are needed by GLFW:
|
||||||
|
|
||||||
The following dependencies are needed by the examples and test programs:
|
The following dependencies are needed by the examples and test programs:
|
||||||
|
|
||||||
- [Free Getopt](http://freegetopt.sourceforge.net/) for getopt
|
- [getopt\_port](https://github.com/kimgr/getopt_port/) for getopt
|
||||||
- [TinyCThread](https://gitorious.org/tinythread/tinycthread/) for threading
|
- [TinyCThread](https://gitorious.org/tinythread/tinycthread/) for threading
|
||||||
- An OpenGL loader generated by [glad](https://github.com/Dav1dde/glad)
|
- An OpenGL loader generated by [glad](https://github.com/Dav1dde/glad)
|
||||||
|
|
||||||
|
|
439
deps/getopt.c
vendored
439
deps/getopt.c
vendored
|
@ -1,267 +1,230 @@
|
||||||
/*****************************************************************************
|
/* Copyright (c) 2012, Kim Gräsman
|
||||||
* getopt.c - competent and free getopt library.
|
* All rights reserved.
|
||||||
* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $
|
*
|
||||||
*
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* Copyright (c)2002-2003 Mark K. Kim
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* All rights reserved.
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
*
|
* this list of conditions and the following disclaimer.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* modification, are permitted provided that the following conditions
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* are met:
|
* and/or other materials provided with the distribution.
|
||||||
*
|
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||||
* * Redistributions of source code must retain the above copyright
|
* to endorse or promote products derived from this software without specific
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* prior written permission.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* the documentation and/or other materials provided with the
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* distribution.
|
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||||
*
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* * Neither the original author of this software nor the names of its
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* contributors may be used to endorse or promote products derived
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* from this software without specific prior written permission.
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
*
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
*/
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
||||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
* DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
/* 2013-01-06 Camilla Berglund <elmindreda@elmindreda.org>
|
#include <stddef.h>
|
||||||
*
|
#include <string.h>
|
||||||
* Only define _CRT_SECURE_NO_WARNINGS if not already defined.
|
|
||||||
*/
|
|
||||||
/* 2012-08-12 Lambert Clara <lambert.clara@yahoo.fr>
|
|
||||||
*
|
|
||||||
* Constify third argument of getopt.
|
|
||||||
*/
|
|
||||||
/* 2011-07-27 Camilla Berglund <elmindreda@elmindreda.org>
|
|
||||||
*
|
|
||||||
* Added _CRT_SECURE_NO_WARNINGS macro.
|
|
||||||
*/
|
|
||||||
/* 2009-10-12 Camilla Berglund <elmindreda@elmindreda.org>
|
|
||||||
*
|
|
||||||
* Removed unused global static variable 'ID'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
char* optarg = NULL;
|
const int no_argument = 0;
|
||||||
int optind = 0;
|
const int required_argument = 1;
|
||||||
int opterr = 1;
|
const int optional_argument = 2;
|
||||||
int optopt = '?';
|
|
||||||
|
|
||||||
|
char* optarg;
|
||||||
|
int optopt;
|
||||||
|
/* The variable optind [...] shall be initialized to 1 by the system. */
|
||||||
|
int optind = 1;
|
||||||
|
int opterr;
|
||||||
|
|
||||||
static char** prev_argv = NULL; /* Keep a copy of argv and argc to */
|
static char* optcursor = NULL;
|
||||||
static int prev_argc = 0; /* tell if getopt params change */
|
|
||||||
static int argv_index = 0; /* Option we're checking */
|
|
||||||
static int argv_index2 = 0; /* Option argument we're checking */
|
|
||||||
static int opt_offset = 0; /* Index into compounded "-option" */
|
|
||||||
static int dashdash = 0; /* True if "--" option reached */
|
|
||||||
static int nonopt = 0; /* How many nonopts we've found */
|
|
||||||
|
|
||||||
static void increment_index()
|
/* Implemented based on [1] and [2] for optional arguments.
|
||||||
{
|
optopt is handled FreeBSD-style, per [3].
|
||||||
/* Move onto the next option */
|
Other GNU and FreeBSD extensions are purely accidental.
|
||||||
if(argv_index < argv_index2)
|
|
||||||
{
|
|
||||||
while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-'
|
|
||||||
&& argv_index < argv_index2+1);
|
|
||||||
}
|
|
||||||
else argv_index++;
|
|
||||||
opt_offset = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
|
||||||
/*
|
[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||||
* Permutes argv[] so that the argument currently being processed is moved
|
[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
|
||||||
* to the end.
|
|
||||||
*/
|
*/
|
||||||
static int permute_argv_once()
|
int getopt(int argc, char* const argv[], const char* optstring) {
|
||||||
{
|
int optchar = -1;
|
||||||
/* Movability check */
|
const char* optdecl = NULL;
|
||||||
if(argv_index + nonopt >= prev_argc) return 1;
|
|
||||||
/* Move the current option to the end, bring the others to front */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char* tmp = prev_argv[argv_index];
|
|
||||||
|
|
||||||
/* Move the data */
|
|
||||||
memmove(&prev_argv[argv_index], &prev_argv[argv_index+1],
|
|
||||||
sizeof(char**) * (prev_argc - argv_index - 1));
|
|
||||||
prev_argv[prev_argc - 1] = tmp;
|
|
||||||
|
|
||||||
nonopt++;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int getopt(int argc, char** argv, const char* optstr)
|
|
||||||
{
|
|
||||||
int c = 0;
|
|
||||||
|
|
||||||
/* If we have new argv, reinitialize */
|
|
||||||
if(prev_argv != argv || prev_argc != argc)
|
|
||||||
{
|
|
||||||
/* Initialize variables */
|
|
||||||
prev_argv = argv;
|
|
||||||
prev_argc = argc;
|
|
||||||
argv_index = 1;
|
|
||||||
argv_index2 = 1;
|
|
||||||
opt_offset = 1;
|
|
||||||
dashdash = 0;
|
|
||||||
nonopt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Jump point in case we want to ignore the current argv_index */
|
|
||||||
getopt_top:
|
|
||||||
|
|
||||||
/* Misc. initializations */
|
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
opterr = 0;
|
||||||
|
optopt = 0;
|
||||||
|
|
||||||
/* Dash-dash check */
|
/* Unspecified, but we need it to avoid overrunning the argv bounds. */
|
||||||
if(argv[argv_index] && !strcmp(argv[argv_index], "--"))
|
if (optind >= argc)
|
||||||
{
|
goto no_more_optchars;
|
||||||
dashdash = 1;
|
|
||||||
increment_index();
|
/* If, when getopt() is called argv[optind] is a null pointer, getopt()
|
||||||
|
shall return -1 without changing optind. */
|
||||||
|
if (argv[optind] == NULL)
|
||||||
|
goto no_more_optchars;
|
||||||
|
|
||||||
|
/* If, when getopt() is called *argv[optind] is not the character '-',
|
||||||
|
getopt() shall return -1 without changing optind. */
|
||||||
|
if (*argv[optind] != '-')
|
||||||
|
goto no_more_optchars;
|
||||||
|
|
||||||
|
/* If, when getopt() is called argv[optind] points to the string "-",
|
||||||
|
getopt() shall return -1 without changing optind. */
|
||||||
|
if (strcmp(argv[optind], "-") == 0)
|
||||||
|
goto no_more_optchars;
|
||||||
|
|
||||||
|
/* If, when getopt() is called argv[optind] points to the string "--",
|
||||||
|
getopt() shall return -1 after incrementing optind. */
|
||||||
|
if (strcmp(argv[optind], "--") == 0) {
|
||||||
|
++optind;
|
||||||
|
goto no_more_optchars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're at the end of argv, that's it. */
|
if (optcursor == NULL || *optcursor == '\0')
|
||||||
if(argv[argv_index] == NULL)
|
optcursor = argv[optind] + 1;
|
||||||
{
|
|
||||||
c = -1;
|
|
||||||
}
|
|
||||||
/* Are we looking at a string? Single dash is also a string */
|
|
||||||
else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-"))
|
|
||||||
{
|
|
||||||
/* If we want a string... */
|
|
||||||
if(optstr[0] == '-')
|
|
||||||
{
|
|
||||||
c = 1;
|
|
||||||
optarg = argv[argv_index];
|
|
||||||
increment_index();
|
|
||||||
}
|
|
||||||
/* If we really don't want it (we're in POSIX mode), we're done */
|
|
||||||
else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT"))
|
|
||||||
{
|
|
||||||
c = -1;
|
|
||||||
|
|
||||||
/* Everything else is a non-opt argument */
|
optchar = *optcursor;
|
||||||
nonopt = argc - argv_index;
|
|
||||||
}
|
|
||||||
/* If we mildly don't want it, then move it back */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!permute_argv_once()) goto getopt_top;
|
|
||||||
else c = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Otherwise we're looking at an option */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char* opt_ptr = NULL;
|
|
||||||
|
|
||||||
/* Grab the option */
|
/* FreeBSD: The variable optopt saves the last known option character
|
||||||
c = argv[argv_index][opt_offset++];
|
returned by getopt(). */
|
||||||
|
optopt = optchar;
|
||||||
|
|
||||||
/* Is the option in the optstr? */
|
/* The getopt() function shall return the next option character (if one is
|
||||||
if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c);
|
found) from argv that matches a character in optstring, if there is
|
||||||
else opt_ptr = strchr(optstr, c);
|
one that matches. */
|
||||||
/* Invalid argument */
|
optdecl = strchr(optstring, optchar);
|
||||||
if(!opt_ptr)
|
if (optdecl) {
|
||||||
{
|
/* [I]f a character is followed by a colon, the option takes an
|
||||||
if(opterr)
|
argument. */
|
||||||
{
|
if (optdecl[1] == ':') {
|
||||||
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
|
optarg = ++optcursor;
|
||||||
}
|
if (*optarg == '\0') {
|
||||||
|
/* GNU extension: Two colons mean an option takes an
|
||||||
|
optional arg; if there is text in the current argv-element
|
||||||
|
(i.e., in the same word as the option name itself, for example,
|
||||||
|
"-oarg"), then it is returned in optarg, otherwise optarg is set
|
||||||
|
to zero. */
|
||||||
|
if (optdecl[2] != ':') {
|
||||||
|
/* If the option was the last character in the string pointed to by
|
||||||
|
an element of argv, then optarg shall contain the next element
|
||||||
|
of argv, and optind shall be incremented by 2. If the resulting
|
||||||
|
value of optind is greater than argc, this indicates a missing
|
||||||
|
option-argument, and getopt() shall return an error indication.
|
||||||
|
|
||||||
optopt = c;
|
Otherwise, optarg shall point to the string following the
|
||||||
c = '?';
|
option character in that element of argv, and optind shall be
|
||||||
|
incremented by 1.
|
||||||
/* Move onto the next option */
|
*/
|
||||||
increment_index();
|
if (++optind < argc) {
|
||||||
}
|
optarg = argv[optind];
|
||||||
/* Option takes argument */
|
} else {
|
||||||
else if(opt_ptr[1] == ':')
|
/* If it detects a missing option-argument, it shall return the
|
||||||
{
|
colon character ( ':' ) if the first character of optstring
|
||||||
/* ie, -oARGUMENT, -xxxoARGUMENT, etc. */
|
was a colon, or a question-mark character ( '?' ) otherwise.
|
||||||
if(argv[argv_index][opt_offset] != '\0')
|
*/
|
||||||
{
|
optarg = NULL;
|
||||||
optarg = &argv[argv_index][opt_offset];
|
optchar = (optstring[0] == ':') ? ':' : '?';
|
||||||
increment_index();
|
|
||||||
}
|
|
||||||
/* ie, -o ARGUMENT (only if it's a required argument) */
|
|
||||||
else if(opt_ptr[2] != ':')
|
|
||||||
{
|
|
||||||
/* One of those "you're not expected to understand this" moment */
|
|
||||||
if(argv_index2 < argv_index) argv_index2 = argv_index;
|
|
||||||
while(argv[++argv_index2] && argv[argv_index2][0] == '-');
|
|
||||||
optarg = argv[argv_index2];
|
|
||||||
|
|
||||||
/* Don't cross into the non-option argument list */
|
|
||||||
if(argv_index2 + nonopt >= prev_argc) optarg = NULL;
|
|
||||||
|
|
||||||
/* Move onto the next option */
|
|
||||||
increment_index();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Move onto the next option */
|
|
||||||
increment_index();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case we got no argument for an option with required argument */
|
|
||||||
if(optarg == NULL && opt_ptr[2] != ':')
|
|
||||||
{
|
|
||||||
optopt = c;
|
|
||||||
c = '?';
|
|
||||||
|
|
||||||
if(opterr)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"%s: option requires an argument -- %c\n",
|
|
||||||
argv[0], optopt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Option does not take argument */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Next argv_index */
|
|
||||||
if(argv[argv_index][opt_offset] == '\0')
|
|
||||||
{
|
|
||||||
increment_index();
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
optarg = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate optind */
|
optcursor = NULL;
|
||||||
if(c == -1)
|
|
||||||
{
|
|
||||||
optind = argc - nonopt;
|
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
/* If getopt() encounters an option character that is not contained in
|
||||||
optind = argv_index;
|
optstring, it shall return the question-mark ( '?' ) character. */
|
||||||
|
optchar = '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
if (optcursor == NULL || *++optcursor == '\0')
|
||||||
|
++optind;
|
||||||
|
|
||||||
|
return optchar;
|
||||||
|
|
||||||
|
no_more_optchars:
|
||||||
|
optcursor = NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Implementation based on [1].
|
||||||
|
|
||||||
/* vim:ts=3
|
[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||||
*/
|
*/
|
||||||
|
int getopt_long(int argc, char* const argv[], const char* optstring,
|
||||||
|
const struct option* longopts, int* longindex) {
|
||||||
|
const struct option* o = longopts;
|
||||||
|
const struct option* match = NULL;
|
||||||
|
int num_matches = 0;
|
||||||
|
size_t argument_name_length = 0;
|
||||||
|
const char* current_argument = NULL;
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
optarg = NULL;
|
||||||
|
optopt = 0;
|
||||||
|
|
||||||
|
if (optind >= argc)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
|
||||||
|
return getopt(argc, argv, optstring);
|
||||||
|
|
||||||
|
/* It's an option; starts with -- and is longer than two chars. */
|
||||||
|
current_argument = argv[optind] + 2;
|
||||||
|
argument_name_length = strcspn(current_argument, "=");
|
||||||
|
for (; o->name; ++o) {
|
||||||
|
if (strncmp(o->name, current_argument, argument_name_length) == 0) {
|
||||||
|
match = o;
|
||||||
|
++num_matches;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_matches == 1) {
|
||||||
|
/* If longindex is not NULL, it points to a variable which is set to the
|
||||||
|
index of the long option relative to longopts. */
|
||||||
|
if (longindex)
|
||||||
|
*longindex = (match - longopts);
|
||||||
|
|
||||||
|
/* If flag is NULL, then getopt_long() shall return val.
|
||||||
|
Otherwise, getopt_long() returns 0, and flag shall point to a variable
|
||||||
|
which shall be set to val if the option is found, but left unchanged if
|
||||||
|
the option is not found. */
|
||||||
|
if (match->flag)
|
||||||
|
*(match->flag) = match->val;
|
||||||
|
|
||||||
|
retval = match->flag ? 0 : match->val;
|
||||||
|
|
||||||
|
if (match->has_arg != no_argument) {
|
||||||
|
optarg = strchr(argv[optind], '=');
|
||||||
|
if (optarg != NULL)
|
||||||
|
++optarg;
|
||||||
|
|
||||||
|
if (match->has_arg == required_argument) {
|
||||||
|
/* Only scan the next argv for required arguments. Behavior is not
|
||||||
|
specified, but has been observed with Ubuntu and Mac OSX. */
|
||||||
|
if (optarg == NULL && ++optind < argc) {
|
||||||
|
optarg = argv[optind];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optarg == NULL)
|
||||||
|
retval = ':';
|
||||||
|
}
|
||||||
|
} else if (strchr(argv[optind], '=')) {
|
||||||
|
/* An argument was provided to a non-argument option.
|
||||||
|
I haven't seen this specified explicitly, but both GNU and BSD-based
|
||||||
|
implementations show this behavior.
|
||||||
|
*/
|
||||||
|
retval = '?';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Unknown option or ambiguous match. */
|
||||||
|
retval = '?';
|
||||||
|
}
|
||||||
|
|
||||||
|
++optind;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
94
deps/getopt.h
vendored
94
deps/getopt.h
vendored
|
@ -1,63 +1,57 @@
|
||||||
/*****************************************************************************
|
/* Copyright (c) 2012, Kim Gräsman
|
||||||
* getopt.h - competent and free getopt library.
|
* All rights reserved.
|
||||||
* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $
|
*
|
||||||
*
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* Copyright (c)2002-2003 Mark K. Kim
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* All rights reserved.
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
*
|
* this list of conditions and the following disclaimer.
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* modification, are permitted provided that the following conditions
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* are met:
|
* and/or other materials provided with the distribution.
|
||||||
*
|
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||||
* * Redistributions of source code must retain the above copyright
|
* to endorse or promote products derived from this software without specific
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* prior written permission.
|
||||||
*
|
*
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* the documentation and/or other materials provided with the
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* distribution.
|
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||||
*
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* * Neither the original author of this software nor the names of its
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* contributors may be used to endorse or promote products derived
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* from this software without specific prior written permission.
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
*
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
*/
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
||||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
* DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef GETOPT_H_
|
|
||||||
#define GETOPT_H_
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_GETOPT_PORT_H
|
||||||
|
#define INCLUDED_GETOPT_PORT_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern const int no_argument;
|
||||||
|
extern const int required_argument;
|
||||||
|
extern const int optional_argument;
|
||||||
|
|
||||||
extern char* optarg;
|
extern char* optarg;
|
||||||
extern int optind;
|
extern int optind, opterr, optopt;
|
||||||
extern int opterr;
|
|
||||||
extern int optopt;
|
|
||||||
|
|
||||||
int getopt(int argc, char** argv, const char* optstr);
|
struct option {
|
||||||
|
const char* name;
|
||||||
|
int has_arg;
|
||||||
|
int* flag;
|
||||||
|
int val;
|
||||||
|
};
|
||||||
|
|
||||||
|
int getopt(int argc, char* const argv[], const char* optstring);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
int getopt_long(int argc, char* const argv[],
|
||||||
|
const char* optstring, const struct option* longopts, int* longindex);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // INCLUDED_GETOPT_PORT_H
|
||||||
#endif /* GETOPT_H_ */
|
|
||||||
|
|
||||||
|
|
||||||
/* vim:ts=3
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user