Plugin API: add malloc()
[MonkeyD.git] / src / include / plugin.h
blob899a56db083aabe15b5214298cad766a95f1b795
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
3 /* Monkey HTTP Daemon
4 * ------------------
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.
22 #ifndef MK_PLUGIN_H
23 #define MK_PLUGIN_H
25 #define MK_PLUGIN_LOAD "plugins.load"
27 #define MK_PLUGIN_ERROR -1 /* plugin execution error */
28 #define MK_PLUGIN_
30 #define MK_PLUGIN_STAGE_10 ((__uint32_t) 1) /* Before server's loop */
31 #define MK_PLUGIN_STAGE_20 ((__uint32_t) 2) /* Accepted connection */
32 #define MK_PLUGIN_STAGE_30 ((__uint32_t) 4) /* Connection assigned */
33 #define MK_PLUGIN_STAGE_40 ((__uint32_t) 8) /* Object Handler */
34 #define MK_PLUGIN_STAGE_50 ((__uint32_t) 16) /* Request ended */
35 #define MK_PLUGIN_STAGE_60 ((__uint32_t) 32) /* Connection closed */
37 struct plugins {
38 struct plugin *stage_10;
39 struct plugin *stage_20;
40 struct plugin *stage_30;
41 struct plugin *stage_40;
42 struct plugin *stage_50;
43 struct plugin *stage_60;
46 struct plugin {
47 char *name;
48 char *version;
49 void *handler;
50 __uint32_t *stages;
52 /* Plugin external functions */
53 int (*call_init)(void *api);
54 int (*call_stage_10)();
56 struct plugin *next;
59 struct plugin_api {
60 struct server_config *config;
61 struct sched_list_node **sched_list;
62 /* Functions */
63 void *(*malloc)(int *);
66 typedef char mk_plugin_data_t[];
67 typedef __uint32_t mk_plugin_stage_t;
69 struct plugins *plgs;
71 void mk_plugin_init();
72 void mk_plugin_stage_run(mk_plugin_stage_t stage);
74 #endif