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
19 int handle_getprofile(struct rline
*li
, int argc
, char **argv
);
20 int handle_setprofile(struct rline
*li
, int argc
, char **argv
);
22 struct service_node
*s_node
;
25 s_node
= register_service("S");
29 register_handler(s_node
, "getprofile", 1, handle_getprofile
);
30 register_handler(s_node
, "setprofile", 2, handle_setprofile
);
35 deregister_service(s_node
);
38 int handle_getprofile(struct rline
*li
, int argc
, char **argv
) {
39 spamscan_channelsettings
*cs
;
42 return ri_error(li
, ERR_TARGET_NOT_FOUND
, "Channel not found");
44 cs
= spamscan_getchannelsettings(argv
[0], 0);
46 return ri_error(li
, ERR_CHANNEL_NOT_REGISTERED
, "Channel not registered");
48 ri_append(li
, cs
->cp
?cs
->cp
->profilename
:"unknown");
52 int handle_setprofile(struct rline
*li
, int argc
, char **argv
) {
53 spamscan_channelsettings
*cs
;
54 spamscan_channelprofile
*cp
;
57 return ri_error(li
, ERR_TARGET_NOT_FOUND
, "Channel not found");
59 cs
= spamscan_getchannelsettings(argv
[0], 0);
61 return ri_error(li
, ERR_CHANNEL_NOT_REGISTERED
, "Channel not registered");
63 cp
= spamscan_getchannelprofile(argv
[1], 0);
65 return ri_error(li
, ERR_PROFILE_DOES_NOT_EXIST
, "Profile does not exist");
67 /* TODO: beat Cruicky till he refactors this functionality */
69 cs
->modified
= time(NULL
);
70 cs
->modifiedby
= spamscan_getaccountsettings("nterfacer", 1);
71 spamscan_updatechanneldb(cs
);
73 ri_append(li
, "Done.");