]> git.tuebingen.mpg.de Git - paraslash.git/blob - db.h
5f9f2cbf4b9f7c53a383d03ef36529a8911f5a67
[paraslash.git] / db.h
1 /*
2  * Copyright (C) 2005-2006 Andre Noll <maan@systemlinux.org>
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.
8  *
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  *
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 /** \file db.h data structures common to all database tools */
20
21 int find_audio_files(const char *dirname, int (*f)(const char *, const char *));
22
23 /**
24  * describes one of para_server's supported database tools
25  *
26  * There is exactly one such struct for each supported database tool.  During
27  * the startup part of para_server the \a init() function of the activated
28  * database tool gets called which fills in the other members.
29
30  *
31  *
32  */
33 struct dbtool {
34 /**
35  * name name of this database tool
36  */
37 const char *name;
38 /**
39  * the database init routine
40  *
41  * It should check its command line options and do all necessary initialization
42  * like connecting to a database server.
43  *
44  * A negative return value indicates an initialization error and means that
45  * this database tool should be ignored for now (it may later be activated
46  * again via the cdt command).
47  *
48  * If \a init() returns success (non-negative return value), it must have
49  * initialized in all non-optional function pointers of the given dbtool
50  * struct. Moreover, \a cmd_list must point to a NULL-terminated array which
51  * holds the list of all commands that are supported by this database tool.
52  */
53 int (*init)(struct dbtool *self);
54 /**
55  * list of commands supported by this dbtool
56  */
57 struct server_command *cmd_list;
58 /**
59  * pointer to function returning list of at most \a num audio files to be
60  * streamed next
61  *
62  * \a get_audio_file_list() must return a pointer to a array of at most \a num
63  * char* pointers (terminated by a NULL pointer), or NULL on errors.  Both the
64  * array and its contents must be dynamically allocated and are freed by the
65  * caller.
66  *
67 */
68 char **(*get_audio_file_list)(unsigned int num);
69 /**
70  *
71  * the update hook
72  *
73  * The \a update_audio_file pointer is optional and need not be supplied. In this
74  * case it is not neccessary to init this pointer from within init(). If
75  * \a update_audio_file is non-NULL, the function it points to gets called
76  * whenever a new audio file was successfully loaded and is going to be
77  * streamed by any of paraslash's senders. The full path of the audio file is
78  * passed \a update_audio_file().
79  *
80  */
81 void  (*update_audio_file)(char *audio_file);
82 /**
83  *
84  * shutdown this database tool and free all resources
85  *
86  * This gets called whenever the database tool changes (via the cdt command),
87  * or when para_server receives the HUP signal, or when para_server shuts down.
88  * It is assumed to succeed.
89 */
90 void (*shutdown)(void);
91 };
92
93 int mysql_dbtool_init(struct dbtool*);
94 int random_dbtool_init(struct dbtool*);
95