diff --git a/Changelog b/Changelog index 1a5d5a75c..395f29abf 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +meecast (1.11.14) + * Fixed segmentation fault for gismeteo data + meecast (1.11.13) * Changed url for hourly weather forecast from gismeteo again * Fixed bug - Since version 1.11.8 of MeeCast, no clickable list for the forecast and Pulley-Menu broken #79 diff --git a/debian/changelog b/debian/changelog index 4cb05eb0a..4cfb984d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,6 @@ meecast (1.11.14) unstable; urgency=low + * Added icons to gismeteo.ru + * Fixed segmentation fault for gismeteo data -- Vlad Vasiliev Fri, 21 Dec 2024 12:02:23 +0300 meecast (1.11.13) unstable; urgency=low diff --git a/omweather-gismeteo-ru-stations-db/src/meego-main.cpp b/omweather-gismeteo-ru-stations-db/src/meego-main.cpp index b4a31788c..942aa00d6 100644 --- a/omweather-gismeteo-ru-stations-db/src/meego-main.cpp +++ b/omweather-gismeteo-ru-stations-db/src/meego-main.cpp @@ -443,7 +443,8 @@ gismeteoru_parse_and_write_xml_data(const char *station_id, htmlDocPtr doc, cons xpathObjDescription = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/div[1]/section[2]/div[1]/div/div/div[2]/div[@data-tooltip]", xpathCtx); xpathObjMaxPressure = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row-chart widget-row-chart-pressure row-with-caption' ]/div/div[@class='values']/div[@class='value']/div[@class='maxt']/pressure-value", xpathCtx); xpathObjWindSpeed = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-wind row-wind-speed row-with-caption' ]/div//speed-value", xpathCtx); - xpathObjWindGust = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-wind row-wind-gust row-with-caption' ]/div//speed-value", xpathCtx); + //xpathObjWindGust = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-wind row-wind-gust row-with-caption' ]/div//speed-value", xpathCtx); + xpathObjWindGust = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-wind row-wind-gust row-with-caption' ]/div[@class='row-item']", xpathCtx); xpathObjWindDirection = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-wind row-wind-direction row-with-caption' ]/div//div[@class='direction']/text()", xpathCtx); xpathObjHumidity = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-humidity row-with-caption']/div/text()", xpathCtx); xpathObjUv = xmlXPathEvalExpression((const xmlChar*)"/html/body/main/*//div[@class='widget-row widget-row-radiation row-with-caption']/div/text()", xpathCtx); @@ -622,14 +623,23 @@ gismeteoru_parse_and_write_xml_data(const char *station_id, htmlDocPtr doc, cons /* added wind gust */ memset(buffer, 0, sizeof(buffer)); if (xpathObjWindGust && !xmlXPathNodeSetIsEmpty(xpathObjWindGust->nodesetval) && - xpathObjWindGust->nodesetval->nodeTab[i]){ - /* Normalize speed to km/h from m/s */ - /* fprintf(stderr, "Wind speed \n"); */ - xmlChar *temp_xml_string = NULL; - temp_xml_string = (xmlChar*)xmlGetProp(xpathObjWindGust->nodesetval->nodeTab[i], (xmlChar*) "value"); - snprintf(buffer, sizeof(buffer)-1,"%s", temp_xml_string); - speed = atoi ((char *)buffer); - fprintf(file_out," %1.f\n", (double)(speed)); + xpathObjWindGust->nodesetval->nodeTab[i] && xpathObjWindGust->nodesetval->nodeTab[i]->children){ + /* Normalize speed to km/h from m/s */ + xmlChar *temp_xml_string = NULL; + temp_xml_string = xmlGetProp(xpathObjWindGust->nodesetval->nodeTab[i]->children, (xmlChar*) "class"); + if (temp_xml_string && (strncmp((char *)temp_xml_string, "item-bg", strlen((char *)temp_xml_string)) == 0)){ + for (xmlNodePtr iter_node = xpathObjWindGust->nodesetval->nodeTab[i]->children; iter_node; iter_node = iter_node->next){ + if (iter_node->type == XML_ELEMENT_NODE){ + if ((strncmp((char *)iter_node->name, "speed-value", strlen((char *)iter_node->name)) == 0)){ + xmlChar *temp_xml_string1 = (xmlChar*)xmlGetProp(iter_node, (xmlChar*) "value"); + snprintf(buffer, sizeof(buffer)-1,"%s", temp_xml_string1); + speed = atoi ((char *)buffer); + fprintf(file_out," %1.f\n", (double)(speed)); + xmlFree(temp_xml_string1); + } + } + } + } xmlFree(temp_xml_string); } diff --git a/omweather-gismeteo-ru-stations-db/test.sh b/omweather-gismeteo-ru-stations-db/test.sh index d91ad326b..c2c97ab84 100755 --- a/omweather-gismeteo-ru-stations-db/test.sh +++ b/omweather-gismeteo-ru-stations-db/test.sh @@ -1,5 +1,6 @@ #!/bin/bash -./gismeteoru ./examples/weekly.html ./examples/out.xml ./examples/hourly.html +#./gismeteoru ./examples/weekly.html ./examples/out.xml ./examples/hourly.html # ./gismeteoru ./examples/weekly.html ./examples/out.xml -#valgrind --tool=memcheck --log-file=1.log -v --track-origins=yes --leak-check=full --show-reachable=yes ./gismeteoru ./examples/weekly.html ./examples/out.xml ./examples/hourly.html +valgrind --tool=memcheck --log-file=1.log -v --track-origins=yes --leak-check=full --show-reachable=yes ./gismeteoru ./examples/weekly.html ./examples/out.xml ./examples/hourly.html +#valgrind --tool=memcheck --log-file=1.log -v --track-origins=yes --leak-check=full --show-reachable=yes ./gismeteoru ./examples/weekly.html ./examples/out.xml