-/* tools.c - NeonServ v5.3
+/* tools.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
if(table->contents[row][col][i] == '\002') j++;
else if(table->contents[row][col][i] == '\003') {
j++;
- for(k = 1; k < 2; k++) {
+ for(k = 1; k <= 2; k++) {
if(isdigit(table->contents[row][col][i+k]))
j++;
else
}
}
}
- }
+ } else if(table->col_flags[col] & TABLE_FLAG_COL_SKIP_NULL)
+ continue;
i -= j;
if(col < table->width-1) {
for(;i < table->maxwidth[col]; i++) {
return total_time;
}
+int getCurrentSecondsOfDay() {
+ time_t now = time(0);
+ struct tm *timeofday = localtime(&now);
+ int seconds = 0;
+ seconds += timeofday->tm_hour * 3600;
+ seconds += timeofday->tm_min * 60;
+ seconds += timeofday->tm_sec;
+ return seconds;
+}
+
struct ModeBuffer* initModeBuffer(struct ClientSocket *client, struct ChanNode *chan) {
struct ModeBuffer *modeBuf = malloc(sizeof(*modeBuf));
if(!modeBuf) {
modeStr[modePos++] = modeBuf->addModes[i];
if(modeBuf->addModesParams[i]) {
paramPos += sprintf(paramStr + paramPos, " %s", modeBuf->addModesParams[i]);
+ free(modeBuf->addModesParams[i]);
+ modeBuf->addModesParams[i] = NULL;
}
}
modeBuf->addCount = 0;
modeStr[modePos++] = modeBuf->delModes[i];
if(modeBuf->delModesParams[i]) {
paramPos += sprintf(paramStr + paramPos, " %s", modeBuf->delModesParams[i]);
+ free(modeBuf->delModesParams[i]);
+ modeBuf->delModesParams[i] = NULL;
}
}
modeBuf->delCount = 0;
char *p1, *p2 = host;
//find the last dot to identify if the hostmask is a fake host
- while((p1 = strstr(p2, "."))) {
+ while((p1 = strchr(p2, '.'))) {
p2 = p1 + 1;
}
//TLD database: http://www.iana.org/domains/root/db/
return (crc^0xFFFFFFFF);
}
+int stricmp (const char *s1, const char *s2) {
+ return stricmplen(s1, s2, -1);
+}
+
+int stricmplen(const char *s1, const char *s2, int len) {
+ if (s1 == NULL)
+ return (s2 == NULL ? 0 : -(*s2));
+ if (s2 == NULL)
+ return *s1;
+ char c1, c2;
+ int i = 0;
+ while ((c1 = tolower(*s1)) == (c2 = tolower(*s2))) {
+ if (*s1 == '\0')
+ break;
+ i++;
+ s1++;
+ s2++;
+ if(len != -1 && i == len) break;
+ }
+ return c1 - c2;
+}
+
void init_tools() {
register_default_language_table(msgtab);
crc32_init();