84c9f4a518b6b8cf56a36389aafc5b5deb49b1eb
[platform/core/appfw/pkgmgr-info.git] / src / server / sqlite_util_internal.c
1 // copyright
2
3 #define _GNU_SOURCE
4
5 #include <sqlite3.h>
6
7 #include "pkgmgrinfo_internal.h"
8
9 void _save_column_int(sqlite3_stmt *stmt, int idx, int *i)
10 {
11         *i = sqlite3_column_int(stmt, idx);
12 }
13
14 inline void _save_column_str(sqlite3_stmt *stmt, int idx, char **str)
15 {
16         const char *val;
17
18         val = (const char *)sqlite3_column_text(stmt, idx);
19         if (val)
20                 *str = strdup(val);
21 }
22
23 void _save_column_bool(sqlite3_stmt *stmt, int idx, bool *bool_value)
24 {
25         const char *val;
26
27         val = (const char *)sqlite3_column_text(stmt, idx);
28         if (!val)
29                 return;
30
31         if (strcasecmp(val, "true") == 0)
32                 *bool_value = true;
33         else if (strcasecmp(val, "false") == 0)
34                 *bool_value = false;
35 }