[srvx-commits] CVS: services/src chanserv.c,1.240,1.241 chanserv.h,1.39,1.40 chanserv.help,1.27,1.28
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-07-06 00:32:12
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv30096/src
Modified Files:
chanserv.c chanserv.h chanserv.help
Log Message:
Fix a bug that could cause suspended channels to disappear if they
expired when srvx was not in operation.
Introduce new UserGreeting setting for the greeting sent to only
channel users.
Remove the Greet and GreetUsers settings.
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.240
retrieving revision 1.241
diff -C2 -r1.240 -r1.241
*** chanserv.c 4 Jul 2002 03:46:26 -0000 1.240
--- chanserv.c 6 Jul 2002 00:32:09 -0000 1.241
***************
*** 20,26 ****
#include "config.h"
- #if !defined(TRANSITION)
- #define TRANSITION 0
- #endif
#include <ctype.h>
--- 20,23 ----
***************
*** 122,125 ****
--- 119,123 ----
#define KEY_TOPIC "topic"
#define KEY_GREETING "greeting"
+ #define KEY_USER_GREETING "user_greeting"
#define KEY_MODES "modes"
#define KEY_FLAGS "flags"
***************
*** 1447,1451 ****
static struct chanData*
! register_channel(char *registrar, char *topic, char *greeting, char *modes, char *options, long flags, struct chanNode *cNode)
{
struct chanData *channel;
--- 1445,1449 ----
static struct chanData*
! register_channel(struct chanNode *cNode, char *registrar, char *options, long flags)
{
struct chanData *channel;
***************
*** 1453,1464 ****
channel = calloc(1, sizeof(struct chanData));
channel->registrar = registrar ? strdup(registrar) : NULL;
- channel->greeting = greeting ? strdup(greeting) : NULL;
channel->registered = now;
! channel->visited = channel->registered;
! channel->limitAdjusted = channel->registered;
channel->flags = flags ? flags : CHANNEL_DEFAULT_FLAGS;
- channel->notes = dict_new();
- dict_set_free_data(channel->notes, chanserv_free_note);
safestrncpy(channel->options, options ? options : CHANNEL_DEFAULT_OPTIONS, sizeof(channel->options));
--- 1451,1462 ----
channel = calloc(1, sizeof(struct chanData));
+ channel->notes = dict_new();
+ dict_set_free_data(channel->notes, chanserv_free_note);
+
channel->registrar = registrar ? strdup(registrar) : NULL;
channel->registered = now;
! channel->visited = now;
! channel->limitAdjusted = now;
channel->flags = flags ? flags : CHANNEL_DEFAULT_FLAGS;
safestrncpy(channel->options, options ? options : CHANNEL_DEFAULT_OPTIONS, sizeof(channel->options));
***************
*** 1471,1488 ****
}
- if(topic)
- {
- safestrncpy(channel->topic, topic, sizeof(channel->topic));
- }
-
- if(modes)
- {
- unsigned char *split_modes[3];
- int count;
-
- count = split_line(modes, 0, 3, split_modes);
- parse_mode_lock(split_modes, count, channel);
- }
-
channel->prev = NULL;
channel->next = channelList;
--- 1469,1472 ----
***************
*** 1495,1499 ****
channel->channel = cNode;
-
if(cNode)
{
--- 1479,1482 ----
***************
*** 1740,1743 ****
--- 1723,1727 ----
if(channel->registrar) free(channel->registrar);
if(channel->greeting) free(channel->greeting);
+ if(channel->user_greeting) free(channel->user_greeting);
if(channel->topic_mask) free(channel->topic_mask);
***************
*** 2164,2168 ****
}
! cData = register_channel(user->handle_info->handle, NULL, NULL, NULL, NULL, 0, channel);
add_channel_user(cData, handle, USER_LEVEL_HIGHEST, 0, NULL);
scan_handle_presence(channel, handle, NULL);
--- 2148,2152 ----
}
! cData = register_channel(channel, user->handle_info->handle, NULL, 0);
add_channel_user(cData, handle, USER_LEVEL_HIGHEST, 0, NULL);
scan_handle_presence(channel, handle, NULL);
***************
*** 5517,5535 ****
}
! static OPTION_FUNC(opt_greeting)
{
if(argc > 0)
{
- if(!require_access(channel, user, ulCoowner))
- {
- return 0;
- }
-
unsplit_string(argv, argc);
if(argv[0][0] == '*' && argv[0][1] == 0)
{
! free(channel->channel_info->greeting);
! channel->channel_info->greeting = NULL;
}
else
--- 5501,5516 ----
}
! int opt_greeting_common(struct userNode *user, struct chanNode *channel, int argc, unsigned char *argv[], char *name, char **data)
{
+ (void)channel;
+
if(argc > 0)
{
unsplit_string(argv, argc);
if(argv[0][0] == '*' && argv[0][1] == 0)
{
! free(*data);
! *data = NULL;
}
else
***************
*** 5544,5552 ****
}
! channel->channel_info->greeting = strdup(argv[0]);
}
}
! chanserv_notice(user, CSMSG_STRING_VALUE, "Greeting ", channel->channel_info->greeting ? channel->channel_info->greeting : "None.");
return 1;
}
--- 5525,5545 ----
}
! *data = strdup(argv[0]);
}
}
! chanserv_notice(user, CSMSG_STRING_VALUE, name, *data ? *data : "None.");
! return 1;
! }
!
! static OPTION_FUNC(opt_greeting)
! {
! opt_greeting_common(user, channel, argc, argv, "Greeting ", &channel->channel_info->greeting);
! return 1;
! }
!
! static OPTION_FUNC(opt_usergreeting)
! {
! opt_greeting_common(user, channel, argc, argv, "UserGreeting ", &channel->channel_info->user_greeting);
return 1;
}
***************
*** 5699,5712 ****
}
- static OPTION_FUNC(opt_greet)
- {
- BINARY_OPTION("Greet ", CHANNEL_GREET_ALL);
- }
-
- static OPTION_FUNC(opt_greetusers)
- {
- BINARY_OPTION("GreetUsers ", CHANNEL_GREET_USERS);
- }
-
static OPTION_FUNC(opt_dynlimit)
{
--- 5692,5695 ----
***************
*** 5889,5899 ****
option_func_t *set_display[] = {
/* multiple-choice options */
! opt_defaulttopic, opt_topicmask, opt_greeting, opt_modes, opt_pubcmd,
! opt_strictop, opt_autoop, opt_enfmodes, opt_enftopic, opt_protect,
! opt_toys, opt_setters, opt_topicrefresh, opt_ctcpusers,
! opt_ctcpreaction,
/* binary options */
! opt_voice, opt_greet, opt_greetusers, opt_userinfo, opt_dynlimit,
! opt_topicsnarf, opt_nodelete
};
--- 5872,5883 ----
option_func_t *set_display[] = {
/* multiple-choice options */
! opt_defaulttopic, opt_topicmask, opt_greeting,
! opt_usergreeting, opt_modes, opt_pubcmd, opt_strictop,
! opt_autoop, opt_enfmodes, opt_enftopic, opt_protect,
! opt_toys, opt_setters, opt_topicrefresh, opt_ctcpusers,
! opt_ctcpreaction,
/* binary options */
! opt_voice, opt_userinfo, opt_dynlimit, opt_topicsnarf,
! opt_nodelete
};
***************
*** 6398,6411 ****
uData->present = 1;
! if((cData->flags & CHANNEL_GREET_USERS) && cData->greeting)
{
! chanserv_notice(user, "(%s) %s", channel->name, cData->greeting);
! }
! } else {
! if((cData->flags & CHANNEL_GREET_ALL) && cData->greeting)
! {
! chanserv_notice(user, "(%s) %s", channel->name, cData->greeting);
}
}
}
--- 6382,6394 ----
uData->present = 1;
! if(cData->user_greeting)
{
! chanserv_notice(user, "(%s) %s", channel->name, cData->user_greeting);
}
}
+ else if(cData->greeting)
+ {
+ chanserv_notice(user, "(%s) %s", channel->name, cData->greeting);
+ }
}
***************
*** 6980,6993 ****
struct chanNode *cNode = NULL;
struct chanData *cData = NULL;
! dict_t users, bans, notes;
dict_iterator_t it;
!
! char *flags, *topic, *topic_mask, *modes, *data, *greeting, *registrar, *suspender;
char *options;
unsigned long num_flags;
unsigned int max;
! time_t registered, visited;
!
! users = database_get_data(hir->d.object, KEY_USERS, RECDB_OBJECT);
if(!users)
--- 6963,6976 ----
struct chanNode *cNode = NULL;
struct chanData *cData = NULL;
! dict_t channel, users, bans, notes;
dict_iterator_t it;
! char *flags, *topic, *topic_mask, *modes, *data;
! char *greeting, *user_greeting, *registrar, *suspender;
char *options;
unsigned long num_flags;
unsigned int max;
! time_t registered, visited, expires = 0;
! channel = hir->d.object;
! users = database_get_data(channel, KEY_USERS, RECDB_OBJECT);
if(!users)
***************
*** 6997,7016 ****
}
! bans = database_get_data(hir->d.object, KEY_BANS, RECDB_OBJECT);
! notes = database_get_data(hir->d.object, KEY_NOTES, RECDB_OBJECT);
! flags = database_get_data(hir->d.object, KEY_FLAGS, RECDB_QSTRING);
! topic = database_get_data(hir->d.object, KEY_TOPIC, RECDB_QSTRING);
! topic_mask = database_get_data(hir->d.object, KEY_TOPIC_MASK, RECDB_QSTRING);
! registrar = database_get_data(hir->d.object, KEY_REGISTRAR, RECDB_QSTRING);
! greeting = database_get_data(hir->d.object, KEY_GREETING, RECDB_QSTRING);
! modes = database_get_data(hir->d.object, KEY_MODES, RECDB_QSTRING);
! data = database_get_data(hir->d.object, KEY_REGISTERED, RECDB_QSTRING);
registered = data ? (signed)strtoul(data, NULL, 0) : now;
! data = database_get_data(hir->d.object, KEY_VISITED, RECDB_QSTRING);
visited = data ? (signed)strtoul(data, NULL, 0) : now;
! data = database_get_data(hir->d.object, KEY_MAX, RECDB_QSTRING);
max = data ? strtoul(data, NULL, 0) : 0;
--- 6980,7000 ----
}
! bans = database_get_data(channel, KEY_BANS, RECDB_OBJECT);
! notes = database_get_data(channel, KEY_NOTES, RECDB_OBJECT);
! flags = database_get_data(channel, KEY_FLAGS, RECDB_QSTRING);
! topic = database_get_data(channel, KEY_TOPIC, RECDB_QSTRING);
! topic_mask = database_get_data(channel, KEY_TOPIC_MASK, RECDB_QSTRING);
! registrar = database_get_data(channel, KEY_REGISTRAR, RECDB_QSTRING);
! greeting = database_get_data(channel, KEY_GREETING, RECDB_QSTRING);
! user_greeting = database_get_data(channel, KEY_USER_GREETING, RECDB_QSTRING);
! modes = database_get_data(channel, KEY_MODES, RECDB_QSTRING);
! data = database_get_data(channel, KEY_REGISTERED, RECDB_QSTRING);
registered = data ? (signed)strtoul(data, NULL, 0) : now;
! data = database_get_data(channel, KEY_VISITED, RECDB_QSTRING);
visited = data ? (signed)strtoul(data, NULL, 0) : now;
! data = database_get_data(channel, KEY_MAX, RECDB_QSTRING);
max = data ? strtoul(data, NULL, 0) : 0;
***************
*** 7025,7028 ****
--- 7009,7026 ----
options = CHANNEL_DEFAULT_OPTIONS;
}
+
+ if(num_flags & CHANNEL_SUSPENDED)
+ {
+ char *exp_text;
+ exp_text = database_get_data(channel, KEY_SUSPEND_EXPIRES, RECDB_QSTRING);
+ if(exp_text)
+ {
+ expires = strtoul(exp_text, NULL, 0);
+ if(expires <= now)
+ {
+ num_flags &= ~CHANNEL_SUSPENDED;
+ }
+ }
+ }
if(!(num_flags & CHANNEL_SUSPENDED))
***************
*** 7033,7038 ****
}
! cData = register_channel(registrar, topic, greeting, modes, options, num_flags, cNode);
!
if(!cData)
{
--- 7031,7035 ----
}
! cData = register_channel(cNode, registrar, options, num_flags);
if(!cData)
{
***************
*** 7044,7059 ****
{
struct suspended *suspended;
! char *reason, *exp_text;
! time_t expires = 0;
- if((exp_text = database_get_data(hir->d.object, KEY_SUSPEND_EXPIRES, RECDB_QSTRING)))
- {
- expires = strtoul(exp_text, NULL, 0);
- if(expires < now)
- {
- cData->flags &= ~CHANNEL_SUSPENDED;
- goto suspended_done;
- }
- }
suspended = malloc(sizeof(struct suspended));
if((suspended->expires = expires))
--- 7041,7046 ----
{
struct suspended *suspended;
! char *reason;
suspended = malloc(sizeof(struct suspended));
if((suspended->expires = expires))
***************
*** 7062,7068 ****
}
suspended->name = strdup(key);
! suspender = database_get_data(hir->d.object, KEY_SUSPENDER, RECDB_QSTRING);
suspended->suspender = strdup(suspender);
! reason = database_get_data(hir->d.object, KEY_SUSPEND_REASON, RECDB_QSTRING);
suspended->reason = reason ? strdup(reason) : NULL;
--- 7049,7055 ----
}
suspended->name = strdup(key);
! suspender = database_get_data(channel, KEY_SUSPENDER, RECDB_QSTRING);
suspended->suspender = strdup(suspender);
! reason = database_get_data(channel, KEY_SUSPEND_REASON, RECDB_QSTRING);
suspended->reason = reason ? strdup(reason) : NULL;
***************
*** 7071,7075 ****
dict_insert(sChannels, suspended->name, suspended);
- suspended_done: ;
}
--- 7058,7061 ----
***************
*** 7077,7081 ****
--- 7063,7080 ----
cData->visited = visited;
cData->max = max;
+
+ if(greeting) cData->greeting = strdup(greeting);
+ if(user_greeting) cData->user_greeting = strdup(user_greeting);
if(topic_mask) cData->topic_mask = strdup(topic_mask);
+ if(topic) safestrncpy(cData->topic, topic, sizeof(cData->topic));
+
+ if(modes)
+ {
+ unsigned char *split_modes[3];
+ int count;
+
+ count = split_line(modes, 0, 3, split_modes);
+ parse_mode_lock(split_modes, count, cData);
+ }
for(it = dict_first(users); it; it = iter_next(it))
***************
*** 7322,7325 ****
--- 7321,7329 ----
}
+ if(channel->user_greeting)
+ {
+ dict_insert(obj, KEY_USER_GREETING, alloc_record_data_qstring(channel->user_greeting));
+ }
+
if(channel->topic_mask)
{
***************
*** 7720,7723 ****
--- 7724,7728 ----
DEFINE_OPTION(topicmask);
DEFINE_OPTION(greeting);
+ DEFINE_OPTION(usergreeting);
DEFINE_OPTION(modes);
DEFINE_OPTION(strictop);
***************
*** 7728,7733 ****
DEFINE_OPTION(pubcmd);
DEFINE_OPTION(voice);
- DEFINE_OPTION(greet);
- DEFINE_OPTION(greetusers);
DEFINE_OPTION(userinfo);
DEFINE_OPTION(dynlimit);
--- 7733,7736 ----
Index: chanserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** chanserv.h 16 May 2002 21:29:05 -0000 1.39
--- chanserv.h 6 Jul 2002 00:32:09 -0000 1.40
***************
*** 46,50 ****
optEnfTopic,
optPubCmd,
! optGreet,
optToys,
optSetters,
--- 46,50 ----
optEnfTopic,
optPubCmd,
! optGreet, /* Unused. */
optToys,
optSetters,
***************
*** 66,71 ****
#define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) */
! #define CHANNEL_GREET_ALL 0x00000010 /* (1 << 4) */
! #define CHANNEL_GREET_USERS 0x00000080 /* (1 << 7) */
#define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
--- 66,71 ----
#define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) */
! /* Unused. */ /* (1 << 4) */
! /* Unused. */ /* (1 << 7) */
#define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
***************
*** 93,96 ****
--- 93,97 ----
char key[KEYLEN + 1];
char *greeting;
+ char *user_greeting;
char *registrar;
char *topic_mask;
Index: chanserv.help
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.help,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** chanserv.help 4 Jul 2002 03:08:36 -0000 1.27
--- chanserv.help 6 Jul 2002 00:32:09 -0000 1.28
***************
*** 500,504 ****
"DEFAULTTOPIC: The channel's default topic.",
"TOPICMASK: A pattern that topics must match.",
! "GREETING: A greeting message for the channel.",
"MODES: The channel's default modes.",
"PUBCMD: Restrictions to use commands in public.",
--- 500,505 ----
"DEFAULTTOPIC: The channel's default topic.",
"TOPICMASK: A pattern that topics must match.",
! "GREETING: A greeting message for the channel's regular users.",
! "USERGREETING: A greeting message for the channel's $b$C$b users.",
"MODES: The channel's default modes.",
"PUBCMD: Restrictions to use commands in public.",
***************
*** 514,519 ****
"CTCPREACTION: What happens when a disallowed CTCP is sent to the channel.",
"VOICE: Toggles whether $b$C$b will autovoice people on join.",
- "GREET: Setting to control if channel greeting is displayed.",
- "GREETUSERS: Controls whether greeting is sent to people in userlist.",
"USERINFO: Toggles whether or not infolines are displayed.",
"DYNLIMIT: Adjusts user limit (+l channel mode) to prevent join floods.",
--- 515,518 ----
|