Skip to content

Commit 0e9d647

Browse files
author
drscholl
committed
altered channels file so that # is no longer considered a comment in
`version 1' files.
1 parent 9e772f4 commit 0e9d647

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

channel.c

+20-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ void
1717
load_channels (void)
1818
{
1919
char path[_POSIX_PATH_MAX], *name, *slimit, *slevel, *topic, *ptr;
20+
char realname[256];
2021
FILE *fp;
2122
int limit, level, line = 0;
2223
CHANNEL *chan;
2324
LIST *list;
25+
int version = 0;
2426

2527
snprintf (path, sizeof (path), "%s/channels", Config_Dir);
2628
fp = fopen (path, "r");
@@ -30,13 +32,23 @@ load_channels (void)
3032
logerr ("load_channels", path);
3133
return;
3234
}
35+
if(fgets(Buf,sizeof(Buf),fp)==NULL)
36+
{
37+
fclose(fp);
38+
return;
39+
}
40+
if(!strncmp(":version 1", Buf, 10))
41+
version = 1;
42+
else
43+
rewind(fp);
44+
3345
while (fgets (Buf, sizeof (Buf), fp))
3446
{
3547
line++;
3648
ptr = Buf;
3749
while (ISSPACE (*ptr))
3850
ptr++;
39-
if (*ptr == '#' || *ptr == 0)
51+
if (*ptr == 0 || (version == 0 && *ptr == '#'))
4052
continue; /* blank or comment line */
4153
name = next_arg (&ptr);
4254
slimit = next_arg (&ptr);
@@ -47,6 +59,12 @@ load_channels (void)
4759
log ("load_channels(): %s:%d: too few parameters", path, line);
4860
continue;
4961
}
62+
/*force new channel name restrictions*/
63+
if(*name!='#' && *name!='&')
64+
{
65+
snprintf(realname,sizeof(realname),"#%s",name);
66+
name=realname;
67+
}
5068
if (invalid_channel (name))
5169
{
5270
log ("load_channels(): %s:%d: %s: invalid channel name", name);
@@ -127,9 +145,7 @@ dump_channels (void)
127145
logerr ("dump_channels", path);
128146
return;
129147
}
130-
fprintf (fp,
131-
"# auto generated by %s %s\r\n# Don't edit this file while %s is running or changes will be lost!\r\n",
132-
PACKAGE, VERSION, PACKAGE);
148+
fputs(":version 1\n",fp);
133149
hash_foreach (Channels, (hash_callback_t) dump_channel_cb, fp);
134150
if (fclose (fp))
135151
logerr ("dump_channels", "fclose");

sample.channels

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
# $Id$
2-
#
3-
# sample channel configuration file
4-
#
5-
# This file contains a list of persistent channels that should be maintained
6-
# even when no users are present in them
7-
#
8-
# <channel> <limit> <level> "<topic>" [ nick ... ]
9-
#
10-
# <channel> is the channel name
11-
# <limit> is the maximum number of people allowed on the channel
12-
# <level> is the minimum user level required for a user to enter (leech,
13-
# user, moderator, admin, elite)
14-
# <topic> is the initial topic for the channel (MUST BE QUOTED)
15-
#
16-
# optionally, there may be a list of nicknames separated by a space. these
17-
# nicknames are the channel operators which will be given privilege to
18-
# execute commands relating to the channel (kick, ban, topic, limit, level)
19-
20-
Help 200 Leech "Get your OpenNap questions answered here!"
21-
Admins 200 Moderator "OpenNap administration channel"
22-
Lobby 200 User "General chat channel"
1+
#Help 200 Leech "Get your OpenNap questions answered here!"
2+
#Admins 200 Moderator "OpenNap administration channel"
3+
#Lobby 200 User "General chat channel"

0 commit comments

Comments
 (0)