Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

db.c File Reference

Services database-related procedures. More...

#include "services.h"
#include "nickserv.h"
#include "chanserv.h"
#include "db.h"
#include "hash/md5pw.h"
#include "memoserv.h"
#include "macro.h"
#include "hash.h"
#include "queue.h"
#include "log.h"
#include "infoserv.h"

Go to the source code of this file.

Defines

#define NS_DIR   "nickserv/"
#define CS_DIR   "chanserv/"
#define OS_DIR   "operserv/"
#define MS_DIR   "memoserv/"
#define IS_DIR   "infoserv/"
#define NS_DB   NS_DIR"nickserv.db"
#define CS_DB   CS_DIR"chanserv.db"
#define MS_DB   MS_DIR"memoserv.db"
#define TRG_DB   OS_DIR"trigger.db"
#define AKI_DB   OS_DIR"akill.db"
#define IS_DB   IS_DIR"infoserv.db"

Functions

void AppendBuffer (char **p, const char *)
char * str_dup (const char *)
 Allocates and returns a copy of the supplied string.

void unexpected_eof (const char *file_name)
 Handle an unexpected EOF in database file error.

char * dbReadString (FILE *fp)
void dbWriteString (FILE *fp, const char *istr)
void saveNickData (void)
 Saves the NickServ database to disk.

void readNickData ()
 Loads the NickServ database from disk.

void saveChanUrls (RegChanList *first)
 Saves the URLS of channels to urls.txt.

void saveChanData (RegChanList *first)
 Saves the ChanServ database to disk.

void readChanData ()
 Loads the ChanServ database from disk.

void saveMemoData (void)
 Saves the Memo database to disk.

void readMemoData (void)
 Loads the memo database from disk.

void saveTriggerData (void)
 Saves the Clone rule database to disk.

void readTriggerData (void)
 Loads the clone rule database from disk.

void saveInfoData (void)
 Saves the InfoServ database to disk.

void readInfoData (void)
 Loads the InfoServ database from disk.

void sync_cfg (char *type)
 Periodic synchronizations (saves) of various databases.


Variables

RegId top_regnick_idnum
char cryptstr [PASSLEN+2]
 Working crypt variable.

char dbLine [2048]
parse_t state
 Parse state information for reading database files.


Detailed Description

Services database-related procedures.

Procedures for saving/loading the various services database files

Author:
Chip Norkus

Max Byrd

Greg Poma

James Hess

Date:
1996-2001
Id
db.c,v 1.2 2003/08/17 16:13:35 Mysid Exp

Definition in file db.c.


Function Documentation

void AppendBuffer char **  buf,
const char *  add
 

Precondition:
From points to a valid NUL-terminated character array, and add is a reference to a character array to be changed.
Postcondition:
*Buf area is reallocated to contain its present state plus the string specified as 'add'

Definition at line 744 of file stuff.c.

char* dbReadString FILE *  fp  )  [static]
 

Precondition:
fp Points to an open infile in which a multi-line dbString has been reached

Definition at line 113 of file db.c.

References AppendBuffer(), assert, and database_struct::is.

Referenced by readInfoData().

void dbWriteString FILE *  fp,
const char *  istr
[static]
 

Precondition:
fp Points to an open outfile in which a multi-line dbString is to be written. Str points to a valid NUL-terminated character array.

Definition at line 144 of file db.c.

References assert, parse_getarg(), and str_dup().

Referenced by saveInfoData().

void readChanData void   ) 
 

Loads the ChanServ database from disk.

Bug:
XXX verify this works

Definition at line 625 of file db.c.

References addChanAkick(), addChanOp(), cakicklist_struct::added, addRegChan(), CENCRYPT, ChanServ, database_struct::cs, dbLine, fromBase64(), getRegChanData(), getRegNickData(), initRegChanData(), cakicklist_struct::mask, mostchans, caccesslist_struct::nickId, oalloc(), parse_getarg(), cakicklist_struct::reason, sSend(), sshutdown(), state, strncpyzt, caccesslist_struct::uflags, unexpected_eof(), and xorit().

Referenced by main().

void readInfoData void   ) 
 

