tst-argp2.c 2.6 KB

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