- static char quotes[9][2] = {
- {'b', '\b'},
- {'f', '\f'},
- {'n', '\n'},
- {'r', '\r'},
- {'t', '\t'},
- {'v', '\v'},
- {'\\', '\\'},
- {0, 0}
- };
- char *tmp, *s;
- FBFILE *file;
- int i;
- char line[512];
- int ccount = 0;
- struct ConfItem *aconf = 0;
-
- Debug((DEBUG_DEBUG, "conf_init: ircd.conf = %s", configfile));
- if (0 == (file = fbopen(configfile, "r"))) {
- return 0;
- }
- while (fbgets(line, sizeof(line) - 1, file)) {
- if ((tmp = strchr(line, '\n')))
- *tmp = '\0';
- /*
- * Do quoting of characters and # detection.
- */
- 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));
- sendto_op_mask(SNO_OLDSNO,"Bad Config 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_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 '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;
- 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));
- sendto_op_mask(SNO_OLDSNO,"Unknown prefix in config file: %c",*tmp);
- 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) {
- if (!tmp) {
- Debug((DEBUG_FATAL, "Your M: line must have the Numeric, "
- "assigned to you by routing-com!\n"));
- ircd_log(L_WARNING, "Your M: line must have the Numeric, "
- "assigned to you by routing-com!\n");
- 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;
- }