| 286 | } |
| 287 | |
| 288 | static void cache_location(void) { |
| 289 | if (state.current_loc.lat != LAT_UNDEFINED && state.current_loc.lon != LON_UNDEFINED) { |
| 290 | FILE *f = fopen(cache_file, "w"); |
| 291 | if (f) { |
| 292 | fprintf(f, "%lf %lf\n", state.current_loc.lat, state.current_loc.lon); |
| 293 | DEBUG("Latest location stored in cache file!\n"); |
| 294 | fclose(f); |
| 295 | } else { |
| 296 | WARN("Caching location failed: %s.\n", strerror(errno)); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | static void publish_location(double new_lat, double new_lon, message_t *l) { |
| 302 | l->loc.old.lat = state.current_loc.lat; |