blob: 4d45735e41cf2afe9de3739039c281f4d7a8b7dc
1 | #include <stdio.h> |
2 | #include <stdlib.h> |
3 | #include <string.h> |
4 | #include <errno.h> |
5 | #include "tvconfig.h" |
6 | |
7 | #define LOG_TAG "TVCONFIG" |
8 | #include "CTvLog.h" |
9 | #include "CIniFile.h" |
10 | static const char *TV_SECTION = "TV"; |
11 | //INI_CONFIG* mpConfig = NULL; |
12 | static char mpFilePath[256] = {0}; |
13 | |
14 | static CIniFile *pIniFile = NULL; |
15 | int tv_config_load(const char *file_name) |
16 | { |
17 | if (pIniFile != NULL) |
18 | delete pIniFile; |
19 | |
20 | pIniFile = new CIniFile(); |
21 | pIniFile->LoadFromFile(file_name); |
22 | strcpy(mpFilePath, file_name); |
23 | return 0; |
24 | } |
25 | |
26 | int tv_config_unload() |
27 | { |
28 | if (pIniFile != NULL) |
29 | delete pIniFile; |
30 | return 0; |
31 | } |
32 | |
33 | |
34 | int config_set_str(const char *section, const char *key, const char *value) |
35 | { |
36 | return pIniFile->SetString(section, key, value); |
37 | } |
38 | |
39 | const char *config_get_str(const char *section, const char *key, const char *def_value) |
40 | { |
41 | return pIniFile->GetString(section, key, def_value); |
42 | } |
43 | |
44 | int config_get_int(const char *section, const char *key, const int def_value) |
45 | { |
46 | return pIniFile->GetInt(section, key, def_value); |
47 | } |
48 | |
49 | int config_set_int(const char *section, const char *key, const int value) |
50 | { |
51 | pIniFile->SetInt(section, key, value); |
52 | return 0; |
53 | } |
54 |