diff --git a/elogd.c b/elogd.c index 8ec07a1e..255eef1c 100755 --- a/elogd.c +++ b/elogd.c @@ -6,6 +6,10 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.15 2002/04/22 10:31:58 midas + Added "logfile", fixed hightlighting problems, thanks to + Heiko.Schleit@mpi-hd.mpg.de + Revision 1.14 2002/03/14 11:48:43 midas Added .jpeg file extension @@ -113,7 +117,8 @@ typedef int INT; #define EL_SUCCESS 1 #define EL_FIRST_MSG 2 #define EL_LAST_MSG 3 -#define EL_FILE_ERROR 4 +#define EL_NO_MSG 4 +#define EL_FILE_ERROR 5 #define WEB_BUFFER_SIZE 2000000 @@ -236,6 +241,7 @@ struct { }; int scan_attributes(char *logbook); +void show_error(char *error); /*---- Funcions from the MIDAS library -----------------------------*/ @@ -561,7 +567,7 @@ INT ss_daemon_init() setsid(); /* become session leader */ chdir("/"); /* change working direcotry (not on NFS!) */ - umask(0); /* clear our file mode createion mask */ + umask(0); /* clear our file mode creation mask */ #endif @@ -624,7 +630,7 @@ int fh; while (*p && *p != '=' && *p != '\n') *pstr++ = *p++; *pstr-- = 0; - while (pstr > str && (*pstr == ' ' || *pstr == '=')) + while (pstr > str && (*pstr == ' ' || *pstr == '=' || *pstr == '\t')) *pstr-- = 0; if (equal_ustring(str, param)) @@ -632,13 +638,13 @@ int fh; if (*p == '=') { p++; - while (*p == ' ') + while (*p == ' ' || *p == '\t') p++; pstr = str; while (*p && *p != '\n' && *p != '\r') *pstr++ = *p++; *pstr-- = 0; - while (*pstr == ' ') + while (*pstr == ' ' || *pstr == '\t') *pstr-- = 0; strcpy(value, str); @@ -1344,7 +1350,7 @@ char *file_list; { if (file_list) free(file_list); - return EL_FILE_ERROR; + return EL_NO_MSG; } for (i=0,max=0 ; i sizeof(return_buffer)) @@ -2290,10 +2331,15 @@ char *p, link[256]; else switch (str[i]) { - case 1 : strcat(return_buffer, "<"); j++; break; - case 2 : strcat(return_buffer, ">"); j++; break; case '<': strcat(return_buffer, "<"); j+=4; break; case '>': strcat(return_buffer, ">"); j+=4; break; + + /* the translation for the search highliting */ + case '\001' : strcat(return_buffer, "<"); j++; break; + case '\002' : strcat(return_buffer, ">"); j++; break; + case '\003' : strcat(return_buffer, "\""); j++; break; + case '\004' : strcat(return_buffer, " "); j++; break; + default: return_buffer[j++] = str[i]; } } @@ -2333,18 +2379,24 @@ void initparam() _text[0] = 0; } -void setparam(char *param, char *value) +int setparam(char *param, char *value) { int i; +char str[256]; if (equal_ustring(param, "text")) { if (strlen(value) >= TEXT_SIZE) - printf("Error: parameter value too big\n"); + { + sprintf(str, "Error: Message text too big (%d bytes). Please increase TEXT_SIZE and recompile elogd\n", + strlen(value)); + show_error(str); + return 0; + } strncpy(_text, value, TEXT_SIZE); _text[TEXT_SIZE-1] = 0; - return; + return 1; } for (i=0 ; i= VALUE_SIZE) - printf("Error: parameter value too big\n"); + { + show_error("Error: Parameter value too big. Please increase VALUE_SIZE and recompile elogd\n"); + return 0; + } strncpy(_value[i], value, VALUE_SIZE); _value[i][VALUE_SIZE-1] = 0; @@ -2365,6 +2420,8 @@ int i; { printf("Error: parameter array too small\n"); } + + return 1; } char *getparam(char *param) @@ -2799,7 +2856,7 @@ int i; if (*getparam("full_name")) { rsprintf("", gt("Title BGColor")); - rsprintf("  %s \"%s\"\n", + rsprintf("  %s \"%s\"\n", gt("Title fontcolor"), loc("Logged in as"), getparam("full_name")); } @@ -2947,6 +3004,13 @@ int i; case '&': rsprintf("&"); break; case '\"': rsprintf("""); break; case ' ': rsprintf(" "); break; + + /* the translation for the search highliting */ + case '\001': rsprintf("<"); break; + case '\002': rsprintf(">"); break; + case '\003': rsprintf("\""); break; + case '\004': rsprintf(" "); break; + default: rsprintf("%c", text[i]); } } @@ -3258,7 +3322,7 @@ char str[80], date[80], attrib[MAX_N_ATTR][NAME_LENGTH], void show_elog_new(char *path, BOOL bedit) { -int i, n, n_attr, index, size, wrap, fh, length; +int i, n, n_attr, index, size, width, fh, length; char str[1000], preset[1000], *p, star[80], comment[10000]; char list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, format[256]; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], @@ -3541,8 +3605,15 @@ time_t now; rsprintf("\n"); - /* increased wrapping for replies (leave space for '> ' */ - wrap = (path && !bedit) ? 78 : 76; + /* set textarea width */ + width = 76; + + if (getcfg(logbook, "Message width", str)) + width = atoi(str); + + /* increased wrapping width for replies (leave space for '> ' */ + if (path && !bedit) + width += 2; rsprintf("\n"); @@ -3554,7 +3625,7 @@ time_t now; if (!getcfg(logbook, "Show text", str) || atoi(str) == 1) { - rsprintf("