e92d6e3c369726529c8b480fedcecd173970943f
[lms] / lightmediascanner / src / lib / lightmediascanner_private.h
1 /**
2  * Copyright (C) 2007 by INdT
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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 Lesser 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-1307, USA.
17  *
18  * @author Gustavo Sverzut Barbieri <gustavo.barbieri@openbossa.org>
19  */
20
21 #ifndef _LIGHTMEDIASCANNER_PRIVATE_H_
22 #define _LIGHTMEDIASCANNER_PRIVATE_H_ 1
23
24 #ifdef __GNUC__
25 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
26 #  define GNUC_NON_NULL(...) __attribute__((nonnull(__VA_ARGS__)))
27 # else
28 #  define GNUC_NON_NULL(...)
29 # endif
30 #else
31 #  define GNUC_NON_NULL(...)
32 #endif
33
34 #include "lightmediascanner.h"
35 #include "lightmediascanner_plugin.h"
36 #include "lightmediascanner_charset_conv.h"
37 #include <sys/types.h>
38 #include <poll.h>
39 #include <limits.h>
40 #include <sqlite3.h>
41
42 #define PATH_SIZE PATH_MAX
43
44 struct fds {
45     int r;
46     int w;
47 };
48
49 /* info to be carried along lms_process() and lms_check() */
50 struct pinfo {
51     struct fds master;
52     struct fds slave;
53     struct pollfd poll;
54     lms_t *lms;
55     pid_t child;
56 };
57
58 struct parser {
59     lms_plugin_t *plugin;
60     void *dl_handle;
61     char *so_path;
62 };
63
64 struct lms {
65     struct parser *parsers;
66     int n_parsers;
67     lms_charset_conv_t *cs_conv;
68     char *db_path;
69     int slave_timeout;
70     unsigned int commit_interval;
71     unsigned int is_processing:1;
72     unsigned int stop_processing:1;
73 };
74
75 int lms_parser_del_int(lms_t *lms, int i) GNUC_NON_NULL(1);
76 int lms_create_pipes(struct pinfo *pinfo) GNUC_NON_NULL(1);
77 int lms_close_pipes(struct pinfo *pinfo) GNUC_NON_NULL(1);
78 int lms_create_slave(struct pinfo *pinfo, int (*work)(lms_t *lms, struct fds *fds)) GNUC_NON_NULL(1, 2);
79 int lms_restart_slave(struct pinfo *pinfo, int (*work)(lms_t *lms, struct fds *fds)) GNUC_NON_NULL(1, 2);
80 int lms_finish_slave(struct pinfo *pinfo, int (*finish)(const struct fds *fds)) GNUC_NON_NULL(1, 2);
81
82 int lms_parsers_setup(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
83 int lms_parsers_start(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
84 int lms_parsers_finish(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
85 int lms_parsers_check_using(lms_t *lms, void **parser_match, struct lms_file_info *finfo) GNUC_NON_NULL(1, 2, 3);
86 int lms_parsers_run(lms_t *lms, sqlite3 *db, void **parser_match, struct lms_file_info *finfo) GNUC_NON_NULL(1, 2, 3, 4);
87
88
89 #endif /* _LIGHTMEDIASCANNER_PRIVATE_H_ */