1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/************************************************************************
* IRC - Internet Relay Chat, irc/c_conf.c
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* 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.
*/
#ifndef lint
static char rcsid[] = "@(#)$Id: c_conf.c,v 1.3 1999/02/21 00:33:45 kalt Exp $";
#endif
#include "os.h"
#include "c_defines.h"
#define C_CONF_C
#include "c_externs.h"
#undef C_CONF_C
initconf(host, passwd, myname, port)
char *host, *passwd, *myname;
int *port;
{
FILE *fd;
char line[256], *tmp;
if ((fd = fopen(IRCDCONF_PATH, "r")) == NULL)
return /* (-1) */ ;
while (fgets(line,255,fd)) {
if (line[0] == '#' || line[0] == '\n' ||
line[0] == ' ' || line[0] == '\t')
continue;
switch (*getfield(line))
{
case 'C': /* Server where I should try to connect */
case 'c': /* in case of link failures */
case 'I': /* Just plain normal irc client trying */
case 'i': /* to connect me */
case 'N': /* Server where I should NOT try to */
case 'n': /* connect in case of link failures */
/* but which tries to connect ME */
case 'O': /* Operator. Line should contain at least */
case 'o': /* password and host where connection is */
/* allowed from */
case 'M': /* Me. Host field is name used for this host */
case 'm': /* and port number is the number of the port */
case 'a':
case 'A':
case 'k':
case 'K':
case 'q':
case 'Q':
case 'l':
case 'L':
case 'y':
case 'Y':
case 'h':
case 'H':
case 'p':
case 'P':
break;
case 'U': /* Uphost, ie. host where client reading */
case 'u': /* this should connect. */
if (!(tmp = getfield(NULL)))
break;
strncpyzt(host, tmp, HOSTLEN);
if (!(tmp = getfield(NULL)))
break;
strncpyzt(passwd, tmp, PASSWDLEN);
if (!(tmp = getfield(NULL)))
break;
strncpyzt(myname, tmp, HOSTLEN);
if (!(tmp = getfield(NULL)))
break;
if ((*port = atoi(tmp)) == 0)
debug(DEBUG_ERROR,
"Error in config file, bad port field");
break;
default:
/* debug(DEBUG_ERROR, "Error in config file: %s", line); */
break;
}
}
}
|