tcpprep_opts.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpprep_opts.h)
  4. *
  5. * It has been AutoGen-ed Thursday July 28, 2005 at 09:57:15 PM PDT
  6. * From the definitions tcpprep_opts.def
  7. * and the template file options
  8. */
  9. /*
  10. * This file contains the programmatic interface to the Automated
  11. * Options generated for the tcpprep program.
  12. * These macros are documented in the AutoGen info file in the
  13. * "AutoOpts" chapter. Please refer to that doc for usage help.
  14. */
  15. #ifndef AUTOOPTS_TCPPREP_OPTS_H_GUARD
  16. #define AUTOOPTS_TCPPREP_OPTS_H_GUARD
  17. /*
  18. * tcpprep copyright 2000 - 2004 Aaron Turner - all rights reserved
  19. *
  20. * tcpprep is free software copyrighted by Aaron Turner.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the above copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. Neither the name ``Aaron Turner'' nor the name of any other
  31. * contributor may be used to endorse or promote products derived
  32. * from this software without specific prior written permission.
  33. *
  34. * tcpprep IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS
  35. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  36. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  37. * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS
  38. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  39. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  40. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  41. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  42. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  43. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  44. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. */
  46. #include "config.h"
  47. #include <autoopts/options.h>
  48. /*
  49. * Enumeration of each option:
  50. */
  51. typedef enum {
  52. INDEX_OPT_DBUG = 0,
  53. INDEX_OPT_AUTO = 1,
  54. INDEX_OPT_CIDR = 2,
  55. INDEX_OPT_REGEX = 3,
  56. INDEX_OPT_PORT = 4,
  57. INDEX_OPT_COMMENT = 5,
  58. INDEX_OPT_NO_ARG_COMMENT = 6,
  59. INDEX_OPT_INCLUDE = 7,
  60. INDEX_OPT_EXCLUDE = 8,
  61. INDEX_OPT_CACHEFILE = 9,
  62. INDEX_OPT_PCAP = 10,
  63. INDEX_OPT_PRINT_COMMENT = 11,
  64. INDEX_OPT_PRINT_INFO = 12,
  65. INDEX_OPT_SERVICES = 13,
  66. INDEX_OPT_NONIP = 14,
  67. INDEX_OPT_RATIO = 15,
  68. INDEX_OPT_MINMASK = 16,
  69. INDEX_OPT_MAXMASK = 17,
  70. INDEX_OPT_VERBOSE = 18,
  71. INDEX_OPT_DECODE = 19,
  72. INDEX_OPT_VERSION = 20,
  73. INDEX_OPT_LESS_HELP = 21,
  74. INDEX_OPT_HELP = 22,
  75. INDEX_OPT_MORE_HELP = 23,
  76. INDEX_OPT_SAVE_OPTS = 24,
  77. INDEX_OPT_LOAD_OPTS = 25
  78. } teOptIndex;
  79. #define OPTION_CT 26
  80. /*
  81. * Interface defines for all options. Replace "n" with
  82. * the UPPER_CASED option name (as in the teOptIndex
  83. * enumeration above). e.g. HAVE_OPT( DBUG )
  84. */
  85. #define DESC(n) tcpprepOptions.pOptDesc[INDEX_OPT_ ## n]
  86. #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
  87. #define OPT_ARG(n) (DESC(n).pzLastArg)
  88. #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
  89. #define COUNT_OPT(n) (DESC(n).optOccCt)
  90. #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
  91. #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
  92. #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
  93. #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
  94. #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
  95. #define CLEAR_OPT(n) STMTS( \
  96. DESC(n).fOptState &= OPTST_PERSISTENT; \
  97. if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  98. DESC(n).fOptState |= OPTST_DISABLED; \
  99. DESC(n).optCookie = NULL )
  100. /*
  101. * Interface defines for specific options.
  102. */
  103. #define VALUE_OPT_DBUG 'd'
  104. #define OPT_VALUE_DBUG (*(unsigned long*)(&DESC(DBUG).pzLastArg))
  105. #define VALUE_OPT_AUTO 'a'
  106. #define VALUE_OPT_CIDR 'c'
  107. #define VALUE_OPT_REGEX 'r'
  108. #define VALUE_OPT_PORT 'p'
  109. #define VALUE_OPT_COMMENT 'C'
  110. #define VALUE_OPT_NO_ARG_COMMENT 6
  111. #define VALUE_OPT_INCLUDE 'x'
  112. #define VALUE_OPT_EXCLUDE 'X'
  113. #define VALUE_OPT_CACHEFILE 'o'
  114. #define VALUE_OPT_PCAP 'i'
  115. #define VALUE_OPT_PRINT_COMMENT 'P'
  116. #define VALUE_OPT_PRINT_INFO 'I'
  117. #define VALUE_OPT_SERVICES 's'
  118. #define VALUE_OPT_NONIP 'N'
  119. #define VALUE_OPT_RATIO 'R'
  120. #define VALUE_OPT_MINMASK 'm'
  121. #define OPT_VALUE_MINMASK (*(unsigned long*)(&DESC(MINMASK).pzLastArg))
  122. #define VALUE_OPT_MAXMASK 'M'
  123. #define OPT_VALUE_MAXMASK (*(unsigned long*)(&DESC(MAXMASK).pzLastArg))
  124. #ifdef HAVE_TCPDUMP
  125. #define VALUE_OPT_VERBOSE 'v'
  126. #define SET_OPT_VERBOSE STMTS( \
  127. DESC(VERBOSE).optActualIndex = 18; \
  128. DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
  129. DESC(VERBOSE).fOptState &= OPTST_PERSISTENT; \
  130. DESC(VERBOSE).fOptState |= OPTST_SET )
  131. #endif /* HAVE_TCPDUMP */
  132. #ifdef HAVE_TCPDUMP
  133. #define VALUE_OPT_DECODE 'A'
  134. #endif /* HAVE_TCPDUMP */
  135. #define VALUE_OPT_VERSION 'V'
  136. #define VALUE_OPT_LESS_HELP 'h'
  137. #define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS
  138. #define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS
  139. #define VALUE_OPT_HELP 'H'
  140. #define VALUE_OPT_MORE_HELP '!'
  141. #define SET_OPT_SAVE_OPTS(a) STMTS( \
  142. DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT; \
  143. DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
  144. DESC(SAVE_OPTS).pzLastArg = (tCC*)(a) )
  145. /*
  146. * Interface defines not associated with particular options
  147. */
  148. #define ERRSKIP_OPTERR STMTS( tcpprepOptions.fOptSet &= ~OPTPROC_ERRSTOP )
  149. #define ERRSTOP_OPTERR STMTS( tcpprepOptions.fOptSet |= OPTPROC_ERRSTOP )
  150. #define RESTART_OPT(n) STMTS( \
  151. tcpprepOptions.curOptIdx = (n); \
  152. tcpprepOptions.pzCurOpt = NULL )
  153. #define START_OPT RESTART_OPT(1)
  154. #define USAGE(c) (*tcpprepOptions.pUsageProc)( &tcpprepOptions, c )
  155. /* extracted from /usr/local/share/autogen/opthead.tpl near line 246 */
  156. /* * * * * *
  157. *
  158. * Declare the tcpprep option descriptor.
  159. */
  160. #ifdef __cplusplus
  161. extern "C" {
  162. #endif
  163. extern tOptions tcpprepOptions;
  164. #ifndef _
  165. # if ENABLE_NLS
  166. # include <stdio.h>
  167. static inline char* aoGetsText( const char* pz ) {
  168. if (pz == NULL) return NULL;
  169. return (char*)gettext( pz );
  170. }
  171. # define _(s) aoGetsText(s)
  172. # else /* ENABLE_NLS */
  173. # define _(s) s
  174. # endif /* ENABLE_NLS */
  175. #endif
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* AUTOOPTS_TCPPREP_OPTS_H_GUARD */