Anope IRC Services  Version 1.8
Data Structures | Macros | Typedefs | Functions | Variables
epona2anope.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for epona2anope.c:

Go to the source code of this file.

Data Structures

struct  memo_
 
struct  dbFILE_
 
struct  MemoInfo
 
struct  ChanAccess
 
struct  AutoKick
 
struct  nickcore_
 
struct  chaninfo_
 
struct  botinfo_
 
struct  badword_
 

Macros

#define CHAN_DB_EPONA   "chan1.db"
 
#define CHAN_DB_ANOPE   "chan.db"
 
#define C_LBLUE   "\033[1;34m"
 
#define C_NONE   "\033[m"
 
#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)->fp))
 
#define read_int8(ret, f)   ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0)
 
#define write_int8(val, f)   (fputc((val),(f)->fp)==EOF ? -1 : 0)
 
#define SAFE(x)
 
#define READ(x)
 

Typedefs

typedef int16_t int16
 
typedef u_int16_t uint16
 
typedef int32_t int32
 
typedef u_int32_t uint32
 
typedef struct memo_ Memo
 
typedef struct dbFILE_ dbFILE
 
typedef struct nickalias_ NickAlias
 
typedef struct nickcore_ NickCore
 
typedef struct chaninfo_ ChannelInfo
 
typedef struct botinfo_ BotInfo
 
typedef struct badword_ BadWord
 
typedef struct hostcore_ HostCore
 

Functions

dbFILEopen_db_write (const char *service, const char *filename, int version)
 
dbFILEopen_db_read (const char *service, const char *filename, int version)
 
NickCorefindcore (const char *nick, int version)
 
ChannelInfocs_findchan (const char *chan)
 
char * strscpy (char *d, const char *s, size_t len)
 
int write_file_version (dbFILE *f, uint32 version)
 
int mystricmp (const char *s1, const char *s2)
 
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)
 
int read_ptr (void **ret, dbFILE *f)
 
void alpha_insert_chan (ChannelInfo *ci)
 
void close_db (dbFILE *f)
 
int main (int argc, char *argv[])
 

Variables

ChannelInfochanlists [256]
 
NickCorenclists [1024]
 

Macro Definition Documentation

#define C_LBLUE   "\033[1;34m"

Definition at line 72 of file epona2anope.c.

Referenced by main().

#define C_NONE   "\033[m"

Definition at line 73 of file epona2anope.c.

Referenced by main().

#define CHAN_DB_ANOPE   "chan.db"

Definition at line 67 of file epona2anope.c.

Referenced by main().

#define CHAN_DB_EPONA   "chan1.db"

Definition at line 66 of file epona2anope.c.

Referenced by main().

#define getc_db (   f)    (fgetc((f)->fp))

Definition at line 79 of file epona2anope.c.

Referenced by main().

#define HASH (   nick)    ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))

Definition at line 80 of file epona2anope.c.

Referenced by findcore().

#define HASH2 (   chan)    ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0)

Definition at line 81 of file epona2anope.c.

#define READ (   x)
Value:
do { \
if ((x) < 0) { \
printf("Error, the database is broken, trying to continue... no guarantee.\n"); \
exit(0); \
} \
} while (0)

Definition at line 93 of file epona2anope.c.

Referenced by main().

#define read_buffer (   buf,
 
)    (read_db((f),(buf),sizeof(buf)) == sizeof(buf))

Definition at line 82 of file epona2anope.c.

Referenced by main().

#define read_db (   f,
  buf,
  len 
)    (fread((buf),1,(len),(f)->fp))

Definition at line 84 of file epona2anope.c.

#define read_int8 (   ret,
 
)    ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0)

Definition at line 86 of file epona2anope.c.

#define SAFE (   x)
Value:
do { \
if ((x) < 0) { \
printf("Error, the database is broken, trying to continue... no guarantee.\n"); \
} \
} while (0)

Definition at line 88 of file epona2anope.c.

Referenced by main().

#define write_buffer (   buf,
 
)    (write_db((f),(buf),sizeof(buf)) == sizeof(buf))

Definition at line 83 of file epona2anope.c.

Referenced by main().

#define write_db (   f,
  buf,
  len 
)    (fwrite((buf),1,(len),(f)->fp))

Definition at line 85 of file epona2anope.c.

#define write_int8 (   val,
 
)    (fputc((val),(f)->fp)==EOF ? -1 : 0)

