summaryrefslogtreecommitdiff
path: root/input_gadgets.c
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-10-26 10:58:09 +0200
committerErich Eckner <git@eckner.net>2018-10-26 10:58:09 +0200
commit3470a4ce3a16f51d17127a202bf798d71544ffae (patch)
treedde1bf54cfd4029f11050065785ddef33bef4e7a /input_gadgets.c
parent3d7d5934ce19203b1b795cfea6a51599a20c9639 (diff)
downloadanzeige-3470a4ce3a16f51d17127a202bf798d71544ffae.tar.xz
compile with -pedantic
Diffstat (limited to 'input_gadgets.c')
-rw-r--r--input_gadgets.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/input_gadgets.c b/input_gadgets.c
index 24c5eaa..6d1f878 100644
--- a/input_gadgets.c
+++ b/input_gadgets.c
@@ -36,7 +36,7 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
return realsize;
}
-unsigned char *gadgets_retrieve_current_temperature(unsigned char *output, int max_len)
+char *gadgets_retrieve_current_temperature(char *output, int max_len)
{
CURL *curl_handle;
CURLcode res;
@@ -91,7 +91,7 @@ unsigned char *gadgets_retrieve_current_temperature(unsigned char *output, int m
(int)(rm[2].rm_eo - rm[2].rm_so), (char*)(chunk.memory + rm[2].rm_so),
(int)(rm[1].rm_eo - rm[1].rm_so), (char*)(chunk.memory + rm[1].rm_so)
);
- unsigned char* ende = output + i;
+ char* ende = output + i;
for (; i>=0; i--)
if (output[i] == '(')
break;
@@ -106,7 +106,7 @@ xmlNode *xml_find_node_by_name(xmlNode *cur_node, char *name)
{
while (cur_node) {
if ((cur_node -> type == XML_ELEMENT_NODE) &&
- (strcmp(cur_node -> name, name) == 0))
+ (strcmp((char *)cur_node -> name, name) == 0))
return cur_node;
cur_node = cur_node -> next;
}
@@ -122,7 +122,7 @@ xmlChar *xml_extract_string(xmlDoc *doc, xmlNode *cur_node, char *name)
return xmlNodeListGetString(doc, sub_node -> xmlChildrenNode, 0);
}
-unsigned char *gadgets_retrieve_weather_forecast(unsigned char *output, int max_len)
+char *gadgets_retrieve_weather_forecast(char *output, int max_len)
{
CURL *curl_handle;
CURLcode res;
@@ -189,32 +189,32 @@ unsigned char *gadgets_retrieve_weather_forecast(unsigned char *output, int max_
now = ((int)(now/60/60))*60*60;
for (cur_node = cur_node -> children; cur_node; cur_node = cur_node->next) {
- if ((cur_node->type == XML_ELEMENT_NODE) && (strcmp(cur_node->name,"time")==0) && (strcmp(xmlGetProp(cur_node,"datatype"),"forecast")==0)) {
+ if ((cur_node->type == XML_ELEMENT_NODE) && (strcmp((char *)cur_node->name,"time")==0) && (strcmp((char *)xmlGetProp(cur_node,(xmlChar *)"datatype"),"forecast")==0)) {
for (int i=0; i<=14; i++) {
now += i*60*60;
strftime(time_str[0],21,"%Y-%m-%dT%H:%M:%SZ",gmtime(&now));
now += 60*60;
strftime(time_str[1],21,"%Y-%m-%dT%H:%M:%SZ",gmtime(&now));
now -= (i+1)*60*60;
- if ((strcmp(time_str[1],xmlGetProp(cur_node,"from"))==0) && (strcmp(time_str[1],xmlGetProp(cur_node,"to"))==0)) {
+ if ((strcmp(time_str[1],(char *)xmlGetProp(cur_node,(xmlChar *)"from"))==0) && (strcmp(time_str[1],(char *)xmlGetProp(cur_node,(xmlChar *)"to"))==0)) {
sub_node = xml_find_node_by_name(cur_node -> children,"location");
- cur_val = atof(xmlGetProp(xml_find_node_by_name(sub_node -> children, "temperature"), "value"));
+ cur_val = atof((char *)xmlGetProp(xml_find_node_by_name(sub_node -> children, "temperature"), (xmlChar *)"value"));
if (isnan(temp_max) || (cur_val > temp_max))
temp_max = cur_val;
if (isnan(temp_min) || (cur_val < temp_min))
temp_min = cur_val;
- cur_val = atof(xmlGetProp(xml_find_node_by_name(sub_node -> children, "windSpeed"),"mps"));
+ cur_val = atof((char *)xmlGetProp(xml_find_node_by_name(sub_node -> children, "windSpeed"), (xmlChar *)"mps"));
if (isnan(wind_max) || (cur_val > wind_max))
wind_max = cur_val;
}
- if ((strcmp(time_str[0],xmlGetProp(cur_node,"from"))==0) && (strcmp(time_str[1],xmlGetProp(cur_node,"to"))==0)) {
+ if ((strcmp(time_str[0],(char *)xmlGetProp(cur_node,(xmlChar *)"from"))==0) && (strcmp(time_str[1],(char *)xmlGetProp(cur_node,(xmlChar *)"to"))==0)) {
sub_node = xml_find_node_by_name(cur_node -> children,"location");
if (!sub_node)
continue;
sub_node = xml_find_node_by_name(sub_node -> children, "precipitation");
if (!sub_node)
continue;
- rain_total += atof(xmlGetProp(sub_node,"value"));
+ rain_total += atof((char *)xmlGetProp(sub_node,(xmlChar *)"value"));
}
}
}
@@ -223,7 +223,7 @@ unsigned char *gadgets_retrieve_weather_forecast(unsigned char *output, int max_
xmlCleanupParser();
int i = snprintf(output, max_len, "%0.1f ,, %0.1f °C; %0.1f mm; %0.1f m/s;", temp_min, temp_max, rain_total, wind_max);
- unsigned char *ende = output + i;
+ char *ende = output + i;
for (; i>=0; i--)
if (output[i] == '.')
output[i] = ',';
@@ -233,7 +233,7 @@ unsigned char *gadgets_retrieve_weather_forecast(unsigned char *output, int max_
return ende;
}
-unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_len)
+char *gadgets_retrieve_weather_warnings(char *output, int max_len)
{
CURL *curl_handle;
CURLcode res;
@@ -383,7 +383,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text, "Actual") != 0) { // Warning is not an Actual warning
+ if (strcmp((char *)text, "Actual") != 0) { // Warning is not an Actual warning
printf("no warning, but '%s'\n",text);
xmlFree(text);
free(inflated);
@@ -404,11 +404,11 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text, "Update") == 0)
+ if (strcmp((char *)text, "Update") == 0)
warnings[warnings_len].is_update=1;
- else if (strcmp(text, "Alert") == 0)
+ else if (strcmp((char *)text, "Alert") == 0)
warnings[warnings_len].is_update=0;
- else if (strcmp(text, "Cancel") == 0)
+ else if (strcmp((char *)text, "Cancel") == 0)
warnings[warnings_len].is_update=-1;
else
warnings[warnings_len].is_update=-2;
@@ -454,9 +454,9 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text,"Met") == 0)
+ if (strcmp((char *)text,"Met") == 0)
warnings[warnings_len].category = 0;
- else if (strcmp(text,"Health") == 0)
+ else if (strcmp((char *)text,"Health") == 0)
warnings[warnings_len].category = 1;
else
warnings[warnings_len].category = -1;
@@ -486,7 +486,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if ((strcmp(text,"Prepare") != 0) && (strcmp(text,"None")!=0)) {
+ if ((strcmp((char *)text,"Prepare") != 0) && (strcmp((char *)text,"None")!=0)) {
fprintf(stderr, "responseType is '%s', not Prepare nor None\n", text);
xmlFree(text);
xmlFreeDoc(doc);
@@ -518,13 +518,13 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text,"Minor") == 0)
+ if (strcmp((char *)text,"Minor") == 0)
warnings[warnings_len].severity = 0;
- else if (strcmp(text,"Moderate") == 0)
+ else if (strcmp((char *)text,"Moderate") == 0)
warnings[warnings_len].severity = 1;
- else if (strcmp(text,"Severe") == 0)
+ else if (strcmp((char *)text,"Severe") == 0)
warnings[warnings_len].severity = 2;
- else if (strcmp(text,"Extreme") == 0)
+ else if (strcmp((char *)text,"Extreme") == 0)
warnings[warnings_len].severity = 3;
else {
fprintf(stderr, "Unknown severity '%s'\n",text);
@@ -542,7 +542,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFree(text);
struct tm time_struct;
text = xml_extract_string(doc, cur_node, "onset");
- if (!text) {
+ if (text == NULL) {
fprintf(stderr, "Failed to enter <onset> %s\n",zs.name);
free(inflated);
free(chunk.memory);
@@ -554,7 +554,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strptime(text,"%FT%T+",&time_struct) == NULL) {
+ if (strptime((char *)text,"%FT%T+",&time_struct) == NULL) {
fprintf(stderr, "Failed to parse time '%s'\n",text);
xmlFree(text);
free(inflated);
@@ -571,7 +571,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
warnings[warnings_len].onset = mktime(&time_struct);
text = xml_extract_string(doc, cur_node, "expires");
if (text) {
- if (strptime(text,"%FT%T+",&time_struct) == NULL) {
+ if (strptime((char *)text,"%FT%T+",&time_struct) == NULL) {
fprintf(stderr, "Failed to parse time '%s'\n",text);
xmlFree(text);
free(inflated);
@@ -606,7 +606,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text,"WARNCELLID")!=0) {
+ if (strcmp((char *)text,"WARNCELLID")!=0) {
xmlFree(text);
continue;
}
@@ -624,7 +624,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- if (strcmp(text,"816053000")==0) // Stadt Jena
+ if (strcmp((char *)text,"816053000")==0) // Stadt Jena
is_relevant = 1;
xmlFree(text);
}
@@ -663,9 +663,9 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- warnings[warnings_len].headline = malloc(strlen(text)+1);
+ warnings[warnings_len].headline = malloc(strlen((char *)text)+1);
if (warnings[warnings_len].headline == NULL) {
- fprintf(stderr, "malloc failed allocating %d bytes\n", strlen(text)+1);
+ fprintf(stderr, "malloc failed allocating %d bytes\n", strlen((char *)text)+1);
free(inflated);
for (int i=0; i<warnings_len; i++) {
free(warnings[i].headline);
@@ -676,7 +676,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- strcpy(warnings[warnings_len].headline, text);
+ strcpy(warnings[warnings_len].headline, (char *)text);
xmlFree(text);
text = xml_extract_string(doc, cur_node, "event");
@@ -693,9 +693,9 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- warnings[warnings_len].event = malloc(strlen(text)+1);
+ warnings[warnings_len].event = malloc(strlen((char *)text)+1);
if (warnings[warnings_len].event == NULL) {
- fprintf(stderr, "malloc failed allocating %d bytes\n", strlen(text)+1);
+ fprintf(stderr, "malloc failed allocating %d bytes\n", strlen((char *)text)+1);
free(inflated);
for (int i=0; i<warnings_len; i++) {
free(warnings[i].headline);
@@ -707,7 +707,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
xmlFreeDoc(doc);
return NULL;
}
- strcpy(warnings[warnings_len].event, text);
+ strcpy(warnings[warnings_len].event, (char *)text);
xmlFree(text);
warnings = (warning_t *)realloc(warnings, (++warnings_len + 1) * sizeof(warning_t));
@@ -728,7 +728,7 @@ unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_
}
free(chunk.memory);
- unsigned char *ende = output;
+ char *ende = output;
for (int i=0; i<warnings_len; i++) {
ende += snprintf(ende, output + max_len - ende, "%s: %s ", warnings[i].headline, warnings[i].event);