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>

Go to the source code of this file.

Data Structures

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

Defines

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

Typedefs

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

Functions

void alpha_insert_chan (ChannelInfo *ci)
void close_db (dbFILE *f)
ChannelInfocs_findchan (const char *chan)
NickCorefindcore (const char *nick, int version)
int main (int argc, char *argv[])
int mystricmp (const char *s1, const char *s2)
dbFILEopen_db_read (const char *service, const char *filename, int version)
dbFILEopen_db_write (const char *service, const char *filename, int version)
int read_int16 (int16 *ret, dbFILE *f)
int read_int32 (int32 *ret, dbFILE *f)
int read_ptr (void **ret, dbFILE *f)
int read_string (char **ret, dbFILE *f)
int read_uint16 (uint16 *ret, dbFILE *f)
int read_uint32 (uint32 *ret, dbFILE *f)
char * strscpy (char *d, const char *s, size_t len)
int write_file_version (dbFILE *f, uint32 version)
int write_int16 (uint16 val, dbFILE *f)
int write_int32 (uint32 val, dbFILE *f)
int write_ptr (const void *ptr, dbFILE *f)
int write_string (const char *s, dbFILE *f)

Variables

ChannelInfochanlists [256]
NickCorenclists [1024]


Define Documentation

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

Definition at line 72 of file epona2anope.c.

#define C_NONE   "\033[m"

Definition at line 73 of file epona2anope.c.

#define CHAN_DB_ANOPE   "chan.db"

Definition at line 67 of file epona2anope.c.

#define CHAN_DB_EPONA   "chan1.db"

Definition at line 66 of file epona2anope.c.

Referenced by main().

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

Definition at line 79 of file epona2anope.c.

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

Definition at line 80 of file epona2anope.c.

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

Definition at line 81 of file epona2anope.c.

#define READ (  ) 

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.

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

Definition at line 82 of file epona2anope.c.

#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 (  ) 

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.

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

Definition at line 83 of file epona2anope.c.

#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.


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 1910 of file chanserv.c.

References alog(), chanlists, debug, chaninfo_::name, chaninfo_::next, chaninfo_::prev, stricmp(), and tolower.

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:
dbFile struct
Returns:
void

Definition at line 374 of file datafiles.c.

References dbFILE_::backupfp, dbFILE_::backupname, dbFILE_::filename, dbFILE_::fp, and dbFILE_::mode.

ChannelInfo* cs_findchan ( const char *  chan  ) 

Definition at line 1848 of file chanserv.c.

References alog(), chanlists, debug, chaninfo_::name, chaninfo_::next, stricmp(), and tolower.

NickCore* findcore ( const char *  nick,
int  version 
)

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_::bantype, C_LBLUE, C_NONE, CHAN_DB_EPONA, chanlists, AutoKick::creator, chaninfo_::desc, chaninfo_::email, findcore(), memo_::flags, AutoKick::flags, chaninfo_::flags, chaninfo_::forbidby, chaninfo_::forbidreason, chaninfo_::founder, chaninfo_::founderpass, getc_db, ChanAccess::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, chaninfo_::name, AutoKick::nc, ChanAccess::nc, chaninfo_::next, memo_::number, open_db_read(), chaninfo_::prev, READ, read_buffer, read_int16(), read_int32(), read_string(), read_uint32(), AutoKick::reason, SAFE, memo_::sender, strdup(), chaninfo_::successor, memo_::text, memo_::time, chaninfo_::time_registered, AutoKick::u, and chaninfo_::url.

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

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

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

int read_int16 ( int16 ret,
dbFILE f 
)

int read_int32 ( int32 ret,
dbFILE f 
)

int read_ptr ( void **  ret,
dbFILE f 
)

Read Pointer

Parameters:
ret pointer to read
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 490 of file datafiles.c.

References dbFILE_::fp.

int read_string ( char **  ret,
dbFILE f 
)

Read String

Parameters:
ret string
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 526 of file datafiles.c.

References dbFILE_::fp, read_int16(), and scalloc().

int read_uint16 ( uint16 ret,
dbFILE f 
)

int read_uint32 ( uint32 ret,
dbFILE f 
)

char* strscpy ( char *  d,
const char *  s,
size_t  len 
)

strscpy: Copy at most len-1 characters from a string to a buffer, and add a null terminator after the last character copied.

Parameters:
d Buffer to copy into
s Data to copy int
len Length of data
Returns:
updated buffer

Definition at line 92 of file misc.c.

int write_file_version ( dbFILE f,
uint32  version 
)

Write the current version number to the file.

Parameters:
f dbFile Struct Member
Returns:
0 on error, 1 on success.

Definition at line 63 of file datafiles.c.

References dbFILE_::filename, dbFILE_::fp, and log_perror().

int write_int16 ( uint16  val,
dbFILE f 
)

Write a 16bit integer

Parameters:
ret 16bit integer to write
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 427 of file datafiles.c.

References dbFILE_::fp.

int write_int32 ( uint32  val,
dbFILE f 
)

Write a unsigned 32bit integer

Parameters:
ret unsigned 32bit integer to write
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 468 of file datafiles.c.

References dbFILE_::fp.

int write_ptr ( const void *  ptr,
dbFILE f 
)

Write Pointer

Parameters:
ret pointer to write
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 510 of file datafiles.c.

References dbFILE_::fp.

int write_string ( const char *  s,
dbFILE f 
)

Write String

Parameters:
ret string
dbFile struct
Returns:
-1 on error, 0 otherwise.

Definition at line 555 of file datafiles.c.

References dbFILE_::fp, and write_int16().


Variable Documentation

ChannelInfo* chanlists[256]

Definition at line 239 of file epona2anope.c.

NickCore* nclists[1024]

Definition at line 240 of file epona2anope.c.


Generated on Sun Dec 30 09:27:00 2007 for Anope by  doxygen 1.5.1-20070107