- for (tmp = line; *tmp; tmp++)
- {
- if (*tmp == '\\')
- {
- for (i = 0; quotes[i][0]; i++)
- if (quotes[i][0] == *(tmp + 1))
- {
- *tmp = quotes[i][1];
- break;
- }
- if (!quotes[i][0])
- *tmp = *(tmp + 1);
- if (!*(tmp + 1))
- break;
- else
- for (s = tmp; (*s = *(s + 1)); s++)
- ;
- }
- else if (*tmp == '#')
- *tmp = '\0';
- }
- if (!*line || line[0] == '#' || line[0] == '\n' ||
- line[0] == ' ' || line[0] == '\t')
- continue;
- /* Could we test if it's conf line at all? -Vesa */
- if (line[1] != ':')
- {
- Debug((DEBUG_ERROR, "Bad config line: %s", line));
- continue;
- }
- if (aconf)
- free_conf(aconf);
- aconf = make_conf();
-
- tmp = getfield(line, ':');
- if (!tmp)
- continue;
- switch (*tmp)
- {
- case 'A': /* Name, e-mail address of administrator */
- case 'a': /* of this server. */
- aconf->status = CONF_ADMIN;
- break;
- case 'C': /* Server where I should try to connect */
- case 'c': /* in case of lp failures */
- ccount++;
- aconf->status = CONF_CONNECT_SERVER;
- break;
- /* Connect rule */
- case 'D':
- aconf->status = CONF_CRULEALL;
- break;
- /* Connect rule - autos only */
- case 'd':
- aconf->status = CONF_CRULEAUTO;
- break;
- case 'H': /* Hub server line */
- case 'h':
- aconf->status = CONF_HUB;
- break;
- case 'I': /* Just plain normal irc client trying */
- case 'i': /* to connect me */
- aconf->status = CONF_CLIENT;
- break;
- case 'K': /* Kill user line on irc.conf */
- aconf->status = CONF_KILL;
- break;
- case 'k': /* Kill user line based on IP in ircd.conf */
- aconf->status = CONF_IPKILL;
- break;
- /* Operator. Line should contain at least */
- /* password and host where connection is */
- case 'L': /* guaranteed leaf server */
- case 'l':
- aconf->status = CONF_LEAF;
- break;
- /* Me. Host field is name used for this host */
- /* and port number is the number of the port */
- case 'M':
- case 'm':
- aconf->status = CONF_ME;
- break;
- case 'N': /* Server where I should NOT try to */
- case 'n': /* connect in case of lp failures */
- /* but which tries to connect ME */
- ++ncount;
- aconf->status = CONF_NOCONNECT_SERVER;
- break;
- case 'O':
- aconf->status = CONF_OPERATOR;
- break;
- /* Local Operator, (limited privs --SRB) */
- case 'o':
- aconf->status = CONF_LOCOP;
- break;
- case 'P': /* listen port line */
- case 'p':
- aconf->status = CONF_LISTEN_PORT;
- break;
-#ifdef R_LINES
- case 'R': /* extended K line */
- case 'r': /* Offers more options of how to restrict */
- aconf->status = CONF_RESTRICT;
- break;
-#endif
- case 'T': /* print out different motd's */
- case 't': /* based on hostmask */
- aconf->status = CONF_TLINES;
- break;
- case 'U': /* Underworld server, allowed to hack modes */
- case 'u': /* *Every* server on the net must define the same !!! */
- aconf->status = CONF_UWORLD;
- break;
- case 'Y':
- case 'y':
- aconf->status = CONF_CLASS;
- break;
- default:
- Debug((DEBUG_ERROR, "Error in config file: %s", line));
- break;
- }
- if (IsIllegal(aconf))
- continue;
-
- for (;;) /* Fake loop, that I can use break here --msa */
- {
- if ((tmp = getfield(NULL, ':')) == NULL)
- break;
- DupString(aconf->host, tmp);
- if ((tmp = getfield(NULL, (aconf->status == CONF_KILL
- || aconf->status == CONF_IPKILL) ? '"' : ':')) == NULL)
- break;
- DupString(aconf->passwd, tmp);
- if ((tmp = getfield(NULL, ':')) == NULL)
- break;
- DupString(aconf->name, tmp);
- if ((tmp = getfield(NULL, ':')) == NULL)
- break;
- aconf->port = atoi(tmp);
- tmp = getfield(NULL, ':');
- if (aconf->status & CONF_ME)
- {
- server_port = aconf->port;
- if (!tmp)
- {
- Debug((DEBUG_FATAL, "Your M: line must have the Numeric, "
- "assigned to you by routing-com, behind the port number!\n"));
-#ifdef USE_SYSLOG
- syslog(LOG_WARNING, "Your M: line must have the Numeric, "
- "assigned to you by routing-com, behind the port number!\n");
-#endif
- exit(-1);
- }
- SetYXXServerName(&me, atoi(tmp)); /* Our Numeric Nick */
- }
- else if (tmp)
- aconf->confClass = find_class(atoi(tmp));
- break;
- }
- /*
- * If conf line is a class definition, create a class entry
- * for it and make the conf_line illegal and delete it.
- */
- if (aconf->status & CONF_CLASS)
- {
- add_class(atoi(aconf->host), atoi(aconf->passwd),
- atoi(aconf->name), aconf->port, tmp ? atoi(tmp) : 0);
- continue;
- }
- /*
- * Associate each conf line with a class by using a pointer
- * to the correct class record. -avalon
- */
- if (aconf->status & (CONF_CLIENT_MASK | CONF_LISTEN_PORT))
- {
- if (aconf->confClass == 0)
- aconf->confClass = find_class(0);
- }
- if (aconf->status & (CONF_LISTEN_PORT | CONF_CLIENT))
- {
- aConfItem *bconf;
-
- if ((bconf = find_conf_entry(aconf, aconf->status)))
- {
- delist_conf(bconf);
- bconf->status &= ~CONF_ILLEGAL;
- if (aconf->status == CONF_CLIENT)
- {
- char *passwd = bconf->passwd;
- bconf->passwd = aconf->passwd;
- aconf->passwd = passwd;
- ConfLinks(bconf) -= bconf->clients;
- bconf->confClass = aconf->confClass;
- if (bconf->confClass)
- ConfLinks(bconf) += bconf->clients;
- }
- free_conf(aconf);
- aconf = bconf;
- }
- else if (aconf->host && aconf->status == CONF_LISTEN_PORT)
- add_listener(aconf);
- }
- if (aconf->status & CONF_SERVER_MASK)
- if (ncount > MAXCONFLINKS || ccount > MAXCONFLINKS ||
- !aconf->host || strchr(aconf->host, '*') ||
- strchr(aconf->host, '?') || !aconf->name)
- continue;
-
- if (aconf->status & (CONF_SERVER_MASK | CONF_LOCOP | CONF_OPERATOR))
- if (!strchr(aconf->host, '@') && *aconf->host != '/')
- {
- char *newhost;
- int len = 3; /* *@\0 = 3 */
-
- len += strlen(aconf->host);
- newhost = (char *)RunMalloc(len);
- sprintf_irc(newhost, "*@%s", aconf->host);
- RunFree(aconf->host);
- aconf->host = newhost;
- }
- if (aconf->status & CONF_SERVER_MASK)
- {
- if (BadPtr(aconf->passwd))
- continue;
- else if (!(opt & BOOT_QUICK))
- lookup_confhost(aconf);
- }
-
- /* Create expression tree from connect rule...
- * If there's a parsing error, nuke the conf structure */
- if (aconf->status & (CONF_CRULEALL | CONF_CRULEAUTO))
- {
- RunFree(aconf->passwd);
- if ((aconf->passwd = (char *)crule_parse(aconf->name)) == NULL)
- {
- free_conf(aconf);
- aconf = NULL;
- continue;
- }
- }
-
- /*
- * Own port and name cannot be changed after the startup.
- * (or could be allowed, but only if all links are closed first).
- * Configuration info does not override the name and port
- * if previously defined. Note, that "info"-field can be
- * changed by "/rehash".
- */
- if (aconf->status == CONF_ME)
- {
- strncpy(me.info, aconf->name, sizeof(me.info) - 1);
- if (portnum == 0)
- portnum = aconf->port;
- }