/*
* IRC - Internet Relay Chat, db-merger.c
* (C) Copyright 2005-2006, Florian Schulze (Certus)
*
* Based on the original code of Anope, (C) 2003-2005 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
*
*
* 0.4 beta:
* Fixed some compiler warnings about signed/unsigned ints.
*
* - Certus
* August 8, 2006
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#ifndef _WIN32
#include <unistd.h>
#else
#include "sysconf.h"
#include <windows.h>
#endif
/* Some SUN fixs */
#ifdef __sun
/* Solaris specific code, types that do not exist in Solaris'
* sys/types.h
**/
#undef u_int8_t
#undef u_int16_t
#undef u_int32_t
#undef u_int_64_t
#define u_int8_t uint8_t
#define u_int16_t uint16_t
#define u_int32_t uint32_t
#define u_int64_t uint64_t
#ifndef INADDR_NONE
#define INADDR_NONE (-1)
#endif
#endif
#include <string>
#include <iostream>
#include <fstream>
#ifndef _WIN32
#define C_LBLUE "\033[1;34m"
#define C_NONE "\033[m"
#else
#define C_LBLUE ""
#define C_NONE ""
#endif
#define getc_db(f) (fgetc((f)->fp))
#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
#define HASH2(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0)
#define read_buffer(buf,f) (read_db((f),(buf),sizeof(buf)) == sizeof(buf))
#define write_buffer(buf,f) (write_db((f),(buf),sizeof(buf)) == sizeof(buf))
#define read_db(f,buf,len) (fread((buf),1,(len),(f)->fp))
#define write_db(f,buf,len) (fwrite((buf),1,(len),(f)->
|