Fixed HTTP-client query-string handling bug.
[doldaconnect.git] / daemon / module.h
CommitLineData
d3372da9 1/*
2 * Dolda Connect - Modular multiuser Direct Connect-style client
302a2600 3 * Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
d3372da9 4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19#ifndef _MODULE_H
20#define _MODULE_H
21
22#include <stdio.h>
23
24#include "conf.h"
25
26struct module
27{
28 struct module *next;
29 char *name;
30 /* Called before the configuration file is read. Must either
31 * succeed or call exit. Note that it is called both at startup
32 * and when SIGHUP has been received (then with hup = 1). */
33 void (*preinit)(int hup);
34 /* Called when the configuration file has been read. Return zero
35 * on success and non-zero on failure. Note, as with preinit, that
36 * it can be called both at startup and after SIHUP. */
37 int (*init)(int hup);
38 /* Called every "cycle". Its return value determines whether the
39 * module still has work to do, and thus determines whether the
40 * next pollsocks should block or not. Return non-zero whenever
41 * the module has more work to do. */
42 int (*run)(void);
43 /* Called when the daemon is shutting down. */
44 void (*terminate)(void);
45 struct configmod conf;
46};
47
48#define MODULE(mod) \
49static void __attribute__ ((constructor)) __regmod(void) \
50{ \
51 extern struct module *modchain; \
52 \
53 if(mod.name == NULL) \
54 { \
55 fprintf(stderr, "module at %p has no name", &mod); \
56 exit(1); \
57 } \
58 mod.conf.name = mod.name; \
59 mod.next = modchain; \
60 modchain = &mod; \
61}
62
63void regmod(struct module *);
64
65#endif