getopt.h 581 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <sys/cdefs.h>
  8. __BEGIN_DECLS
  9. #define no_argument 0
  10. #define required_argument 1
  11. #define optional_argument 2
  12. struct option {
  13. char const* name;
  14. int has_arg;
  15. int* flag;
  16. int val;
  17. };
  18. extern int opterr;
  19. extern int optopt;
  20. extern int optind;
  21. extern int optreset;
  22. extern char* optarg;
  23. int getopt_long(int argc, char* const* argv, char const* short_options, const struct option* long_options, int* out_long_option_index);
  24. __END_DECLS