~ctrlproxy/ctrlproxy/trunk

« back to all changes in this revision

Viewing changes to mods/linestack_memory.c

  • Committer: jelmer
  • Date: 2003-10-18 22:02:02 UTC
  • Revision ID: jelmer@samba.org-20031018220202-6801a76318fb4d13
Update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
        ctrlproxy: A modular IRC proxy
 
3
        (c) 2002-2003 Jelmer Vernooij <jelmer@nl.linux.org>
 
4
 
 
5
        This program is free software; you can redistribute it and/or modify
 
6
        it under the terms of the GNU General Public License as published by
 
7
        the Free Software Foundation; either version 2 of the License, or
 
8
        (at your option) any later version.
 
9
 
 
10
        This program is distributed in the hope that it will be useful,
 
11
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
        GNU General Public License for more details.
 
14
 
 
15
        You should have received a copy of the GNU General Public License
 
16
        along with this program; if not, write to the Free Software
 
17
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
*/
 
19
 
 
20
#define _GNU_SOURCE
 
21
#include "ctrlproxy.h"
 
22
#include <string.h>
 
23
 
 
24
gboolean memory_init(struct linestack_context *c, char *args)
 
25
{
 
26
        c->data = NULL;
 
27
}
 
28
 
 
29
gboolean memory_clear(struct linestack_context *c)
 
30
{
 
31
        GSList *gl = (GSList *)c->data;
 
32
        while(gl) {
 
33
                struct line *l = (struct line *)c->data;
 
34
                free_line(l);
 
35
                gl = g_slist_next(gl);
 
36
        }
 
37
        g_slist_free(c->data); c->data = NULL;
 
38
}
 
39
 
 
40
GSList *memory_get_linked_list(struct linestack_context *c)
 
41
{
 
42
        return (GSList *)c->data;
 
43
}
 
44
 
 
45
gboolean memory_add_line(struct linestack_context *b, struct line *l)
 
46
{
 
47
        GSList *gl = (GSList *)b->data;
 
48
        gl = g_slist_append(gl, l);
 
49
        b->data = gl;
 
50
        return TRUE;
 
51
}       
 
52
 
 
53
struct linestack memory = {
 
54
        "memory",
 
55
        memory_init,
 
56
        memory_clear,
 
57
        memory_add_line,
 
58
        memory_get_linked_list,
 
59
        NULL, 
 
60
        memory_clear
 
61
};
 
62
 
 
63
gboolean fini_plugin(struct plugin *p) {
 
64
        unregister_linestack(&memory);
 
65
        return TRUE;
 
66
}
 
67
 
 
68
gboolean init_plugin(struct plugin *p) {
 
69
        register_linestack(&memory);
 
70
        return TRUE;
 
71
}