tcpbridge_opts.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpbridge_opts.h)
  4. *
  5. * It has been AutoGen-ed Thursday July 28, 2005 at 09:57:20 PM PDT
  6. * From the definitions tcpbridge_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 tcpbridge 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_TCPBRIDGE_OPTS_H_GUARD
  16. #define AUTOOPTS_TCPBRIDGE_OPTS_H_GUARD
  17. /*
  18. * tcpbridge copyright 2005 Aaron Turner - all rights reserved
  19. *
  20. * tcpbridge 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. * tcpbridge 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_VERBOSE = 1,
  54. INDEX_OPT_DECODE = 2,
  55. INDEX_OPT_INTF1 = 3,
  56. INDEX_OPT_INTF2 = 4,
  57. INDEX_OPT_UNIDIR = 5,
  58. INDEX_OPT_DMAC = 6,
  59. INDEX_OPT_SMAC = 7,
  60. INDEX_OPT_LIMIT = 8,
  61. INDEX_OPT_INCLUDE = 9,
  62. INDEX_OPT_EXCLUDE = 10,
  63. INDEX_OPT_VLAN = 11,
  64. INDEX_OPT_VLAN_TAG = 12,
  65. INDEX_OPT_VLAN_CFI = 13,
  66. INDEX_OPT_VLAN_PRI = 14,
  67. INDEX_OPT_PID = 15,
  68. INDEX_OPT_VERSION = 16,
  69. INDEX_OPT_LESS_HELP = 17,
  70. INDEX_OPT_HELP = 18,
  71. INDEX_OPT_MORE_HELP = 19,
  72. INDEX_OPT_SAVE_OPTS = 20,
  73. INDEX_OPT_LOAD_OPTS = 21
  74. } teOptIndex;
  75. #define OPTION_CT 22
  76. /*
  77. * Interface defines for all options. Replace "n" with
  78. * the UPPER_CASED option name (as in the teOptIndex
  79. * enumeration above). e.g. HAVE_OPT( DBUG )
  80. */
  81. #define DESC(n) tcpbridgeOptions.pOptDesc[INDEX_OPT_ ## n]
  82. #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
  83. #define OPT_ARG(n) (DESC(n).pzLastArg)
  84. #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
  85. #define COUNT_OPT(n) (DESC(n).optOccCt)
  86. #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
  87. #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
  88. #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
  89. #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
  90. #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
  91. #define CLEAR_OPT(n) STMTS( \
  92. DESC(n).fOptState &= OPTST_PERSISTENT; \
  93. if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  94. DESC(n).fOptState |= OPTST_DISABLED; \
  95. DESC(n).optCookie = NULL )
  96. /*
  97. * Interface defines for specific options.
  98. */
  99. #define VALUE_OPT_DBUG 'd'
  100. #define OPT_VALUE_DBUG (*(unsigned long*)(&DESC(DBUG).pzLastArg))
  101. #ifdef HAVE_TCPDUMP
  102. #define VALUE_OPT_VERBOSE 'v'
  103. #define SET_OPT_VERBOSE STMTS( \
  104. DESC(VERBOSE).optActualIndex = 1; \
  105. DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
  106. DESC(VERBOSE).fOptState &= OPTST_PERSISTENT; \
  107. DESC(VERBOSE).fOptState |= OPTST_SET )
  108. #endif /* HAVE_TCPDUMP */
  109. #ifdef HAVE_TCPDUMP
  110. #define VALUE_OPT_DECODE 'A'
  111. #endif /* HAVE_TCPDUMP */
  112. #define VALUE_OPT_INTF1 'i'
  113. #define VALUE_OPT_INTF2 'I'
  114. #define VALUE_OPT_UNIDIR 'u'
  115. #define VALUE_OPT_DMAC 'D'
  116. #define VALUE_OPT_SMAC 'S'
  117. #define VALUE_OPT_LIMIT 'l'
  118. #define OPT_VALUE_LIMIT (*(unsigned long*)(&DESC(LIMIT).pzLastArg))
  119. #define VALUE_OPT_INCLUDE 'x'
  120. #define VALUE_OPT_EXCLUDE 'X'
  121. #define VALUE_OPT_VLAN 'T'
  122. #define VALUE_OPT_VLAN_TAG 't'
  123. #define OPT_VALUE_VLAN_TAG (*(unsigned long*)(&DESC(VLAN_TAG).pzLastArg))
  124. #define VALUE_OPT_VLAN_CFI 'c'
  125. #define OPT_VALUE_VLAN_CFI (*(unsigned long*)(&DESC(VLAN_CFI).pzLastArg))
  126. #define VALUE_OPT_VLAN_PRI 'p'
  127. #define OPT_VALUE_VLAN_PRI (*(unsigned long*)(&DESC(VLAN_PRI).pzLastArg))
  128. #define VALUE_OPT_PID 'P'
  129. #define VALUE_OPT_VERSION 'V'
  130. #define VALUE_OPT_LESS_HELP 'h'
  131. #define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS
  132. #define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS
  133. #define VALUE_OPT_HELP 'H'
  134. #define VALUE_OPT_MORE_HELP '!'
  135. #define SET_OPT_SAVE_OPTS(a) STMTS( \
  136. DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT; \
  137. DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
  138. DESC(SAVE_OPTS).pzLastArg = (tCC*)(a) )
  139. /*
  140. * Interface defines not associated with particular options
  141. */
  142. #define ERRSKIP_OPTERR STMTS( tcpbridgeOptions.fOptSet &= ~OPTPROC_ERRSTOP )
  143. #define ERRSTOP_OPTERR STMTS( tcpbridgeOptions.fOptSet |= OPTPROC_ERRSTOP )
  144. #define RESTART_OPT(n) STMTS( \
  145. tcpbridgeOptions.curOptIdx = (n); \
  146. tcpbridgeOptions.pzCurOpt = NULL )
  147. #define START_OPT RESTART_OPT(1)
  148. #define USAGE(c) (*tcpbridgeOptions.pUsageProc)( &tcpbridgeOptions, c )
  149. /* extracted from /usr/local/share/autogen/opthead.tpl near line 246 */
  150. /* * * * * *
  151. *
  152. * Declare the tcpbridge option descriptor.
  153. */
  154. #ifdef __cplusplus
  155. extern "C" {
  156. #endif
  157. extern tOptions tcpbridgeOptions;
  158. #ifndef _
  159. # if ENABLE_NLS
  160. # include <stdio.h>
  161. static inline char* aoGetsText( const char* pz ) {
  162. if (pz == NULL) return NULL;
  163. return (char*)gettext( pz );
  164. }
  165. # define _(s) aoGetsText(s)
  166. # else /* ENABLE_NLS */
  167. # define _(s) s
  168. # endif /* ENABLE_NLS */
  169. #endif
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif /* AUTOOPTS_TCPBRIDGE_OPTS_H_GUARD */