diff --git a/src/calcelestial.c b/src/calcelestial.c index ec91828..3a038fa 100644 --- a/src/calcelestial.c +++ b/src/calcelestial.c @@ -245,7 +245,7 @@ int main(int argc, char *argv[]) { #ifdef GEONAMES_SUPPORT /* lookup place at http://geonames.org */ - if (query && geonames_lookup(query, (struct pos *) &obs, NULL, 0) != 0) { + if (query && geonames_lookup(query, &obs, NULL, 0) != 0) { fprintf(stderr, "failed to lookup location: %s\n", query); error = true; } diff --git a/src/geonames.c b/src/geonames.c index 270bd58..9b0522d 100644 --- a/src/geonames.c +++ b/src/geonames.c @@ -29,6 +29,7 @@ #include #include +#include #include "../config.h" #include "geonames.h" @@ -68,7 +69,7 @@ static size_t json_parse_callback(void *contents, size_t size, size_t nmemb, voi return realsize; } -int geonames_lookup(const char *place, struct coords *result, char *name, int n) { +int geonames_lookup(const char *place, struct ln_lnlat_posn *result, char *name, int n) { #ifdef GEONAMES_CACHE_SUPPORT if (geonames_cache_lookup(place, result, name, n) == EXIT_SUCCESS) { @@ -135,7 +136,7 @@ int geonames_lookup(const char *place, struct coords *result, char *name, int n) } } -int geonames_parse(struct json_object *jobj, struct coords *result, char *name, int n) { +int geonames_parse(struct json_object *jobj, struct ln_lnlat_posn *result, char *name, int n) { int results = json_object_get_int(json_object_object_get(jobj, "totalResultsCount")); if (results == 0) { return EXIT_FAILURE; @@ -152,7 +153,7 @@ int geonames_parse(struct json_object *jobj, struct coords *result, char *name, return EXIT_SUCCESS; } -int geonames_cache_lookup(const char *place, struct coords *result, char *name, int n) { +int geonames_cache_lookup(const char *place, struct ln_lnlat_posn *result, char *name, int n) { /* create filename */ char filename[256]; snprintf(filename, sizeof(filename), "%s/%s", getenv("HOME"), GEONAMES_CACHE_FILE); @@ -204,7 +205,7 @@ int geonames_cache_lookup(const char *place, struct coords *result, char *name, return 1; /* not found */ } -int geonames_cache_store(const char *place, struct coords *result, char *name, int n) { +int geonames_cache_store(const char *place, struct ln_lnlat_posn *result, char *name, int n) { /* create filename */ char filename[256]; snprintf(filename, sizeof(filename), "%s/%s", getenv("HOME"), GEONAMES_CACHE_FILE); diff --git a/src/geonames.h b/src/geonames.h index 7c4d940..1ebfdb2 100644 --- a/src/geonames.h +++ b/src/geonames.h @@ -28,17 +28,15 @@ #include +/* Forward declaration */ +struct ln_lnlat_posn; + #define GEONAMES_CACHE_SUPPORT 1 #define GEONAMES_CACHE_FILE ".geonames.cache" /* in users home dir */ -struct coords { - double lng; - double lat; -}; - -int geonames_lookup(const char *place, struct coords *coords, char *name, int n); -int geonames_cache_lookup(const char *place, struct coords *result, char *name, int n); -int geonames_cache_store(const char *place, struct coords *result, char *name, int n); -int geonames_parse(struct json_object *jobj, struct coords *result, char *name, int n); +int geonames_lookup(const char *place, struct ln_lnlat_posn *coords, char *name, int n); +int geonames_cache_lookup(const char *place, struct ln_lnlat_posn *result, char *name, int n); +int geonames_cache_store(const char *place, struct ln_lnlat_posn *result, char *name, int n); +int geonames_parse(struct json_object *jobj, struct ln_lnlat_posn *result, char *name, int n); #endif /* _GEONAMES_H_ */ diff --git a/src/geonames_main.c b/src/geonames_main.c index 3d54c5f..f35db72 100644 --- a/src/geonames_main.c +++ b/src/geonames_main.c @@ -26,11 +26,13 @@ #include #include +#include + #include "../config.h" #include "geonames.h" int main(int argc, char *argv[]) { - struct coords res; + struct ln_lnlat_posn res; char *result_name = malloc(32); char *name = "Aachen"; diff --git a/src/helpers.c b/src/helpers.c index b1224ed..7b6c0e4 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -44,8 +44,8 @@ char * strfjddur(char *s, size_t max, const char *format, double jd) { if (strstr(format, "%s") != NULL) { char timestamp_str[16]; - int seconds = round(jd * 86400); - snprintf(timestamp_str, sizeof(timestamp_str), "%lu", seconds); + unsigned long long seconds = round(jd * 86400); + snprintf(timestamp_str, sizeof(timestamp_str), "%llu", seconds); format = strreplace(local_format, "%s", timestamp_str); } diff --git a/src/objects.c b/src/objects.c index 1613708..845b5a4 100644 --- a/src/objects.c +++ b/src/objects.c @@ -53,6 +53,7 @@ void object_pos(enum object obj, double jd, struct object_details *details) { case OBJECT_SATURN: return object_pos_saturn(jd, details); case OBJECT_VENUS: return object_pos_venus(jd, details); case OBJECT_PLUTO: return object_pos_pluto(jd, details); + default: ; } } @@ -68,6 +69,7 @@ int object_rst(enum object obj, double jd, double horizon, struct ln_lnlat_posn case OBJECT_SATURN: return ln_get_saturn_rst(jd, obs, rst); case OBJECT_VENUS: return ln_get_venus_rst(jd, obs, rst); case OBJECT_PLUTO: return ln_get_pluto_rst(jd, obs, rst); + default: return -1; } }