| The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 1 | /* Copyright (C) 2008 The Android Open Source Project |
| 2 | ** |
| 3 | ** This software is licensed under the terms of the GNU General Public |
| 4 | ** License version 2, as published by the Free Software Foundation, and |
| 5 | ** may be copied, distributed, and modified under those terms. |
| 6 | ** |
| 7 | ** This program is distributed in the hope that it will be useful, |
| 8 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | ** GNU General Public License for more details. |
| 11 | */ |
| 12 | #include "android/avd/hw-config.h" |
| 13 | #include "android/utils/ini.h" |
| 14 | #include <string.h> |
| 15 | #include <stdlib.h> |
| 16 | |
| 17 | |
| 18 | /* the global variable containing the hardware config for this device */ |
| 19 | AndroidHwConfig android_hw[1]; |
| 20 | |
| 21 | int |
| 22 | androidHwConfig_read( AndroidHwConfig* config, |
| 23 | IniFile* ini ) |
| 24 | { |
| 25 | if (ini == NULL) |
| 26 | return -1; |
| 27 | |
| 28 | /* use the magic of macros to implement the hardware configuration loaded */ |
| 29 | |
| 30 | #define HWCFG_BOOL(n,s,d,a,t) config->n = iniFile_getBoolean(ini, s, d); |
| 31 | #define HWCFG_INT(n,s,d,a,t) config->n = iniFile_getInteger(ini, s, d); |
| 32 | #define HWCFG_STRING(n,s,d,a,t) config->n = iniFile_getString(ini, s, d); |
| 33 | #define HWCFG_DOUBLE(n,s,d,a,t) config->n = iniFile_getDouble(ini, s, d); |
| 34 | #define HWCFG_DISKSIZE(n,s,d,a,t) config->n = iniFile_getDiskSize(ini, s, d); |
| 35 | |
| 36 | #include "android/avd/hw-config-defs.h" |
| 37 | |
| 38 | return 0; |
| 39 | } |
| David 'Digit' Turner | 622f153 | 2011-02-01 17:48:37 +0100 | [diff] [blame] | 40 | |
| 41 | int |
| 42 | androidHwConfig_write( AndroidHwConfig* config, |
| 43 | IniFile* ini ) |
| 44 | { |
| 45 | if (ini == NULL) |
| 46 | return -1; |
| 47 | |
| 48 | /* use the magic of macros to implement the hardware configuration loaded */ |
| 49 | |
| 50 | #define HWCFG_BOOL(n,s,d,a,t) iniFile_setBoolean(ini, s, config->n); |
| 51 | #define HWCFG_INT(n,s,d,a,t) iniFile_setInteger(ini, s, config->n); |
| 52 | #define HWCFG_STRING(n,s,d,a,t) iniFile_setValue(ini, s, config->n); |
| 53 | #define HWCFG_DOUBLE(n,s,d,a,t) iniFile_setDouble(ini, s, config->n); |
| 54 | #define HWCFG_DISKSIZE(n,s,d,a,t) iniFile_setDiskSize(ini, s, config->n); |
| 55 | |
| 56 | #include "android/avd/hw-config-defs.h" |
| 57 | |
| 58 | return 0; |
| 59 | } |