xref: /php-src/main/php_getopt.h (revision 01b3fc03)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author: Marcus Boerger <helly@php.net>                               |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_GETOPT_H
18 #define PHP_GETOPT_H
19 
20 #include "php.h"
21 
22 /* Define structure for one recognized option (both single char and long name).
23  * If short_open is '-' this is the last option. */
24 typedef struct _opt_struct {
25 	char opt_char;
26 	int  need_param;
27 	char * opt_name;
28 } opt_struct;
29 
30 BEGIN_EXTERN_C()
31 /* holds the index of the latest fetched element from the opts array */
32 extern PHPAPI int php_optidx;
33 PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start);
34 END_EXTERN_C()
35 
36 /* php_getopt will return this value if there is an error in arguments */
37 #define PHP_GETOPT_INVALID_ARG (-2)
38 
39 #endif
40