Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv13539/src
Modified Files:
chanserv.c
Log Message:
Snarf topics set with !topic when TopicSnarf is enabled.
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.248
retrieving revision 1.249
diff -C2 -r1.248 -r1.249
*** chanserv.c 12 Jul 2002 17:40:44 -0000 1.248
--- chanserv.c 25 Jul 2002 01:27:03 -0000 1.249
***************
*** 4197,4260 ****
static CHANSERV_FUNC(cmd_topic)
{
if(argc < 2)
{
! if(channel->channel_info->topic[0])
{
! SetChannelTopic(channel, chanserv, channel->channel_info->topic, 1);
! chanserv_notice(user, CSMSG_TOPIC_SET, channel->channel_info->topic);
}
! else
! {
! chanserv_notice(user, CSMSG_NO_TOPIC, channel->name);
! return 0;
! }
! } else {
! unsplit_string(argv + 1, argc - 1);
! /* If they say "!topic *", use an empty topic. */
! if ((argv[1][0] == '*') && (argv[1][1] == 0)) {
! argv[1][0] = 0;
! }
! if(bad_topic(channel, user, argv[1]))
{
! char *topic_mask = channel->channel_info->topic_mask;
! if(topic_mask)
! {
! char new_topic[TOPICLEN+1], tchar;
! int pos=0, starpos=-1, dpos=0, len;
! while((tchar = topic_mask[pos++]) && (dpos <= TOPICLEN))
{
! switch(tchar)
! {
! case '*':
! if (starpos != -1) goto bad_mask;
! len = strlen(argv[1]);
! if ((dpos + len) > TOPICLEN) len = TOPICLEN + 1 - dpos;
! memcpy(new_topic+dpos, argv[1], len);
! dpos += len;
! starpos = pos;
! break;
! case '?': goto bad_mask;
! case '\\': tchar = topic_mask[pos++]; /* and fall through */
! default: new_topic[dpos++] = tchar; break;
! }
! }
! if ((dpos > TOPICLEN) || tchar) {
! bad_mask:
! chanserv_notice(user, CSMSG_TOPICMASK_CONFLICT1, channel->name, topic_mask);
! chanserv_notice(user, CSMSG_TOPICMASK_CONFLICT2, TOPICLEN);
! return 0;
}
! new_topic[dpos] = 0;
! SetChannelTopic(channel, chanserv, new_topic, 1);
! } else {
! chanserv_notice(user, CSMSG_TOPIC_LOCKED, channel->name);
return 0;
}
}
! else
! {
! SetChannelTopic(channel, chanserv, argv[1], 1);
! }
}
--- 4197,4268 ----
static CHANSERV_FUNC(cmd_topic)
{
+ struct chanData *cData;
+
+ cData = channel->channel_info;
if(argc < 2)
{
! if(cData->topic[0])
{
! SetChannelTopic(channel, chanserv, cData->topic, 1);
! chanserv_notice(user, CSMSG_TOPIC_SET, cData->topic);
! return 1;
}
!
! chanserv_notice(user, CSMSG_NO_TOPIC, channel->name);
! return 0;
! }
!
! unsplit_string(argv + 1, argc - 1);
! /* If they say "!topic *", use an empty topic. */
! if ((argv[1][0] == '*') && (argv[1][1] == 0)) {
! argv[1][0] = 0;
! }
! if(bad_topic(channel, user, argv[1]))
! {
! char *topic_mask = cData->topic_mask;
! if(topic_mask)
{
! char new_topic[TOPICLEN+1], tchar;
! int pos=0, starpos=-1, dpos=0, len;
! while((tchar = topic_mask[pos++]) && (dpos <= TOPICLEN))
! {
! switch(tchar)
{
! case '*':
! if (starpos != -1) goto bad_mask;
! len = strlen(argv[1]);
! if ((dpos + len) > TOPICLEN) len = TOPICLEN + 1 - dpos;
! memcpy(new_topic+dpos, argv[1], len);
! dpos += len;
! starpos = pos;
! break;
! case '?': goto bad_mask;
! case '\\': tchar = topic_mask[pos++]; /* and fall through */
! default: new_topic[dpos++] = tchar; break;
}
! }
! if ((dpos > TOPICLEN) || tchar) {
! bad_mask:
! chanserv_notice(user, CSMSG_TOPICMASK_CONFLICT1, channel->name, topic_mask);
! chanserv_notice(user, CSMSG_TOPICMASK_CONFLICT2, TOPICLEN);
return 0;
}
+ new_topic[dpos] = 0;
+ SetChannelTopic(channel, chanserv, new_topic, 1);
+ } else {
+ chanserv_notice(user, CSMSG_TOPIC_LOCKED, channel->name);
+ return 0;
}
! }
! else
! {
! SetChannelTopic(channel, chanserv, argv[1], 1);
! }
!
! if(cData->flags & CHANNEL_TOPIC_SNARF)
! {
! /* Grab the topic and save it as the default topic. */
! safestrncpy(cData->topic, channel->topic, sizeof(cData->topic));
}
|