1158115Sume/*-
2158115Sume * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru>
3158115Sume * All rights reserved.
4158115Sume *
5158115Sume * Redistribution and use in source and binary forms, with or without
6158115Sume * modification, are permitted provided that the following conditions
7158115Sume * are met:
8158115Sume * 1. Redistributions of source code must retain the above copyright
9158115Sume *    notice, this list of conditions and the following disclaimer.
10158115Sume * 2. Redistributions in binary form must reproduce the above copyright
11158115Sume *    notice, this list of conditions and the following disclaimer in the
12158115Sume *    documentation and/or other materials provided with the distribution.
13158115Sume *
14158115Sume * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15158115Sume * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16158115Sume * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17158115Sume * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18158115Sume * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19158115Sume * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20158115Sume * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21158115Sume * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22158115Sume * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23158115Sume * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24158115Sume * SUCH DAMAGE.
25158115Sume *
26158115Sume * $FreeBSD$
27158115Sume */
28158115Sume
29171795Sbushman#ifndef __NSCD_AGENT_H__
30171795Sbushman#define __NSCD_AGENT_H__
31158115Sume
32158115Sume/*
33158115Sume * Agents are used to perform the actual lookups from the caching daemon.
34158115Sume * There are two types of daemons: for common requests and for multipart
35158115Sume * requests.
36158115Sume * All agents are stored in the agents table, which is the singleton.
37158115Sume */
38158115Sume
39158115Sumeenum agent_type {
40158115Sume    COMMON_AGENT = 0,
41158115Sume    MULTIPART_AGENT = 1
42158115Sume};
43158115Sume
44158115Sumestruct agent {
45158115Sume   	char	*name;
46158115Sume    	enum agent_type type;
47158115Sume};
48158115Sume
49158115Sumestruct common_agent {
50158115Sume    	struct agent	parent;
51158115Sume	int (*lookup_func)(const char *, size_t, char **, size_t *);
52158115Sume};
53158115Sume
54158115Sumestruct multipart_agent {
55158115Sume    	struct agent	parent;
56194087Sdes	void *(*mp_init_func)(void);
57158115Sume    	int (*mp_lookup_func)(char **, size_t *, void *);
58158115Sume	void (*mp_destroy_func)(void *);
59158115Sume};
60158115Sume
61158115Sumestruct agent_table {
62158115Sume   	struct agent	**agents;
63158115Sume	size_t		agents_num;
64158115Sume};
65158115Sume
66194112Sdesstruct agent_table *init_agent_table(void);
67194112Sdesvoid register_agent(struct agent_table *, struct agent *);
68194112Sdesstruct agent *find_agent(struct agent_table *, const char *, enum agent_type);
69194112Sdesvoid destroy_agent_table(struct agent_table *);
70158115Sume
71158115Sume#endif
72