From 34491ca8c8ab719472c644668c7b14f09e088be4 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Tue, 3 May 2016 12:21:01 +0200 Subject: [PATCH] - dpf: read goodbye message from /tmp/lcd/goodbye --- drv_dpf.c | 38 +++++++++++++++++++++++++++++++++++--- drv_generic_graphic.c | 5 +++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drv_dpf.c b/drv_dpf.c index d4c051d..01243c2 100644 --- a/drv_dpf.c +++ b/drv_dpf.c @@ -418,9 +418,41 @@ int drv_dpf_quit(const int quiet) drv_generic_graphic_clear(); /* say goodbye... */ - if (!quiet) { - drv_generic_graphic_greet("goodbye!", NULL); - } + //read goodby message from /tmp/lcd/goodbye + char line1[80], value[80]; + FILE *fp; + int i, size; + + fp = fopen("/tmp/lcd/goodbye", "r"); + if (!fp) { + debug("couldn't open file '/tmp/lcd/goodbye'"); + line1[0] = '\0'; + if (!quiet) { + drv_generic_graphic_greet("goodbye!", NULL); + } + } else { + i = 0; + while (!feof(fp) && i++ < 1) { + fgets(value, sizeof(value), fp); + size = strcspn(value, "\r\n"); + strncpy(line1, value, size); + line1[size] = '\0'; + /* more than 80 chars, chew up rest of line */ + while (!feof(fp) && strchr(value, '\n') == NULL) { + fgets(value, sizeof(value), fp); + } + } + fclose(fp); + if (i <= 1) { + debug("'/tmp/lcd/goodbye' seems empty"); + line1[0] = '\0'; + } + /* remove the file */ + debug("removing '/tmp/lcd/goodbye'"); + unlink("/tmp/lcd/goodbye"); + + drv_generic_graphic_greet(NULL, line1); + } drv_generic_graphic_quit(); diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c index 847bbf4..396f229 100644 --- a/drv_generic_graphic.c +++ b/drv_generic_graphic.c @@ -290,6 +290,7 @@ static void drv_generic_graphic_render(const int layer, const int row, const int /* say hello to the user */ int drv_generic_graphic_greet(const char *msg1, const char *msg2) { +#if 0 char *line1[] = { "* LCD4Linux " VERSION " *", "LCD4Linux " VERSION, "* LCD4Linux *", @@ -302,6 +303,10 @@ int drv_generic_graphic_greet(const char *msg1, const char *msg2) "lcd4linux.bulix.org", NULL }; +#endif + + char *line1[] = { NULL }; + char *line2[] = { NULL }; int i; int flag = 0; -- 2.39.5