diff --git a/src/conky.c b/src/conky.c index b459a1ff..df45fa6b 100644 --- a/src/conky.c +++ b/src/conky.c @@ -3047,9 +3047,9 @@ static struct text_object *construct_text_object(const char *s, obj->data.weather_forecast.uri = uri; obj->data.weather_forecast.data_type = data_type; - /* Limit the day between 0 (today) and 4 */ - if (day > 4) { - day = 4; + /* Limit the day between 0 (today) and FORECAST_DAYS */ + if (day >= FORECAST_DAYS) { + day = FORECAST_DAYS-1; } obj->data.weather_forecast.day = day; diff --git a/src/text_object.h b/src/text_object.h index f916f18f..519c3184 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -385,8 +385,10 @@ enum text_object_type { #endif /* RSS */ #ifdef WEATHER OBJ_weather, - OBJ_weather_forecast, #endif /* WEATHER */ +#ifdef XOAP + OBJ_weather_forecast, +#endif /* XOAP */ #ifdef HAVE_LUA OBJ_lua, OBJ_lua_parse, diff --git a/src/weather.c b/src/weather.c index 86b91faa..671d5265 100644 --- a/src/weather.c +++ b/src/weather.c @@ -141,7 +141,7 @@ static void parse_df(PWEATHER_FORECAST *res, xmlXPathContextPtr xpathCtx) res->hmid[k] = atoi(content); } xmlFree(content); - if (k++ == 4) break; + if (++k == FORECAST_DAYS) break; } } xmlXPathFreeObject(xpathObj); @@ -766,6 +766,7 @@ void load_xoap_keys(void) strcat(xoap_cc, key); strcat(xoap_cc, "&unit=m"); + /* TODO: Use FORECAST_DAYS instead of 5 */ strcpy(xoap_df, "?dayf=5&link=xoap&prod=xoap&par="); strcat(xoap_df, par); strcat(xoap_df, "&key="); diff --git a/src/weather.h b/src/weather.h index a6773329..d70ec196 100644 --- a/src/weather.h +++ b/src/weather.h @@ -50,15 +50,16 @@ typedef struct PWEATHER_ { } PWEATHER; #ifdef XOAP +#define FORECAST_DAYS 5 typedef struct PWEATHER_FORECAST_ { - int hi[5]; - int low[5]; - char icon[5][3]; - char xoap_t[5][32]; - int wind_s[5]; - int wind_d[5]; - int hmid[5]; - int ppcp[5]; + int hi[FORECAST_DAYS]; + int low[FORECAST_DAYS]; + char icon[FORECAST_DAYS][3]; + char xoap_t[FORECAST_DAYS][32]; + int wind_s[FORECAST_DAYS]; + int wind_d[FORECAST_DAYS]; + int hmid[FORECAST_DAYS]; + int ppcp[FORECAST_DAYS]; } PWEATHER_FORECAST; #endif /* XOAP */