From 36e50ccfa590809fdb0655bf71219a2b10e80bbd Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 21 Sep 2014 18:20:26 +0200 Subject: [PATCH] tools: Remove Hybrid 6 conversion tools. Hybrid 6 is old enough that the conversion tools can go away now. They are for I and K lines; the ircd.conf converter was already removed. This removes compiler/analyzer warnings about these tools. --- .gitignore | 2 - INSTALL | 31 --- tools/Makefile.in | 12 +- tools/README | 5 - tools/convertilines.c | 620 ------------------------------------------ tools/convertklines.c | 305 --------------------- 6 files changed, 3 insertions(+), 972 deletions(-) delete mode 100644 tools/convertilines.c delete mode 100644 tools/convertklines.c diff --git a/.gitignore b/.gitignore index eea74e57f..2daa65dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,6 @@ src/version.c.last src/y.tab.h src/y.tab.c ssld/ssld -tools/convertilines -tools/convertklines tools/genssl tools/mkpasswd tools/viconf diff --git a/INSTALL b/INSTALL index c11e942d8..e5abd5fc8 100644 --- a/INSTALL +++ b/INSTALL @@ -103,37 +103,6 @@ Note: If you use different names in ircd.conf, you must 'touch' the specific names. - 6. - - If you are upgrading from Hybrid 5 or Hybrid 6, the config file has - changed drastically... - - There is a utility to convert your old config file to the new format. - In prefix/bin there is something called "convertconf". Its usage is: - ./convertconf (old config file to convert) (converted file name) - - Convertconf will NOT convert I: lines. You must use "convertilines" - for this which contains a much superior method of conversion and - will group I: together under one auth {};. - - Once this is done, move your new config to prefix/etc/ircd.conf and - EDIT IT! There are still things that need changing in the config, - including the fact that classes MUST be above auth/connect blocks! - - 7. - - If you are upgrading from Hybrid 5 or Hybrid 6, the kline file has - also changed... - - There is a utility to convert the old kline configuration file to the - new format. In prefix/bin there is a program called "convertklines". - Its usage is: ./convertklines (old kline.conf filename) (new - kline.conf filename) (dline.conf filename). - - Once this is done, move the new files into the prefix/etc/ directory - under their proper names. By default, the kline file is named - kline.conf and the dline file is named dline.conf. - ---------------------------------------------------------------------- HOW TO GET HELP diff --git a/tools/Makefile.in b/tools/Makefile.in index 6adf531a1..2568903de 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -29,7 +29,7 @@ libexecdir = @libexecdir@ sysconfdir = @sysconfdir@ localstatedir = @localstatedir@ -PROGS = viconf mkpasswd convertilines convertklines genssl +PROGS = viconf mkpasswd genssl all: $(PROGS) @@ -41,23 +41,17 @@ mkpasswd: mkpasswd.c viconf: viconf.c ../include/setup.h ../include/config.h $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) viconf.c -o viconf $(IRCDLIBS) -convertilines: convertilines.c - $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) convertilines.c -o convertilines $(IRCDLIBS) - -convertklines: convertklines.c - $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) convertklines.c -o convertklines $(IRCDLIBS) - genssl: genssl.in cd .. && ./config.status tools/genssl && ./config.status tools/genssl_chmod clean: - $(RM) -f encspeed viconf chkconf mkpasswd *~ core *.exe convertklines convertilines + $(RM) -f encspeed viconf chkconf mkpasswd *~ core *.exe distclean: clean $(RM) -f genssl Makefile lint: - lint -aacgprxhH $(CPPFLAGS) -DIRCD_PREFIX=\"@prefix@\" $(convertklines_SOURCES) $(mkpasswd_SOURCES) $(viconf_SOURCES) $(encspeed_SOURCES) >>../lint.out + lint -aacgprxhH $(CPPFLAGS) -DIRCD_PREFIX=\"@prefix@\" $(mkpasswd_SOURCES) $(viconf_SOURCES) $(encspeed_SOURCES) >>../lint.out depend: diff --git a/tools/README b/tools/README index 9ea64db99..2bb42444f 100644 --- a/tools/README +++ b/tools/README @@ -2,11 +2,6 @@ $Id: README 6 2005-09-10 01:02:21Z nenolod $ A directory of support programs for ircd. -convertconf.c - converts a Hybrid 5 or 6 conf file to the new - style. will not convert I: -convertilines.c - convert hybrid 5/6 I: to auth {}; -convertklines.c - convert Hybrid 5/6 and early 7beta kline.conf files - to the new spreadsheet like format. encspeed.c - test the speed of various encryption algorithms used in cryptlinks mkkeypair - a small program used for generating a public and private diff --git a/tools/convertilines.c b/tools/convertilines.c deleted file mode 100644 index 653530cbb..000000000 --- a/tools/convertilines.c +++ /dev/null @@ -1,620 +0,0 @@ -/* tools/convertilines.c - * Copyright (c) 2002 Hybrid Development Team - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1.Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2.Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3.The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: convertilines.c 6 2005-09-10 01:02:21Z nenolod $ - */ - -#include -#include -#include -#include - -#define BUFSIZE 512 - -#define FLAGS_RESTRICTED 0x001 -#define FLAGS_EXCEEDLIMIT 0x002 -#define FLAGS_KLINEEXEMPT 0x004 -#define FLAGS_NEEDIDENT 0x010 -#define FLAGS_NOTILDE 0x020 - -struct flag_table_struct -{ - const char *name; - int flag; -}; -static struct flag_table_struct flag_table[] = -{ - { "restricted", FLAGS_RESTRICTED }, - { "exceed_limit", FLAGS_EXCEEDLIMIT }, - { "kline_exempt", FLAGS_KLINEEXEMPT }, - { "need_ident", FLAGS_NEEDIDENT }, - { "no_tilde", FLAGS_NOTILDE }, - { NULL, 0 } -}; - -struct AuthBlock -{ - struct AuthBlock *next; - - char **hostname; - int hostnum; - - char *spoof; - char *passwd; - int class; - int flags; - - /* indicates one of above */ - int special; - int specialk; -}; - -static struct AuthBlock *auth_spoof = NULL; -static struct AuthBlock *auth_special = NULL; -static struct AuthBlock *auth_passwd = NULL; -static struct AuthBlock *auth_general = NULL; -static struct AuthBlock *auth_restricted = NULL; - -static void ConvertConf(FILE* file,FILE *out); -static void set_flags(struct AuthBlock *, const char *, const char *); -static void usage(void); -static char *getfield(char *); -static struct AuthBlock *find_matching_conf(struct AuthBlock *); -static void ReplaceQuotes(char *out, char *in); -static void oldParseOneLine(FILE *out, char *in); -static void write_auth_entries(FILE *out); -static void write_specific(FILE *out, struct AuthBlock *); -static int match(struct AuthBlock *, struct AuthBlock *); - -int main(int argc,char *argv[]) -{ - FILE *in; - FILE *out; - - if(argc < 3) - usage(); - - if((in = fopen(argv[1],"r")) == NULL) - { - fprintf(stderr, "Can't open %s for reading\n", argv[1]); - usage(); - } - - if((out = fopen(argv[2],"w")) == NULL) - { - fprintf(stderr, "Can't open %s for writing\n", argv[2]); - usage(); - } - - ConvertConf(in, out); - - return 0; -} - -void usage() -{ - fprintf(stderr, "convertilines conf.old conf.new\n"); - exit(-1); -} - -/* - * ConvertConf() - * Read configuration file. - * - * - * Inputs - FILE* to config file to convert - * - FILE* to output for new style conf - * - */ - -#define MAXCONFLINKS 150 - -static void ConvertConf(FILE* file, FILE *out) -{ - char line[BUFSIZE]; - char quotedLine[BUFSIZE]; - char* p; - - while (fgets(line, sizeof(line), file)) - { - if ((p = strchr(line, '\n'))) - *p = '\0'; - - ReplaceQuotes(quotedLine,line); - - if(!*quotedLine || quotedLine[0] == '#' || quotedLine[0] == '\n' || - quotedLine[0] == ' ' || quotedLine[0] == '\t') - continue; - - if(quotedLine[0] == '.') - { - char *filename; - char *back; - - if(!strncmp(quotedLine+1,"include ",8)) - { - if( (filename = strchr(quotedLine+8,'"')) ) - filename++; - else - { - fprintf(stderr, "Bad config line: %s", quotedLine); - continue; - } - - if((back = strchr(filename,'"'))) - *back = '\0'; - else - { - fprintf(stderr, "Bad config line: %s", quotedLine); - continue; - } - - } - } - - /* Could we test if it's conf line at all? -Vesa */ - if (quotedLine[1] == ':') - oldParseOneLine(out,quotedLine); - - } - - fclose(file); - - write_auth_entries(out); - fclose(out); -} - -/* - * ReplaceQuotes - * Inputs - input line to quote - * Output - quoted line - * Side Effects - All quoted chars in input are replaced - * with quoted values in output, # chars replaced with '\0' - * otherwise input is copied to output. - */ -static void ReplaceQuotes(char* quotedLine,char *inputLine) -{ - char *in; - char *out; - static char quotes[] = { - 0, /* */ - 0, /* a */ - '\b', /* b */ - 0, /* c */ - 0, /* d */ - 0, /* e */ - '\f', /* f */ - 0, /* g */ - 0, /* h */ - 0, /* i */ - 0, /* j */ - 0, /* k */ - 0, /* l */ - 0, /* m */ - '\n', /* n */ - 0, /* o */ - 0, /* p */ - 0, /* q */ - '\r', /* r */ - 0, /* s */ - '\t', /* t */ - 0, /* u */ - '\v', /* v */ - 0, /* w */ - 0, /* x */ - 0, /* y */ - 0, /* z */ - 0,0,0,0,0,0 - }; - - /* - * Do quoting of characters and # detection. - */ - for (out = quotedLine,in = inputLine; *in; out++, in++) - { - if (*in == '\\') - { - in++; - if(*in == '\\') - *out = '\\'; - else if(*in == '#') - *out = '#'; - else - *out = quotes[ (unsigned int) (*in & 0x1F) ]; - } - else if (*in == '#') - { - *out = '\0'; - return; - } - else - *out = *in; - } - *out = '\0'; -} - -/* - * oldParseOneLine - * Inputs - pointer to line to parse - * - pointer to output to write - * Output - - * Side Effects - Parse one old style conf line. - */ - -static void oldParseOneLine(FILE *out,char* line) -{ - char conf_letter; - char* tmp; - const char* host_field=NULL; - const char* passwd_field=NULL; - const char* user_field=NULL; - const char* port_field = NULL; - const char* classconf_field = NULL; - int class_field = 0; - - tmp = getfield(line); - - conf_letter = *tmp; - - for (;;) /* Fake loop, that I can use break here --msa */ - { - /* host field */ - if ((host_field = getfield(NULL)) == NULL) - return; - - /* pass field */ - if ((passwd_field = getfield(NULL)) == NULL) - break; - - /* user field */ - if ((user_field = getfield(NULL)) == NULL) - break; - - /* port field */ - if ((port_field = getfield(NULL)) == NULL) - break; - - /* class field */ - if ((classconf_field = getfield(NULL)) == NULL) - break; - - break; - } - - if (!passwd_field) - passwd_field = ""; - if (!user_field) - user_field = ""; - if (!port_field) - port_field = ""; - if (classconf_field) - class_field = atoi(classconf_field); - - switch( conf_letter ) - { - case 'i': - case 'I': - { - struct AuthBlock *ptr; - struct AuthBlock *tempptr; - - tempptr = malloc(sizeof(struct AuthBlock)); - memset(tempptr, 0, sizeof(*tempptr)); - - if(conf_letter == 'i') - { - tempptr->flags |= FLAGS_RESTRICTED; - tempptr->specialk = 1; - } - - if(passwd_field && *passwd_field) - tempptr->passwd = strdup(passwd_field); - - tempptr->class = class_field; - - set_flags(tempptr, user_field, host_field); - - /* dont add specials/passworded ones to existing auth blocks */ - if((ptr = find_matching_conf(tempptr))) - { - int authindex; - - authindex = ptr->hostnum; - ptr->hostnum++; - - ptr->hostname = realloc((void *)ptr->hostname, ptr->hostnum * sizeof(void *)); - - ptr->hostname[authindex] = strdup(tempptr->hostname[0]); - - free(tempptr->hostname[0]); - free(tempptr->hostname); - free(tempptr); - } - else - { - ptr = tempptr; - - if(ptr->spoof) - { - ptr->next = auth_spoof; - auth_spoof = ptr; - } - else if(ptr->special) - { - ptr->next = auth_special; - auth_special = ptr; - } - else if(ptr->passwd) - { - ptr->next = auth_passwd; - auth_passwd = ptr; - } - else if(ptr->specialk) - { - ptr->next = auth_restricted; - auth_restricted = ptr; - } - else - { - ptr->next = auth_general; - auth_general = ptr; - } - } - } - break; - - default: - break; - } -} - -static void write_auth_entries(FILE *out) -{ - struct AuthBlock *ptr; - - for(ptr = auth_spoof; ptr; ptr = ptr->next) - write_specific(out, ptr); - - for(ptr = auth_special; ptr; ptr = ptr->next) - write_specific(out, ptr); - - for(ptr = auth_passwd; ptr; ptr = ptr->next) - write_specific(out, ptr); - - for(ptr = auth_general; ptr; ptr = ptr->next) - write_specific(out, ptr); - - for(ptr = auth_restricted; ptr; ptr = ptr->next) - write_specific(out, ptr); -} - - -static void write_specific(FILE *out, struct AuthBlock *ptr) -{ - int i; - int prev = 0; - - fprintf(out, "auth {\n"); - - for(i = 0; i < ptr->hostnum; i++) - fprintf(out, "\tuser = \"%s\";\n", ptr->hostname[i]); - - if(ptr->spoof) - fprintf(out, "\tspoof = \"%s\";\n", ptr->spoof); - - if(ptr->passwd) - fprintf(out, "\tpassword = \"%s\";\n", ptr->passwd); - - if(ptr->flags) - { - fprintf(out, "\tflags = "); - - for(i = 0; flag_table[i].flag; i++) - { - if(ptr->flags & flag_table[i].flag) - { - fprintf(out, "%s%s", - prev ? ", " : "", - flag_table[i].name); - prev = 1; - } - } - - fprintf(out, ";\n"); - } - - fprintf(out, "\tclass = \"%d\";\n", ptr->class); - fprintf(out, "};\n"); -} - -/* - * field breakup for ircd.conf file. - */ -static char *getfield(char *newline) -{ - static char *line = NULL; - char *end, *field; - - if (newline) - line = newline; - - if (line == NULL) - return(NULL); - - field = line; - if ((end = strchr(line,':')) == NULL) - { - line = NULL; - if ((end = strchr(field,'\n')) == NULL) - end = field + strlen(field); - } - else - line = end + 1; - *end = '\0'; - return(field); -} - -struct AuthBlock *find_matching_conf(struct AuthBlock *acptr) -{ - struct AuthBlock *ptr; - - for(ptr = auth_spoof; ptr; ptr = ptr->next) - { - if(match(ptr, acptr)) - return ptr; - } - - for(ptr = auth_special; ptr; ptr = ptr->next) - { - if(match(ptr, acptr)) - return ptr; - } - - for(ptr = auth_passwd; ptr; ptr = ptr->next) - { - if(match(ptr, acptr)) - return ptr; - } - - for(ptr = auth_restricted; ptr; ptr = ptr->next) - { - if(match(ptr, acptr)) - return ptr; - } - - for(ptr = auth_general; ptr; ptr = ptr->next) - { - if(match(ptr, acptr)) - return ptr; - } - - - return NULL; -} - -static int match(struct AuthBlock *ptr, struct AuthBlock *acptr) -{ - if((ptr->class == acptr->class) && - (ptr->flags == acptr->flags)) - { - const char *p1, *p2; - - /* check the spoofs match.. */ - if(ptr->spoof) - p1 = ptr->spoof; - else - p1 = ""; - - if(acptr->spoof) - p2 = acptr->spoof; - else - p2 = ""; - - if(strcmp(p1, p2)) - return 0; - - /* now check the passwords match.. */ - if(ptr->passwd) - p1 = ptr->passwd; - else - p1 = ""; - - if(acptr->passwd) - p2 = acptr->passwd; - else - p2 = ""; - - if(strcmp(p1, p2)) - return 0; - - return 1; - } - - return 0; -} - -void set_flags(struct AuthBlock *ptr, const char *user_field, const char *host_field) -{ - for(; *user_field; user_field++) - { - switch(*user_field) - { - case '=': - if(host_field) - ptr->spoof = strdup(host_field); - - ptr->special = 1; - break; - - case '-': - ptr->flags |= FLAGS_NOTILDE; - ptr->special = 1; - break; - - case '+': - ptr->flags |= FLAGS_NEEDIDENT; - ptr->specialk = 1; - break; - - case '^': /* is exempt from k/g lines */ - ptr->flags |= FLAGS_KLINEEXEMPT; - ptr->special = 1; - break; - - case '>': - ptr->flags |= FLAGS_EXCEEDLIMIT; - ptr->special = 1; - break; - - case '!': - case '$': - case '%': - case '&': - case '<': - break; - - default: - { - int authindex; - authindex = ptr->hostnum; - ptr->hostnum++; - - ptr->hostname = realloc((void *)ptr->hostname, ptr->hostnum * sizeof(void *)); - - /* if the IP field contains something useful, use that */ - if(strcmp(host_field, "NOMATCH") && (*host_field != 'x') && - strcmp(host_field, "*") && !ptr->spoof) - ptr->hostname[authindex] = strdup(host_field); - else - ptr->hostname[authindex] = strdup(user_field); - - return; - } - } - } -} - diff --git a/tools/convertklines.c b/tools/convertklines.c deleted file mode 100644 index 484337ba9..000000000 --- a/tools/convertklines.c +++ /dev/null @@ -1,305 +0,0 @@ -/************************************************************************ - * IRC - Internet Relay Chat, tools/convertklines.c - * - * 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 1, 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: convertklines.c 6 2005-09-10 01:02:21Z nenolod $ - */ - -#include -#include -#include -#include - -#define BUFSIZE 512 - -static void ConvertConf(FILE* file,FILE *outkline, FILE *outdline); -static void usage(void); -static char *getfield(char *); -static void ReplaceQuotes(char *out, char *in); -static void parse(FILE *outkline, FILE *outdline, char *in); - -int main(int argc,char *argv[]) -{ - FILE *in; - FILE *outkline; - FILE *outdline; - - if(argc < 4) - usage(); - - if (( in = fopen(argv[1],"r")) == NULL ) - { - fprintf(stderr,"Can't open %s for reading\n", argv[1]); - usage(); - } - - if (( outkline = fopen(argv[2],"w")) == NULL ) - { - fprintf(stderr,"Can't open %s for writing\n", argv[2]); - usage(); - } - - if(( outdline = fopen(argv[3], "w")) == NULL ) - { - fprintf(stderr, "Can't open %s for writing\n", argv[3]); - usage(); - } - - ConvertConf(in, outkline, outdline); - - fprintf(stderr, "The kline file has been converted and should be renamed to\n"); - fprintf(stderr, "the config.h options (normally kline.conf and dline.conf) and\n"); - fprintf(stderr, "placed in your etc/ dir\n"); - return 0; -} - -static void usage() -{ - fprintf(stderr, "klines and dlines now go in separate files:\n"); - fprintf(stderr,"convertklines kline.conf.old kline.conf.new dline.conf.new\n"); - exit(-1); -} - - -/* - * ConvertConf() - * Read configuration file. - * - * - * inputs - FILE* to config file to convert - * - FILE* to output for new klines - * - FILE* to output for new dlines - * outputs - -1 if the file cannot be opened - * - 0 otherwise - */ - -static void ConvertConf(FILE* file, FILE *outkline, FILE *outdline) -{ - char line[BUFSIZE]; - char quotedLine[BUFSIZE]; - char* p; - - while (fgets(line, sizeof(line), file)) - { - if ((p = strchr(line, '\n'))) - *p = '\0'; - - ReplaceQuotes(quotedLine,line); - - if (!*quotedLine || quotedLine[0] == '#' || quotedLine[0] == '\n' || - quotedLine[0] == ' ' || quotedLine[0] == '\t') - continue; - - /* Could we test if it's conf line at all? -Vesa */ - if (quotedLine[1] == ':') - { - parse(outkline, outdline, quotedLine); - } - } - - fclose(file); -} - -/* - * ReplaceQuotes - * Inputs - input line to quote - * Output - quoted line - * Side Effects - All quoted chars in input are replaced - * with quoted values in output, # chars replaced with '\0' - * otherwise input is copied to output. - */ -static void ReplaceQuotes(char* quotedLine,char *inputLine) -{ - char *in; - char *out; - static char quotes[] = { - 0, /* */ - 0, /* a */ - '\b', /* b */ - 0, /* c */ - 0, /* d */ - 0, /* e */ - '\f', /* f */ - 0, /* g */ - 0, /* h */ - 0, /* i */ - 0, /* j */ - 0, /* k */ - 0, /* l */ - 0, /* m */ - '\n', /* n */ - 0, /* o */ - 0, /* p */ - 0, /* q */ - '\r', /* r */ - 0, /* s */ - '\t', /* t */ - 0, /* u */ - '\v', /* v */ - 0, /* w */ - 0, /* x */ - 0, /* y */ - 0, /* z */ - 0,0,0,0,0,0 - }; - - /* - * Do quoting of characters and # detection. - */ - for (out = quotedLine,in = inputLine; *in; out++, in++) - { - if (*in == '\\') - { - in++; - if(*in == '\\') - *out = '\\'; - else if(*in == '#') - *out = '#'; - else - *out = quotes[ (unsigned int) (*in & 0x1F) ]; - } - else if (*in == '#') - { - *out = '\0'; - return; - } - else - *out = *in; - } - *out = '\0'; -} - -/* - * parse() - * Inputs - pointer to line to parse - * - pointer to output to write - * Output - - * Side Effects - Parse one old style conf line. - */ - -static void parse(FILE *outkline, FILE *outdline, char* line) -{ - char conf_letter; - char *tmp; - const char *user_field = NULL; - const char *passwd_field = NULL; - const char *host_field = NULL; - const char *operpasswd_field = NULL; - - tmp = getfield(line); - - conf_letter = *tmp; - - for (;;) /* Fake loop, that I can use break here --msa */ - { - /* host field */ - if ((host_field = getfield(NULL)) == NULL) - return; - - /* pass field */ - if ((passwd_field = getfield(NULL)) == NULL) - break; - else - { - /* if theres a password, try splitting the operreason out */ - char *p; - - if((p = strchr(passwd_field, '|'))) - { - *p++ = '\0'; - operpasswd_field = p; - } - else - operpasswd_field = ""; - } - - /* user field */ - if ((user_field = getfield(NULL)) == NULL) - break; - - /* what could possibly be after a userfield? */ - break; - } - - if (!passwd_field) - { - passwd_field = ""; - operpasswd_field = ""; - } - - if (!user_field) - user_field = ""; - - switch( conf_letter ) - { - case 'd': - fprintf(stderr, "exempt in old file, ignoring.\n"); - break; - - case 'D': /* Deny lines (immediate refusal) */ - if(host_field && passwd_field) - fprintf(outdline, "\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n", - host_field, passwd_field, operpasswd_field); - break; - - case 'K': /* Kill user line on irc.conf */ - case 'k': - if(host_field && passwd_field && user_field) - fprintf(outkline, "\"%s\",\"%s\",\"%s\",\"%s\",\"\",\"Unknown\",0\n", - user_field, host_field, passwd_field, operpasswd_field); - break; - - default: - fprintf(stderr, "Error in config file: %s", line); - break; - } -} - - -/* - * field breakup for ircd.conf file. - */ -static char *getfield(char *newline) -{ - static char *line = NULL; - char *end, *field; - - if (newline) - line = newline; - - if (line == NULL) - { - fprintf(stderr, "returned null!\n"); - return NULL; - } - - field = line; - - if ((end = strchr(line,':')) == NULL) - { - line = NULL; - if ((end = strchr(field,'\n')) == NULL) - end = field + strlen(field); - } - else - line = end + 1; - - *end = '\0'; - - return field; -} - -