00001
00021 #ifndef _LIGHTMEDIASCANNER_PRIVATE_H_
00022 #define _LIGHTMEDIASCANNER_PRIVATE_H_ 1
00023
00024 #ifdef __GNUC__
00025 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
00026 # define GNUC_NON_NULL(...) __attribute__((nonnull(__VA_ARGS__)))
00027 # else
00028 # define GNUC_NON_NULL(...)
00029 # endif
00030 #else
00031 # define GNUC_NON_NULL(...)
00032 #endif
00033
00034 #include "lightmediascanner.h"
00035 #include "lightmediascanner_plugin.h"
00036 #include "lightmediascanner_charset_conv.h"
00037 #include <sys/types.h>
00038 #include <poll.h>
00039 #include <limits.h>
00040 #include <sqlite3.h>
00041
00042 #define PATH_SIZE PATH_MAX
00043
00044 struct fds {
00045 int r;
00046 int w;
00047 };
00048
00049 struct cinfo {
00050 lms_t *lms;
00051 };
00052
00053
00054 struct pinfo {
00055 struct cinfo common;
00056 pid_t child;
00057 struct fds master;
00058 struct fds slave;
00059 struct pollfd poll;
00060 };
00061
00062
00063 struct sinfo {
00064 struct cinfo common;
00065 struct db *db;
00066 void **parser_match;
00067 int commit_counter;
00068 };
00069
00070 struct parser {
00071 lms_plugin_t *plugin;
00072 void *dl_handle;
00073 char *so_path;
00074 };
00075
00076 struct lms {
00077 struct parser *parsers;
00078 int n_parsers;
00079 lms_charset_conv_t *cs_conv;
00080 char *db_path;
00081 int slave_timeout;
00082 struct {
00083 lms_progress_callback_t cb;
00084 void *data;
00085 lms_free_callback_t free_data;
00086 } progress;
00087 unsigned int commit_interval;
00088 unsigned int is_processing:1;
00089 unsigned int stop_processing:1;
00090 };
00091
00092 typedef int (*process_file_callback_t)(struct cinfo *info, int base, char *path, const char *name);
00093 typedef int (*check_row_callback_t)(void *db_ptr, struct cinfo *info);
00094
00095 int lms_parser_del_int(lms_t *lms, int i) GNUC_NON_NULL(1);
00096 int lms_create_pipes(struct pinfo *pinfo) GNUC_NON_NULL(1);
00097 int lms_close_pipes(struct pinfo *pinfo) GNUC_NON_NULL(1);
00098 int lms_create_slave(struct pinfo *pinfo, int (*work)(lms_t *lms, struct fds *fds)) GNUC_NON_NULL(1, 2);
00099 int lms_restart_slave(struct pinfo *pinfo, int (*work)(lms_t *lms, struct fds *fds)) GNUC_NON_NULL(1, 2);
00100 int lms_finish_slave(struct pinfo *pinfo, int (*finish)(const struct fds *fds)) GNUC_NON_NULL(1, 2);
00101
00102 int lms_parsers_setup(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
00103 int lms_parsers_start(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
00104 int lms_parsers_finish(lms_t *lms, sqlite3 *db) GNUC_NON_NULL(1, 2);
00105 int lms_parsers_check_using(lms_t *lms, void **parser_match, struct lms_file_info *finfo) GNUC_NON_NULL(1, 2, 3);
00106 int lms_parsers_run(lms_t *lms, sqlite3 *db, void **parser_match, struct lms_file_info *finfo) GNUC_NON_NULL(1, 2, 3, 4);
00107
00108
00109 #endif