From 839f79127bc46fac3e853d57be29d701bc67671b Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Tue, 13 Jan 2004 21:24:42 +0000 Subject: [PATCH] Added 'extendable options' SVN revision: 675 --- src/elogd.c | 263 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 226 insertions(+), 37 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 15eb348d..56d2014c 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.188 2004/01/13 21:24:42 midas + Added 'extendable options' + Revision 1.187 2004/01/13 16:37:27 midas Fixed bug with elog:/ referencing @@ -334,6 +337,7 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = { #define AF_FIXED_REPLY (1<<4) #define AF_ICON (1<<5) #define AF_RADIO (1<<6) +#define AF_EXTENDABLE (1<<7) /* attribute format flags */ #define AFF_SAME_LINE 1 @@ -1760,6 +1764,60 @@ int getcfg(char *group, char *param, char *value) /*-------------------------------------------------------------------*/ +char *find_param(char *buf, char *group, char *param) +{ + char *str, *p, *pstr, *pstart; + + /* search group */ + str = malloc(10000); + p = buf; + do { + if (*p == '[') { + p++; + pstr = str; + while (*p && *p != ']' && *p != '\n') + *pstr++ = *p++; + *pstr = 0; + if (equal_ustring(str, group)) { + /* search parameter */ + p = strchr(p, '\n'); + if (p) + p++; + while (p && *p && *p != '[') { + pstr = str; + pstart = p; + while (*p && *p != '=' && *p != '\n') + *pstr++ = *p++; + *pstr-- = 0; + while (pstr > str && (*pstr == ' ' || *pstr == '=' || *pstr == '\t')) + *pstr-- = 0; + + if (equal_ustring(str, param)) { + free(str); + return pstart; + } + + if (p) + p = strchr(p, '\n'); + if (p) + p++; + } + } + } + if (p) + p = strchr(p, '\n'); + if (p) + p++; + } while (p); + + + free(str); + + return NULL; +} + +/*-------------------------------------------------------------------*/ + int isgroup(char *group) { char *str, *p, *pstr; @@ -4357,6 +4415,16 @@ and attr_flags arrays */ if (equal_ustring(attr_list[j], tmp_list[i])) attr_flags[j] |= AF_FIXED_REPLY; } + + /* check for extendable options */ + getcfg_cond(logbook, condition, "Extendable Options", list); + m = strbreak(list, tmp_list, MAX_N_ATTR); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) + if (equal_ustring(attr_list[j], tmp_list[i])) + attr_flags[j] |= AF_EXTENDABLE; + } + } else { memcpy(attr_list, attr_list_default, sizeof(attr_list_default)); memcpy(attr_options, attr_options_default, sizeof(attr_options_default)); @@ -5809,8 +5877,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } else { if (attr_options[index][0][0] == 0) { rsprintf - ("\n", - class_value, input_size, input_maxlen, attr_list[index], attrib[index]); + ("\n", + input_size, input_maxlen, attr_list[index], attrib[index]); } else { if (equal_ustring(attr_options[index][0], "boolean")) { /* display checkbox */ @@ -5894,48 +5962,71 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\n"); } else { - /* display drop-down box */ - rsprintf("\n", + input_size, input_maxlen, attr_list[index], attrib[index]); - if (equal_ustring(attr_options[index][i], attrib[index]) - || equal_ustring(str, attrib[index])) - rsprintf("