[srvx-commits] CVS: services/src saxdb.h,1.2,1.3 saxdb.c,1.4,1.5 nickserv.c,1.195,1.196 main.c,1.134
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-08-17 14:31:18
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv14316/src
Modified Files:
nickserv.c main.c Makefile.am
Added Files:
saxdb.h saxdb.c
Log Message:
first version of saxdb, including a nickserv.db writer
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -C2 -r1.195 -r1.196
*** nickserv.c 13 Aug 2002 03:04:07 -0000 1.195
--- nickserv.c 17 Aug 2002 14:31:15 -0000 1.196
***************
*** 25,28 ****
--- 25,29 ----
#include "opserv.h"
#include "policer.h"
+ #include "saxdb.h"
#include "sendmail.h"
#include "timeq.h"
***************
*** 2413,2416 ****
--- 2414,2489 ----
}
+ static int
+ nickserv_saxdb_write(struct saxdb_context *ctx) {
+ dict_iterator_t it;
+ struct handle_info *hi;
+ char flags[33];
+
+ for (it = dict_first(nickserv_handle_dict); it; it = iter_next(it)) {
+ hi = iter_data(it);
+ assert(hi->id);
+ saxdb_start_record(ctx, iter_key(it), 0);
+ saxdb_write_int(ctx, KEY_ID, hi->id);
+ saxdb_write_int(ctx, KEY_REGISTER_ON, hi->registered);
+ saxdb_write_int(ctx, KEY_LAST_SEEN, hi->lastseen);
+ saxdb_write_int(ctx, KEY_OPSERV_LEVEL, hi->opserv_level);
+ if (hi->screen_width) saxdb_write_int(ctx, KEY_SCREEN_WIDTH, hi->screen_width);
+ if (hi->table_width) saxdb_write_int(ctx, KEY_TABLE_WIDTH, hi->table_width);
+ saxdb_write_string(ctx, KEY_PASSWD, hi->passwd);
+ flags[0] = hi->userlist_style;
+ flags[1] = 0;
+ saxdb_write_string(ctx, KEY_USERLIST_STYLE, flags);
+ if (hi->infoline) saxdb_write_string(ctx, KEY_INFO, hi->infoline);
+ if (hi->last_authed_host[0]) saxdb_write_string(ctx, KEY_LAST_AUTHED_HOST, hi->last_authed_host);
+ if (hi->email_addr) saxdb_write_string(ctx, KEY_EMAIL_ADDR, hi->email_addr);
+ if (hi->epithet) saxdb_write_string(ctx, KEY_EPITHET, hi->epithet);
+ if (hi->announcements != '?') {
+ flags[0] = hi->announcements;
+ flags[1] = 0;
+ saxdb_write_string(ctx, KEY_ANNOUNCEMENTS, flags);
+ }
+ if (hi->flags) {
+ int ii, flen;
+
+ for (ii=flen=0; handle_flags[ii]; ++ii) {
+ if (hi->flags & (1 << ii)) flags[flen++] = handle_flags[ii];
+ }
+ flags[flen] = 0;
+ saxdb_write_string(ctx, KEY_FLAGS, flags);
+ }
+ if (hi->masks->used) saxdb_write_string_list(ctx, KEY_MASKS, hi->masks);
+ if (hi->nicks) {
+ struct string_list *slist;
+ struct nick_info *ni;
+
+ slist = alloc_string_list(nickserv_conf.nicks_per_handle);
+ for (ni = hi->nicks; ni; ni = ni->next) string_list_append(slist, ni->nick);
+ saxdb_write_string_list(ctx, KEY_NICKS, slist);
+ free(slist->list);
+ free(slist);
+ }
+ if (hi->cookie) {
+ struct handle_cookie *cookie = hi->cookie;
+ char *type;
+
+ saxdb_start_record(ctx, KEY_COOKIE, 0);
+ switch (cookie->type) {
+ case ACTIVATION: type = KEY_ACTIVATION; break;
+ case PASSWORD_CHANGE: type = KEY_PASSWORD_CHANGE; break;
+ case EMAIL_CHANGE: type = KEY_EMAIL_CHANGE; break;
+ case ALLOWAUTH: type = KEY_ALLOWAUTH; break;
+ default: type = NULL; break;
+ }
+ if (type) saxdb_write_string(ctx, KEY_COOKIE_TYPE, type);
+ saxdb_write_int(ctx, KEY_COOKIE_EXPIRES, cookie->expires);
+ if (cookie->data) saxdb_write_string(ctx, KEY_COOKIE_DATA, cookie->data);
+ saxdb_write_string(ctx, KEY_COOKIE, cookie->cookie);
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+ }
+ return 0;
+ }
+
void
nickserv_timed_write(void *data)
***************
*** 2930,2933 ****
--- 3003,3012 ----
}
+ static int
+ nickserv_saxdb_read(dict_t db) {
+ (void)db;
+ return 0;
+ }
+
static NICKSERV_FUNC(cmd_mergedb)
{
***************
*** 3318,3321 ****
--- 3397,3401 ----
nickserv_db_read(NICKSERV_DB_NAME);
+ saxdb_register("NickServ", nickserv_saxdb_read, nickserv_saxdb_write);
if(nickserv_conf.db_backup_frequency) timeq_add(now + nickserv_conf.db_backup_frequency, nickserv_timed_write, NULL);
Index: main.c
===================================================================
RCS file: /cvsroot/srvx/services/src/main.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -r1.134 -r1.135
*** main.c 17 Aug 2002 14:24:42 -0000 1.134
--- main.c 17 Aug 2002 14:31:15 -0000 1.135
***************
*** 49,52 ****
--- 49,53 ----
#include "modcmd.h"
#include "policer.h"
+ #include "saxdb.h"
#include "sendmail.h"
#include "timeq.h"
***************
*** 797,800 ****
--- 798,802 ----
modcmd_init();
+ saxdb_init();
timeq_init();
sendmail_init();
***************
*** 807,810 ****
--- 809,813 ----
modules_init();
modcmd_finalize();
+ saxdb_finalize();
if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n");
Index: Makefile.am
===================================================================
RCS file: /cvsroot/srvx/services/src/Makefile.am,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -r1.54 -r1.55
*** Makefile.am 17 Aug 2002 14:24:41 -0000 1.54
--- Makefile.am 17 Aug 2002 14:31:15 -0000 1.55
***************
*** 37,40 ****
--- 37,41 ----
proto.h \
recdb.c recdb.h \
+ saxdb.c saxdb.h \
sendmail.c sendmail.h \
sockcheck.c sockcheck.h \
|