mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-12 19:33:03 +00:00
Fixed problem with 'preset text' under conditional attributes
SVN revision: 896
This commit is contained in:
parent
bba741ee49
commit
741bd6615d
82
src/elogd.c
82
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.337 2004/06/07 14:59:42 midas
|
||||||
|
Fixed problem with 'preset text' under conditional attributes
|
||||||
|
|
||||||
Revision 1.336 2004/06/07 10:36:48 midas
|
Revision 1.336 2004/06/07 10:36:48 midas
|
||||||
Version 2.5.3
|
Version 2.5.3
|
||||||
|
|
||||||
@ -1992,26 +1995,6 @@ int is_group(char *group)
|
|||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
int getcfg_cond1(char *group, char *condition, char *param, char *value)
|
|
||||||
{
|
|
||||||
char str[256];
|
|
||||||
|
|
||||||
if (condition == NULL || condition[0] == 0)
|
|
||||||
return getcfg(group, param, value);
|
|
||||||
|
|
||||||
sprintf(str, "{%s}%s", condition, param);
|
|
||||||
if (getcfg(group, str, value))
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
sprintf(str, "{%s} %s", condition, param);
|
|
||||||
if (getcfg(group, str, value))
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
return getcfg(group, param, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int enumcfg(char *group, char *param, char *value, int index)
|
int enumcfg(char *group, char *param, char *value, int index)
|
||||||
{
|
{
|
||||||
char str[10000], *p, *pstr;
|
char str[10000], *p, *pstr;
|
||||||
@ -7025,34 +7008,39 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!message_id || breedit)
|
|
||||||
&& getcfg(lbs->name, "Preset text", str)) {
|
|
||||||
/* check if file starts with an absolute directory */
|
|
||||||
if (str[0] == DIR_SEPARATOR || str[1] == ':')
|
|
||||||
strcpy(file_name, str);
|
|
||||||
else {
|
|
||||||
strlcpy(file_name, resource_dir, sizeof(file_name));
|
|
||||||
strlcat(file_name, str, sizeof(file_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check if file exists */
|
if ((i = getcfg(lbs->name, "Preset text", str)) > 0) {
|
||||||
fh = open(file_name, O_RDONLY | O_BINARY);
|
|
||||||
if (fh > 0) {
|
if (!bedit || (breedit && i == 2)) { /* preset on reedit only if preset is under condition */
|
||||||
length = lseek(fh, 0, SEEK_END);
|
|
||||||
lseek(fh, 0, SEEK_SET);
|
/* check if file starts with an absolute directory */
|
||||||
buffer = malloc(length + 1);
|
if (str[0] == DIR_SEPARATOR || str[1] == ':')
|
||||||
read(fh, buffer, length);
|
strcpy(file_name, str);
|
||||||
buffer[length] = 0;
|
else {
|
||||||
close(fh);
|
strlcpy(file_name, resource_dir, sizeof(file_name));
|
||||||
rsputs(buffer);
|
strlcat(file_name, str, sizeof(file_name));
|
||||||
free(buffer);
|
}
|
||||||
} else {
|
|
||||||
j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
|
/* check if file exists */
|
||||||
strsubst(str, slist, svalue, j);
|
fh = open(file_name, O_RDONLY | O_BINARY);
|
||||||
while (strstr(str, "\\n"))
|
if (fh > 0) {
|
||||||
memcpy(strstr(str, "\\n"), "\r\n", 2);
|
length = lseek(fh, 0, SEEK_END);
|
||||||
rsputs(str);
|
lseek(fh, 0, SEEK_SET);
|
||||||
}
|
buffer = malloc(length + 1);
|
||||||
|
read(fh, buffer, length);
|
||||||
|
buffer[length] = 0;
|
||||||
|
close(fh);
|
||||||
|
rsputs(buffer);
|
||||||
|
free(buffer);
|
||||||
|
} else {
|
||||||
|
j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
|
||||||
|
strsubst(str, slist, svalue, j);
|
||||||
|
while (strstr(str, "\\n"))
|
||||||
|
memcpy(strstr(str, "\\n"), "\r\n", 2);
|
||||||
|
rsputs(str);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
rsputs(text); /* otherwise keep original text */
|
||||||
}
|
}
|
||||||
|
|
||||||
rsprintf("</textarea><br>\n");
|
rsprintf("</textarea><br>\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user