Loads the InfoServ database from disk.

There was still a crash bug in what was here before... cleaning this up .. allocate memory when it's needed, don't allocate it in the beginning and give it up later if superflous in a linked list load. -Mysidia

Bug:
XXX be nicer here...

Definition at line 1213 of file db.c.

References dbLine, dbReadString(), Newsitem::importance, database_struct::is, is_last_post_time, is_listhead, Newsitem::next, oalloc(), parse_getarg(), SomeNews, sshutdown(), state, strncpyzt, and unexpected_eof().

Referenced by main().

void readMemoData void   ) 
 

Loads the memo database from disk.

Bug:
XXX be nicer here...

Increment the arguments.. we REALLY need to fix the dbs

Increment the argument 1, we need to fix the db

Definition at line 919 of file db.c.

References memoblocklist_struct::blockId, dbLine, DEBUGCHAN, _memolist::flags, _memolist::from, getRegNickData(), LIST_ENTRY_INIT, LIST_INSERT_HEAD, MEMO_UNREAD, MemoServ, _memolist::memotxt, database_struct::ms, memoblocklist_struct::next, oalloc(), parse_getarg(), _memolist::realto, _memolist::sent, sSend(), sshutdown(), state, strncpyzt, _memolist::to, and unexpected_eof().

Referenced by readNickData().

void readNickData void   ) 
 

Loads the NickServ database from disk.

Bug:
XXX make a nicer error here!

Definition at line 262 of file db.c.

References ADD_MEMO_BOX, addAccItem(), addOpData(), addRegNick(), assert, corelog, dbLine, DEBUGCHAN, fromBase64(), getRegNickData(), logDump(), NENCRYPT, database_struct::ns, oalloc(), OROOT, OSERVOP, parse_getarg(), readMemoData(), SetDynBuffer(), sSend(), sshutdown(), state, strncpyzt, unexpected_eof(), and xorit().

Referenced by main().

void readTriggerData void   ) 
 

Loads the clone rule database from disk.

Bug:
XXX be nicer here...

Definition at line 1102 of file db.c.

References AddCrule(), CloneRule, corelog, dbLine, DEBUGCHAN, trigger_rule::flags, trigger_rule::kill_msg, logDump(), trigger_rule::mask, NewCrule(), OperServ, parse_getarg(), sSend(), state, strncpyzt, database_struct::trigger, trigger_rule::trigger, unexpected_eof(), trigger_rule::utrigger, and trigger_rule::warn_msg.

Referenced by main().

void saveInfoData void   ) 
 

Saves the InfoServ database to disk.

Bug:
Huh? Why check for NULL -twice- ?

Definition at line 1177 of file db.c.

References Newsitem::content, corelog, dbWriteString(), Newsitem::from, Newsitem::header, Newsitem::importance, InfoServ, database_struct::is, is_listhead, LOGCHAN, logDump(), myname, Newsitem::next, SomeNews, sSend(), and Newsitem::timestamp.

Referenced by is_save(), and sshutdown().

char * str_dup const char *  input  ) 
 

Allocates and returns a copy of the supplied string.

Parameters:
input String to duplicate

Definition at line 597 of file stuff.c.

void unexpected_eof const char *  file_name  ) 
 

Handle an unexpected EOF in database file error.

Precondition:
file_name points to a valid Zero-terminated character array
Postcondition:
None

Definition at line 101 of file db.c.

References corelog, logDump(), and sshutdown().

Referenced by readChanData(), readInfoData(), readMemoData(), readNickData(), and readTriggerData().


Variable Documentation

char cryptstr[PASSLEN + 2] [static]
 

Working crypt variable.

We'll set it up here as it is used in nearly all the functions

Bug:
This shouldn't necessarily be so global.

Definition at line 78 of file db.c.

Referenced by saveChanData(), and saveNickData().

char dbLine[2048] [static]
 

I don't know what you feel, but I think that having 2048 bytes allocated in static arrays all over is useless.

Definition at line 85 of file db.c.

Referenced by readChanData(), readInfoData(), readMemoData(), readNickData(), and readTriggerData().


Generated at Sat Oct 25 20:56:11 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.