Definition at line 87 of file epona2anope.c.

Referenced by main().

Typedef Documentation

typedef struct badword_ BadWord

Definition at line 110 of file epona2anope.c.

typedef struct botinfo_ BotInfo

Definition at line 109 of file epona2anope.c.

typedef struct chaninfo_ ChannelInfo

Definition at line 108 of file epona2anope.c.

typedef struct dbFILE_ dbFILE

Definition at line 105 of file epona2anope.c.

typedef struct hostcore_ HostCore

Definition at line 111 of file epona2anope.c.

typedef int16_t int16

Definition at line 100 of file epona2anope.c.

typedef int32_t int32

Definition at line 102 of file epona2anope.c.

typedef struct memo_ Memo

Definition at line 104 of file epona2anope.c.

typedef struct nickalias_ NickAlias

Definition at line 106 of file epona2anope.c.

typedef struct nickcore_ NickCore

Definition at line 107 of file epona2anope.c.

typedef u_int16_t uint16

Definition at line 101 of file epona2anope.c.

typedef u_int32_t uint32

Definition at line 103 of file epona2anope.c.

Function Documentation

void alpha_insert_chan ( ChannelInfo ci)

Definition at line 839 of file epona2anope.c.

References mystricmp(), chaninfo_::name, chaninfo_::next, chaninfo_::prev, and tolower.

Referenced by db_mysql_load_cs_dbase().

void close_db ( dbFILE f)

Close a database file. If the file was opened for write, remove the backup we (may have) created earlier.

Parameters
dbFilestruct
Returns
void

Definition at line 635 of file epona2anope.c.

References dbFILE_::fp.

Referenced by load_bs_dbase(), load_cs_dbase(), load_exceptions(), load_hs_dbase(), load_news(), load_ns_dbase(), load_ns_req_db(), load_old_akill(), load_old_ns_dbase(), load_os_dbase(), main(), save_bs_dbase(), save_cs_dbase(), save_exceptions(), save_hs_dbase(), save_news(), save_ns_dbase(), save_ns_req_dbase(), and save_os_dbase().

ChannelInfo* cs_findchan ( const char *  chan)
NickCore* findcore ( const char *  nick,
int  version 
)

Definition at line 773 of file epona2anope.c.

References nickcore_::display, HASH, mystricmp(), nickcore_::next, and nickcore_::unused.

Referenced by main().

int main ( int  argc,
char *  argv[] 
)

Definition at line 242 of file epona2anope.c.

References chaninfo_::access, chaninfo_::accesscount, AutoKick::addtime, chaninfo_::akick, chaninfo_::akickcount, chaninfo_::badwords, chaninfo_::bantype, chaninfo_::bi, chaninfo_::botflags, chaninfo_::bwcount, c, C_LBLUE, C_NONE, chaninfo_::capsmin, chaninfo_::capspercent, CHAN_DB_ANOPE, CHAN_DB_EPONA, close_db(), AutoKick::creator, chaninfo_::desc, nickcore_::display, chaninfo_::email, chaninfo_::entry_message, findcore(), memo_::flags, AutoKick::flags, chaninfo_::flags, chaninfo_::floodlines, chaninfo_::floodsecs, chaninfo_::forbidby, chaninfo_::forbidreason, chaninfo_::founder, chaninfo_::founderpass, getc_db, ChanAccess::in_use, badword_::in_use, ChanAccess::last_seen, chaninfo_::last_topic, chaninfo_::last_topic_setter, chaninfo_::last_topic_time, chaninfo_::last_used, ChanAccess::level, chaninfo_::levels, AutoKick::mask, MemoInfo::memocount, MemoInfo::memomax, MemoInfo::memos, chaninfo_::memos, chaninfo_::mlock_flood, chaninfo_::mlock_joinrate, chaninfo_::mlock_key, chaninfo_::mlock_limit, chaninfo_::mlock_off, chaninfo_::mlock_on, chaninfo_::mlock_redirect, chaninfo_::name, ChanAccess::nc, AutoKick::nc, chaninfo_::next, memo_::number, open_db_read(), open_db_write(), chaninfo_::prev, READ, read_buffer, read_int16(), read_int32(), read_string(), read_uint32(), AutoKick::reason, chaninfo_::repeattimes, SAFE, memo_::sender, strdup(), chaninfo_::successor, memo_::text, memo_::time, chaninfo_::time_registered, chaninfo_::ttb, badword_::type, AutoKick::u, chaninfo_::url, badword_::word, write_buffer, write_int16(), write_int32(), write_int8, and write_string().

