Changeset 1110
- Timestamp:
- 02/12/10 14:18:16 (7 months ago)
- File:
-
- 1 edited
-
trunk/plugin_fifo.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin_fifo.c
r1108 r1110 2 2 * $URL$ 3 3 * 4 * plugin template4 * Fifo plugin 5 5 * 6 6 * Copyright (C) 2008 Michael Vogt <michu@neophob.com> … … 26 26 */ 27 27 28 /* define the include files you need */ 28 /* 29 * Configuration parameters: 30 * 31 * - FifoPath 'string' : use <string> as the fifo complete file path 32 * If absent use /tmp/lcd4linux.fifo) 33 * 34 * - FifoBufSize num : if the plugin is unable to determine the display size then 35 * set the size of the internal buffer to <num> characters 36 * otherwise use the display size (number of columns). 37 * If no display size is available and no FifoBufSize parameter 38 * is specified then arbitrarily set the internal buffer size 39 * to 80 characters. 40 */ 41 29 42 #include "config.h" 30 43 … … 38 51 #include <signal.h> 39 52 40 /* these should always be included */41 53 #include "debug.h" 42 54 #include "plugin.h" … … 79 91 path = cfg_get(fifosect, "FifoPath", string(FIFO_DEFAULT_PATH)); 80 92 pathlen = strlen(path); 93 if (pathlen == 0) { 94 info("[FIFO] Invalid '%s.FifoPath' entry from '%s'. " 95 "Assuming "string(FIFO_DEFAULT_PATH), fifosect, cfg_source()); 96 free(path); 97 path = strdup(string(FIFO_DEFAULT_PATH)); 98 pathlen = strlen(path); 99 } 81 100 if (pathlen > FIFO_MAXPATH) { 82 101 error("[FIFO] Error: Too long '%s.FifoPath' entry from '%s'. " … … 89 108 disp = cfg_get(NULL, "Display", NULL); 90 109 if (disp == NULL) { 91 error("[FIFO] Error: Could not get the Display name from '%s' .", cfg_source());110 error("[FIFO] Error: Could not get the Display name from '%s'", cfg_source()); 92 111 free(path); 93 112 return (-1); … … 106 125 disp = cfg_get(sect, "Size", NULL); 107 126 if (disp != NULL) { 108 info("[FIFO] Getting the buffer size from '%s.Size'.", sect); 109 sscanf(disp, "%dx%*d", &p->msglen); 127 info("[FIFO] Getting the buffer size from '%s.Size'", sect); 128 if (sscanf(disp, "%dx%*d", &p->msglen) != 1) { 129 info("[FIFO] Could not determine the display size. " 130 "Assuming "string(FIFO_DEFAULT_BUFSIZE)); 131 p->msglen = FIFO_DEFAULT_BUFSIZE; 132 } 133 free(disp); 110 134 } else { 111 135 info("[FIFO] Could not find a '%s.Size' entry.", sect); 112 136 if (cfg_number(fifosect, "FifoBufSize", FIFO_DEFAULT_BUFSIZE, 0, -1, &p->msglen) > 0) { 113 info("[FIFO] Getting the buffer size from '%s.FifoBufSize' .", fifosect);137 info("[FIFO] Getting the buffer size from '%s.FifoBufSize'", fifosect); 114 138 } else { 115 139 info("[FIFO] Could not find a valid '%s.FifoBufSize' entry. " 116 "Assuming "string(FIFO_DEFAULT_BUFSIZE) ".", fifosect);140 "Assuming "string(FIFO_DEFAULT_BUFSIZE), fifosect); 117 141 p->msglen = FIFO_DEFAULT_BUFSIZE; 118 142 } … … 120 144 info("[FIFO] Read buffer size is '%d'", p->msglen); 121 145 free(sect); 122 free(disp);123 146 124 147 if ((p->msg = malloc(2+pathlen+p->msglen)) == NULL) {
Note: See TracChangeset
for help on using the changeset viewer.
