~ctrlproxy/ctrlproxy/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* 
	ctrlproxy: A modular IRC proxy
	(c) 2002-2005 Jelmer Vernooij <jelmer@nl.linux.org>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __REDIRECT_H__
#define __REDIRECT_H__

/**
 * IRC Query done by a client
 */
struct query {
	/** Command name. */
	char *name;

	/** Possible replies */
	int replies[20];
	/** Possible replies that are the last reply to this command. */
	int end_replies[20];
	/** Possible errors. */
	int errors[20];
	/* Should add this query to the stack. return TRUE if this has 
	 * been done successfully, FALSE otherwise */
	/** Function for handling the responses. */
	int (*handle) (const struct irc_line *, struct query_stack *, void *userdata, struct query *);
};



struct query_stack_entry {
	const struct query *query;
	void *userdata;
	time_t time;
};

struct query_stack {
	GList *entries;
	void (*unref_userdata) (void *);
	void (*ref_userdata) (void *);
};



void *query_stack_match_response(struct query_stack *stack, const struct irc_line *l);
gboolean query_stack_record(struct query_stack *stack, void *c, const struct irc_line *l);
struct query_stack *new_query_stack(void (*ref_userdata) (void *), void (*unref_userdata) (void *));
void query_stack_clear(struct query_stack *n);
void query_stack_free(struct query_stack *n);


#endif /* __REDIRECT_H__ */