summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--anzeige.c4
-rw-r--r--fonts.c3
-rw-r--r--fonts.h2
-rw-r--r--input_gadgets.c70
-rw-r--r--input_gadgets.h8
-rw-r--r--multiplexer.h4
7 files changed, 46 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index ab06f53..f04d9ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS=-Werror -O3
+CFLAGS=-Werror -O3 -pedantic
anzeige: anzeige.c fonts.o input_gadgets.o multiplexer.o
gcc -o "$@" $(CFLAGS) -lpthread -lzip -lxml2 -lcurl $^
diff --git a/anzeige.c b/anzeige.c
index 4059e9a..52116bf 100644
--- a/anzeige.c
+++ b/anzeige.c
@@ -21,8 +21,8 @@ int main(int argc, char **argv)
t_display_data display_data;
int ret_val;
#define TEXT_BUFFER_LENGTH 256
- unsigned char *text_buffer;
- unsigned char *text_buffer_end;
+ char *text_buffer;
+ char *text_buffer_end;
t_scroll_buffer scroll_buffers[2];
// Set up gpi pointer for direct register access
diff --git a/fonts.c b/fonts.c
index 352b728..b7a68c7 100644
--- a/fonts.c
+++ b/fonts.c
@@ -2,8 +2,7 @@
#include "fonts.h"
-int render(unsigned char *input, int input_len, unsigned char *output, int max_output_len, int skip_unprintables)
-{
+int render(char *input, int input_len, char *output, int max_output_len, int skip_unprintables) {
memset(output, 0, max_output_len);
int output_i = 0;
for (int input_i=0; (input_i < input_len) && (output_i*(SYMBOL_WIDTH+1) < max_output_len) && input[input_i]; input_i++) {
diff --git a/fonts.h b/fonts.h
index c577d82..93b63f0 100644
--- a/fonts.h
+++ b/fonts.h
@@ -100,4 +100,4 @@ static char const symbols[96 * SYMBOL_WIDTH] = {
0x00,0x02,0x05,0x02,0x00 // °
};
-int render(unsigned char *input, int input_len, unsigned char *output, int max_output_len, int skip_unprintables);
+int render(char *input, int input_len, char *output, int max_output_len, int skip_unprintables);
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);
diff --git a/input_gadgets.h b/input_gadgets.h
index 37542f6..2f4f135 100644
--- a/input_gadgets.h
+++ b/input_gadgets.h
@@ -1,5 +1,5 @@
typedef struct {
- unsigned char *memory;
+ char *memory;
size_t size;
} MemoryStruct;
@@ -12,6 +12,6 @@ typedef struct {
time_t onset, expires;
} warning_t;
-unsigned char *gadgets_retrieve_current_temperature(unsigned char *output, int max_len);
-unsigned char *gadgets_retrieve_weather_forecast(unsigned char *output, int max_len);
-unsigned char *gadgets_retrieve_weather_warnings(unsigned char *output, int max_len);
+char *gadgets_retrieve_current_temperature(char *output, int max_len);
+char *gadgets_retrieve_weather_forecast(char *output, int max_len);
+char *gadgets_retrieve_weather_warnings(char *output, int max_len);
diff --git a/multiplexer.h b/multiplexer.h
index f42fb8d..9c73632 100644
--- a/multiplexer.h
+++ b/multiplexer.h
@@ -27,12 +27,12 @@ int mem_fd;
void *gpio_map;
typedef struct {
- unsigned char buf[3][40];
+ char buf[3][40];
int should_buf, is_buf, keep_running;
} t_display_data;
typedef struct {
- unsigned char buf[2048];
+ char buf[2048];
int scroll_len;
} t_scroll_buffer;