tst-argp2.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (C) 2007-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include <argp.h>
  15. static const struct argp_option opt1[] =
  16. {
  17. { "opt1", '1', "NUMBER", 0, "Option 1" },
  18. { NULL, 0, NULL, 0, NULL }
  19. };
  20. static const struct argp_option opt2[] =
  21. {
  22. { "opt2", '2', "NUMBER", 0, "Option 2" },
  23. { NULL, 0, NULL, 0, NULL }
  24. };
  25. static const struct argp_option opt3[] =
  26. {
  27. { "opt3", '3', "NUMBER", 0, "Option 3" },
  28. { NULL, 0, NULL, 0, NULL }
  29. };
  30. static const struct argp_option opt4[] =
  31. {
  32. { "opt4", '4', "NUMBER", 0, "Option 4" },
  33. { NULL, 0, NULL, 0, NULL }
  34. };
  35. static const struct argp_option opt5[] =
  36. {
  37. { "opt5", '5', "NUMBER", 0, "Option 5" },
  38. { NULL, 0, NULL, 0, NULL }
  39. };
  40. static struct argp argp5 =
  41. {
  42. opt5, NULL, "args doc5", "doc5", NULL, NULL, NULL
  43. };
  44. static struct argp argp4 =
  45. {
  46. opt4, NULL, "args doc4", "doc4", NULL, NULL, NULL
  47. };
  48. static struct argp argp3 =
  49. {
  50. opt3, NULL, "args doc3", "doc3", NULL, NULL, NULL
  51. };
  52. static struct argp_child children2[] =
  53. {
  54. { &argp4, 0, "child3", 3 },
  55. { &argp5, 0, "child4", 4 },
  56. { NULL, 0, NULL, 0 }
  57. };
  58. static struct argp argp2 =
  59. {
  60. opt2, NULL, "args doc2", "doc2", children2, NULL, NULL
  61. };
  62. static struct argp_child children1[] =
  63. {
  64. { &argp2, 0, "child1", 1 },
  65. { &argp3, 0, "child2", 2 },
  66. { NULL, 0, NULL, 0 }
  67. };
  68. static struct argp argp1 =
  69. {
  70. opt1, NULL, "args doc1", "doc1", children1, NULL, NULL
  71. };
  72. static int
  73. do_test (void)
  74. {
  75. argp_help (&argp1, stdout, ARGP_HELP_LONG, (char *) "tst-argp2");
  76. return 0;
  77. }
  78. #define TEST_FUNCTION do_test ()
  79. #include "../test-skeleton.c"