tst-argp2.c 2.4 KB

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