Fixed a couple of compiler warnings
This commit is contained in:
parent
6dbd21bc07
commit
908bfc1a78
6 changed files with 20 additions and 17 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <curl/curl.h>
|
||||
#include <json-c/json.h>
|
||||
#include <libnova/libnova.h>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -28,17 +28,15 @@
|
|||
|
||||
#include <json-c/json.h>
|
||||
|
||||
/* 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_ */
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libnova/libnova.h>
|
||||
|
||||
#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";
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue