* Declarations for getopt_long()
*****************************************************************************
* Copyright (C) 1987-1997 Free Software Foundation, Inc.
- * Copyright (C) 2005-2010 the VideoLAN team
+ * Copyright (C) 2005-2010 VLC authors and VideoLAN
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
#ifndef VLC_GETOPT_H
#define VLC_GETOPT_H 1
+typedef struct vlc_getopt_s
+{
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
+ the argument value is returned here. */
- extern char *optarg;
+ char *arg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
- extern int optind;
+ int ind;
/* Set to an option character which was unrecognized. */
- extern int optopt;
+ int opt;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+ char *nextchar;
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+ int first_nonopt;
+ int last_nonopt;
+
+} vlc_getopt_t;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
- struct option
- {
- const char *name;
- bool has_arg;
- int *flag;
- int val;
- };
-
- extern int vlc_getopt_long(int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
+struct vlc_option
+{
+ const char *name;
+ bool has_arg;
+ int *flag;
+ int val;
+};
+
+extern int vlc_getopt_long(int argc, char *const *argv, const char *shortopts,
+ const struct vlc_option *longopts, int *longind,
+ vlc_getopt_t *restrict state);
#endif /* VLC_GETOPT_H */