ea83fbd835dd1b395c05ecb895a0f6c82028f42f
[platform/core/multimedia/libmedia-service.git] / include / media-svc-db-utils.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21 #ifndef _MEDIA_SVC_DB_UTILS_H_
22 #define _MEDIA_SVC_DB_UTILS_H_
23
24 #include <stdbool.h>
25 #include <sqlite3.h>
26 #include <glib.h>
27 #include "media-svc-env.h"
28
29 static inline void __sqlfree(void *p)
30 {
31     void **pp = (void **)p;
32     sqlite3_free(*pp);
33 }
34 #define sql_autoptr __attribute__((cleanup(__sqlfree))) char *
35
36 int _media_svc_create_table(uid_t uid);
37 int _media_svc_sql_query(const char *sql_str, uid_t uid);
38 int _media_svc_sql_query_direct(const char *sql_str, uid_t uid);
39 int _media_svc_check_table_exist(sqlite3 *db_handle, bool *exist);
40 int _media_svc_get_result_with_check_record(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
41 int _media_svc_get_result(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
42 int _media_svc_sql_query_list(GList **query_list, uid_t uid);
43 int _media_svc_sql_query_list_direct(GList **query_list, uid_t uid);
44 void _media_svc_sql_query_add(GList **query_list, char **query);
45
46 #endif /*_MEDIA_SVC_DB_UTILS_H_*/