getopt_posix.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Declarations for getopt (POSIX compatibility shim).
  17. Copyright (C) 1989-2026 Free Software Foundation, Inc.
  18. Unlike the bulk of the getopt implementation, this file is NOT part
  19. of gnulib.
  20. The GNU C Library is free software; you can redistribute it and/or
  21. modify it under the terms of the GNU Lesser General Public
  22. License as published by the Free Software Foundation; either
  23. version 2.1 of the License, or (at your option) any later version.
  24. The GNU C Library is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  27. Lesser General Public License for more details.
  28. You should have received a copy of the GNU Lesser General Public
  29. License along with the GNU C Library; if not, see
  30. <https://www.gnu.org/licenses/>. */
  31. #ifndef _GETOPT_POSIX_H
  32. #define _GETOPT_POSIX_H 1
  33. #if !defined _UNISTD_H && !defined _STDIO_H
  34. #error "Never include getopt_posix.h directly; use unistd.h instead."
  35. #endif
  36. #include <bits/getopt_core.h>
  37. __BEGIN_DECLS
  38. #if defined __USE_POSIX2 && !defined __USE_POSIX_IMPLICITLY \
  39. && !defined __USE_GNU && !defined _GETOPT_H
  40. /* GNU getopt has more functionality than POSIX getopt. When we are
  41. explicitly conforming to POSIX and not GNU, and getopt.h (which is
  42. not part of POSIX) has not been included, the extra functionality
  43. is disabled. */
  44. # ifdef __REDIRECT
  45. extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
  46. const char *__shortopts),
  47. __posix_getopt);
  48. # else
  49. extern int __posix_getopt (int ___argc, char *const *___argv,
  50. const char *__shortopts)
  51. __THROW __nonnull ((2, 3));
  52. # define getopt __posix_getopt
  53. # endif
  54. #endif
  55. __END_DECLS
  56. #endif /* getopt_posix.h */