diff options
Diffstat (limited to 'src/sessions.c')
-rw-r--r-- | src/sessions.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/sessions.c b/src/sessions.c index 1372ba1a0..934e3bc3f 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -305,100 +305,6 @@ Exception *find_hostip_exception(const char *host, const char *hostip) return NULL; } -/*************************************************************************/ -/*********************** Exception Load/Save *****************************/ -/*************************************************************************/ - -#define SAFE(x) do { \ - if ((x) < 0) { \ - if (!forceload) \ - fatal("Read error on %s", Config.ExceptionDBName); \ - nexceptions = i; \ - break; \ - } \ -} while (0) - -void load_exceptions() -{ - dbFILE *f; - int i; - uint16 n; - uint16 tmp16; - uint32 tmp32; - - if (! - (f = open_db(Config.s_OperServ, Config.ExceptionDBName, "r", EXCEPTION_VERSION))) - return; - switch (i = get_file_version(f)) { - case 9: - case 8: - case 7: - SAFE(read_int16(&n, f)); - nexceptions = n; - exceptions = static_cast<Exception *>(scalloc(sizeof(Exception) * nexceptions, 1)); - if (!nexceptions) { - close_db(f); - return; - } - for (i = 0; i < nexceptions; i++) { - SAFE(read_string(&exceptions[i].mask, f)); - SAFE(read_int16(&tmp16, f)); - exceptions[i].limit = tmp16; - SAFE(read_buffer(exceptions[i].who, f)); - SAFE(read_string(&exceptions[i].reason, f)); - SAFE(read_int32(&tmp32, f)); - exceptions[i].time = tmp32; - SAFE(read_int32(&tmp32, f)); - exceptions[i].expires = tmp32; - } - break; - - default: - fatal("Unsupported version (%d) on %s", i, Config.ExceptionDBName); - } /* switch (ver) */ - - close_db(f); -} - -#undef SAFE - -/*************************************************************************/ - -#define SAFE(x) do { \ - if ((x) < 0) { \ - restore_db(f); \ - log_perror("Write error on %s", Config.ExceptionDBName); \ - if (time(NULL) - lastwarn > Config.WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", Config.ExceptionDBName, \ - strerror(errno)); \ - lastwarn = time(NULL); \ - } \ - return; \ - } \ -} while (0) - -void save_exceptions() -{ - dbFILE *f; - int i; - static time_t lastwarn = 0; - - if (! - (f = open_db(Config.s_OperServ, Config.ExceptionDBName, "w", EXCEPTION_VERSION))) - return; - SAFE(write_int16(nexceptions, f)); - for (i = 0; i < nexceptions; i++) { - SAFE(write_string(exceptions[i].mask, f)); - SAFE(write_int16(static_cast<uint16>(exceptions[i].limit), f)); - SAFE(write_buffer(exceptions[i].who, f)); - SAFE(write_string(exceptions[i].reason, f)); - SAFE(write_int32(exceptions[i].time, f)); - SAFE(write_int32(exceptions[i].expires, f)); - } - close_db(f); -} - -#undef SAFE /*************************************************************************/ /************************ Exception Manipulation *************************/ |