1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

weather: change hardcoded constant 5 to FORECAST_DAYS macro

This commit is contained in:
Cesare Tirabassi 2009-08-03 11:49:26 +02:00
parent d707d536bb
commit 4fe70ad0e6
4 changed files with 17 additions and 13 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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=");

View File

@ -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 */