2 nterfacer spamscan2 module
3 Copyright (C) 2005 Chris Porter.
7 #include "../localuser/localuserchannel.h"
8 #include "../channel/channel.h"
10 #include "../spamscan2/spamscan2.h"
13 #include "nterfacer.h"
15 #define ERR_TARGET_NOT_FOUND 0x01
16 #define ERR_CHANNEL_NOT_REGISTERED 0x02
17 #define ERR_PROFILE_DOES_NOT_EXIST 0x03
18 #define ERR_BAD_FLAGS 0x04
20 int handle_getprofile(struct rline
*li
, int argc
, char **argv
);
21 int handle_setprofile(struct rline
*li
, int argc
, char **argv
);
23 struct service_node
*s_node
;
26 s_node
= register_service("S");
30 register_handler(s_node
, "getprofile", 1, handle_getprofile
);
31 register_handler(s_node
, "setprofile", 3, handle_setprofile
);
36 deregister_service(s_node
);
39 int handle_getprofile(struct rline
*li
, int argc
, char **argv
) {
40 spamscan_channelsettings
*cs
;
43 return ri_error(li
, ERR_TARGET_NOT_FOUND
, "Channel not found");
45 cs
= spamscan_getchannelsettings(argv
[0], 0);
47 return ri_error(li
, ERR_CHANNEL_NOT_REGISTERED
, "Channel not registered");
49 ri_append(li
, "%s,%s", cs
->cp
?cs
->cp
->profilename
:"unknown", printflags(cs
->flags
, s_cfflags
));
53 int handle_setprofile(struct rline
*li
, int argc
, char **argv
) {
54 spamscan_channelsettings
*cs
;
55 spamscan_channelprofile
*cp
;
58 return ri_error(li
, ERR_TARGET_NOT_FOUND
, "Channel not found");
60 cs
= spamscan_getchannelsettings(argv
[0], 0);
62 return ri_error(li
, ERR_CHANNEL_NOT_REGISTERED
, "Channel not registered");
64 cp
= spamscan_getchannelprofile(argv
[1], 0);
66 return ri_error(li
, ERR_PROFILE_DOES_NOT_EXIST
, "Profile does not exist");
68 if(setflags(&cs
->flags
, SPAMSCAN_CF_ALL
, argv
[2], s_cfflags
, REJECT_UNKNOWN
) != REJECT_NONE
)
69 return ri_error(li
, ERR_BAD_FLAGS
, "Bad flags");
71 /* TODO: beat Cruicky till he refactors this functionality */
72 spamscan_checkchannelpresence(findchannel(cs
->channelname
)); /* what if findchannel returns NULL? */
74 cs
->modified
= time(NULL
);
75 cs
->modifiedby
= spamscan_getaccountsettings("nterfacer", 1);
76 spamscan_updatechanneldb(cs
);
78 ri_append(li
, "Done.");