+/* tools.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "tools.h"
#include "UserNode.h"
#include "ChanNode.h"
char modeStr[MAXMODES+3];
int modePos = 0;
char paramStr[MAXLEN];
+ *paramStr = '\0';
int paramPos = 0;
int i;
if(modeBuf->addCount) {
return (strlen(p2+1) > 4);
}
+static unsigned long crc_table[256];
+
+static void crc32_init() {
+ unsigned long crc;
+ int i, j;
+ for(i = 0; i < 256; i++) {
+ crc = i;
+ for(j = 8; j > 0; j--) {
+ if(crc & 1)
+ crc = (crc >> 1) ^ 0xEDB88320L;
+ else
+ crc >>= 1;
+ }
+ crc_table[i] = crc;
+ }
+}
+
+unsigned long crc32(const char *text) {
+ register unsigned long crc = 0xFFFFFFFF;
+ unsigned int c, i = 0;
+ while((c = (unsigned int)text[i++]) != 0)
+ crc = ((crc >> 8) & 0x00FFFFFF) ^ crc_table[(crc^c) & 0xFF];
+ return (crc^0xFFFFFFFF);
+}
+
void init_tools() {
register_default_language_table(msgtab);
+ crc32_init();
}