#include "config.h"
#include <stdio.h>
#include <wchar.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include "wgetopt.h"
#include "wutil.h"
#include "fallback.h"
Defines | |
| #define | _(string) wgettext(string) |
| Use translation functions if available. | |
Enumerations | |
| enum | { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } |
Functions | |
| char * | getenv () |
| static wchar_t * | my_index (wchar_t *str, int chr) const |
| static void | exchange (wchar_t **argv) |
| static const wchar_t * | _wgetopt_initialize (wchar_t *optstring) const |
| int | _wgetopt_internal (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct woption *longopts, int *longind, int long_only) |
| int | wgetopt (int argc, wchar_t *const *argv, const wchar_t *optstring) |
| int | wgetopt_long (int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index) |
| int | wgetopt_long_only (int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index) |
Variables | |
| wchar_t * | woptarg = NULL |
| For communication from `getopt' to the caller. | |
| int | woptind = 0 |
| Index in ARGV of the next element to be scanned. | |
| static wchar_t * | nextchar |
| int | wopterr = 1 |
| Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. | |
| int | woptopt = '?' |
| Set to an option character which was unrecognized. | |
| static enum { ... } | ordering |
| static char * | posixly_correct |
| static int | first_nonopt |
| static int | last_nonopt |
This is simply the gnu getopt library, but converted for use with wchar_t instead of char. This is not usually useful since the argv array is always defined to be of type char**, but in fish, all internal commands use wide characters and hence this library is useful.
If you want to use this version of getopt in your program, download the fish sourcecode, available at the fish homepage. Extract the sourcode, copy wgetopt.c and wgetopt.h into your program directory, include wgetopt.h in your program, and use all the regular getopt functions, prefixing every function, global variable and structure with a 'w', and use only wide character strings. There are no other functional changes in this version of getopt besides using wide character strings.
For examples of how to use wgetopt, see the fish builtin functions, many of which are defined in builtin.c.
|
|
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. |
|
|
Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `woptind' communicates from one call to the next how much of ARGV has been scanned so far. |
1.4.4