1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-15 19:56:55 +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.uri = uri;
obj->data.weather_forecast.data_type = data_type; obj->data.weather_forecast.data_type = data_type;
/* Limit the day between 0 (today) and 4 */ /* Limit the day between 0 (today) and FORECAST_DAYS */
if (day > 4) { if (day >= FORECAST_DAYS) {
day = 4; day = FORECAST_DAYS-1;
} }
obj->data.weather_forecast.day = day; obj->data.weather_forecast.day = day;

View File

@ -385,8 +385,10 @@ enum text_object_type {
#endif /* RSS */ #endif /* RSS */
#ifdef WEATHER #ifdef WEATHER
OBJ_weather, OBJ_weather,
OBJ_weather_forecast,
#endif /* WEATHER */ #endif /* WEATHER */
#ifdef XOAP
OBJ_weather_forecast,
#endif /* XOAP */
#ifdef HAVE_LUA #ifdef HAVE_LUA
OBJ_lua, OBJ_lua,
OBJ_lua_parse, OBJ_lua_parse,

View File

@ -141,7 +141,7 @@ static void parse_df(PWEATHER_FORECAST *res, xmlXPathContextPtr xpathCtx)
res->hmid[k] = atoi(content); res->hmid[k] = atoi(content);
} }
xmlFree(content); xmlFree(content);
if (k++ == 4) break; if (++k == FORECAST_DAYS) break;
} }
} }
xmlXPathFreeObject(xpathObj); xmlXPathFreeObject(xpathObj);
@ -766,6 +766,7 @@ void load_xoap_keys(void)
strcat(xoap_cc, key); strcat(xoap_cc, key);
strcat(xoap_cc, "&unit=m"); strcat(xoap_cc, "&unit=m");
/* TODO: Use FORECAST_DAYS instead of 5 */
strcpy(xoap_df, "?dayf=5&link=xoap&prod=xoap&par="); strcpy(xoap_df, "?dayf=5&link=xoap&prod=xoap&par=");
strcat(xoap_df, par); strcat(xoap_df, par);
strcat(xoap_df, "&key="); strcat(xoap_df, "&key=");

View File

@ -50,15 +50,16 @@ typedef struct PWEATHER_ {
} PWEATHER; } PWEATHER;
#ifdef XOAP #ifdef XOAP
#define FORECAST_DAYS 5
typedef struct PWEATHER_FORECAST_ { typedef struct PWEATHER_FORECAST_ {
int hi[5]; int hi[FORECAST_DAYS];
int low[5]; int low[FORECAST_DAYS];
char icon[5][3]; char icon[FORECAST_DAYS][3];
char xoap_t[5][32]; char xoap_t[FORECAST_DAYS][32];
int wind_s[5]; int wind_s[FORECAST_DAYS];
int wind_d[5]; int wind_d[FORECAST_DAYS];
int hmid[5]; int hmid[FORECAST_DAYS];
int ppcp[5]; int ppcp[FORECAST_DAYS];
} PWEATHER_FORECAST; } PWEATHER_FORECAST;
#endif /* XOAP */ #endif /* XOAP */