summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--src/tools/db-merger.c176
-rw-r--r--src/tools/epona2anope.c14
-rw-r--r--version.log10
4 files changed, 114 insertions, 87 deletions
diff --git a/Changes b/Changes
index 56096e261..786a794a6 100644
--- a/Changes
+++ b/Changes
@@ -46,6 +46,7 @@ Provided by Anope Dev. <dev@anope.org> - 2006
07/13 F Fixed socket buffering, hopefully should make inspircd play nice. [ #00]
07/14 F Removed old HAS_RTLD_LOCAL check. [#541]
07/20 F Removed bold chars from botserv langauge files. [#530]
+07/20 F Fixed win32 versions of db-merger.c and epona2anope.c. [#536]
Provided by ThaPrince <jon@vile.com> - 2006
05/19 A Plexus 3 support. [ #00]
diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c
index 4e9fde1df..aed7adc08 100644
--- a/src/tools/db-merger.c
+++ b/src/tools/db-merger.c
@@ -1,3 +1,41 @@
+/*
+ * IRC - Internet Relay Chat, db-merger.c
+ * (C) Copyright 2005, Florian Schulze (Certus)
+ *
+ * Based on the original code of Anope, (C) 2003 Anope Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (see it online
+ * at http://www.gnu.org/copyleft/gpl.html) as published by the Free
+ * Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program tries to merge two standard anope-1.7.7+ database sets,
+ * that includes chanserv, nickserv, botserv and memoserv databases.
+ *
+ * - Certus
+ * February 11, 2005
+ *
+ *
+ * 0.2 beta:
+ * Fixed some overflows in the ->flags and the ->status fields. Use db-fix
+ * to fix your broken nick dbs.
+ *
+ * - Certus
+ * August 04, 2005
+ *
+ *
+ * 0.3 beta:
+ * Fixed win32 stuff. Merging should now work fine under windows.
+ *
+ * - Certus
+ * July 20, 2006
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -10,6 +48,7 @@
#include <unistd.h>
#else
#include "sysconf.h"
+#include <windows.h>
#endif
/* Some SUN fixs */
@@ -247,9 +286,7 @@ int delnick(NickAlias *na, int donttouchthelist);
int write_string(const char *s, dbFILE * f);
int write_ptr(const void *ptr, dbFILE * f);
int read_int16(int16 * ret, dbFILE * f);
-int read_uint16(uint16 * ret, dbFILE * f);
int read_int32(int32 * ret, dbFILE * f);
-int read_uint32(uint32 * ret, dbFILE * f);
int read_string(char **ret, dbFILE * f);
int write_int16(uint16 val, dbFILE * f);
int write_int32(uint32 val, dbFILE * f);
@@ -274,7 +311,7 @@ int main(int argc, char *argv[])
NickCore *nc, *ncnext;
HostCore *firsthc = NULL;
- printf("\n"C_LBLUE"DB Merger v0.2 beta for Anope IRC Services by Certus"C_NONE"\n\n");
+ printf("\n"C_LBLUE"DB Merger v0.3 beta for Anope IRC Services by Certus"C_NONE"\n\n");
if (argc >= 2) {
if (!mystricmp(argv[1], "--PREFEROLDEST")) {
@@ -300,7 +337,7 @@ int main(int argc, char *argv[])
NickCore *nc, **nclast, *ncprev;
int16 tmp16;
int32 tmp32;
- int i, j, c, mycount = 0;
+ int i, j, c;
printf("Trying to merge nicks...\n");
@@ -325,15 +362,14 @@ int main(int argc, char *argv[])
ncprev = nc;
READ(read_string(&nc->display, f));
- mycount++;
READ(read_string(&nc->pass, f));
READ(read_string(&nc->email, f));
READ(read_string(&nc->greet, f));
- READ(read_uint32(&nc->icq, f));
+ READ(read_int32(&nc->icq, f));
READ(read_string(&nc->url, f));
- READ(read_uint32(&nc->flags, f));
- READ(read_uint16(&nc->language, f));
- READ(read_uint16(&nc->accesscount, f));
+ READ(read_int32(&nc->flags, f));
+ READ(read_int16(&nc->language, f));
+ READ(read_int16(&nc->accesscount, f));
if (nc->accesscount) {
char **access;
access = calloc(sizeof(char *) * nc->accesscount, 1);
@@ -348,20 +384,19 @@ int main(int argc, char *argv[])
memos = calloc(sizeof(Memo) * nc->memos.memocount, 1);
nc->memos.memos = memos;
for (j = 0; j < nc->memos.memocount; j++, memos++) {
- READ(read_uint32(&memos->number, f));
- READ(read_uint16(&memos->flags, f));
+ READ(read_int32(&memos->number, f));
+ READ(read_int16(&memos->flags, f));
READ(read_int32(&tmp32, f));
memos->time = tmp32;
READ(read_buffer(memos->sender, f));
READ(read_string(&memos->text, f));
}
}
- READ(read_uint16(&nc->channelcount, f));
+ READ(read_int16(&nc->channelcount, f));
READ(read_int16(&tmp16, f));
} /* getc_db() */
*nclast = NULL;
} /* for() loop */
- printf("mycount is %d\n", mycount);
/* Nick aliases */
for (i = 0; i < 1024; i++) {
@@ -387,7 +422,7 @@ int main(int argc, char *argv[])
na->time_registered = tmp32;
READ(read_int32(&tmp32, f));
na->last_seen = tmp32;
- READ(read_uint16(&na->status, f));
+ READ(read_int16(&na->status, f));
READ(read_string(&s, f));
na->nc = findcore(s, 0);
na->nc->aliascount++;
@@ -444,11 +479,11 @@ int main(int argc, char *argv[])
nclists[index] = nc;
READ(read_string(&nc->greet, f));
- READ(read_uint32(&nc->icq, f));
+ READ(read_int32(&nc->icq, f));
READ(read_string(&nc->url, f));
- READ(read_uint32(&nc->flags, f));
- READ(read_uint16(&nc->language, f));
- READ(read_uint16(&nc->accesscount, f));
+ READ(read_int32(&nc->flags, f));
+ READ(read_int16(&nc->language, f));
+ READ(read_int16(&nc->accesscount, f));
if (nc->accesscount) {
char **access;
access = calloc(sizeof(char *) * nc->accesscount, 1);
@@ -463,15 +498,15 @@ int main(int argc, char *argv[])
memos = calloc(sizeof(Memo) * nc->memos.memocount, 1);
nc->memos.memos = memos;
for (j = 0; j < nc->memos.memocount; j++, memos++) {
- READ(read_uint32(&memos->number, f));
- READ(read_uint16(&memos->flags, f));
+ READ(read_int32(&memos->number, f));
+ READ(read_int16(&memos->flags, f));
READ(read_int32(&tmp32, f));
memos->time = tmp32;
READ(read_buffer(memos->sender, f));
READ(read_string(&memos->text, f));
}
}
- READ(read_uint16(&nc->channelcount, f));
+ READ(read_int16(&nc->channelcount, f));
READ(read_int16(&tmp16, f));
} /* getc_db() */
} /* for() loop */
@@ -497,7 +532,7 @@ int main(int argc, char *argv[])
na->time_registered = tmp32;
READ(read_int32(&tmp32, f));
na->last_seen = tmp32;
- READ(read_uint16(&na->status, f));
+ READ(read_int16(&na->status, f));
READ(read_string(&s, f));
naptr = findnick(na->nick);
@@ -601,15 +636,13 @@ int main(int argc, char *argv[])
NickCore *nc;
char **access;
Memo *memos;
- int i, j, mycount = 0;
+ int i, j;
/* Nick cores */
for (i = 0; i < 1024; i++) {
for (nc = nclists[i]; nc; nc = nc->next) {
SAFE(write_int8(1, f));
- mycount++;
SAFE(write_string(nc->display, f));
- printf("Writing entry for nick %s\n", nc->display);
SAFE(write_string(nc->pass, f));
SAFE(write_string(nc->email, f));
SAFE(write_string(nc->greet, f));
@@ -636,7 +669,6 @@ int main(int argc, char *argv[])
} /* for (nc) */
SAFE(write_int8(0, f));
} /* for (i) */
- printf("%d nicks merged\n", mycount);
/* Nick aliases */
for (i = 0; i < 1024; i++) {
@@ -708,7 +740,7 @@ int main(int argc, char *argv[])
READ(read_buffer(ci->last_topic_setter, f));
READ(read_int32(&tmp32, f));
ci->last_topic_time = tmp32;
- READ(read_uint32(&ci->flags, f));
+ READ(read_int32(&ci->flags, f));
/* Temporary flags cleanup */
ci->flags &= ~0x80000000;
READ(read_string(&ci->forbidby, f));
@@ -724,11 +756,11 @@ int main(int argc, char *argv[])
else
READ(read_int16(&tmp16, f));
}
- READ(read_uint16(&ci->accesscount, f));
+ READ(read_int16(&ci->accesscount, f));
if (ci->accesscount) {
ci->access = calloc(ci->accesscount, sizeof(ChanAccess));
for (j = 0; j < ci->accesscount; j++) {
- READ(read_uint16(&ci->access[j].in_use, f));
+ READ(read_int16(&ci->access[j].in_use, f));
if (ci->access[j].in_use) {
READ(read_int16(&ci->access[j].level, f));
READ(read_string(&s, f));
@@ -745,11 +777,11 @@ int main(int argc, char *argv[])
} else {
ci->access = NULL;
}
- READ(read_uint16(&ci->akickcount, f));
+ READ(read_int16(&ci->akickcount, f));
if (ci->akickcount) {
ci->akick = calloc(ci->akickcount, sizeof(AutoKick));
for (j = 0; j < ci->akickcount; j++) {
- SAFE(read_uint16(&ci->akick[j].flags, f));
+ SAFE(read_int16(&ci->akick[j].flags, f));
if (ci->akick[j].flags & 0x0001) {
SAFE(read_string(&s, f));
if (ci->akick[j].flags & 0x0002) {
@@ -779,9 +811,9 @@ int main(int argc, char *argv[])
} else {
ci->akick = NULL;
}
- READ(read_uint32(&ci->mlock_on, f));
- READ(read_uint32(&ci->mlock_off, f));
- READ(read_uint32(&ci->mlock_limit, f));
+ READ(read_int32(&ci->mlock_on, f));
+ READ(read_int32(&ci->mlock_off, f));
+ READ(read_int32(&ci->mlock_limit, f));
READ(read_string(&ci->mlock_key, f));
READ(read_string(&ci->mlock_flood, f));
READ(read_string(&ci->mlock_redirect, f));
@@ -792,8 +824,8 @@ int main(int argc, char *argv[])
memos = calloc(sizeof(Memo) * ci->memos.memocount, 1);
ci->memos.memos = memos;
for (j = 0; j < ci->memos.memocount; j++, memos++) {
- READ(read_uint32(&memos->number, f));
- READ(read_uint16(&memos->flags, f));
+ READ(read_int32(&memos->number, f));
+ READ(read_int16(&memos->flags, f));
READ(read_int32(&tmp32, f));
memos->time = tmp32;
READ(read_buffer(memos->sender, f));
@@ -828,14 +860,14 @@ int main(int argc, char *argv[])
READ(read_int16(&tmp16, f));
ci->repeattimes = tmp16;
- READ(read_uint16(&ci->bwcount, f));
+ READ(read_int16(&ci->bwcount, f));
if (ci->bwcount) {
ci->badwords = calloc(ci->bwcount, sizeof(BadWord));
for (j = 0; j < ci->bwcount; j++) {
- SAFE(read_uint16(&ci->badwords[j].in_use, f));
+ SAFE(read_int16(&ci->badwords[j].in_use, f));
if (ci->badwords[j].in_use) {
SAFE(read_string(&ci->badwords[j].word, f));
- SAFE(read_uint16(&ci->badwords[j].type, f));
+ SAFE(read_int16(&ci->badwords[j].type, f));
}
}
} else {
@@ -890,7 +922,7 @@ int main(int argc, char *argv[])
READ(read_buffer(ci->last_topic_setter, f));
READ(read_int32(&tmp32, f));
ci->last_topic_time = tmp32;
- READ(read_uint32(&ci->flags, f));
+ READ(read_int32(&ci->flags, f));
/* Temporary flags cleanup */
ci->flags &= ~0x80000000;
READ(read_string(&ci->forbidby, f));
@@ -906,11 +938,11 @@ int main(int argc, char *argv[])
else
READ(read_int16(&tmp16, f));
}
- READ(read_uint16(&ci->accesscount, f));
+ READ(read_int16(&ci->accesscount, f));
if (ci->accesscount) {
ci->access = calloc(ci->accesscount, sizeof(ChanAccess));
for (j = 0; j < ci->accesscount; j++) {
- READ(read_uint16(&ci->access[j].in_use, f));
+ READ(read_int16(&ci->access[j].in_use, f));
if (ci->access[j].in_use) {
READ(read_int16(&ci->access[j].level, f));
READ(read_string(&s, f));
@@ -927,11 +959,11 @@ int main(int argc, char *argv[])
} else {
ci->access = NULL;
}
- READ(read_uint16(&ci->akickcount, f));
+ READ(read_int16(&ci->akickcount, f));
if (ci->akickcount) {
ci->akick = calloc(ci->akickcount, sizeof(AutoKick));
for (j = 0; j < ci->akickcount; j++) {
- SAFE(read_uint16(&ci->akick[j].flags, f));
+ SAFE(read_int16(&ci->akick[j].flags, f));
if (ci->akick[j].flags & 0x0001) {
SAFE(read_string(&s, f));
if (ci->akick[j].flags & 0x0002) {
@@ -961,9 +993,9 @@ int main(int argc, char *argv[])
} else {
ci->akick = NULL;
}
- READ(read_uint32(&ci->mlock_on, f));
- READ(read_uint32(&ci->mlock_off, f));
- READ(read_uint32(&ci->mlock_limit, f));
+ READ(read_int32(&ci->mlock_on, f));
+ READ(read_int32(&ci->mlock_off, f));
+ READ(read_int32(&ci->mlock_limit, f));
READ(read_string(&ci->mlock_key, f));
READ(read_string(&ci->mlock_flood, f));
READ(read_string(&ci->mlock_redirect, f));
@@ -974,8 +1006,8 @@ int main(int argc, char *argv[])
memos = calloc(sizeof(Memo) * ci->memos.memocount, 1);
ci->memos.memos = memos;
for (j = 0; j < ci->memos.memocount; j++, memos++) {
- READ(read_uint32(&memos->number, f));
- READ(read_uint16(&memos->flags, f));
+ READ(read_int32(&memos->number, f));
+ READ(read_int16(&memos->flags, f));
READ(read_int32(&tmp32, f));
memos->time = tmp32;
READ(read_buffer(memos->sender, f));
@@ -1010,14 +1042,14 @@ int main(int argc, char *argv[])
READ(read_int16(&tmp16, f));
ci->repeattimes = tmp16;
- READ(read_uint16(&ci->bwcount, f));
+ READ(read_int16(&ci->bwcount, f));
if (ci->bwcount) {
ci->badwords = calloc(ci->bwcount, sizeof(BadWord));
for (j = 0; j < ci->bwcount; j++) {
- SAFE(read_uint16(&ci->badwords[j].in_use, f));
+ SAFE(read_int16(&ci->badwords[j].in_use, f));
if (ci->badwords[j].in_use) {
SAFE(read_string(&ci->badwords[j].word, f));
- SAFE(read_uint16(&ci->badwords[j].type, f));
+ SAFE(read_int16(&ci->badwords[j].type, f));
}
}
} else {
@@ -1630,7 +1662,7 @@ dbFILE *open_db_read(const char *service, const char *filename, int version)
}
/* Open a database file for reading and check for the version */
-dbFILE *open_db_write(const char *service, const char *filename, int version)
+dbFILE *open_db_write(const char *service, const char *filename, uint32 version)
{
dbFILE *f;
int fd;
@@ -1643,14 +1675,21 @@ dbFILE *open_db_write(const char *service, const char *filename, int version)
strscpy(f->filename, filename, sizeof(f->filename));
filename = f->filename;
f->mode = 'w';
- /* Use open() to avoid people sneaking a new file in under us */
+#ifndef _WIN32
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
+#else
+ fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666);
+#endif
f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */
if (!f->fp || !write_file_version(f, version)) {
printf("Can't write to %s database %s.\n", service, filename);
if (f->fp) {
fclose(f->fp);
+#ifndef _WIN32
unlink(filename);
+#else
+ DeleteFile(filename);
+#endif
}
free(f);
return NULL;
@@ -1677,18 +1716,6 @@ int read_int16(int16 * ret, dbFILE * f)
return 0;
}
-int read_uint16(uint16 * ret, dbFILE * f)
-{
- int c1, c2;
-
- c1 = fgetc(f->fp);
- c2 = fgetc(f->fp);
- if (c1 == EOF || c2 == EOF)
- return -1;
- *ret = c1 << 8 | c2;
- return 0;
-}
-
int write_int16(uint16 val, dbFILE * f)
{
if (fputc((val >> 8) & 0xFF, f->fp) == EOF
@@ -1697,7 +1724,6 @@ int write_int16(uint16 val, dbFILE * f)
return 0;
}
-
int read_int32(int32 * ret, dbFILE * f)
{
int c1, c2, c3, c4;
@@ -1712,20 +1738,6 @@ int read_int32(int32 * ret, dbFILE * f)
return 0;
}
-int read_uint32(uint32 * ret, dbFILE * f)
-{
- int c1, c2, c3, c4;
-
- c1 = fgetc(f->fp);
- c2 = fgetc(f->fp);
- c3 = fgetc(f->fp);
- c4 = fgetc(f->fp);
- if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF)
- return -1;
- *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4;
- return 0;
-}
-
int write_int32(uint32 val, dbFILE * f)
{
if (fputc((val >> 24) & 0xFF, f->fp) == EOF)
@@ -1764,7 +1776,7 @@ int read_string(char **ret, dbFILE * f)
char *s;
uint16 len;
- if (read_uint16(&len, f) < 0)
+ if (read_int16(&len, f) < 0)
return -1;
if (len == 0) {
*ret = NULL;
diff --git a/src/tools/epona2anope.c b/src/tools/epona2anope.c
index dd3bef3ee..193cfdb11 100644
--- a/src/tools/epona2anope.c
+++ b/src/tools/epona2anope.c
@@ -19,6 +19,10 @@
*
* - Certus
* February 26, 2005
+ *
+ * Added win32 fix. Who needs that anyways? :P
+ * - Certus
+ * July 20, 2006
*/
@@ -33,6 +37,7 @@
#include <unistd.h>
#else
#include "sysconf.h"
+#include <windows.h>
#endif
/* Some SUN fixs */
@@ -593,14 +598,21 @@ dbFILE *open_db_write(const char *service, const char *filename, int version)
strscpy(f->filename, filename, sizeof(f->filename));
filename = f->filename;
f->mode = 'w';
- /* Use open() to avoid people sneaking a new file in under us */
+#ifndef _WIN32
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
+#else
+ fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666);
+#endif
f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */
if (!f->fp || !write_file_version(f, version)) {
printf("Can't write to %s database %s.\n", service, filename);
if (f->fp) {
fclose(f->fp);
+#ifndef _WIN32
unlink(filename);
+#else
+ DeleteFile(filename);
+#endif
}
free(f);
return NULL;
diff --git a/version.log b/version.log
index cc904b3ee..341b019df 100644
--- a/version.log
+++ b/version.log
@@ -9,19 +9,21 @@ VERSION_MAJOR="1"
VERSION_MINOR="7"
VERSION_PATCH="14"
VERSION_EXTRA=""
-VERSION_BUILD="1095"
+VERSION_BUILD="1096"
# $Log$
#
+# BUILD : 1.7.14 (1096)
+# BUGS : 536
+# NOTES : Fixed win32 versions of db-merger.c and epona2anope.c
+#
# BUILD : 1.7.14 (1095)
# BUGS : 554
# NOTES : Applied heinzs manifest patch
-#
#
# BUILD : 1.7.14 (1094)
# BUGS : 530
-# NOTES : Applied marks botserv bold striping patch
-#
+# NOTES : Applied marks botserv bold striping patch
#
# BUILD : 1.7.14 (1093)
# BUGS :