tst-argp2.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #include <stdio.h>
  16. #if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
  17. #include <argp.h>
  18. static const struct argp_option opt1[] =
  19. {
  20. { "opt1", '1', "NUMBER", 0, "Option 1" },
  21. { NULL, 0, NULL, 0, NULL }
  22. };
  23. static const struct argp_option opt2[] =
  24. {
  25. { "opt2", '2', "NUMBER", 0, "Option 2" },
  26. { NULL, 0, NULL, 0, NULL }
  27. };
  28. static const struct argp_option opt3[] =
  29. {
  30. { "opt3", '3', "NUMBER", 0, "Option 3" },
  31. { NULL, 0, NULL, 0, NULL }
  32. };
  33. static const struct argp_option opt4[] =
  34. {
  35. { "opt4", '4', "NUMBER", 0, "Option 4" },
  36. { NULL, 0, NULL, 0, NULL }
  37. };
  38. static const struct argp_option opt5[] =
  39. {
  40. { "opt5", '5', "NUMBER", 0, "Option 5" },
  41. { NULL, 0, NULL, 0, NULL }
  42. };
  43. static struct argp argp5 =
  44. {
  45. opt5, NULL, "args doc5", "doc5", NULL, NULL, NULL
  46. };
  47. static struct argp argp4 =
  48. {
  49. opt4, NULL, "args doc4", "doc4", NULL, NULL, NULL
  50. };
  51. static struct argp argp3 =
  52. {
  53. opt3, NULL, "args doc3", "doc3", NULL, NULL, NULL
  54. };
  55. static struct argp_child children2[] =
  56. {
  57. { &argp4, 0, "child3", 3 },
  58. { &argp5, 0, "child4", 4 },
  59. { NULL, 0, NULL, 0 }
  60. };
  61. static struct argp argp2 =
  62. {
  63. opt2, NULL, "args doc2", "doc2", children2, NULL, NULL
  64. };
  65. static struct argp_child children1[] =
  66. {
  67. { &argp2, 0, "child1", 1 },
  68. { &argp3, 0, "child2", 2 },
  69. { NULL, 0, NULL, 0 }
  70. };
  71. static struct argp argp1 =
  72. {
  73. opt1, NULL, "args doc1", "doc1", children1, NULL, NULL
  74. };
  75. #endif
  76. static int
  77. do_test (void)
  78. {
  79. #if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
  80. argp_help (&argp1, stdout, ARGP_HELP_LONG, (char *) "tst-argp2");
  81. return 0;
  82. #else
  83. return 23;
  84. #endif
  85. }
  86. #define TEST_FUNCTION do_test ()
  87. #include "../test-skeleton.c"