mkconsts
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. #!/usr/bin/perl
  2. %constants = (
  3. # Symbol    0 = define, 1 = enum
  4. DB_AFTER => 0,
  5. DB_APPEND => 0,
  6. DB_ARCH_ABS => 0,
  7. DB_ARCH_DATA => 0,
  8. DB_ARCH_LOG => 0,
  9. DB_BEFORE => 0,
  10. DB_BTREE => 1,
  11. DB_BTREEMAGIC => 0,
  12. DB_BTREEOLDVER => 0,
  13. DB_BTREEVERSION   => 0,
  14. DB_CHECKPOINT => 0,
  15. DB_CONSUME => 0,
  16. DB_CREATE => 0,
  17. DB_CURLSN => 0,
  18. DB_CURRENT => 0,
  19. DB_DBT_MALLOC => 0,
  20. DB_DBT_PARTIAL => 0,
  21. DB_DBT_USERMEM => 0,
  22. DB_DELETED => 0,
  23. DB_DELIMITER => 0,
  24. DB_DUP => 0,
  25. DB_DUPSORT => 0,
  26. DB_ENV_APPINIT => 0,
  27. DB_ENV_STANDALONE => 0,
  28. DB_ENV_THREAD => 0,
  29. DB_EXCL => 0,
  30. DB_FILE_ID_LEN => 0,
  31. DB_FIRST => 0,
  32. DB_FIXEDLEN => 0,
  33. DB_FLUSH => 0,
  34. DB_FORCE => 0,
  35. DB_GET_BOTH => 0,
  36. DB_GET_RECNO => 0,
  37. DB_HASH => 1,
  38. DB_HASHMAGIC => 0,
  39. DB_HASHOLDVER => 0,
  40. DB_HASHVERSION  => 0,
  41. DB_INCOMPLETE => 0,
  42. DB_INIT_CDB => 0,
  43. DB_INIT_LOCK => 0,
  44. DB_INIT_LOG => 0,
  45. DB_INIT_MPOOL => 0,
  46. DB_INIT_TXN => 0,
  47. DB_JOIN_ITEM => 0,
  48. DB_KEYEMPTY => 0,
  49. DB_KEYEXIST => 0,
  50. DB_KEYFIRST => 0,
  51. DB_KEYLAST => 0,
  52. DB_LAST => 0,
  53. DB_LOCK_CONFLICT => 0,
  54. DB_LOCK_DEADLOCK => 0,
  55. DB_LOCK_DEFAULT => 0,
  56. DB_LOCK_GET => 1,
  57. DB_LOCK_NORUN => 0,
  58. DB_LOCK_NOTGRANTED => 0,
  59. DB_LOCK_NOTHELD => 0,
  60. DB_LOCK_NOWAIT => 0,
  61. DB_LOCK_OLDEST => 0,
  62. DB_LOCK_RANDOM => 0,
  63. DB_LOCK_RIW_N => 0,
  64. DB_LOCK_RW_N => 0,
  65. DB_LOCK_YOUNGEST => 0,
  66. DB_LOCKMAGIC => 0,
  67. DB_LOCKVERSION  => 0,
  68. DB_LOGMAGIC => 0,
  69. DB_LOGOLDVER   => 0,
  70. DB_MAX_PAGES => 0,
  71. DB_MAX_RECORDS => 0,
  72. DB_MPOOL_CLEAN => 0,
  73. DB_MPOOL_CREATE => 0,
  74. DB_MPOOL_DIRTY => 0,
  75. DB_MPOOL_DISCARD => 0,
  76. DB_MPOOL_LAST => 0,
  77. DB_MPOOL_NEW => 0,
  78. DB_MPOOL_PRIVATE => 0,
  79. DB_MUTEXDEBUG => 0,
  80. DB_MUTEXLOCKS => 0,
  81. DB_NEEDSPLIT => 0,
  82. DB_NEXT => 0,
  83. DB_NEXT_DUP => 0,
  84. DB_NOMMAP => 0,
  85. DB_NOOVERWRITE => 0,
  86. DB_NOSYNC => 0,
  87. DB_NOTFOUND => 0,
  88. DB_PAD => 0,
  89. DB_PAGEYIELD => 0,
  90. DB_POSITION => 0,
  91. DB_PREV => 0,
  92. DB_PRIVATE => 0,
  93. DB_QUEUE => 1,
  94. DB_RDONLY => 0,
  95. DB_RECNO => 1,
  96. DB_RECNUM => 0,
  97. DB_RECORDCOUNT => 0,
  98. DB_RECOVER => 0,
  99. DB_RECOVER_FATAL => 0,
  100. DB_REGISTERED => 0,
  101. DB_RENUMBER => 0,
  102. DB_RMW => 0,
  103. DB_RUNRECOVERY => 0,
  104. DB_SEQUENTIAL => 0,
  105. DB_SET => 0,
  106. DB_SET_RANGE => 0,
  107. DB_SET_RECNO => 0,
  108. DB_SNAPSHOT => 0,
  109. DB_SWAPBYTES => 0,
  110. DB_TEMPORARY => 0,
  111. DB_THREAD => 0,
  112. DB_TRUNCATE => 0,
  113. DB_TXN_ABORT => 1,
  114. DB_TXN_BACKWARD_ROLL => 1,
  115. DB_TXN_CKP => 0,
  116. DB_TXN_FORWARD_ROLL => 1,
  117. DB_TXN_LOCK_2PL => 0,
  118. DB_TXN_LOCK_MASK => 0,
  119. DB_TXN_LOCK_OPTIMISTIC => 0,
  120. DB_TXN_LOG_MASK => 0,
  121. DB_TXN_LOG_REDO => 0,
  122. DB_TXN_LOG_UNDO => 0,
  123. DB_TXN_LOG_UNDOREDO => 0,
  124. DB_TXN_NOSYNC => 0,
  125. DB_TXN_NOWAIT => 0,
  126. DB_TXN_SYNC => 0,
  127. DB_TXN_OPENFILES => 1,
  128. DB_TXN_REDO => 0,
  129. DB_TXN_UNDO => 0,
  130. DB_TXNMAGIC => 0,
  131. DB_TXNVERSION => 0,
  132. DB_TXN_LOCK_OPTIMIST => 0,
  133. DB_UNKNOWN => 1,
  134. DB_USE_ENVIRON => 0,
  135. DB_USE_ENVIRON_ROOT => 0,
  136. DB_VERSION_MAJOR => 0,
  137. DB_VERSION_MINOR => 0,
  138. DB_VERSION_PATCH => 0,
  139. DB_WRITECURSOR => 0,
  140. ) ;
  141. sub OutputXS
  142. {
  143.     # skip to the marker
  144.     if (0) {
  145.         while (<>)
  146.         {
  147.             last if /^MARKER/ ;
  148.             print ;
  149.         }
  150.     }
  151.     
  152.     foreach my $key (sort keys %constants)
  153.     {
  154.         my $isEnum = $constants{$key} ;
  155. if ($isEnum) {
  156.             print <<EOM
  157.         if (strEQ(name, "$key"))
  158.             return $key;
  159. EOM
  160. }
  161. else
  162. {
  163.             print <<EOM
  164.         if (strEQ(name, "$key"))
  165. #ifdef $key
  166.             return $key;
  167. #else
  168.             goto not_there;
  169. #endif
  170. EOM
  171. }
  172.     
  173.     }
  174.     
  175.     if (0) {
  176.         while (<>)
  177.         {
  178.     print ;
  179.         }
  180.     }
  181. }
  182. sub OutputPM
  183. {
  184.     # skip to the marker
  185.     if (0) {
  186.         while (<>)
  187.         {
  188.             last if /^MARKER/ ;
  189.             print ;
  190.         }
  191.     }
  192.     
  193.     foreach my $key (sort keys %constants)
  194.     {
  195. print "t$keyn";
  196.     }
  197.     
  198.     if (0) {
  199.         while (<>)
  200.         {
  201.     print ;
  202.         }
  203.     }
  204. }
  205. OutputXS() if $ARGV[0] =~ /xs/i ;
  206. OutputPM() if $ARGV[0] =~ /pm/i ;