]> Pileus Git - aweather/blobdiff - src/plugins/radar.c
Update San Juan site
[aweather] / src / plugins / radar.c
index ff888f4a65fd40dbafcc8f2d2f28a46c33a60ef7..555534f9c9b9c3d528ec0a10f4cf8eba5139d599 100644 (file)
@@ -141,7 +141,7 @@ gpointer _site_update_thread(gpointer _site)
        gchar *dir_list = g_strconcat(nexrad_url, "/", site->city->code,
                        "/", "dir.list", NULL);
        GList *files = grits_http_available(site->http,
-                       "^K\\w{3}_\\d{8}_\\d{4}$", site->city->code,
+                       "^\\w{4}_\\d{8}_\\d{4}$", site->city->code,
                        "\\d+ (.*)", (offline ? NULL : dir_list));
        g_free(dir_list);
        gchar *nearest = _find_nearest(site->time, files, 5, "%Y%m%d_%H%M");
@@ -495,7 +495,7 @@ gpointer _conus_update_thread(gpointer _conus)
                 * the index pages get cached and out of date */
                struct tm tm;
                gmtime_r(&conus->time, &tm);
-               time_t onthe8 = conus->time - 60*((tm.tm_min+2)%10);
+               time_t onthe8 = conus->time - 60*((tm.tm_min+1)%10+1);
                gmtime_r(&onthe8, &tm);
                nearest = g_strdup_printf("Conus_%04d%02d%02d_%02d%02d_N0Ronly.gif",
                                tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
@@ -641,14 +641,14 @@ static void _draw_hud(GritsCallback *callback, GritsOpenGL *opengl, gpointer _se
 static void _load_colormap(gchar *filename, AWeatherColormap *cm)
 {
        g_debug("GritsPluginRadar: _load_colormap - %s", filename);
-       FILE *file = g_fopen(filename, "r");
+       FILE *file = fopen(filename, "r");
        if (!file)
                g_error("GritsPluginRadar: open failed");
        guint8 color[4];
        GArray *array = g_array_sized_new(FALSE, TRUE, sizeof(color), 256);
-       fgets(cm->name, sizeof(cm->name), file);
-       fscanf(file, "%f\n", &cm->scale);
-       fscanf(file, "%f\n", &cm->shift);
+       if (!fgets(cm->name, sizeof(cm->name), file)) goto out;
+       if (!fscanf(file, "%f\n", &cm->scale))        goto out;
+       if (!fscanf(file, "%f\n", &cm->shift))        goto out;
        int r, g, b, a;
        while (fscanf(file, "%d %d %d %d\n", &r, &g, &b, &a) == 4) {
                color[0] = r;
@@ -659,7 +659,9 @@ static void _load_colormap(gchar *filename, AWeatherColormap *cm)
        }
        cm->len  = (gint )array->len;
        cm->data = (void*)array->data;
+out:
        g_array_free(array, FALSE);
+       fclose(file);
 }
 
 static void _update_hidden(GtkNotebook *notebook,