1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * $Id: libdb.h,v 1.10 2005/03/05 21:39:44 nedko Exp $
7 * Unified access to database.
10 * Nedko Arnaudov <nedko@users.sourceforge.net>
13 * GNU GENERAL PUBLIC LICENSE version 2
15 *****************************************************************************/
17 #ifndef LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED
18 #define LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED
20 /* mediadb type is *handle*, use it as *handle* */
21 typedef struct { int unused
; } * mediadb
;
22 #define MEDIADB_INVALID_VALUE NULL
24 typedef unsigned long long mediadb_uint
;
26 #define MEDIADB_MT_UNKNOWN 0
27 #define MEDIADB_MT_AUDIO 1
28 #define MEDIADB_MT_DATA 2
29 #define MEDIADB_MT_EMPTY 3
31 /* Contains on of MEDIADB_MT_XXX values */
32 typedef unsigned int mediadb_mediatype
;
34 #define MEDIADB_DBTYPE_UNKNOWN 0
35 #define MEDIADB_DBTYPE_MYSQL 1
36 #define MEDIADB_DBTYPE_SQLITE 2
38 typedef unsigned int mediadb_filetype
;
40 #define MEDIADB_FILETYPE_FILE 1
41 #define MEDIADB_FILETYPE_DIR 2
43 typedef unsigned int mediadb_bool
;
45 #define MEDIADB_FALSE 0
46 #define MEDIADB_TRUE 1
48 struct mediadb_pattern_match_method
52 const char *pszDescription
;
56 #define MEDIADB_PMM_NULL 0
58 /* Open handle to media database */
61 unsigned int nDBType
, /* MEDIADB_DBTYPE_XXX */
68 /* Add new media to database */
70 mediadb_media_add_new(
73 const char *pszComment
,
74 mediadb_mediatype nType
,
75 mediadb_uint
*pnNewMediaID
);
77 /* Update media properties */
79 mediadb_media_update_properties(
81 mediadb_uint nMediaID
,
82 mediadb_uint nTimeAdded
,
83 mediadb_uint nTotalFiles
,
84 mediadb_uint nTotalSize
);
86 /* Add new file to database */
90 mediadb_uint nMediaID
,
91 mediadb_filetype Filetype
,
94 mediadb_uint nFileSize
,
95 mediadb_uint nFileTime
);
98 mediadb_media_get_properties(
100 mediadb_uint nMediaID
,
101 mediadb_uint
*pnTimeAdded
,
102 mediadb_mediatype
*pnType
,
103 mediadb_uint
*pnLocationID
,
107 mediadb_location_get_properties(
109 mediadb_uint nLocationID
,
110 mediadb_uint
*pnLocationTypeID
,
111 char **ppszDescription
);
114 mediadb_location_type_get_properties(
116 mediadb_uint nLocationTypeID
,
117 char **ppszDescription
);
120 mediadb_media_get_properties_data(
122 mediadb_uint nMediaID
,
123 mediadb_uint
*pnTotalFiles
,
124 mediadb_uint
*pnTotalSize
);
128 mediadb_media_get_properties_audio(
130 mediadb_uint nMediaID);
134 mediadb_delete_media_files(
136 mediadb_uint nMediaID
);
139 mediadb_media_update_name(
141 mediadb_uint nMediaID
,
142 const char *pszName
);
144 typedef void (* mediadb_media_callback
)(
146 mediadb_uint nMediaID
,
147 mediadb_mediatype nType
,
149 const char *pszComment
,
150 mediadb_uint nTimeAdded
,
151 mediadb_uint nTotalFiles
,
152 mediadb_uint nTotalSize
,
153 mediadb_uint nLocationID
,
154 const char *pszLocation
158 mediadb_media_get_all(
160 mediadb_media_callback pCallback
,
163 typedef void (* mediadb_files_callback
)(
167 mediadb_filetype Filetype
,
174 mediadb_uint nMediaID
,
176 mediadb_files_callback pCallback
,
180 mediadb_file_get_properties(
182 mediadb_uint nMediaID
,
185 mediadb_filetype
*pFiletype
,
186 mediadb_uint
*pnSize
,
187 mediadb_uint
*pnTime
);
189 /* Close previously opened handle to database */
195 mediadb_get_error_message(
198 /* *ppPSM is valid until hDB is valid */
200 mediadb_get_pattern_match_methods(
202 const struct mediadb_pattern_match_method
**ppPMM
);
204 typedef void (* mediadb_files_search_callback
)(
206 mediadb_uint nMediaID
,
207 mediadb_mediatype nMediaType
,
208 const char *pszMediaName
,
209 const char *pszMediaLocation
,
212 mediadb_filetype Filetype
,
217 mediadb_files_search(
219 mediadb_uint nFilenamePMMID
,
220 const char *pszFilenamePattern
,
221 mediadb_uint nPathPMMID
,
222 const char *pszPathPattern
,
223 const mediadb_uint
*pnMinSize
,
224 const mediadb_uint
*pnMaxSize
,
225 mediadb_files_search_callback pCallback
,
228 #endif /* #ifndef LIBDB_H__3CA527C8_33FF_45D6_9D36_228F0E920EEA__INCLUDED */
230 /*****************************************************************************
234 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
237 * Revision 1.10 2005/03/05 21:39:44 nedko
238 * new functionality - file_get_properties()
240 * Revision 1.9 2004/09/18 21:34:35 nedko
241 * Return media name, media type and media location when searching files.
243 * Revision 1.8 2004/08/31 22:40:15 nedko
244 * Partitally implemented search feature.
246 * Revision 1.7 2004/08/08 00:47:42 nedko
247 * Get more info for media from database.
249 * Revision 1.6 2004/05/21 23:40:46 nedko
250 * New functionality: mediadb_files_get()
252 * Revision 1.5 2004/05/16 18:57:12 nedko
253 * media_get_all functionality implemented.
255 * Revision 1.4 2004/05/03 20:47:15 nedko
256 * Update mode for cui
258 * Revision 1.3 2004/05/02 20:12:11 nedko
259 * Improve error dumps.
261 * Revision 1.2 2004/05/02 13:16:58 nedko
262 * Supply filetype when adding new file
264 * Revision 1.1 2004/04/27 09:12:28 nedko
267 *****************************************************************************/