php_getopt.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef PHP_GETOPT_H
  17. #define PHP_GETOPT_H
  18. #include "php.h"
  19. /* Define structure for one recognized option (both single char and long name).
  20. * If short_open is '-' this is the last option. */
  21. typedef struct _opt_struct {
  22. char opt_char;
  23. int need_param;
  24. char * opt_name;
  25. } opt_struct;
  26. BEGIN_EXTERN_C()
  27. /* holds the index of the latest fetched element from the opts array */
  28. extern PHPAPI int php_optidx;
  29. PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start);
  30. END_EXTERN_C()
  31. /* php_getopt will return this value if there is an error in arguments */
  32. #define PHP_GETOPT_INVALID_ARG (-2)
  33. #endif