[srvx-commits] CVS: services/src common.h,1.79,1.80 proto-bahamut.c,1.16,1.17 proto-p10.c,1.24,1.25
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-08-14 20:25:21
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv4277/src
Modified Files:
common.h proto-bahamut.c proto-p10.c proto.h tools.c
Log Message:
Make individual protocol modules responsible for parsing user modes.
Index: common.h
===================================================================
RCS file: /cvsroot/srvx/services/src/common.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -C2 -r1.79 -r1.80
*** common.h 14 Aug 2002 20:05:04 -0000 1.79
--- common.h 14 Aug 2002 20:25:08 -0000 1.80
***************
*** 83,93 ****
void write_databases(void);
- typedef void (*oper_func_t) (struct userNode *user);
- void reg_oper_func(oper_func_t handler);
-
const char *inttobase64(char *buf, unsigned int v, unsigned int count);
unsigned long base64toint(const unsigned char *s, int count);
- int getusermodes(char *sender);
- void mod_usermode(struct userNode *user, const char *modes);
int split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[]);
--- 83,88 ----
Index: proto-bahamut.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-bahamut.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** proto-bahamut.c 14 Aug 2002 20:05:04 -0000 1.16
--- proto-bahamut.c 14 Aug 2002 20:25:08 -0000 1.17
***************
*** 854,858 ****
--- 854,862 ----
}
+ static oper_func_t *of_list;
+ static unsigned int of_size = 0, of_used = 0;
+
void parse_cleanup(void) {
+ if (of_list) free(of_list);
dict_delete(irc_func_dict);
}
***************
*** 964,967 ****
--- 968,1038 ----
}
info->on_notice = handler;
+ }
+
+ void
+ reg_oper_func(oper_func_t handler)
+ {
+ if (of_used == of_size) {
+ if (of_size) {
+ of_size <<= 1;
+ of_list = realloc(of_list, of_size*sizeof(oper_func_t));
+ } else {
+ of_size = 8;
+ of_list = malloc(of_size*sizeof(oper_func_t));
+ }
+ }
+ of_list[of_used++] = handler;
+ }
+
+ static void
+ call_oper_funcs(struct userNode *user)
+ {
+ unsigned int n;
+
+ for (n=0; n<of_used; n++)
+ {
+ of_list[n](user);
+ }
+ }
+
+ void mod_usermode(struct userNode *user, const char *mode_change) {
+ extern struct policer_params *oper_policer_params, *luser_policer_params;
+ int add = 1;
+
+ if (!user || !mode_change || !*mode_change) return;
+ while (1) {
+ #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
+ switch (*mode_change++) {
+ case 0: return;
+ case '+': add = 1; break;
+ case '-': add = 0; break;
+ case 'o':
+ do_user_mode(FLAGS_OPER);
+ if (add) {
+ userList_append(&curr_opers, user);
+ if (user->command_policer) {
+ policer_set_params(user->command_policer, oper_policer_params);
+ }
+ call_oper_funcs(user);
+ } else {
+ userList_remove(&curr_opers, user);
+ if (user->command_policer) {
+ policer_set_params(user->command_policer, luser_policer_params);
+ }
+ }
+ break;
+ case 'O': do_user_mode(FLAGS_LOCOP); break;
+ case 'i': do_user_mode(FLAGS_INVISIBLE);
+ if (add) invis_clients++; else invis_clients--;
+ break;
+ case 'w': do_user_mode(FLAGS_WALLOP); break;
+ case 's': do_user_mode(FLAGS_SERVNOTICE); break;
+ case 'd': do_user_mode(FLAGS_DEAF); break;
+ case 'k': do_user_mode(FLAGS_SERVICE); break;
+ case 'g': do_user_mode(FLAGS_GLOBAL); break;
+ case 'h': do_user_mode(FLAGS_HELPER); break;
+ }
+ #undef do_user_mode
+ }
}
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** proto-p10.c 14 Aug 2002 20:05:04 -0000 1.24
--- proto-p10.c 14 Aug 2002 20:25:08 -0000 1.25
***************
*** 1266,1272 ****
--- 1266,1276 ----
}
+ static oper_func_t *of_list;
+ static unsigned int of_size = 0, of_used = 0;
+
static void
parse_cleanup(void)
{
+ if (of_list) free(of_list);
free(privmsg_funcs);
free(notice_funcs);
***************
*** 1755,1758 ****
--- 1759,1804 ----
}
+ void mod_usermode(struct userNode *user, const char *mode_change) {
+ extern struct policer_params *oper_policer_params, *luser_policer_params;
+ static void call_oper_funcs(struct userNode *user);
+ int add = 1;
+
+ if (!user || !mode_change || !*mode_change) return;
+ while (1) {
+ #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
+ switch (*mode_change++) {
+ case 0: return;
+ case '+': add = 1; break;
+ case '-': add = 0; break;
+ case 'o':
+ do_user_mode(FLAGS_OPER);
+ if (add) {
+ userList_append(&curr_opers, user);
+ if (user->command_policer) {
+ policer_set_params(user->command_policer, oper_policer_params);
+ }
+ call_oper_funcs(user);
+ } else {
+ userList_remove(&curr_opers, user);
+ if (user->command_policer) {
+ policer_set_params(user->command_policer, luser_policer_params);
+ }
+ }
+ break;
+ case 'O': do_user_mode(FLAGS_LOCOP); break;
+ case 'i': do_user_mode(FLAGS_INVISIBLE);
+ if (add) invis_clients++; else invis_clients--;
+ break;
+ case 'w': do_user_mode(FLAGS_WALLOP); break;
+ case 's': do_user_mode(FLAGS_SERVNOTICE); break;
+ case 'd': do_user_mode(FLAGS_DEAF); break;
+ case 'k': do_user_mode(FLAGS_SERVICE); break;
+ case 'g': do_user_mode(FLAGS_GLOBAL); break;
+ case 'h': do_user_mode(FLAGS_HELPER); break;
+ }
+ #undef do_user_mode
+ }
+ }
+
int
irc_make_chanmode(struct chanNode *chan, char *out)
***************
*** 2161,2164 ****
--- 2207,2236 ----
}
notice_funcs[numeric] = handler;
+ }
+
+ void
+ reg_oper_func(oper_func_t handler)
+ {
+ if (of_used == of_size) {
+ if (of_size) {
+ of_size <<= 1;
+ of_list = realloc(of_list, of_size*sizeof(oper_func_t));
+ } else {
+ of_size = 8;
+ of_list = malloc(of_size*sizeof(oper_func_t));
+ }
+ }
+ of_list[of_used++] = handler;
+ }
+
+ static void
+ call_oper_funcs(struct userNode *user)
+ {
+ unsigned int n;
+
+ for (n=0; n<of_used; n++)
+ {
+ of_list[n](user);
+ }
}
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -r1.62 -r1.63
*** proto.h 14 Aug 2002 20:05:05 -0000 1.62
--- proto.h 14 Aug 2002 20:25:08 -0000 1.63
***************
*** 109,112 ****
--- 109,115 ----
#define MODE_CHANGE_BAN 0x008
+ typedef void (*oper_func_t) (struct userNode *user);
+ void reg_oper_func(oper_func_t handler);
+
extern struct userList dead_users;
***************
*** 133,137 ****
void irc_join(struct userNode *who, struct chanNode *what);
void irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to);
- int irc_make_chanmode(struct chanNode *chan, char *out);
void irc_mode(struct userNode *who, struct chanNode *target, const char *modes);
void irc_kick(struct userNode *who, struct userNode *target, struct chanNode *from, const char *msg);
--- 136,139 ----
***************
*** 171,174 ****
--- 173,181 ----
void DelUser(struct userNode* user, struct userNode *killer, int announce, const char *why);
+ /* User modes */
+ void mod_usermode(struct userNode *user, const char *modes);
+
+ /* Channel modes */
+ int irc_make_chanmode(struct chanNode *chan, char *out);
int verify_chanmode(const char *modes, int member);
int mod_chanmode(struct chanNode *channel, struct userNode *who, const char *modes, const char *key, int limit);
Index: tools.c
===================================================================
RCS file: /cvsroot/srvx/services/src/tools.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -C2 -r1.113 -r1.114
*** tools.c 14 Aug 2002 20:05:05 -0000 1.113
--- tools.c 14 Aug 2002 20:25:08 -0000 1.114
***************
*** 114,187 ****
}
- static oper_func_t *of_list;
- static unsigned int of_size = 0, of_used = 0;
-
- void
- reg_oper_func(oper_func_t handler)
- {
- if (of_used == of_size) {
- if (of_size) {
- of_size <<= 1;
- of_list = realloc(of_list, of_size*sizeof(oper_func_t));
- } else {
- of_size = 8;
- of_list = malloc(of_size*sizeof(oper_func_t));
- }
- }
- of_list[of_used++] = handler;
- }
-
- static void
- call_oper_funcs(struct userNode *user)
- {
- unsigned int n;
-
- for (n=0; n<of_used; n++)
- {
- of_list[n](user);
- }
- }
-
- void mod_usermode(struct userNode *user, const char *mode_change) {
- extern struct policer_params *oper_policer_params, *luser_policer_params;
- int add = 1;
-
- if (!user || !mode_change || !*mode_change) return;
- while (1) {
- #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
- switch (*mode_change++) {
- case 0: return;
- case '+': add = 1; break;
- case '-': add = 0; break;
- case 'o':
- do_user_mode(FLAGS_OPER);
- if (add) {
- userList_append(&curr_opers, user);
- if (user->command_policer) {
- policer_set_params(user->command_policer, oper_policer_params);
- }
- call_oper_funcs(user);
- } else {
- userList_remove(&curr_opers, user);
- if (user->command_policer) {
- policer_set_params(user->command_policer, luser_policer_params);
- }
- }
- break;
- case 'O': do_user_mode(FLAGS_LOCOP); break;
- case 'i': do_user_mode(FLAGS_INVISIBLE);
- if (add) invis_clients++; else invis_clients--;
- break;
- case 'w': do_user_mode(FLAGS_WALLOP); break;
- case 's': do_user_mode(FLAGS_SERVNOTICE); break;
- case 'd': do_user_mode(FLAGS_DEAF); break;
- case 'k': do_user_mode(FLAGS_SERVICE); break;
- case 'g': do_user_mode(FLAGS_GLOBAL); break;
- case 'h': do_user_mode(FLAGS_HELPER); break;
- }
- #undef do_user_mode
- }
- }
-
int
split_line(unsigned char *line, int irc_colon, int argv_size, unsigned char *argv[])
--- 114,117 ----
***************
*** 891,894 ****
tools_cleanup(void)
{
! if (of_list) free(of_list);
}
--- 821,824 ----
tools_cleanup(void)
{
! /* NOOP */
}
|