X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/4c77d5e0aec3c7aab32965ca4e02abb17bb6108f..80471a6a905e00bf80ad04fa2061f88ea81f15cb:/src/googlesearch.c?ds=sidebyside diff --git a/src/googlesearch.c b/src/googlesearch.c index 3448200f..6a63eb54 100644 --- a/src/googlesearch.c +++ b/src/googlesearch.c @@ -23,7 +23,10 @@ #include "config.h" #endif #include +#include #include +#include +#include #include #include @@ -39,7 +42,7 @@ static gchar *last_search_str = NULL; static VikCoord *last_coord = NULL; static gchar *last_successful_search_str = NULL; -static DownloadOptions googlesearch_options = { "http://maps.google.com/", 0 }; +static DownloadOptions googlesearch_options = { "http://maps.google.com/", 0, a_check_map_file }; gchar * a_googlesearch_get_search_string_for_this_place(VikWindow *vw) { @@ -120,7 +123,7 @@ static gboolean parse_file_for_latlon(gchar *file_name, struct LatLon *ll) lat_buf[0] = lon_buf[0] = '\0'; if ((mf = g_mapped_file_new(file_name, FALSE, NULL)) == NULL) { - g_critical(_("couldn't map temp file\n")); + g_critical(_("couldn't map temp file")); exit(1); } len = g_mapped_file_get_length(mf); @@ -209,7 +212,7 @@ static int google_search_get_coord(VikWindow *vw, VikViewport *vvp, gchar *srch_ escaped_srch_str = uri_escape(srch_str); if ((tmp_fd = g_file_open_tmp ("vikgsearch.XXXXXX", &tmpname, NULL)) == -1) { - g_critical(_("couldn't open temp file\n")); + g_critical(_("couldn't open temp file")); exit(1); } @@ -220,11 +223,13 @@ static int google_search_get_coord(VikWindow *vw, VikViewport *vvp, gchar *srch_ /* TODO: curl may not be available */ if (curl_download_uri(uri, tmp_file, &googlesearch_options)) { /* error */ fclose(tmp_file); + tmp_file = NULL; ret = -1; goto done; } fclose(tmp_file); + tmp_file = NULL; if (!parse_file_for_latlon(tmpname, &ll)) { ret = -1; goto done; @@ -243,7 +248,7 @@ static int google_search_get_coord(VikWindow *vw, VikViewport *vvp, gchar *srch_ done: g_free(escaped_srch_str); g_free(uri); - remove(tmpname); + g_remove(tmpname); g_free(tmpname); return ret; }