int mystricmp ( const char *  s1,
const char *  s2 
)

Definition at line 814 of file epona2anope.c.

References c, and tolower.

Referenced by alpha_insert_chan(), cs_findchan(), and findcore().

dbFILE* open_db_read ( const char *  service,
const char *  filename,
int  version 
)

Definition at line 562 of file epona2anope.c.

References dbFILE_::filename, dbFILE_::fp, dbFILE_::mode, and strscpy().

Referenced by main().

dbFILE* open_db_write ( const char *  service,
const char *  filename,
int  version 
)

Definition at line 594 of file epona2anope.c.

References dbFILE_::filename, dbFILE_::fp, dbFILE_::mode, strscpy(), and write_file_version().

Referenced by main().

int read_int16 ( int16 ret,
dbFILE f 
)

Definition at line 641 of file epona2anope.c.

References dbFILE_::fp.

Referenced by main().

int read_int32 ( int32 ret,
dbFILE f 
)

Definition at line 674 of file epona2anope.c.

References dbFILE_::fp.

Referenced by main().

int read_ptr ( void **  ret,
dbFILE f 
)

Read Pointer

Parameters
retpointer to read
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 716 of file epona2anope.c.

References c, and dbFILE_::fp.

int read_string ( char **  ret,
dbFILE f 
)

Read String

Parameters
retstring
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 735 of file epona2anope.c.

References dbFILE_::fp, and read_uint16().

Referenced by load_bs_dbase(), load_cs_dbase(), load_exceptions(), load_hs_dbase_v1(), load_hs_dbase_v2(), load_hs_dbase_v3(), load_news(), load_ns_dbase(), load_ns_req_db(), load_old_akill(), load_old_ns_dbase(), load_os_dbase(), and main().

int read_uint16 ( uint16 ret,
dbFILE f 
)

Definition at line 653 of file epona2anope.c.

References dbFILE_::fp.

Referenced by read_string().

int read_uint32 ( uint32 ret,
dbFILE f 
)

Definition at line 688 of file epona2anope.c.

References dbFILE_::fp.

Referenced by main().

char* strscpy ( char *  d,
const char *  s,
size_t  len 
)
int write_file_version ( dbFILE f,
uint32  version 
)

Write the current version number to the file.

Parameters
fdbFile Struct Member
Returns
0 on error, 1 on success.

Definition at line 786 of file epona2anope.c.

References dbFILE_::filename, and dbFILE_::fp.

Referenced by open_db_write().

int write_int16 ( uint16  val,
dbFILE f 
)

Write a 16bit integer

Parameters
ret16bit integer to write
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 665 of file epona2anope.c.

References dbFILE_::fp.

Referenced by main(), save_bs_dbase(), save_cs_dbase(), save_exceptions(), save_news(), save_ns_dbase(), save_os_dbase(), and write_string().

int write_int32 ( uint32  val,
dbFILE f 
)

Write a unsigned 32bit integer

Parameters
retunsigned 32bit integer to write
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 702 of file epona2anope.c.

References dbFILE_::fp.

Referenced by main(), save_bs_dbase(), save_cs_dbase(), save_exceptions(), save_hs_dbase(), save_news(), save_ns_dbase(), save_ns_req_dbase(), and save_os_dbase().

int write_ptr ( const void *  ptr,
dbFILE f 
)

Write Pointer

Parameters
retpointer to write
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 727 of file epona2anope.c.

References dbFILE_::fp.

int write_string ( const char *  s,
dbFILE f 
)

Write String

Parameters
retstring
dbFilestruct
Returns
-1 on error, 0 otherwise.

Definition at line 755 of file epona2anope.c.

References dbFILE_::fp, and write_int16().

Referenced by main(), save_bs_dbase(), save_cs_dbase(), save_exceptions(), save_hs_dbase(), save_news(), save_ns_dbase(), save_ns_req_dbase(), and save_os_dbase().

Variable Documentation

ChannelInfo* chanlists[256]

Definition at line 239 of file epona2anope.c.

NickCore* nclists[1024]

Definition at line 240 of file epona2anope.c.