From 141c229afc55afcca3538ebee35b45807d27ab8b Mon Sep 17 00:00:00 2001 From: Cesare Tirabassi Date: Mon, 10 Aug 2009 22:46:21 +0200 Subject: [PATCH] Add day and date data_type to --- ChangeLog | 3 +++ doc/variables.xml | 16 ++++++++++++---- src/weather.c | 24 +++++++++++++++++++----- src/weather.h | 2 ++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e9d08d..2c01546 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-08-10 + * Add day and date data_type to $weather_forecast + 2009-08-03 * Added support for $weather_forecast (experimental) diff --git a/doc/variables.xml b/doc/variables.xml index 9759d62..661ce25 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -3445,27 +3445,35 @@ 'data_type' must be one of the following: + day + + + + date + + + low - + high - + icon - + forecast - + wind_speed diff --git a/src/weather.c b/src/weather.c index 4265a25..df4c3cb 100644 --- a/src/weather.c +++ b/src/weather.c @@ -46,12 +46,13 @@ const char *xpath_expression_cc[NUM_XPATH_EXPRESSIONS_CC] = { "/weather/cc/hmid", "/weather/cc/icon" }; -#define NUM_XPATH_EXPRESSIONS_DF 8 +#define NUM_XPATH_EXPRESSIONS_DF 10 const char *xpath_expression_df[NUM_XPATH_EXPRESSIONS_DF] = { "/weather/dayf/day[*]/hi", "/weather/dayf/day[*]/low", "/weather/dayf/day[*]/part[1]/icon", "/weather/dayf/day[*]/part[1]/t", "/weather/dayf/day[*]/part[1]/wind/s","/weather/dayf/day[*]/part[1]/wind/d", - "/weather/dayf/day[*]/part[1]/ppcp", "/weather/dayf/day[*]/part[1]/hmid" + "/weather/dayf/day[*]/part[1]/ppcp", "/weather/dayf/day[*]/part[1]/hmid", + "//@t", "//@dt" }; #endif /* XOAP */ @@ -151,12 +152,21 @@ static void parse_df(PWEATHER_FORECAST *res, xmlXPathContextPtr xpathCtx) case 7: res->hmid[k] = atoi(content); } - xmlFree(content); - if (++k == FORECAST_DAYS) break; + } else if (nodes->nodeTab[j]->type == XML_ATTRIBUTE_NODE) { + content = (char *)xmlNodeGetContent(nodes->nodeTab[k]); + switch(i) { + case 8: + strncpy(res->day[k], content, 8); + break; + case 9: + strncpy(res->date[k], content, 6); + } } + xmlFree(content); + if (++k == FORECAST_DAYS) break; } - xmlXPathFreeObject(xpathObj); } + xmlXPathFreeObject(xpathObj); } return; } @@ -683,6 +693,10 @@ void weather_forecast_process_info(char *p, int p_max_size, char *uri, unsigned snprintf(p, p_max_size, "%d", data->hmid[day]); } else if (strcmp(data_type, "precipitation") == EQUAL) { snprintf(p, p_max_size, "%d", data->ppcp[day]); + } else if (strcmp(data_type, "day") == EQUAL) { + strncpy(p, data->day[day], p_max_size); + } else if (strcmp(data_type, "date") == EQUAL) { + strncpy(p, data->date[day], p_max_size); } timed_thread_unlock(curloc->p_timed_thread); diff --git a/src/weather.h b/src/weather.h index d70ec19..b1db019 100644 --- a/src/weather.h +++ b/src/weather.h @@ -56,6 +56,8 @@ typedef struct PWEATHER_FORECAST_ { int low[FORECAST_DAYS]; char icon[FORECAST_DAYS][3]; char xoap_t[FORECAST_DAYS][32]; + char day[FORECAST_DAYS][9]; + char date[FORECAST_DAYS][7]; int wind_s[FORECAST_DAYS]; int wind_d[FORECAST_DAYS]; int hmid[FORECAST_DAYS]; -- 1.7.9.5