summaryrefslogtreecommitdiff
path: root/src/operserv.c
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-14 20:57:20 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-14 20:57:20 +0000
commit6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch)
tree91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/operserv.c
parent069409cd99cf78ab8bf87a1fe69a833576414fd3 (diff)
Insane commit of doom: s/ \t/g
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/operserv.c')
-rw-r--r--src/operserv.c2438
1 files changed, 1219 insertions, 1219 deletions
diff --git a/src/operserv.c b/src/operserv.c
index a32ca46e3..20e63a41b 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -27,9 +27,9 @@ SList akills, sglines, sqlines, szlines;
/*************************************************************************/
static int compare_adminlist_entries(SList * slist, void *item1,
- void *item2);
+ void *item2);
static int compare_operlist_entries(SList * slist, void *item1,
- void *item2);
+ void *item2);
static void free_adminlist_entry(SList * slist, void *item);
static void free_operlist_entry(SList * slist, void *item);
@@ -46,13 +46,13 @@ time_t DefContimer;
int DefConModesSet = 0;
char *defconReverseModes(const char *modes);
-uint32 DefConModesOn; /* Modes to be enabled during DefCon */
-uint32 DefConModesOff; /* Modes to be disabled during DefCon */
-ChannelInfo DefConModesCI; /* ChannelInfo containg params for locked modes
- * during DefCon; I would've done this nicer if i
- * could, but all damn mode functions require a
- * ChannelInfo struct! --gdex
- */
+uint32 DefConModesOn; /* Modes to be enabled during DefCon */
+uint32 DefConModesOff; /* Modes to be disabled during DefCon */
+ChannelInfo DefConModesCI; /* ChannelInfo containg params for locked modes
+ * during DefCon; I would've done this nicer if i
+ * could, but all damn mode functions require a
+ * ChannelInfo struct! --gdex
+ */
void moduleAddOperServCmds(void);
@@ -61,14 +61,14 @@ void moduleAddOperServCmds(void);
/* Options for the lists */
SListOpts akopts = { 0, NULL, &is_akill_entry_equal, &free_akill_entry };
SListOpts saopts = { SLISTF_SORT, &compare_adminlist_entries, NULL,
- &free_adminlist_entry
+ &free_adminlist_entry
};
SListOpts sgopts = { 0, NULL, &is_sgline_entry_equal, &free_sgline_entry };
SListOpts soopts =
- { SLISTF_SORT, &compare_operlist_entries, NULL, &free_operlist_entry };
+ { SLISTF_SORT, &compare_operlist_entries, NULL, &free_operlist_entry };
SListOpts sqopts =
- { SLISTF_SORT, NULL, &is_sqline_entry_equal, &free_sqline_entry };
+ { SLISTF_SORT, NULL, &is_sqline_entry_equal, &free_sqline_entry };
SListOpts szopts = { 0, NULL, &is_szline_entry_equal, &free_szline_entry };
/*************************************************************************/
@@ -85,29 +85,29 @@ void moduleAddOperServCmds(void) {
void os_init(void)
{
- moduleAddOperServCmds();
-
- /* Initialization of the lists */
- slist_init(&servadmins);
- servadmins.opts = &saopts;
- slist_init(&servopers);
- servopers.opts = &soopts;
-
- slist_init(&akills);
- akills.opts = &akopts;
-
- if (ircd->sgline) {
- slist_init(&sglines);
- sglines.opts = &sgopts;
- }
- if (ircd->sqline) {
- slist_init(&sqlines);
- sqlines.opts = &sqopts;
- }
- if (ircd->szline) {
- slist_init(&szlines);
- szlines.opts = &szopts;
- }
+ moduleAddOperServCmds();
+
+ /* Initialization of the lists */
+ slist_init(&servadmins);
+ servadmins.opts = &saopts;
+ slist_init(&servopers);
+ servopers.opts = &soopts;
+
+ slist_init(&akills);
+ akills.opts = &akopts;
+
+ if (ircd->sgline) {
+ slist_init(&sglines);
+ sglines.opts = &sgopts;
+ }
+ if (ircd->sqline) {
+ slist_init(&sqlines);
+ sqlines.opts = &sqopts;
+ }
+ if (ircd->szline) {
+ slist_init(&szlines);
+ szlines.opts = &szopts;
+ }
}
/*************************************************************************/
@@ -116,22 +116,22 @@ void os_init(void)
void operserv(User * u, char *buf)
{
- const char *cmd;
- const char *s;
-
- alog("%s: %s: %s", s_OperServ, u->nick, buf);
-
- cmd = strtok(buf, " ");
- if (!cmd) {
- return;
- } else if (stricmp(cmd, "\1PING") == 0) {
- if (!(s = strtok(NULL, ""))) {
- s = "";
- }
- ircdproto->SendCTCP(findbot(s_OperServ), u->nick, "PING %s", s);
- } else {
- mod_run_cmd(s_OperServ, u, OPERSERV, cmd);
- }
+ const char *cmd;
+ const char *s;
+
+ alog("%s: %s: %s", s_OperServ, u->nick, buf);
+
+ cmd = strtok(buf, " ");
+ if (!cmd) {
+ return;
+ } else if (stricmp(cmd, "\1PING") == 0) {
+ if (!(s = strtok(NULL, ""))) {
+ s = "";
+ }
+ ircdproto->SendCTCP(findbot(s_OperServ), u->nick, "PING %s", s);
+ } else {
+ mod_run_cmd(s_OperServ, u, OPERSERV, cmd);
+ }
}
/*************************************************************************/
@@ -141,111 +141,111 @@ void operserv(User * u, char *buf)
/* Load old AKILL data. */
#define SAFE(x) do { \
- if ((x) < 0) { \
+ if ((x) < 0) { \
if (!forceload) \
- fatal("Read error on %s", AutokillDBName); \
+ fatal("Read error on %s", AutokillDBName); \
break; \
- } \
+ } \
} while (0)
static void load_old_akill(void)
{
- dbFILE *f;
- int i, j;
- uint16 tmp16;
- uint32 tmp32;
- char buf[NICKMAX], mask2[BUFSIZE], *mask, *s;
- Akill *ak, *entry;
-
- if (!
- (f =
- open_db("AKILL", AutokillDBName ? AutokillDBName : "akill.db",
- "r", 9)))
- return;
-
- get_file_version(f);
-
- read_int16(&tmp16, f);
- slist_setcapacity(&akills, tmp16);
-
- for (j = 0; j < akills.capacity; j++) {
- ak = (Akill *)scalloc(sizeof(Akill), 1);
-
- SAFE(read_string(&mask, f));
- s = strchr(mask, '@');
- *s = 0;
- s++;
- ak->user = sstrdup(mask);
- ak->host = sstrdup(s);
- SAFE(read_string(&ak->reason, f));
- SAFE(read_buffer(buf, f));
- if (!*buf)
- ak->by = sstrdup("<unknown>");
- else
- ak->by = sstrdup(buf);
- SAFE(read_int32(&tmp32, f));
- ak->seton = tmp32 ? tmp32 : time(NULL);
- SAFE(read_int32(&tmp32, f));
- ak->expires = tmp32;
-
- /* Sanity checks *sigh* */
-
- /* No nicknames allowed! */
- if (strchr(ak->user, '!')) {
- ircdproto->SendAkillDel(ak->user, ak->host);
- free(ak);
- continue;
- }
-
- snprintf(mask2, sizeof(mask2), "%s@%s", ak->user, ak->host);
-
- /* Is the mask already in the AKILL list? */
- if (slist_indexof(&akills, mask2) != -1) {
- free(ak);
- continue;
- }
-
- /* Checks whether there is an AKILL that already covers
- * the one we want to add, and whether there are AKILLs
- * that would be covered by this one. Expiry time
- * does *also* matter.
- */
-
- if (akills.count > 0) {
-
- for (i = akills.count - 1; i >= 0; i--) {
-
- char amask[BUFSIZE];
-
- entry = (Akill *)akills.list[i];
-
- if (!entry)
- continue;
-
- snprintf(amask, sizeof(amask), "%s@%s", entry->user,
- entry->host);
-
- if (match_wild_nocase(amask, mask2)
- && (entry->expires >= ak->expires
- || entry->expires == 0)) {
- ircdproto->SendAkillDel(ak->user, ak->host);
- free(ak);
- ak = NULL;
- break;
- }
-
- if (match_wild_nocase(mask2, amask)
- && (entry->expires <= ak->expires || ak->expires == 0))
- slist_delete(&akills, i);
- }
-
- }
-
- if (ak)
- slist_add(&akills, ak);
- }
-
- close_db(f);
+ dbFILE *f;
+ int i, j;
+ uint16 tmp16;
+ uint32 tmp32;
+ char buf[NICKMAX], mask2[BUFSIZE], *mask, *s;
+ Akill *ak, *entry;
+
+ if (!
+ (f =
+ open_db("AKILL", AutokillDBName ? AutokillDBName : "akill.db",
+ "r", 9)))
+ return;
+
+ get_file_version(f);
+
+ read_int16(&tmp16, f);
+ slist_setcapacity(&akills, tmp16);
+
+ for (j = 0; j < akills.capacity; j++) {
+ ak = (Akill *)scalloc(sizeof(Akill), 1);
+
+ SAFE(read_string(&mask, f));
+ s = strchr(mask, '@');
+ *s = 0;
+ s++;
+ ak->user = sstrdup(mask);
+ ak->host = sstrdup(s);
+ SAFE(read_string(&ak->reason, f));
+ SAFE(read_buffer(buf, f));
+ if (!*buf)
+ ak->by = sstrdup("<unknown>");
+ else
+ ak->by = sstrdup(buf);
+ SAFE(read_int32(&tmp32, f));
+ ak->seton = tmp32 ? tmp32 : time(NULL);
+ SAFE(read_int32(&tmp32, f));
+ ak->expires = tmp32;
+
+ /* Sanity checks *sigh* */
+
+ /* No nicknames allowed! */
+ if (strchr(ak->user, '!')) {
+ ircdproto->SendAkillDel(ak->user, ak->host);
+ free(ak);
+ continue;
+ }
+
+ snprintf(mask2, sizeof(mask2), "%s@%s", ak->user, ak->host);
+
+ /* Is the mask already in the AKILL list? */
+ if (slist_indexof(&akills, mask2) != -1) {
+ free(ak);
+ continue;
+ }
+
+ /* Checks whether there is an AKILL that already covers
+ * the one we want to add, and whether there are AKILLs
+ * that would be covered by this one. Expiry time
+ * does *also* matter.
+ */
+
+ if (akills.count > 0) {
+
+ for (i = akills.count - 1; i >= 0; i--) {
+
+ char amask[BUFSIZE];
+
+ entry = (Akill *)akills.list[i];
+
+ if (!entry)
+ continue;
+
+ snprintf(amask, sizeof(amask), "%s@%s", entry->user,
+ entry->host);
+
+ if (match_wild_nocase(amask, mask2)
+ && (entry->expires >= ak->expires
+ || entry->expires == 0)) {
+ ircdproto->SendAkillDel(ak->user, ak->host);
+ free(ak);
+ ak = NULL;
+ break;
+ }
+
+ if (match_wild_nocase(mask2, amask)
+ && (entry->expires <= ak->expires || ak->expires == 0))
+ slist_delete(&akills, i);
+ }
+
+ }
+
+ if (ak)
+ slist_add(&akills, ak);
+ }
+
+ close_db(f);
}
#undef SAFE
@@ -253,148 +253,148 @@ static void load_old_akill(void)
/* Load OperServ data. */
#define SAFE(x) do { \
- if ((x) < 0) { \
+ if ((x) < 0) { \
if (!forceload) \
- fatal("Read error on %s", OperDBName); \
+ fatal("Read error on %s", OperDBName); \
failed = 1; \
break; \
- } \
+ } \
} while (0)
void load_os_dbase(void)
{
- dbFILE *f;
- int16 i, ver;
- uint16 tmp16, n;
- uint32 tmp32;
- char *s;
- int failed = 0;
-
- if (!(f = open_db(s_OperServ, OperDBName, "r", OPER_VERSION)))
- return;
-
- ver = get_file_version(f);
-
- if (ver <= 9) {
- NickAlias *na;
-
- SAFE(read_int16(&n, f));
- for (i = 0; i < n && !failed; i++) {
- SAFE(read_string(&s, f));
- if (s) {
- na = findnick(s);
- if (na) {
- na->nc->flags |= NI_SERVICES_ADMIN;
- if (slist_indexof(&servadmins, na) == -1)
- slist_add(&servadmins, na);
- }
- free(s);
- }
- }
- if (!failed)
- SAFE(read_int16(&n, f));
- for (i = 0; i < n && !failed; i++) {
- SAFE(read_string(&s, f));
- if (s) {
- na = findnick(s);
- if (na) {
- na->nc->flags |= NI_SERVICES_OPER;
- if (slist_indexof(&servopers, na) == -1)
- slist_add(&servopers, na);
- }
- free(s);
- }
- }
- }
-
- if (ver >= 7) {
- SAFE(read_int32(&maxusercnt, f));
- SAFE(read_int32(&tmp32, f));
- maxusertime = tmp32;
- }
-
- if (ver <= 10)
- load_old_akill();
- else {
- Akill *ak;
-
- read_int16(&tmp16, f);
- slist_setcapacity(&akills, tmp16);
-
- for (i = 0; i < akills.capacity; i++) {
- ak = (Akill *)scalloc(sizeof(Akill), 1);
-
- SAFE(read_string(&ak->user, f));
- SAFE(read_string(&ak->host, f));
- SAFE(read_string(&ak->by, f));
- SAFE(read_string(&ak->reason, f));
- SAFE(read_int32(&tmp32, f));
- ak->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- ak->expires = tmp32;
-
- slist_add(&akills, ak);
- }
- }
-
- if (ver >= 11) {
- SXLine *sx;
-
- read_int16(&tmp16, f);
- slist_setcapacity(&sglines, tmp16);
-
- for (i = 0; i < sglines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
-
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
-
- slist_add(&sglines, sx);
- }
-
- if (ver >= 13) {
- read_int16(&tmp16, f);
- slist_setcapacity(&sqlines, tmp16);
-
- for (i = 0; i < sqlines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
-
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
-
- slist_add(&sqlines, sx);
- }
- }
-
- read_int16(&tmp16, f);
- slist_setcapacity(&szlines, tmp16);
-
- for (i = 0; i < szlines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
-
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
-
- slist_add(&szlines, sx);
- }
- }
-
- close_db(f);
+ dbFILE *f;
+ int16 i, ver;
+ uint16 tmp16, n;
+ uint32 tmp32;
+ char *s;
+ int failed = 0;
+
+ if (!(f = open_db(s_OperServ, OperDBName, "r", OPER_VERSION)))
+ return;
+
+ ver = get_file_version(f);
+
+ if (ver <= 9) {
+ NickAlias *na;
+
+ SAFE(read_int16(&n, f));
+ for (i = 0; i < n && !failed; i++) {
+ SAFE(read_string(&s, f));
+ if (s) {
+ na = findnick(s);
+ if (na) {
+ na->nc->flags |= NI_SERVICES_ADMIN;
+ if (slist_indexof(&servadmins, na) == -1)
+ slist_add(&servadmins, na);
+ }
+ free(s);
+ }
+ }
+ if (!failed)
+ SAFE(read_int16(&n, f));
+ for (i = 0; i < n && !failed; i++) {
+ SAFE(read_string(&s, f));
+ if (s) {
+ na = findnick(s);
+ if (na) {
+ na->nc->flags |= NI_SERVICES_OPER;
+ if (slist_indexof(&servopers, na) == -1)
+ slist_add(&servopers, na);
+ }
+ free(s);
+ }
+ }
+ }
+
+ if (ver >= 7) {
+ SAFE(read_int32(&maxusercnt, f));
+ SAFE(read_int32(&tmp32, f));
+ maxusertime = tmp32;
+ }
+
+ if (ver <= 10)
+ load_old_akill();
+ else {
+ Akill *ak;
+
+ read_int16(&tmp16, f);
+ slist_setcapacity(&akills, tmp16);
+
+ for (i = 0; i < akills.capacity; i++) {
+ ak = (Akill *)scalloc(sizeof(Akill), 1);
+
+ SAFE(read_string(&ak->user, f));
+ SAFE(read_string(&ak->host, f));
+ SAFE(read_string(&ak->by, f));
+ SAFE(read_string(&ak->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ ak->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ ak->expires = tmp32;
+
+ slist_add(&akills, ak);
+ }
+ }
+
+ if (ver >= 11) {
+ SXLine *sx;
+
+ read_int16(&tmp16, f);
+ slist_setcapacity(&sglines, tmp16);
+
+ for (i = 0; i < sglines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
+
+ slist_add(&sglines, sx);
+ }
+
+ if (ver >= 13) {
+ read_int16(&tmp16, f);
+ slist_setcapacity(&sqlines, tmp16);
+
+ for (i = 0; i < sqlines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
+
+ slist_add(&sqlines, sx);
+ }
+ }
+
+ read_int16(&tmp16, f);
+ slist_setcapacity(&szlines, tmp16);
+
+ for (i = 0; i < szlines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
+
+ slist_add(&szlines, sx);
+ }
+ }
+
+ close_db(f);
}
@@ -405,77 +405,77 @@ void load_os_dbase(void)
/* Save OperServ data. */
#define SAFE(x) do { \
- if ((x) < 0) { \
+ if ((x) < 0) { \
restore_db(f); \
log_perror("Write error on %s", OperDBName); \
if (time(NULL) - lastwarn > WarningTimeout) { \
- ircdproto->SendGlobops(NULL, "Write error on %s: %s", OperDBName, \
+ ircdproto->SendGlobops(NULL, "Write error on %s: %s", OperDBName, \
strerror(errno)); \
- lastwarn = time(NULL); \
+ lastwarn = time(NULL); \
} \
return; \
- } \
+ } \
} while (0)
void save_os_dbase(void)
{
- int i;
- dbFILE *f;
- static time_t lastwarn = 0;
- Akill *ak;
- SXLine *sx;
-
- if (!(f = open_db(s_OperServ, OperDBName, "w", OPER_VERSION)))
- return;
- SAFE(write_int32(maxusercnt, f));
- SAFE(write_int32(maxusertime, f));
-
- SAFE(write_int16(akills.count, f));
- for (i = 0; i < akills.count; i++) {
- ak = (Akill *)akills.list[i];
-
- SAFE(write_string(ak->user, f));
- SAFE(write_string(ak->host, f));
- SAFE(write_string(ak->by, f));
- SAFE(write_string(ak->reason, f));
- SAFE(write_int32(ak->seton, f));
- SAFE(write_int32(ak->expires, f));
- }
-
- SAFE(write_int16(sglines.count, f));
- for (i = 0; i < sglines.count; i++) {
- sx = (SXLine *)sglines.list[i];
-
- SAFE(write_string(sx->mask, f));
- SAFE(write_string(sx->by, f));
- SAFE(write_string(sx->reason, f));
- SAFE(write_int32(sx->seton, f));
- SAFE(write_int32(sx->expires, f));
- }
-
- SAFE(write_int16(sqlines.count, f));
- for (i = 0; i < sqlines.count; i++) {
- sx = (SXLine *)sqlines.list[i];
-
- SAFE(write_string(sx->mask, f));
- SAFE(write_string(sx->by, f));
- SAFE(write_string(sx->reason, f));
- SAFE(write_int32(sx->seton, f));
- SAFE(write_int32(sx->expires, f));
- }
-
- SAFE(write_int16(szlines.count, f));
- for (i = 0; i < szlines.count; i++) {
- sx = (SXLine *)szlines.list[i];
-
- SAFE(write_string(sx->mask, f));
- SAFE(write_string(sx->by, f));
- SAFE(write_string(sx->reason, f));
- SAFE(write_int32(sx->seton, f));
- SAFE(write_int32(sx->expires, f));
- }
-
- close_db(f);
+ int i;
+ dbFILE *f;
+ static time_t lastwarn = 0;
+ Akill *ak;
+ SXLine *sx;
+
+ if (!(f = open_db(s_OperServ, OperDBName, "w", OPER_VERSION)))
+ return;
+ SAFE(write_int32(maxusercnt, f));
+ SAFE(write_int32(maxusertime, f));
+
+ SAFE(write_int16(akills.count, f));
+ for (i = 0; i < akills.count; i++) {
+ ak = (Akill *)akills.list[i];
+
+ SAFE(write_string(ak->user, f));
+ SAFE(write_string(ak->host, f));
+ SAFE(write_string(ak->by, f));
+ SAFE(write_string(ak->reason, f));
+ SAFE(write_int32(ak->seton, f));
+ SAFE(write_int32(ak->expires, f));
+ }
+
+ SAFE(write_int16(sglines.count, f));
+ for (i = 0; i < sglines.count; i++) {
+ sx = (SXLine *)sglines.list[i];
+
+ SAFE(write_string(sx->mask, f));
+ SAFE(write_string(sx->by, f));
+ SAFE(write_string(sx->reason, f));
+ SAFE(write_int32(sx->seton, f));
+ SAFE(write_int32(sx->expires, f));
+ }
+
+ SAFE(write_int16(sqlines.count, f));
+ for (i = 0; i < sqlines.count; i++) {
+ sx = (SXLine *)sqlines.list[i];
+
+ SAFE(write_string(sx->mask, f));
+ SAFE(write_string(sx->by, f));
+ SAFE(write_string(sx->reason, f));
+ SAFE(write_int32(sx->seton, f));
+ SAFE(write_int32(sx->expires, f));
+ }
+
+ SAFE(write_int16(szlines.count, f));
+ for (i = 0; i < szlines.count; i++) {
+ sx = (SXLine *)szlines.list[i];
+
+ SAFE(write_string(sx->mask, f));
+ SAFE(write_string(sx->by, f));
+ SAFE(write_string(sx->reason, f));
+ SAFE(write_int32(sx->seton, f));
+ SAFE(write_int32(sx->expires, f));
+ }
+
+ close_db(f);
}
@@ -487,8 +487,8 @@ void save_os_dbase(void)
void os_remove_nick(NickCore * nc)
{
- slist_remove(&servadmins, nc);
- slist_remove(&servopers, nc);
+ slist_remove(&servadmins, nc);
+ slist_remove(&servopers, nc);
}
/*************************************************************************/
@@ -498,12 +498,12 @@ void os_remove_nick(NickCore * nc)
int is_services_root(User * u)
{
- if ((NSStrictPrivileges && !is_oper(u))
- || (!nick_identified(u)))
- return 0;
- if ((u->na->nc->flags & NI_SERVICES_ROOT))
- return 1;
- return 0;
+ if ((NSStrictPrivileges && !is_oper(u))
+ || (!nick_identified(u)))
+ return 0;
+ if ((u->na->nc->flags & NI_SERVICES_ROOT))
+ return 1;
+ return 0;
}
/*************************************************************************/
@@ -512,12 +512,12 @@ int is_services_root(User * u)
int is_services_admin(User * u)
{
- if ((NSStrictPrivileges && !is_oper(u))
- || (!nick_identified(u)))
- return 0;
- if ((u->na->nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT)))
- return 1;
- return 0;
+ if ((NSStrictPrivileges && !is_oper(u))
+ || (!nick_identified(u)))
+ return 0;
+ if ((u->na->nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT)))
+ return 1;
+ return 0;
}
/*************************************************************************/
@@ -526,14 +526,14 @@ int is_services_admin(User * u)
int is_services_oper(User * u)
{
- if ((NSStrictPrivileges && !is_oper(u))
- || (!nick_identified(u)))
- return 0;
- if ((u->na->nc->
- flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN |
- NI_SERVICES_ROOT)))
- return 1;
- return 0;
+ if ((NSStrictPrivileges && !is_oper(u))
+ || (!nick_identified(u)))
+ return 0;
+ if ((u->na->nc->
+ flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN |
+ NI_SERVICES_ROOT)))
+ return 1;
+ return 0;
}
/*************************************************************************/
@@ -542,11 +542,11 @@ int is_services_oper(User * u)
int nick_is_services_root(NickCore * nc)
{
- if (nc) {
- if (nc->flags & (NI_SERVICES_ROOT))
- return 1;
- }
- return 0;
+ if (nc) {
+ if (nc->flags & (NI_SERVICES_ROOT))
+ return 1;
+ }
+ return 0;
}
/*************************************************************************/
@@ -555,11 +555,11 @@ int nick_is_services_root(NickCore * nc)
int nick_is_services_admin(NickCore * nc)
{
- if (nc) {
- if (nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT))
- return 1;
- }
- return 0;
+ if (nc) {
+ if (nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT))
+ return 1;
+ }
+ return 0;
}
/*************************************************************************/
@@ -568,13 +568,13 @@ int nick_is_services_admin(NickCore * nc)
int nick_is_services_oper(NickCore * nc)
{
- if (nc) {
- if (nc->
- flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN |
- NI_SERVICES_ROOT))
- return 1;
- }
- return 0;
+ if (nc) {
+ if (nc->
+ flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN |
+ NI_SERVICES_ROOT))
+ return 1;
+ }
+ return 0;
}
@@ -587,44 +587,44 @@ int nick_is_services_oper(NickCore * nc)
Server *server_global(Server * s, char *msg)
{
- Server *sl;
-
- while (s) {
- /* Do not send the notice to ourselves our juped servers */
- if (!(s->flags & (SERVER_ISME | SERVER_JUPED)))
- notice_server(s_GlobalNoticer, s, "%s", msg);
-
- if (s->links) {
- sl = server_global(s->links, msg);
- if (sl)
- s = sl;
- else
- s = s->next;
- } else {
- s = s->next;
- }
- }
- return s;
+ Server *sl;
+
+ while (s) {
+ /* Do not send the notice to ourselves our juped servers */
+ if (!(s->flags & (SERVER_ISME | SERVER_JUPED)))
+ notice_server(s_GlobalNoticer, s, "%s", msg);
+
+ if (s->links) {
+ sl = server_global(s->links, msg);
+ if (sl)
+ s = sl;
+ else
+ s = s->next;
+ } else {
+ s = s->next;
+ }
+ }
+ return s;
}
void oper_global(char *nick, const char *fmt, ...)
{
- va_list args;
- char msg[2048]; /* largest valid message is 512, this should cover any global */
- char dmsg[2048]; /* largest valid message is 512, this should cover any global */
-
- va_start(args, fmt);
- vsnprintf(msg, sizeof(msg), fmt, args);
- va_end(args);
-
- /* I don't like the way this is coded... */
- if ((nick) && (!AnonymousGlobal)) {
- snprintf(dmsg, sizeof(dmsg), "[%s] %s", nick, msg);
- server_global(servlist, dmsg);
- } else {
- server_global(servlist, msg);
- }
+ va_list args;
+ char msg[2048]; /* largest valid message is 512, this should cover any global */
+ char dmsg[2048]; /* largest valid message is 512, this should cover any global */
+
+ va_start(args, fmt);
+ vsnprintf(msg, sizeof(msg), fmt, args);
+ va_end(args);
+
+ /* I don't like the way this is coded... */
+ if ((nick) && (!AnonymousGlobal)) {
+ snprintf(dmsg, sizeof(dmsg), "[%s] %s", nick, msg);
+ server_global(servlist, dmsg);
+ } else {
+ server_global(servlist, msg);
+ }
}
@@ -640,209 +640,209 @@ void oper_global(char *nick, const char *fmt, ...)
*/
int add_akill(User * u, char *mask, const char *by, const time_t expires,
- const char *reason)
+ const char *reason)
{
- int deleted = 0, i;
- char *user, *mask2, *host;
- Akill *entry;
-
- if (!mask) {
- return -1;
- }
-
- /* Checks whether there is an AKILL that already covers
- * the one we want to add, and whether there are AKILLs
- * that would be covered by this one. The masks AND the
- * expiry times are used to determine this, because some
- * AKILLs may become useful when another one expires.
- * If so, warn the user in the first case and cleanup
- * the useless AKILLs in the second.
- */
-
- if (akills.count > 0) {
-
- for (i = akills.count - 1; i >= 0; i--) {
- char amask[BUFSIZE];
-
- entry = (Akill *)akills.list[i];
-
- if (!entry)
- continue;
-
- snprintf(amask, sizeof(amask), "%s@%s", entry->user,
- entry->host);
-
- if (!stricmp(amask, mask)) {
- /* We change the AKILL expiry time if its current one is less than the new.
- * This is preferable to be sure we don't change an important AKILL
- * accidentely.
- */
- if (entry->expires >= expires || entry->expires == 0) {
- if (u)
- notice_lang(s_OperServ, u, OPER_AKILL_EXISTS,
- mask);
- return -1;
- } else {
- entry->expires = expires;
- if (u)
- notice_lang(s_OperServ, u, OPER_AKILL_CHANGED,
- amask);
- return -2;
- }
- }
-
- if (match_wild_nocase(amask, mask)
- && (entry->expires >= expires || entry->expires == 0)) {
- if (u)
- notice_lang(s_OperServ, u, OPER_AKILL_ALREADY_COVERED,
- mask, amask);
- return -1;
- }
-
- if (match_wild_nocase(mask, amask)
- && (entry->expires <= expires || expires == 0)) {
- slist_delete(&akills, i);
- deleted++;
- }
- }
-
- }
-
- /* We can now check whether the list is full or not. */
- if (slist_full(&akills)) {
- if (u)
- notice_lang(s_OperServ, u, OPER_AKILL_REACHED_LIMIT,
- akills.limit);
- return -1;
- }
-
- /* We can now (really) add the AKILL. */
- mask2 = sstrdup(mask);
- host = strchr(mask2, '@');
-
- if (!host) {
- free(mask2);
- return -1;
- }
-
- user = mask2;
- *host = 0;
- host++;
-
- entry = (Akill *)scalloc(sizeof(Akill), 1);
-
- if (!entry) {
- free(mask2);
- return -1;
- }
-
- entry->user = sstrdup(user);
- entry->host = sstrdup(host);
- entry->by = sstrdup(by);
- entry->reason = sstrdup(reason);
- entry->seton = time(NULL);
- entry->expires = expires;
-
- slist_add(&akills, entry);
-
- if (AkillOnAdd)
- ircdproto->SendAkill(entry->user, entry->host, entry->by, entry->seton,
- entry->expires, entry->reason);
-
- free(mask2);
-
- return deleted;
+ int deleted = 0, i;
+ char *user, *mask2, *host;
+ Akill *entry;
+
+ if (!mask) {
+ return -1;
+ }
+
+ /* Checks whether there is an AKILL that already covers
+ * the one we want to add, and whether there are AKILLs
+ * that would be covered by this one. The masks AND the
+ * expiry times are used to determine this, because some
+ * AKILLs may become useful when another one expires.
+ * If so, warn the user in the first case and cleanup
+ * the useless AKILLs in the second.
+ */
+
+ if (akills.count > 0) {
+
+ for (i = akills.count - 1; i >= 0; i--) {
+ char amask[BUFSIZE];
+
+ entry = (Akill *)akills.list[i];
+
+ if (!entry)
+ continue;
+
+ snprintf(amask, sizeof(amask), "%s@%s", entry->user,
+ entry->host);
+
+ if (!stricmp(amask, mask)) {
+ /* We change the AKILL expiry time if its current one is less than the new.
+ * This is preferable to be sure we don't change an important AKILL
+ * accidentely.
+ */
+ if (entry->expires >= expires || entry->expires == 0) {
+ if (u)
+ notice_lang(s_OperServ, u, OPER_AKILL_EXISTS,
+ mask);
+ return -1;
+ } else {
+ entry->expires = expires;
+ if (u)
+ notice_lang(s_OperServ, u, OPER_AKILL_CHANGED,
+ amask);
+ return -2;
+ }
+ }
+
+ if (match_wild_nocase(amask, mask)
+ && (entry->expires >= expires || entry->expires == 0)) {
+ if (u)
+ notice_lang(s_OperServ, u, OPER_AKILL_ALREADY_COVERED,
+ mask, amask);
+ return -1;
+ }
+
+ if (match_wild_nocase(mask, amask)
+ && (entry->expires <= expires || expires == 0)) {
+ slist_delete(&akills, i);
+ deleted++;
+ }
+ }
+
+ }
+
+ /* We can now check whether t