inn-db4.patch 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. diff -Naur inn-2.3.3.orig/storage/ovdb/ovdb.c inn-2.3.3/storage/ovdb/ovdb.c
  2. --- inn-2.3.3.orig/storage/ovdb/ovdb.c Mon May 6 08:02:07 2002
  3. +++ inn-2.3.3/storage/ovdb/ovdb.c Mon Oct 14 21:37:07 2002
  4. @@ -99,7 +99,7 @@
  5. #error Need BerkeleyDB 2.6.x, 2.7.x, or 3.x
  6. #endif
  7. #else
  8. -#if DB_VERSION_MAJOR != 3
  9. +#if DB_VERSION_MAJOR != 3 && DB_VERSION_MAJOR != 4
  10. #error Need BerkeleyDB 2.6.x, 2.7.x, or 3.x
  11. #endif
  12. #endif
  13. @@ -401,13 +401,23 @@
  14. if(ovdb_conf.pagesize > 0)
  15. (dbs[which])->set_pagesize(dbs[which], ovdb_conf.pagesize);
  16. +#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MAJOR >= 1)
  17. +/* starting sometime early db 4.X, db->open gets a new parameter */
  18. + if(ret = (dbs[which])->open(dbs[which], 0, _dbnames[which], NULL,
  19. + DB_BTREE, _db_flags, 0666)) {
  20. + (dbs[which])->close(dbs[which], 0);
  21. + dbs[which] = NULL;
  22. + return ret;
  23. + }
  24. +#else
  25. if(ret = (dbs[which])->open(dbs[which], _dbnames[which], NULL, DB_BTREE,
  26. _db_flags, 0666)) {
  27. (dbs[which])->close(dbs[which], 0);
  28. dbs[which] = NULL;
  29. return ret;
  30. }
  31. -#endif
  32. +#endif /* #if DB_VERSION_MAJOR >= 4 */
  33. +#endif /* #if DB_VERSION_MAJOR == 2 */
  34. return 0;
  35. }
  36. @@ -590,7 +600,7 @@
  37. return TRUE;
  38. }
  39. -#if DB_VERSION_MAJOR == 3
  40. +#if DB_VERSION_MAJOR >= 3
  41. static int upgrade_database(char *name)
  42. {
  43. int ret;
  44. @@ -659,7 +669,7 @@
  45. if(flags & OVDB_RECOVER)
  46. ai_flags |= DB_RECOVER;
  47. -#if DB_VERSION_MAJOR == 2 || DB_VERSION_MINOR < 2
  48. +#if DB_VERSION_MAJOR == 2 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 2)
  49. if(ovdb_conf.txn_nosync)
  50. ai_flags |= DB_TXN_NOSYNC;
  51. #endif
  52. @@ -697,12 +707,12 @@
  53. OVDBenv->set_errcall(OVDBenv, OVDBerror);
  54. OVDBenv->set_cachesize(OVDBenv, 0, ovdb_conf.cachesize, 1);
  55. -#if DB_VERSION_MINOR >= 2
  56. +#if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 2) || DB_VERSION_MAJOR >= 4
  57. if(ovdb_conf.txn_nosync)
  58. OVDBenv->set_flags(OVDBenv, DB_TXN_NOSYNC, 1);
  59. #endif
  60. -#if DB_VERSION_MINOR == 0
  61. +#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 0
  62. if(ret = OVDBenv->open(OVDBenv, ovdb_conf.home, NULL, ai_flags, 0666)) {
  63. #else
  64. if(ret = OVDBenv->open(OVDBenv, ovdb_conf.home, ai_flags, 0666)) {
  65. @@ -726,12 +736,22 @@
  66. syslog(L_FATAL, "OVDB: open: db_create: %s", db_strerror(ret));
  67. return ret;
  68. }
  69. - if(ret = vdb->open(vdb, "version", NULL, DB_BTREE,
  70. +
  71. +#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MAJOR >= 1)
  72. +/* starting sometime early db 4.X, db->open gets a new parameter */
  73. + if(ret = vdb->open(vdb, 0, "version", NULL, DB_BTREE,
  74. _db_flags, 0666)) {
  75. vdb->close(vdb, 0);
  76. syslog(L_FATAL, "OVDB: open: version->open: %s", db_strerror(ret));
  77. return ret;
  78. }
  79. +#else
  80. + if(ret = vdb->open(vdb, "version", NULL, DB_BTREE, _db_flags, 0666)) {
  81. + vdb->close(vdb, 0);
  82. + syslog(L_FATAL, "OVDB: open: version->open: %s", db_strerror(ret));
  83. + return ret;
  84. + }
  85. +#endif /* DB_VERSION_MAJOR >= 4 */
  86. #endif /* DB_VERSION_MAJOR == 2 */
  87. memset(&key, 0, sizeof key);
  88. @@ -841,33 +861,62 @@
  89. syslog(L_FATAL, "OVDB: open: db_create: %s", db_strerror(ret));
  90. return FALSE;
  91. }
  92. +
  93. +#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MAJOR >= 1)
  94. +/* starting sometime early db 4.X, db->open gets a new parameter */
  95. + if(ret = groupstats->open(groupstats, 0, "groupstats", NULL,
  96. + DB_BTREE, _db_flags, 0666)) {
  97. + groupstats->close(groupstats, 0);
  98. + syslog(L_FATAL, "OVDB: open: groupstats->open: %s", db_strerror(ret));
  99. + return FALSE;
  100. + }
  101. +#else
  102. if(ret = groupstats->open(groupstats, "groupstats", NULL, DB_BTREE,
  103. _db_flags, 0666)) {
  104. groupstats->close(groupstats, 0);
  105. syslog(L_FATAL, "OVDB: open: groupstats->open: %s", db_strerror(ret));
  106. return FALSE;
  107. }
  108. +#endif /* #if DB_VERSION_MAJOR >= 4 */
  109. if(ret = db_create(&groupsbyname, OVDBenv, 0)) {
  110. syslog(L_FATAL, "OVDB: open: db_create: %s", db_strerror(ret));
  111. return FALSE;
  112. }
  113. +#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MAJOR >= 1)
  114. + if(ret = groupsbyname->open(groupsbyname, 0, "groupsbyname", NULL, DB_HASH,
  115. + _db_flags, 0666)) {
  116. + groupsbyname->close(groupsbyname, 0);
  117. + syslog(L_FATAL, "OVDB: open: groupsbyname->open: %s", db_strerror(ret));
  118. + return FALSE;
  119. + }
  120. +#else
  121. if(ret = groupsbyname->open(groupsbyname, "groupsbyname", NULL, DB_HASH,
  122. _db_flags, 0666)) {
  123. groupsbyname->close(groupsbyname, 0);
  124. syslog(L_FATAL, "OVDB: open: groupsbyname->open: %s", db_strerror(ret));
  125. return FALSE;
  126. }
  127. +#endif /* #if DB_VERSION_MAJOR >= 4 */
  128. if(ret = db_create(&groupaliases, OVDBenv, 0)) {
  129. syslog(L_FATAL, "OVDB: open: db_create: %s", db_strerror(ret));
  130. return FALSE;
  131. }
  132. +#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MAJOR >= 1)
  133. + if(ret = groupaliases->open(groupaliases, 0, "groupaliases", NULL, DB_HASH,
  134. + _db_flags, 0666)) {
  135. + groupaliases->close(groupaliases, 0);
  136. + syslog(L_FATAL, "OVDB: open: groupaliases->open: %s", db_strerror(ret));
  137. + return FALSE;
  138. + }
  139. +#else
  140. if(ret = groupaliases->open(groupaliases, "groupaliases", NULL, DB_HASH,
  141. _db_flags, 0666)) {
  142. groupaliases->close(groupaliases, 0);
  143. syslog(L_FATAL, "OVDB: open: groupaliases->open: %s", db_strerror(ret));
  144. return FALSE;
  145. }
  146. -#endif
  147. +#endif /* #if DB_VERSION_MAJOR >= 4 */
  148. +#endif /* #if DB_VERSION_MAJOR == 2 */
  149. Cutofflow = FALSE;
  150. return TRUE;