]> jfr.im git - irc/quakenet/newserv.git/blob - qabot/qabot_texts.c
Merge default.
[irc/quakenet/newserv.git] / qabot / qabot_texts.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <time.h>
4
5 #include "../nick/nick.h"
6 #include "../localuser/localuserchannel.h"
7 #include "../core/hooks.h"
8 #include "../core/schedule.h"
9 #include "../lib/array.h"
10 #include "../lib/base64.h"
11 #include "../lib/irc_string.h"
12 #include "../lib/splitline.h"
13
14 #include "qabot.h"
15
16 void qabot_freetext(qab_bot* bot, qab_text* text) {
17 qab_textsection* section;
18 qab_textsection* nsection;
19
20 for (section = text->sections; section; section = nsection) {
21 nsection = section->next;
22 qabot_freesection(text, section);
23 }
24
25 if (text->next)
26 text->next->prev = text->prev;
27 if (text->prev)
28 text->prev->next = text->next;
29 else
30 bot->texts = text->next;
31 free(text);
32 }
33
34 void qabot_freesection(qab_text* text, qab_textsection* section) {
35 qab_spam* line;
36 qab_spam* nline;
37
38 for (line = section->lines; line; line = nline) {
39 nline = line->next;
40
41 free(line->message);
42 free(line);
43 }
44
45 if (section->next)
46 section->next->prev = section->prev;
47 if (section->prev)
48 section->prev->next = section->next;
49 else
50 text->sections = section->next;
51
52 if (text->section_tail == section)
53 text->section_tail = section->prev;
54
55 free(section);
56
57 text->section_count--;
58 if (text->section_count < 0)
59 text->section_count = 0;
60 }