Initial import (again)
[srvx.git] / src / saxdb.h
1 /* saxdb.h - srvx database manager
2  * Copyright 2002-2004 srvx Development Team
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.  Important limitations are
8  * listed in the COPYING file that accompanies this software.
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, email srvx-maintainers@srvx.net.
17  */
18
19 #if !defined(DBMGR_H)
20 #define DBMGR_H
21
22 #include "recdb.h"
23
24 struct saxdb;
25 struct saxdb_context;
26
27 #define SAXDB_READER(NAME) int NAME(struct dict *db)
28 typedef SAXDB_READER(saxdb_reader_func_t);
29
30 #define SAXDB_WRITER(NAME) int NAME(struct saxdb_context *ctx)
31 typedef SAXDB_WRITER(saxdb_writer_func_t);
32
33 void saxdb_init(void);
34 void saxdb_finalize(void);
35 struct saxdb *saxdb_register(const char *name, saxdb_reader_func_t *reader, saxdb_writer_func_t *writer);
36 void saxdb_write(const char *db_name);
37 void saxdb_write_all(void);
38 int write_database(FILE *out, struct dict *db);
39
40 /* Callbacks for SAXDB_WRITERs */
41 void saxdb_start_record(struct saxdb_context *dest, const char *name, int complex);
42 void saxdb_end_record(struct saxdb_context *dest);
43 void saxdb_write_string_list(struct saxdb_context *dest, const char *name, struct string_list *list);
44 void saxdb_write_string(struct saxdb_context *dest, const char *name, const char *value);
45 void saxdb_write_int(struct saxdb_context *dest, const char *name, unsigned long value);
46
47 /* For doing db writing by hand */
48 struct saxdb_context *saxdb_open_context(FILE *f);
49 void saxdb_close_context(struct saxdb_context *ctx);
50
51 #endif /* !defined(DBMGR_H) */