1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
5 * Copyright (C) 2001-2009, Eduardo Silva P.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program 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
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #define MK_PLUGIN_LOAD "plugins.load"
33 #define MK_PLUGIN_ERROR -1 /* plugin execution error */
36 #define MK_PLUGIN_STAGE_00 ((__uint32_t) 0) /* Dummy plugin */
37 #define MK_PLUGIN_STAGE_10 ((__uint32_t) 1) /* Before server's loop */
38 #define MK_PLUGIN_STAGE_20 ((__uint32_t) 2) /* Accepted connection */
39 #define MK_PLUGIN_STAGE_30 ((__uint32_t) 4) /* Connection assigned */
40 #define MK_PLUGIN_STAGE_40 ((__uint32_t) 8) /* Object Handler */
41 #define MK_PLUGIN_STAGE_50 ((__uint32_t) 16) /* Request ended */
42 #define MK_PLUGIN_STAGE_60 ((__uint32_t) 32) /* Connection closed */
44 #define MK_PLUGIN_RET_CLOSE_CONX 100
45 #define MK_PLUGIN_RET_OWNER 200
46 #define MK_PLUGIN_RET_CONTINUE 300
48 struct plugin_stages
{
49 struct plugin
*stage_00
;
50 struct plugin
*stage_10
;
51 struct plugin
*stage_20
;
52 struct plugin
*stage_30
;
53 struct plugin
*stage_40
;
54 struct plugin
*stage_50
;
55 struct plugin
*stage_60
;
60 struct plugin_list
*next
;
63 struct plugin_list
*plg_list
;
72 /* Plugin external functions */
73 int (*call_init
)(void *api
);
74 int (*call_worker_init
)();
75 int (*call_stage_10
)();
76 int (*call_stage_20
)(unsigned int,
77 struct sched_connection
*,
78 struct client_request
*);
79 int (*call_stage_30
)(struct client_request
*, struct request
*);
80 int (*call_stage_40
)(struct client_request
*, struct request
*);
86 struct server_config
*config
;
87 struct plugin_list
*plugins
;
88 struct sched_list_node
**sched_list
;
90 /* Exporting Functions */
91 void *(*mem_alloc
)(int);
92 void *(*mem_alloc_z
)(int);
93 void *(*mem_free
)(void *);
94 void *(*str_build
)(char **, unsigned long *, const char *, ...);
95 void *(*str_dup
)(const char *);
96 void *(*str_search
)(char *, char *);
97 void *(*str_search_n
)(char *, char *, int);
98 void *(*str_copy_substr
)(const char *, int, int);
99 void *(*str_split_line
)(const char *);
100 void *(*file_to_buffer
)(char *);
101 void *(*file_get_info
)(char *);
102 void *(*header_send
)(int,
103 struct client_request
*,
106 void *(*iov_create
)(int, int);
107 void *(*iov_free
)(struct mk_iov
*);
108 void *(*iov_add_entry
)(struct mk_iov
*,
113 void *(*iov_set_entry
)(struct mk_iov
*,
118 void *(*iov_send
)(int, struct mk_iov
*, int);
119 void *(*iov_print
)(struct mk_iov
*);
120 void *(*pointer_set
)(mk_pointer
*, char *);
121 void *(*pointer_print
)(mk_pointer
);
122 void *(*socket_cork_flag
)(int, int);
123 void *(*socket_set_tcp_nodelay
)(int);
124 void *(*socket_connect
)(int, char *, int);
125 void *(*socket_create
)();
126 void *(*config_create
)(char *);
127 void *(*config_free
)(struct mk_config
*);
128 void *(*config_getval
)(struct mk_config
*, char *, int);
129 void *(*sched_get_connection
)(struct sched_list_node
*, int);
132 typedef char mk_plugin_data_t
[];
133 typedef __uint32_t mk_plugin_stage_t
;
135 void mk_plugin_init();
136 int mk_plugin_stage_run(mk_plugin_stage_t stage
,
138 struct sched_connection
*conx
,
139 struct client_request
*cr
,
141 void mk_plugin_worker_startup();