]>
jfr.im git - irc/quakenet/newserv.git/blob - qabot/qabot_dbase.c
4 #include "../nick/nick.h"
5 #include "../localuser/localuserchannel.h"
6 #include "../core/hooks.h"
7 #include "../core/schedule.h"
8 #include "../lib/array.h"
9 #include "../lib/base64.h"
10 #include "../lib/irc_string.h"
11 #include "../lib/splitline.h"
15 qab_user
* qabot_users
= 0;
24 if (!(f
= fopen("qab_users", "r")))
28 if (fgets(buf
, 2048, f
)) {
30 if (splitline(buf
, args
, 50, 0) != 3) {
35 flags
= (flag_t
)strtoul(args
[1], NULL
, 10);
36 created
= strtoul(args
[2], NULL
, 10);
38 qabot_adduser(args
[0], flags
, created
);
44 if (!(f
= fopen("qab_bots", "r")))
48 if (fgets(buf
, 2048, f
)) {
50 if (splitline(buf
, args
, 50, 0) != 10) {
55 qabot_addbot(args
[0], args
[1], args
[2], args
[3], args
[4], args
[5], (flag_t
)strtol(args
[6], NULL
, 10),
56 (int)strtol(args
[7], NULL
, 10), (int)strtol(args
[8], NULL
, 10), (int)strtol(args
[9], NULL
, 10), 0);
68 if (!(f
= fopen("qab_users", "w")))
71 for (u
= qabot_users
; u
; u
= u
->next
)
72 fprintf(f
, "%s %d %ld\n", u
->authname
, (int)u
->flags
, u
->created
);
76 if (!(f
= fopen("qab_bots", "w")))
79 for (b
= qab_bots
; b
; b
= b
->next
)
80 fprintf(f
, "%s %s %s %s %s %s %d %d %d %d\n", b
->nick
, b
->user
, b
->host
, b
->public_chan
->name
->content
,
81 b
->question_chan
->name
->content
, b
->staff_chan
->name
->content
, (int)b
->flags
, b
->spam_interval
,
82 b
->ask_wait
, b
->queued_question_interval
);
87 void qabot_savetimer(void* arg
) {
91 void qabot_adduser(const char* authname
, flag_t flags
, time_t created
) {
94 if ((u
= qabot_getuser(authname
)))
97 u
= (qab_user
*)malloc(sizeof(qab_user
));
98 strncpy(u
->authname
, authname
, ACCOUNTLEN
);
99 u
->authname
[ACCOUNTLEN
] = '\0';
101 u
->created
= created
;
104 u
->next
= qabot_users
;
106 qabot_users
->prev
= u
;
110 void qabot_deluser(const char* authname
) {
111 qab_user
* u
= qabot_getuser(authname
);
116 qabot_squelchuser(u
);
119 void qabot_squelchuser(qab_user
* user
) {
121 user
->next
->prev
= user
->prev
;
123 user
->prev
->next
= user
->next
;
125 qabot_users
= user
->next
;
130 qab_user
* qabot_getuser(const char* authname
) {
133 for (u
= qabot_users
; u
; u
= u
->next
)
134 if (!ircd_strcmp(u
->authname
, authname
))