#include <wchar.h>
Go to the source code of this file.
Data Structures | |
| struct | woption |
| Describe the long-named options requested by the application. More... | |
Defines | |
| #define | no_argument 0 |
| Specifies that a switch does not accept an argument. | |
| #define | required_argument 1 |
| Specifies that a switch requires an argument. | |
| #define | optional_argument 2 |
| Specifies that a switch accepts an optional argument. | |
Functions | |
| int | wgetopt () |
| Get options from argument list. | |
| int | wgetopt_long () |
| Get options from argument list. | |
| int | wgetopt_long_only () |
| Get options from argument list. | |
| int | _wgetopt_internal () |
| Internal only. | |
Variables | |
| wchar_t * | woptarg |
| For communication from `getopt' to the caller. | |
| int | woptind |
| Index in ARGV of the next element to be scanned. | |
| int | wopterr |
| Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. | |
| int | woptopt |
| Set to an option character which was unrecognized. | |
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.
| int _wgetopt_internal | ( | ) |
Internal only.
Users should not call this directly.
| int wgetopt | ( | ) |
Get options from argument list.
See the glibc manual for information on how to use this function.
| int wgetopt_long | ( | ) |
Get options from argument list.
See the glibc manual for information on how to use this function.
Referenced by builtin_bind(), builtin_block(), builtin_builtin(), builtin_commandline(), builtin_complete(), builtin_contains(), builtin_emit(), builtin_function(), builtin_functions(), builtin_generic(), builtin_jobs(), builtin_random(), builtin_read(), builtin_set(), builtin_status(), and builtin_ulimit().
| int wgetopt_long_only | ( | ) |
Get options from argument list.
See the glibc manual for information on how to use this function.
| wchar_t* woptarg |
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.
Referenced by builtin_commandline(), builtin_complete(), builtin_function(), builtin_functions(), builtin_read(), and builtin_status().
| int wopterr |
Callers store zero here to inhibit the error message `getopt' prints for unrecognized options.
Referenced by builtin_init().
| int woptind |
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.
Referenced by builtin_bind(), builtin_block(), builtin_builtin(), builtin_commandline(), builtin_complete(), builtin_contains(), builtin_emit(), builtin_function(), builtin_functions(), builtin_generic(), builtin_jobs(), builtin_random(), builtin_read(), builtin_set(), builtin_status(), and builtin_ulimit().
1.5.6