| 1229 | } |
| 1230 | |
| 1231 | HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file) |
| 1232 | { |
| 1233 | FILE *fp; |
| 1234 | char buf[4096]; |
| 1235 | char settingstmp[4096]; |
| 1236 | |
| 1237 | if (settings_file == NULL) |
| 1238 | { |
| 1239 | rig_settings_get_path(settingstmp, sizeof(settingstmp)); |
| 1240 | settings_file = settingstmp; |
| 1241 | } |
| 1242 | |
| 1243 | fp = fopen(settings_file, "r"); |
| 1244 | |
| 1245 | if (fp == NULL) |
| 1246 | { |
| 1247 | #if 0 // until we actually implement this |
| 1248 | rig_debug(RIG_DEBUG_VERBOSE, "%s: settings_file (%s): %s\n", __func__, |
| 1249 | settings_file, strerror(errno)); |
| 1250 | return -RIG_EINVAL; |
| 1251 | #else |
| 1252 | return RIG_OK; |
| 1253 | #endif |
| 1254 | } |
| 1255 | |
| 1256 | rig_debug(RIG_DEBUG_TRACE, "%s: opened %s\n", __func__, settings_file); |
| 1257 | |
| 1258 | while (fgets(buf, sizeof(buf), fp)) |
| 1259 | { |
| 1260 | const char *s = strtok(buf, "="); |
| 1261 | const char *v = strtok(NULL, "\r\n"); |
| 1262 | |
| 1263 | if (strcmp(s, "sharedkey") == 0) |
| 1264 | { |
| 1265 | char *sharedkey = strdup(v); |
| 1266 | rig_debug(RIG_DEBUG_TRACE, "%s: settings_file=%s, shared_key=%s\n", __func__, |
| 1267 | settings_file, sharedkey); |
| 1268 | free(sharedkey); |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | fclose(fp); |
| 1273 | |
| 1274 | return RIG_OK; |
| 1275 | } |
| 1276 | |
| 1277 | |
| 1278 | /*! @} */ |
no test coverage detected