blob: 44c2f834c60dce007ded366166eaa3e98b0fe6d1 [file] [log] [blame]
Willy Tarreau3fdb3662012-11-12 00:42:33 +01001/*
2 * include/proto/obj_type.h
3 * This file contains function prototypes to manipulate object types
4 *
5 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _PROTO_OBJ_TYPE_H
23#define _PROTO_OBJ_TYPE_H
24
25#include <common/config.h>
26#include <common/memory.h>
27#include <types/listener.h>
28#include <types/obj_type.h>
29#include <types/proxy.h>
30#include <types/server.h>
31#include <types/stream_interface.h>
32
33static inline enum obj_type obj_type(enum obj_type *t)
34{
35 if (!t || *t > OBJ_TYPE_APPLET)
36 return OBJ_TYPE_NONE;
37 return *t;
38}
39
40static inline struct listener *objt_listener(enum obj_type *t)
41{
42 if (!t || *t != OBJ_TYPE_LISTENER)
43 return NULL;
44 return container_of(t, struct listener, obj_type);
45}
46
47static inline struct proxy *objt_proxy(enum obj_type *t)
48{
49 if (!t || *t != OBJ_TYPE_PROXY)
50 return NULL;
51 return container_of(t, struct proxy, obj_type);
52}
53
54static inline struct server *objt_server(enum obj_type *t)
55{
56 if (!t || *t != OBJ_TYPE_SERVER)
57 return NULL;
58 return container_of(t, struct server, obj_type);
59}
60
61static inline struct si_applet *objt_applet(enum obj_type *t)
62{
63 if (!t || *t != OBJ_TYPE_APPLET)
64 return NULL;
65 return container_of(t, struct si_applet, obj_type);
66}
67
68#endif /* _PROTO_OBJ_TYPE_H */
69
70/*
71 * Local variables:
72 * c-indent-level: 8
73 * c-basic-offset: 8
74 * End:
75 */