diff --git a/src/elogd.c b/src/elogd.c index 8b3a1850..8b53bee1 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.172 2004/01/07 11:14:36 midas + Only section of current logbook can be edited in elogd.cfg + Revision 1.171 2004/01/06 13:21:34 midas Changed indent style @@ -115,6 +118,7 @@ #include #include #include +#include #ifdef _MSC_VER @@ -384,11 +388,11 @@ LOGBOOK *lb_list = NULL; void show_error(char *error); BOOL enum_user_line(LOGBOOK * lbs, int n, char *user); -int get_user_line(char *logbook_name, char *user, char *password, - char *full_name, char *email, char *email_notify); +int get_user_line(char *logbook_name, char *user, char *password, char *full_name, + char *email, char *email_notify); int strbreak(char *str, char list[][NAME_LENGTH], int size); -int execute_shell(LOGBOOK * lbs, int message_id, - char attrib[MAX_N_ATTR][NAME_LENGTH], char *sh_cmd); +int execute_shell(LOGBOOK * lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH], + char *sh_cmd); BOOL isparam(char *param); char *getparam(char *param); void logf(LOGBOOK * lbs, const char *format, ...); @@ -396,7 +400,7 @@ BOOL check_login_user(LOGBOOK * lbs, char *user); /*---- Funcions from the MIDAS library -----------------------------*/ -BOOL equal_ustring(char *str1, char *str2) +BOOL equal_ustring(const char *str1, const char *str2) { if (str1 == NULL && str2 != NULL) return FALSE; @@ -482,8 +486,7 @@ size_t strlcat(char *dst, const char *src, size_t size) /*-------------------------------------------------------------------*/ -void strsubst(char *string, char name[][NAME_LENGTH], - char value[][NAME_LENGTH], int n) +void strsubst(char *string, char name[][NAME_LENGTH], char value[][NAME_LENGTH], int n) /* subsitute "$name" with value corresponding to name */ { int i, j; @@ -591,8 +594,7 @@ void url_encode(char *ps, int size) /*-------------------------------------------------------------------*/ -char *map = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +char *map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int cind(char c) { @@ -613,8 +615,7 @@ void base64_decode(char *s, char *d) unsigned int t; while (*s) { - t = (cind(*s++) << 18) | - (cind(*s++) << 12) | (cind(*s++) << 6) | (cind(*s++) << 0); + t = (cind(*s++) << 18) | (cind(*s++) << 12) | (cind(*s++) << 6) | (cind(*s++) << 0); *(d + 2) = (char) (t & 0xFF); t >>= 8; @@ -751,8 +752,7 @@ void _MD5_decode(unsigned int *, unsigned char *, unsigned int); /* main MD5 checksum routine, returns digest from pdata buffer */ -void MD5_checksum(const void *pdata, unsigned int len, - unsigned char digest[16]) +void MD5_checksum(const void *pdata, unsigned int len, unsigned char digest[16]) { MD5_CONTEXT ctx; unsigned char bits[8]; @@ -804,8 +804,7 @@ void _MD5_update(MD5_CONTEXT * pctx, const void *pdata, unsigned int len) index = (unsigned int) ((pctx->count[0] >> 3) & 0x3F); // update number of bits - if ((pctx->count[0] += - ((unsigned int) len << 3)) < ((unsigned int) len << 3)) + if ((pctx->count[0] += ((unsigned int) len << 3)) < ((unsigned int) len << 3)) pctx->count[1]++; pctx->count[1] += ((unsigned int) len >> 29); @@ -944,8 +943,7 @@ void _MD5_decode(unsigned int *pout, unsigned char *pin, unsigned int len) for (i = 0, j = 0; j < len; i++, j += 4) pout[i] = ((unsigned int) pin[j]) | - (((unsigned int) pin[j + 1]) << 8) | - (((unsigned int) pin[j + 2]) << 16) | + (((unsigned int) pin[j + 1]) << 8) | (((unsigned int) pin[j + 2]) << 16) | (((unsigned int) pin[j + 3]) << 24); } @@ -960,8 +958,7 @@ int setgroup(char *str) gr = getgrnam(str); if (gr != NULL) - if (setegid(gr->gr_gid) >= 0 - && initgroups(gr->gr_name, gr->gr_gid) >= 0) + if (setegid(gr->gr_gid) >= 0 && initgroups(gr->gr_name, gr->gr_gid) >= 0) return 0; else { printf("Cannot set effective GID to group \"%s\"\n", gr->gr_name); @@ -1017,8 +1014,7 @@ INT recv_string(int sock, char *buffer, INT buffer_size, INT millisec) timeout.tv_sec = millisec / 1000; timeout.tv_usec = (millisec % 1000) * 1000; - select(FD_SETSIZE, (void *) &readfds, NULL, NULL, - (void *) &timeout); + select(FD_SETSIZE, (void *) &readfds, NULL, NULL, (void *) &timeout); if (!FD_ISSET(sock, &readfds)) break; @@ -1055,14 +1051,12 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char list[1024][NAME_LENGTH], buffer[256]; if (verbose) - printf("\n\nEmail from %s to %s, SMTP host %s:\n", from, to, - smtp_host); + printf("\n\nEmail from %s to %s, SMTP host %s:\n", from, to, smtp_host); /* count attachments */ n_att = 0; if (att_file) - for (n_att = 0; att_file[n_att][0] && n_att < MAX_ATTACHMENTS; - n_att++); + for (n_att = 0; att_file[n_att][0] && n_att < MAX_ATTACHMENTS; n_att++); /* create a new socket for connecting to remote server */ s = socket(AF_INET, SOCK_STREAM, 0); @@ -1147,8 +1141,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, if (verbose) fputs(str, stdout); - snprintf(str, strsize - 1, "From: %s\r\nSubject: %s\r\n", from, - subject); + snprintf(str, strsize - 1, "From: %s\r\nSubject: %s\r\n", from, subject); send(s, str, strlen(str), 0); if (verbose) fputs(str, stdout); @@ -1176,8 +1169,8 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, offset = (-(int) timezone); if (ts->tm_isdst) offset += 3600; - snprintf(str, strsize - 1, "Date: %s %+03d%02d\r\n", buf, - (int) (offset / 3600), (int) ((abs((int) offset) / 60) % 60)); + snprintf(str, strsize - 1, "Date: %s %+03d%02d\r\n", buf, (int) (offset / 3600), + (int) ((abs((int) offset) / 60) % 60)); send(s, str, strlen(str), 0); if (verbose) fputs(str, stdout); @@ -1189,8 +1182,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, fputs(str, stdout); sprintf(boundary, "%04X-%04X=:%04X", rand(), rand(), rand()); - snprintf(str, strsize - 1, - "Content-Type: MULTIPART/MIXED; BOUNDARY=\"%s\"\r\n\r\n", + snprintf(str, strsize - 1, "Content-Type: MULTIPART/MIXED; BOUNDARY=\"%s\"\r\n\r\n", boundary); send(s, str, strlen(str), 0); if (verbose) @@ -1209,14 +1201,12 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, fputs(str, stdout); snprintf(str, strsize - 1, - "--%s\r\nContent-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n", - boundary); + "--%s\r\nContent-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n", boundary); send(s, str, strlen(str), 0); if (verbose) fputs(str, stdout); } else { - snprintf(str, strsize - 1, - "Content-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n"); + snprintf(str, strsize - 1, "Content-Type: TEXT/PLAIN; charset=US-ASCII\r\n\r\n"); send(s, str, strlen(str), 0); if (verbose) fputs(str, stdout); @@ -1257,8 +1247,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, snprintf(str, strsize - 1, "Content-Type: %s; name=\"%s\"\r\n", filetype[i].type, att_file[index] + 14); else if (strchr(str, '.') == NULL) - snprintf(str, strsize - 1, - "Content-Type: text/plain; name=\"%s\"\r\n", + snprintf(str, strsize - 1, "Content-Type: text/plain; name=\"%s\"\r\n", att_file[index] + 14); else snprintf(str, strsize - 1, @@ -1269,8 +1258,7 @@ INT sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, if (verbose) fputs(str, stdout); - snprintf(str, strsize - 1, - "Content-Transfer-Encoding: BASE64\r\n"); + snprintf(str, strsize - 1, "Content-Transfer-Encoding: BASE64\r\n"); send(s, str, strlen(str), 0); if (verbose) fputs(str, stdout); @@ -1404,8 +1392,8 @@ int retrieve_url(char *url, char **buffer) /* add local username/password */ if (isparam("unm")) - sprintf(str + strlen(str), "Cookie: unm=%s; upwd=%s\r\n", - getparam("unm"), getparam("upwd")); + sprintf(str + strlen(str), "Cookie: unm=%s; upwd=%s\r\n", getparam("unm"), + getparam("upwd")); strcat(str, "\r\n"); @@ -1574,8 +1562,7 @@ int getcfg(char *group, char *param, char *value) while (*p && *p != '=' && *p != '\n') *pstr++ = *p++; *pstr-- = 0; - while (pstr > str - && (*pstr == ' ' || *pstr == '=' || *pstr == '\t')) + while (pstr > str && (*pstr == ' ' || *pstr == '=' || *pstr == '\t')) *pstr-- = 0; if (equal_ustring(str, param)) { @@ -1624,6 +1611,38 @@ int getcfg(char *group, char *param, char *value) return 0; } +/*-------------------------------------------------------------------*/ + +int isgroup(char *group) +{ + char *str, *p, *pstr; + + /* search group */ + str = malloc(10000); + p = cfgbuffer; + do { + if (*p == '[') { + p++; + pstr = str; + while (*p && *p != ']' && *p != '\n') + *pstr++ = *p++; + *pstr = 0; + if (equal_ustring(str, group)) { + free(str); + return 1; + } + } + if (p) + p = strchr(p, '\n'); + if (p) + p++; + } while (p); + + + free(str); + return 0; +} + /*------------------------------------------------------------------*/ int getcfg_cond(char *group, char *condition, char *param, char *value) @@ -1677,8 +1696,7 @@ int enumcfg(char *group, char *param, char *value, int index) while (*p && *p != '=' && *p != '\n' && *p != '\r') *pstr++ = *p++; *pstr-- = 0; - while (pstr > str - && (*pstr == ' ' || *pstr == '\t' || *pstr == '=')) + while (pstr > str && (*pstr == ' ' || *pstr == '\t' || *pstr == '=')) *pstr-- = 0; if (i == index) { @@ -1885,8 +1903,8 @@ char *loc(char *orig) } getcfg("global", "Language", language); - printf("Language error: string \"%s\" not found for language \"%s\"\n", - orig, language); + printf("Language error: string \"%s\" not found for language \"%s\"\n", orig, + language); return orig; } @@ -1947,10 +1965,9 @@ void el_decode(char *message, char *key, char *result) } while (1); - if ((pc = strstr(message, key)) != NULL && - pc < ph && (*(pc - 1) == '\n' || *(pc - 1) == '\r')) { - for (pc = strstr(message, key) + strlen(key); - *pc != '\n' && *pc != '\r';) + if ((pc = strstr(message, key)) != NULL && pc < ph + && (*(pc - 1) == '\n' || *(pc - 1) == '\r')) { + for (pc = strstr(message, key) + strlen(key); *pc != '\n' && *pc != '\r';) *result++ = *pc++; *result = 0; } else @@ -2036,8 +2053,7 @@ INT ss_file_find(char *path, char *pattern, char **plist) for (dp = readdir(dir_pointer); dp != NULL; dp = readdir(dir_pointer)) { if (fnmatch1(pattern, dp->d_name) == 0) { *plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH); - strncpy(*plist + (i * MAX_PATH_LENGTH), dp->d_name, - strlen(dp->d_name)); + strncpy(*plist + (i * MAX_PATH_LENGTH), dp->d_name, strlen(dp->d_name)); *(*plist + (i * MAX_PATH_LENGTH) + strlen(dp->d_name)) = '\0'; i++; seekdir(dir_pointer, telldir(dir_pointer)); @@ -2073,8 +2089,7 @@ INT ss_file_find(char *path, char *pattern, char **plist) *plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH); strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName, strlen(lpfdata->cFileName)); - *(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = - '\0'; + *(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0'; i++; } free(lpfdata); @@ -2099,8 +2114,8 @@ int eli_compare(const void *e1, const void *e2) int el_build_index(LOGBOOK * lbs, BOOL rebuild) /* scan all ??????a.log files and build an index table in eli[] */ { - char *file_list, str[256], date[256], dir[256], - file_name[MAX_PATH_LENGTH], *buffer, *p, *pn, in_reply_to[80]; + char *file_list, str[256], date[256], dir[256], file_name[MAX_PATH_LENGTH], *buffer, + *p, *pn, in_reply_to[80]; int index, n, length; int i, fh, len; time_t ltime; @@ -2150,8 +2165,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) /* go through all files */ for (index = 0; index < n; index++) { strlcpy(file_name, dir, sizeof(file_name)); - strlcat(file_name, file_list + index * MAX_PATH_LENGTH, - sizeof(file_name)); + strlcat(file_name, file_list + index * MAX_PATH_LENGTH, sizeof(file_name)); fh = open(file_name, O_RDWR | O_BINARY, 0644); @@ -2167,9 +2181,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) if (length > 0) { buffer = malloc(length + 1); if (buffer == NULL) { - printf - ("Not enough memory to allocate file buffer (%d bytes)\n", - length); + printf("Not enough memory to allocate file buffer (%d bytes)\n", length); return EL_MEM_ERROR; } @@ -2186,8 +2198,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) if (p) { lbs->el_index = - realloc(lbs->el_index, - sizeof(EL_INDEX) * (*lbs->n_el_index + 1)); + realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index + 1)); if (lbs->el_index == NULL) { printf("Not enough memory to allocate message index\n"); return EL_MEM_ERROR; @@ -2220,10 +2231,8 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) lbs->el_index[*lbs->n_el_index].file_time = ltime; lbs->el_index[*lbs->n_el_index].message_id = atoi(p + 8); - lbs->el_index[*lbs->n_el_index].offset = - (int) p - (int) buffer; - lbs->el_index[*lbs->n_el_index].in_reply_to = - atoi(in_reply_to); + lbs->el_index[*lbs->n_el_index].offset = (int) p - (int) buffer; + lbs->el_index[*lbs->n_el_index].in_reply_to = atoi(in_reply_to); pn = strstr(p + 8, "$@MID@$:"); if (pn) @@ -2231,8 +2240,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) else len = strlen(p); - MD5_checksum(p, len, - lbs->el_index[*lbs->n_el_index].md5_digest); + MD5_checksum(p, len, lbs->el_index[*lbs->n_el_index].md5_digest); if (lbs->el_index[*lbs->n_el_index].message_id > 0) { if (verbose) { @@ -2246,9 +2254,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) in_reply_to ? "reply" : "thead"); for (i = 0; i < 16; i++) - printf("%02X", - lbs->el_index[*lbs->n_el_index]. - md5_digest[i]); + printf("%02X", lbs->el_index[*lbs->n_el_index].md5_digest[i]); printf("\n"); } @@ -2274,9 +2280,8 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild) if (verbose) { printf("After sort:\n"); for (i = 0; i < *lbs->n_el_index; i++) - printf(" ID %3d in %s, ofs %5d\n", - lbs->el_index[i].message_id, lbs->el_index[i].file_name, - lbs->el_index[i].offset); + printf(" ID %3d in %s, ofs %5d\n", lbs->el_index[i].message_id, + lbs->el_index[i].file_name, lbs->el_index[i].offset); } return EL_SUCCESS; @@ -2420,9 +2425,8 @@ int el_index_logbooks(BOOL reinit) if (status == EL_EMPTY) printf("Found empty logbook \"%s\"\n", logbook); else if (status == EL_UPGRADE) { - printf - ("Please upgrade data files in \"%s\" with the elconv program.\n", - data_dir); + printf("Please upgrade data files in \"%s\" with the elconv program.\n", + data_dir); return EL_UPGRADE; } else if (status != EL_SUCCESS) { printf("Error generating index.\n"); @@ -2437,8 +2441,7 @@ int el_index_logbooks(BOOL reinit) /*------------------------------------------------------------------*/ -int el_search_message(LOGBOOK * lbs, int mode, int message_id, - BOOL head_only) +int el_search_message(LOGBOOK * lbs, int mode, int message_id, BOOL head_only) /********************************************************************\ Routine: el_search_message @@ -2539,8 +2542,7 @@ INT el_retrieve(LOGBOOK * lbs, char attr_list[MAX_N_ATTR][NAME_LENGTH], char attrib[MAX_N_ATTR][NAME_LENGTH], int n_attr, char *text, int *textsize, char *in_reply_to, - char *reply_to, - char attachment[MAX_ATTACHMENTS][MAX_PATH_LENGTH], + char *reply_to, char attachment[MAX_ATTACHMENTS][MAX_PATH_LENGTH], char *encoding, char *locked_by) /********************************************************************\ @@ -2593,15 +2595,14 @@ INT el_retrieve(LOGBOOK * lbs, if (index == *lbs->n_el_index) return EL_NO_MSG; - sprintf(file_name, "%s%s", lbs->data_dir, - lbs->el_index[index].file_name); + sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) { /* file might have been deleted, rebuild index */ el_build_index(lbs, TRUE); return el_retrieve(lbs, message_id, date, attr_list, attrib, n_attr, - text, textsize, in_reply_to, reply_to, attachment, - encoding, locked_by); + text, textsize, in_reply_to, reply_to, attachment, encoding, + locked_by); } lseek(fh, lbs->el_index[index].offset, SEEK_SET); @@ -2618,8 +2619,8 @@ INT el_retrieve(LOGBOOK * lbs, /* file might have been edited, rebuild index */ el_build_index(lbs, TRUE); return el_retrieve(lbs, message_id, date, attr_list, attrib, n_attr, - text, textsize, in_reply_to, reply_to, attachment, - encoding, locked_by); + text, textsize, in_reply_to, reply_to, attachment, encoding, + locked_by); } /* check for correct ID */ @@ -2714,11 +2715,10 @@ INT el_retrieve(LOGBOOK * lbs, /*------------------------------------------------------------------*/ -int el_submit_attachment(LOGBOOK * lbs, char *afilename, char *buffer, - int buffer_size, char *full_name) +int el_submit_attachment(LOGBOOK * lbs, char *afilename, char *buffer, int buffer_size, + char *full_name) { - char file_name[MAX_PATH_LENGTH], dir[MAX_PATH_LENGTH], - str[MAX_PATH_LENGTH], *p; + char file_name[MAX_PATH_LENGTH], dir[MAX_PATH_LENGTH], str[MAX_PATH_LENGTH], *p; int fh; time_t now; struct tm tms; @@ -2743,12 +2743,12 @@ int el_submit_attachment(LOGBOOK * lbs, char *afilename, char *buffer, strcpy(str, p); if (full_name) sprintf(full_name, "%02d%02d%02d_%02d%02d%02d_%s", - tms.tm_year % 100, tms.tm_mon + 1, tms.tm_mday, - tms.tm_hour, tms.tm_min, tms.tm_sec, str); + tms.tm_year % 100, tms.tm_mon + 1, tms.tm_mday, tms.tm_hour, tms.tm_min, + tms.tm_sec, str); sprintf(file_name, "%s%02d%02d%02d_%02d%02d%02d_%s", dir, - tms.tm_year % 100, tms.tm_mon + 1, tms.tm_mday, - tms.tm_hour, tms.tm_min, tms.tm_sec, str); + tms.tm_year % 100, tms.tm_mon + 1, tms.tm_mday, tms.tm_hour, tms.tm_min, + tms.tm_sec, str); /* save attachment */ fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644); @@ -2795,8 +2795,7 @@ INT el_retrieve_attachment(LOGBOOK * lbs, int message_id, int n, if (index == *lbs->n_el_index) return EL_NO_MSG; - sprintf(file_name, "%s%s", lbs->data_dir, - lbs->el_index[index].file_name); + sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) { /* file might have been deleted, rebuild index */ @@ -2861,9 +2860,8 @@ int el_submit(LOGBOOK * lbs, int message_id, char attr_value[MAX_N_ATTR][NAME_LENGTH], int n_attr, char *text, char *in_reply_to, char *reply_to, - char *encoding, - char afilename[MAX_ATTACHMENTS][256], - BOOL mark_original, char *locked_by) + char *encoding, char afilename[MAX_ATTACHMENTS][256], BOOL mark_original, + char *locked_by) /********************************************************************\ Routine: el_submit @@ -2917,8 +2915,7 @@ int el_submit(LOGBOOK * lbs, int message_id, if (index == *lbs->n_el_index) return -1; - sprintf(file_name, "%s%s", lbs->data_dir, - lbs->el_index[index].file_name); + sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name); fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644); if (fh < 0) return -1; @@ -2934,8 +2931,8 @@ int el_submit(LOGBOOK * lbs, int message_id, /* file might have been edited, rebuild index */ el_build_index(lbs, TRUE); return el_submit(lbs, message_id, date, attr_name, attr_value, - n_attr, text, in_reply_to, reply_to, encoding, - afilename, TRUE, locked_by); + n_attr, text, in_reply_to, reply_to, encoding, afilename, TRUE, + locked_by); } /* check for correct ID */ @@ -3004,8 +3001,8 @@ int el_submit(LOGBOOK * lbs, int message_id, if (date[8] == ' ') date[8] = '0'; - sprintf(file_name, "%c%c%02d%c%ca.log", - date[22], date[23], i + 1, date[8], date[9]); + sprintf(file_name, "%c%c%02d%c%ca.log", date[22], date[23], i + 1, date[8], + date[9]); sprintf(str, "%s%s", dir, file_name); fh = open(str, O_CREAT | O_RDWR | O_BINARY, 0644); @@ -3022,8 +3019,7 @@ int el_submit(LOGBOOK * lbs, int message_id, /* enter message in index */ (*lbs->n_el_index)++; - lbs->el_index = - realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index)); + lbs->el_index = realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index)); lbs->el_index[*lbs->n_el_index - 1].message_id = message_id; strcpy(lbs->el_index[*lbs->n_el_index - 1].file_name, file_name); lbs->el_index[*lbs->n_el_index - 1].file_time = ltime; @@ -3032,15 +3028,12 @@ int el_submit(LOGBOOK * lbs, int message_id, /* if index not ordered, sort it */ i = *lbs->n_el_index; - if (i > 1 - && lbs->el_index[i - 1].file_time < - lbs->el_index[i - 2].file_time) + if (i > 1 && lbs->el_index[i - 1].file_time < lbs->el_index[i - 2].file_time) qsort(lbs->el_index, i, sizeof(EL_INDEX), eli_compare); /* if other logbook has same index, update pointers */ for (i = 0; lb_list[i].name[0]; i++) - if (&lb_list[i] != lbs - && lb_list[i].n_el_index == lbs->n_el_index) + if (&lb_list[i] != lbs && lb_list[i].n_el_index == lbs->n_el_index) lb_list[i].el_index = lbs->el_index; } @@ -3056,8 +3049,7 @@ int el_submit(LOGBOOK * lbs, int message_id, sprintf(message + strlen(message), "In reply to: %s\n", in_reply_to); for (i = 0; i < n_attr; i++) - sprintf(message + strlen(message), "%s: %s\n", attr_name[i], - attr_value[i]); + sprintf(message + strlen(message), "%s: %s\n", attr_name[i], attr_value[i]); sprintf(message + strlen(message), "Attachment: "); @@ -3071,8 +3063,7 @@ int el_submit(LOGBOOK * lbs, int message_id, if (locked_by && locked_by[0]) sprintf(message + strlen(message), "Locked by: %s\n", locked_by); - sprintf(message + strlen(message), - "========================================\n"); + sprintf(message + strlen(message), "========================================\n"); strlcat(message, text, sizeof(message)); strlcat(message, "\n", sizeof(message)); @@ -3090,9 +3081,10 @@ int el_submit(LOGBOOK * lbs, int message_id, if (lbs->el_index[i].message_id == message_id) break; - for (j = i + 1; j < *lbs->n_el_index && - equal_ustring(lbs->el_index[i].file_name, - lbs->el_index[j].file_name); j++) + for (j = i + 1; + j < *lbs->n_el_index + && equal_ustring(lbs->el_index[i].file_name, lbs->el_index[j].file_name); + j++) lbs->el_index[j].offset += delta; } @@ -3108,24 +3100,23 @@ int el_submit(LOGBOOK * lbs, int message_id, /* if reply, mark original message */ if (mark_original && in_reply_to[0] && !bedit && atoi(in_reply_to) > 0) { - char date[80], attr[MAX_N_ATTR][NAME_LENGTH], enc[80], - att[MAX_ATTACHMENTS][256], reply_to[MAX_REPLY_TO * 10], - lock[256]; + char date[80], attr[MAX_N_ATTR][NAME_LENGTH], enc[80], att[MAX_ATTACHMENTS][256], + reply_to[MAX_REPLY_TO * 10], lock[256]; reply_id = atoi(in_reply_to); /* retrieve original message */ size = sizeof(message); - el_retrieve(lbs, reply_id, date, attr_list, attr, n_attr, - message, &size, in_reply_to, reply_to, att, enc, lock); + el_retrieve(lbs, reply_id, date, attr_list, attr, n_attr, message, &size, + in_reply_to, reply_to, att, enc, lock); if (reply_to[0]) strcat(reply_to, ", "); sprintf(reply_to + strlen(reply_to), "%d", message_id); /* write modified message */ - el_submit(lbs, reply_id, date, attr_list, attr, n_attr, - message, in_reply_to, reply_to, enc, att, TRUE, lock); + el_submit(lbs, reply_id, date, attr_list, attr, n_attr, message, in_reply_to, + reply_to, enc, att, TRUE, lock); } return message_id; @@ -3133,8 +3124,7 @@ int el_submit(LOGBOOK * lbs, int message_id, /*------------------------------------------------------------------*/ -void remove_reference(LOGBOOK * lbs, int message_id, int remove_id, - BOOL reply_to_flag) +void remove_reference(LOGBOOK * lbs, int message_id, int remove_id, BOOL reply_to_flag) { char date[80], attr[MAX_N_ATTR][NAME_LENGTH], enc[80], in_reply_to[80], reply_to[MAX_REPLY_TO * 10], att[MAX_ATTACHMENTS][256], lock[256]; @@ -3144,8 +3134,8 @@ void remove_reference(LOGBOOK * lbs, int message_id, int remove_id, /* retrieve original message */ size = sizeof(message); status = - el_retrieve(lbs, message_id, date, attr_list, attr, lbs->n_attr, - message, &size, in_reply_to, reply_to, att, enc, lock); + el_retrieve(lbs, message_id, date, attr_list, attr, lbs->n_attr, message, &size, + in_reply_to, reply_to, att, enc, lock); if (status != EL_SUCCESS) return; @@ -3173,8 +3163,8 @@ void remove_reference(LOGBOOK * lbs, int message_id, int remove_id, } /* write modified message */ - el_submit(lbs, message_id, date, attr_list, attr, lbs->n_attr, - message, in_reply_to, reply_to, enc, att, TRUE, lock); + el_submit(lbs, message_id, date, attr_list, attr, lbs->n_attr, message, in_reply_to, + reply_to, enc, att, TRUE, lock); } /*------------------------------------------------------------------*/ @@ -3206,8 +3196,8 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, \********************************************************************/ { INT i, index, n, size, fh, tail_size; - char str[MAX_PATH_LENGTH], file_name[MAX_PATH_LENGTH], - reply_to[MAX_REPLY_TO * 10], in_reply_to[256]; + char str[MAX_PATH_LENGTH], file_name[MAX_PATH_LENGTH], reply_to[MAX_REPLY_TO * 10], + in_reply_to[256]; char *buffer, *p; char *message, attachment_all[64 * MAX_ATTACHMENTS]; @@ -3218,8 +3208,7 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, if (index == *lbs->n_el_index) return -1; - sprintf(file_name, "%s%s", lbs->data_dir, - lbs->el_index[index].file_name); + sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) return EL_FILE_ERROR; @@ -3245,8 +3234,8 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, /* file might have been edited, rebuild index */ el_build_index(lbs, TRUE); - return el_delete_message(lbs, message_id, delete_attachments, - attachment, delete_bw_ref, delete_reply_to); + return el_delete_message(lbs, message_id, delete_attachments, attachment, + delete_bw_ref, delete_reply_to); } /* check for correct ID */ @@ -3343,8 +3332,7 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, lbs->el_index[i].offset -= size; } (*lbs->n_el_index)--; - lbs->el_index = - realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index)); + lbs->el_index = realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index)); /* if other logbook has same index, update pointers */ for (i = 0; lb_list[i].name[0]; i++) @@ -3395,22 +3383,19 @@ int el_correct_links(LOGBOOK * lbs, int old_id, int new_id) { int i, i1, n, n1, size; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], - in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], - locked_by[256]; + in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; char list[MAX_N_ATTR][NAME_LENGTH], list1[MAX_N_ATTR][NAME_LENGTH]; char att_file[MAX_ATTACHMENTS][256]; - el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, - NULL, 0, in_reply_to, reply_to, att_file, encoding, - locked_by); + el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, NULL, 0, in_reply_to, + reply_to, att_file, encoding, locked_by); /* go through in_reply_to list */ n = strbreak(in_reply_to, list, MAX_N_ATTR); for (i = 0; i < n; i++) { size = sizeof(text); el_retrieve(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, - locked_by); + text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); n1 = strbreak(reply_to, list1, MAX_N_ATTR); reply_to[0] = 0; @@ -3426,21 +3411,18 @@ int el_correct_links(LOGBOOK * lbs, int old_id, int new_id) } el_submit(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, in_reply_to, reply_to, encoding, att_file, TRUE, - locked_by); + text, in_reply_to, reply_to, encoding, att_file, TRUE, locked_by); } - el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, - NULL, 0, in_reply_to, reply_to, att_file, encoding, - locked_by); + el_retrieve(lbs, new_id, date, attr_list, attrib, lbs->n_attr, NULL, 0, in_reply_to, + reply_to, att_file, encoding, locked_by); /* go through reply_to list */ n = strbreak(reply_to, list, MAX_N_ATTR); for (i = 0; i < n; i++) { size = sizeof(text); el_retrieve(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, - locked_by); + text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); n1 = strbreak(in_reply_to, list1, MAX_N_ATTR); in_reply_to[0] = 0; @@ -3456,8 +3438,7 @@ int el_correct_links(LOGBOOK * lbs, int old_id, int new_id) } el_submit(lbs, atoi(list[i]), date, attr_list, attrib, lbs->n_attr, - text, in_reply_to, reply_to, encoding, att_file, TRUE, - locked_by); + text, in_reply_to, reply_to, encoding, att_file, TRUE, locked_by); } return EL_SUCCESS; @@ -3469,22 +3450,19 @@ int el_move_message_thread(LOGBOOK * lbs, int message_id) { int i, n, size, new_id; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], - in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], - locked_by[256]; + in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; char list[MAX_N_ATTR][NAME_LENGTH], str[256]; char att_file[MAX_ATTACHMENTS][256]; /* retrieve message */ size = sizeof(text); el_retrieve(lbs, message_id, date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, - locked_by); + text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); /* submit as new message */ date[0] = 0; new_id = el_submit(lbs, 0, date, attr_list, attrib, lbs->n_attr, text, - in_reply_to, reply_to, encoding, att_file, FALSE, - locked_by); + in_reply_to, reply_to, encoding, att_file, FALSE, locked_by); /* correct links */ el_correct_links(lbs, message_id, new_id); @@ -3511,19 +3489,17 @@ int el_lock_message(LOGBOOK * lbs, int message_id, char *user) { int size; char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], - in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], - locked_by[256]; + in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; char att_file[MAX_ATTACHMENTS][256]; /* retrieve message */ size = sizeof(text); el_retrieve(lbs, message_id, date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, att_file, encoding, - locked_by); + text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); /* submit message, unlocked if user==NULL */ - el_submit(lbs, message_id, date, attr_list, attrib, lbs->n_attr, text, - in_reply_to, reply_to, encoding, att_file, FALSE, user); + el_submit(lbs, message_id, date, attr_list, attrib, lbs->n_attr, text, in_reply_to, + reply_to, encoding, att_file, FALSE, user); return EL_SUCCESS; } @@ -3566,8 +3542,7 @@ void logf(LOGBOOK * lbs, const char *format, ...) strlcpy(lb, lbs->name, sizeof(lb)); if (*getparam("unm")) - fprintf(f, "%s [%s@%s] %s: %s", buf, getparam("unm"), rem_host, lb, - str); + fprintf(f, "%s [%s@%s] %s: %s", buf, getparam("unm"), rem_host, lb, str); else fprintf(f, "%s [%s] %s: %s", buf, rem_host, lb, str); @@ -3593,8 +3568,7 @@ void rsputs(const char *str) /*------------------------------------------------------------------*/ -char *list[] = - { "http://", "https://", "ftp://", "mailto:", "elog:", "file://", "" }; +char *list[] = { "http://", "https://", "ftp://", "mailto:", "elog:", "file://", "" }; void rsputs2(const char *str) { @@ -3674,19 +3648,17 @@ void rsputs2(const char *str) if (m < (int) strlen(tmp)) /* if link contains reference to other logbook, add ".." in front */ - sprintf(return_buffer + j, - "elog:%s", link, + sprintf(return_buffer + j, "elog:%s", link, link_text); else if (link[0] == '/') - sprintf(return_buffer + j, - "elog:%s", + sprintf(return_buffer + j, "elog:%s", _current_message_id, link, link_text); else - sprintf(return_buffer + j, "elog:%s", - link, link_text); + sprintf(return_buffer + j, "elog:%s", link, + link_text); } else - sprintf(return_buffer + j, "%s%s", - list[l], link, list[l], link_text); + sprintf(return_buffer + j, "%s%s", list[l], link, + list[l], link_text); j += strlen(return_buffer + j); break; @@ -3818,8 +3790,7 @@ int setparam(char *param, char *value) if (i < MAX_PARAM) { if (strlen(param) >= NAME_LENGTH) { - sprintf(str, "Error: Parameter name too big (%d bytes).\n", - strlen(param)); + sprintf(str, "Error: Parameter name too big (%d bytes).\n", strlen(param)); show_error(str); return 0; } @@ -3987,8 +3958,7 @@ void set_redir(LOGBOOK * lbs, char *redir) /*------------------------------------------------------------------*/ -void set_cookie(LOGBOOK * lbs, char *name, char *value, BOOL global, - char *expiration) +void set_cookie(LOGBOOK * lbs, char *name, char *value, BOOL global, char *expiration) { char lb_name[256], str[NAME_LENGTH]; double exp; @@ -4194,8 +4164,7 @@ int scan_attributes(char *logbook, char *condition) } } else { memcpy(attr_list, attr_list_default, sizeof(attr_list_default)); - memcpy(attr_options, attr_options_default, - sizeof(attr_options_default)); + memcpy(attr_options, attr_options_default, sizeof(attr_options_default)); memcpy(attr_flags, attr_flags_default, sizeof(attr_flags_default)); n = 4; } @@ -4237,8 +4206,7 @@ void show_html_header(LOGBOOK * lbs, BOOL expires, char *title) show_http_header(expires); /* DOCTYPE */ - rsprintf - ("\n"); + rsprintf("\n"); /* page title */ rsprintf("%s\n", title); @@ -4252,14 +4220,12 @@ void show_html_header(LOGBOOK * lbs, BOOL expires, char *title) else if (lbs == NULL && getcfg("global", "CSS", str)) strlcpy(css, str, sizeof(css)); - rsprintf("", - css); + rsprintf("", css); rsprintf("\n"); } -void show_standard_header(LOGBOOK * lbs, BOOL expires, char *title, - char *path) +void show_standard_header(LOGBOOK * lbs, BOOL expires, char *title, char *path) { show_html_header(lbs, expires, title); @@ -4292,8 +4258,7 @@ void show_upgrade_page(LOGBOOK * lbs) ("You probably use an elogd.cfg configuration file for a ELOG version\n"); rsprintf ("1.1.x, since it contains a \"Types = ...\" entry. From version\n"); - rsprintf - ("1.2.0 on, the fixed attributes Type and Category have been\n"); + rsprintf("1.2.0 on, the fixed attributes Type and Category have been\n"); rsprintf ("replaced by arbitrary attributes. Please replace these two lines with the\n"); rsprintf("following entries:

\n"); @@ -4310,8 +4275,7 @@ void show_upgrade_page(LOGBOOK * lbs) rsprintf ("It is of course possible to change the attributes or add new ones. The new\n"); - rsprintf - ("options in the configuration file are described under http://midas.psi.ch/elog/config.html\n"); rsprintf(".\n"); @@ -4320,8 +4284,7 @@ void show_upgrade_page(LOGBOOK * lbs) rsprintf("


\n"); rsprintf("
\n"); - rsprintf - ("S. Ritt, 18 October 2001"); + rsprintf("S. Ritt, 18 October 2001"); rsprintf("
"); rsprintf("\r\n"); @@ -4412,8 +4375,7 @@ int is_logbook_in_group(LBLIST lbl, char *logbook) if (equal_ustring(logbook, lbl->member[i].name)) return 1; - if (lbl->member[i].n_members > 0 && - is_logbook_in_group(&(lbl->member[i]), logbook)) + if (lbl->member[i].n_members > 0 && is_logbook_in_group(&(lbl->member[i]), logbook)) return 1; } @@ -4450,9 +4412,7 @@ void show_standard_title(char *logbook, char *text, int printable) rsprintf("\n"); if (level == 0 && getcfg("global", "main tab", str)) - rsprintf - ("%s\n", - str); + rsprintf("%s\n", str); for (i = 0; i < n_lb; i++) { if (level == 0 && clb[i].subgroup) // check for subgroup @@ -4494,8 +4454,7 @@ void show_standard_title(char *logbook, char *text, int printable) } // rsprintf(" ", sclass, sclass, ref); - rsprintf("", sclass, - ref); + rsprintf("", sclass, ref); strlcpy(str, clb[i].name, sizeof(str)); @@ -4527,8 +4486,7 @@ void show_standard_title(char *logbook, char *text, int printable) /*---- title row ----*/ - rsprintf - ("\n"); + rsprintf("
\n"); /* left cell */ rsprintf("\n", - loc("Logged in as"), getparam("full_name")); + rsprintf("\n", loc("Logged in as"), + getparam("full_name")); else if (getcfg(logbook, "Guest menu commands", str)) - rsprintf("\n", - loc("Not logged in")); + rsprintf("\n", loc("Not logged in")); /* right cell */ rsprintf("
"); @@ -4541,11 +4499,10 @@ void show_standard_title(char *logbook, char *text, int printable) /* middle cell */ if (*getparam("full_name")) - rsprintf("%s \"%s\"%s \"%s\"%s%s"); @@ -4574,8 +4531,7 @@ void show_error(char *error) show_html_header(NULL, FALSE, "ELOG error"); rsprintf("
\n"); - rsprintf - ("\n", error); rsprintf("\n", loc("Change password for user"), - user); + rsprintf("%s \"%s\"\n", loc("Change password for user"), user); - if (!getcfg(lbs->name, "Admin user", str) || - !strstr(str, getparam("unm")) != 0) { + if (!getcfg(lbs->name, "Admin user", str) || !strstr(str, getparam("unm")) != 0) { if (isparam("old_pwd")) - rsprintf("\n"); } } - rsprintf("\n", - loc("New password")); + rsprintf("\n", loc("New password")); rsprintf ("\n"); @@ -5071,14 +5012,13 @@ int get_last_index(LOGBOOK * lbs, int index) auto-increment tags */ { int i, message_id; - char str[80], attrib[MAX_N_ATTR][NAME_LENGTH], - att[MAX_ATTACHMENTS][256]; + char str[80], attrib[MAX_N_ATTR][NAME_LENGTH], att[MAX_ATTACHMENTS][256]; str[0] = 0; message_id = el_search_message(lbs, EL_LAST, 0, FALSE); - el_retrieve(lbs, message_id, NULL, attr_list, attrib, lbs->n_attr, - NULL, 0, NULL, NULL, att, NULL, NULL); + el_retrieve(lbs, message_id, NULL, attr_list, attrib, lbs->n_attr, NULL, 0, NULL, NULL, + att, NULL, NULL); strcpy(str, attrib[index]); @@ -5092,8 +5032,7 @@ int get_last_index(LOGBOOK * lbs, int index) /*------------------------------------------------------------------*/ -BOOL is_author(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], - char *owner) +BOOL is_author(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], char *owner) { char str[1000], preset[1000]; int i; @@ -5142,8 +5081,7 @@ BOOL is_cond_attr(index) int i; for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) - if (strchr(attr_options[index][i], '{') && - strchr(attr_options[index][i], '}')) + if (strchr(attr_options[index][i], '{') && strchr(attr_options[index][i], '}')) return TRUE; return FALSE; @@ -5151,21 +5089,18 @@ BOOL is_cond_attr(index) /*------------------------------------------------------------------*/ -void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, - BOOL breedit) +void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL breedit) { - int i, j, n, index, size, width, height, fh, length, first, input_size, - input_maxlen, format_flags; - char str[1000], preset[1000], *p, *pend, star[80], comment[10000], - reply_string[256]; - char list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, - format[256]; + int i, j, n, index, size, width, height, fh, length, first, input_size, input_maxlen, + format_flags; + char str[1000], preset[1000], *p, *pend, star[80], comment[10000], reply_string[256]; + 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], orig_tag[80], reply_tag[MAX_REPLY_TO * 10], att[MAX_ATTACHMENTS][256], encoding[80], slist[MAX_N_ATTR + 10][NAME_LENGTH], - svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], - class_value[80], class_name[80], condition[256]; + svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], class_value[80], + class_name[80], condition[256]; time_t now; char fl[8][NAME_LENGTH]; struct tm *ts; @@ -5196,8 +5131,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, first = 0; else strlcat(attrib[i], " | ", NAME_LENGTH); - if (strlen(attrib[i]) + strlen(getparam(str)) < - NAME_LENGTH - 2) + if (strlen(attrib[i]) + strlen(getparam(str)) < NAME_LENGTH - 2) strlcat(attrib[i], getparam(str), NAME_LENGTH); else break; @@ -5226,8 +5160,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, size = sizeof(text); el_retrieve(lbs, message_id, date, attr_list, attrib, lbs->n_attr, - text, &size, orig_tag, reply_tag, att, encoding, - locked_by); + text, &size, orig_tag, reply_tag, att, encoding, locked_by); if (bedit) { if (getcfg(lbs->name, "Use Lock", str) && atoi(str) == 1) { @@ -5280,8 +5213,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, } if (i >= MAX_REPLY_TO) { - sprintf(str, loc("Maximum number of replies (%d) exceeded"), - MAX_REPLY_TO); + sprintf(str, loc("Maximum number of replies (%d) exceeded"), MAX_REPLY_TO); show_error(str); return; } @@ -5291,25 +5223,21 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, if (bedit && getcfg_cond(lbs->name, condition, "Restrict edit", str) && atoi(str) == 1) { if (!is_author(lbs, attrib, owner)) { - sprintf(str, loc("Only user %s can edit this entry"), - owner); + sprintf(str, loc("Only user %s can edit this entry"), owner); show_error(str); return; } } /* check for editing interval */ - if (bedit - && getcfg_cond(lbs->name, condition, "Restrict edit time", str)) { + if (bedit && getcfg_cond(lbs->name, condition, "Restrict edit time", str)) { for (i = 0; i < *lbs->n_el_index; i++) if (lbs->el_index[i].message_id == message_id) break; if (i < *lbs->n_el_index && time(NULL) > lbs->el_index[i].file_time + atof(str) * 3600) { - sprintf(str, - loc - ("Message can only be edited %1.2lg hours after creation"), + sprintf(str, loc("Message can only be edited %1.2lg hours after creation"), atof(str)); show_error(str); return; @@ -5369,10 +5297,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, rsprintf("\n", str); if (getcfg(lbs->name, "Password file", str)) { - rsprintf("\n", - getparam("unm")); - rsprintf("\n", - getparam("upwd")); + rsprintf("\n", getparam("unm")); + rsprintf("\n", getparam("upwd")); } /*---- title row ----*/ @@ -5386,17 +5312,14 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, /* default cmd */ rsprintf("\n", loc("Update")); - rsprintf("\n", - loc("Submit")); - rsprintf("\n", - loc("Back")); + rsprintf("\n", loc("Submit")); + rsprintf("\n", loc("Back")); rsprintf("\n\n"); /*---- entry form ----*/ /* table for two-column items */ - rsprintf - ("
%s
"); @@ -4592,8 +4548,7 @@ void show_error(char *error) rsprintf("\n"); @@ -4704,11 +4659,9 @@ void send_file_direct(char *file_name) /* increase return buffer size if file too big */ if (length > return_buffer_size - (int) strlen(return_buffer)) { - delta = - length - (return_buffer_size - strlen(return_buffer)) + 1000; + delta = length - (return_buffer_size - strlen(return_buffer)) + 1000; - return_buffer = - realloc(return_buffer, return_buffer_size + delta); + return_buffer = realloc(return_buffer, return_buffer_size + delta); memset(return_buffer + return_buffer_size, 0, delta); return_buffer_size += delta; } @@ -4721,12 +4674,9 @@ void send_file_direct(char *file_name) show_html_header(NULL, FALSE, "404 Not Found"); rsprintf("

Not Found

\r\n"); - rsprintf - ("The requested file %s was not found on this server

\r\n", - file_name); - rsprintf - ("


ELOG version %s
\r\n\r\n", - VERSION); + rsprintf("The requested file %s was not found on this server

\r\n", + file_name); + rsprintf("


ELOG version %s
\r\n\r\n", VERSION); return_length = strlen_retbuf; keep_alive = 0; } @@ -4811,8 +4761,8 @@ void strencode2(char *b, char *text) /*------------------------------------------------------------------*/ -int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], - char value[][NAME_LENGTH], char attrib[][NAME_LENGTH]) +int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_LENGTH], + char attrib[][NAME_LENGTH]) { int i; char str[NAME_LENGTH], format[256]; @@ -4964,8 +4914,7 @@ BOOL change_pwd(LOGBOOK * lbs, char *user, char *pwd) void show_change_pwd_page(LOGBOOK * lbs) { - char str[256], old_pwd[32], - new_pwd[32], new_pwd2[32], act_pwd[32], user[80]; + char str[256], old_pwd[32], new_pwd[32], new_pwd2[32], act_pwd[32], user[80]; int wrong_pwd; do_crypt(getparam("oldpwd"), old_pwd); @@ -4982,8 +4931,7 @@ void show_change_pwd_page(LOGBOOK * lbs) if (user[0] && get_user_line(lbs->name, user, act_pwd, NULL, NULL, NULL)) { /* administrator does not have to supply old password */ - if (getcfg(lbs->name, "Admin user", str) && - strstr(str, getparam("unm")) != 0) + if (getcfg(lbs->name, "Admin user", str) && strstr(str, getparam("unm")) != 0) wrong_pwd = 0; else { if (strcmp(old_pwd, act_pwd) != 0) @@ -5005,8 +4953,7 @@ void show_change_pwd_page(LOGBOOK * lbs) if (!wrong_pwd) { /* redirect back to configuration page */ - sprintf(str, "?cmd=%s&cfg_user=%s", loc("Config"), - getparam("config")); + sprintf(str, "?cmd=%s&cfg_user=%s", loc("Config"), getparam("config")); redirect(lbs, str); return; } @@ -5028,25 +4975,19 @@ void show_change_pwd_page(LOGBOOK * lbs) rsprintf("", user); - rsprintf("%s \"%s\"
%s:\n", - loc("Old password")); - rsprintf - ("\n"); + rsprintf("
%s:\n", loc("Old password")); + rsprintf("\n"); rsprintf("
%s:
%s:
"); + rsprintf("
"); /* print required message if one of the attributes has it set */ for (i = 0; i < lbs->n_attr; i++) { @@ -5443,8 +5366,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, rsprintf("", loc("Entry date")); rsprintf("\n", - date); + rsprintf("\n", date); /* rescan attributes if condition set */ if (condition[0]) @@ -5472,9 +5394,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, input_maxlen = atoi(fl[4]); } - strcpy(star, - (attr_flags[index] & AF_REQUIRED) ? "*" - : ""); + strcpy(star, (attr_flags[index] & AF_REQUIRED) ? "*" : ""); /* check for preset string */ sprintf(str, "Preset %s", attr_list[index]); @@ -5498,21 +5418,20 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, } /* display text box */ - rsprintf("\n"); /* if attribute cannot be changed, just display text */ if ((attr_flags[index] & AF_LOCKED) || - (bedit && (attr_flags[index] & AF_FIXED_EDIT)) || - (message_id && !bedit && (attr_flags[index] & AF_FIXED_REPLY))) { + (bedit && (attr_flags[index] & AF_FIXED_EDIT)) || (message_id && !bedit + && (attr_flags[index] & + AF_FIXED_REPLY))) { rsprintf("\n", - attr_list[index], attrib[index]); + rsprintf("\n", + attr_list[index], attrib[index]); } else { if (attr_options[index][0][0] == 0) { rsprintf ("\n", - class_value, input_size, input_maxlen, attr_list[index], - attrib[index]); + class_value, input_size, input_maxlen, attr_list[index], attrib[index]); } else { if (equal_ustring(attr_options[index][0], "boolean")) { /* display checkbox */ @@ -5570,20 +5484,17 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, /* display multiple check boxes */ rsprintf("\n"); @@ -5738,17 +5640,14 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, if (breply) /* hidden text for original message */ - rsprintf("\n", - message_id); + rsprintf("\n", message_id); if (breedit) /* hidden text for original message */ - rsprintf("\n", - getparam("reply_to")); + rsprintf("\n", getparam("reply_to")); if (bedit && message_id) - rsprintf("\n", - message_id); + rsprintf("\n", message_id); if (getcfg_cond(lbs->name, condition, "Message comment", comment) && !message_id) { @@ -5758,13 +5657,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, if (!getcfg_cond(lbs->name, condition, "Show text", str) || atoi(str) == 1) { - rsprintf("
%s:%s\n", str); - rsprintf("
%s%s:", - attr_list[index], star); + rsprintf("
%s%s:", attr_list[index], star); /* show optional comment */ sprintf(str, "Comment %s", attr_list[index]); if (getcfg_cond(lbs->name, condition, str, comment)) - rsprintf("
%s\n", - comment); + rsprintf("
%s\n", comment); rsprintf("
\n"); rsputs2(attrib[index]); rsprintf(" "); @@ -5522,38 +5441,33 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, sprintf(str, "%s#%d", attr_list[index], i); if (strstr(attrib[index], attr_options[index][i])) - rsprintf - ("\n", - str, attr_options[index][i]); + rsprintf("\n", str, + attr_options[index][i]); } } else if (attr_flags[index] & AF_RADIO) { for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { sprintf(str, "%s#%d", attr_list[index], i); if (strstr(attrib[index], attr_options[index][i])) - rsprintf - ("\n", - str, attr_options[index][i]); + rsprintf("\n", str, + attr_options[index][i]); } } else if (attr_flags[index] & AF_ICON) { for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { sprintf(str, "%s#%d", attr_list[index], i); if (strstr(attrib[index], attr_options[index][i])) - rsprintf - ("\n", - str, attr_options[index][i]); + rsprintf("\n", str, + attr_options[index][i]); } } else - rsprintf - ("
\n"); - for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; - i++) { + for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { sprintf(str, "%s#%d", attr_list[index], i); if (strstr(attrib[index], attr_options[index][i])) rsprintf ("%s\n", - str, attr_options[index][i], - attr_options[index][i]); + str, attr_options[index][i], attr_options[index][i]); else rsprintf ("%s\n", - str, attr_options[index][i], - attr_options[index][i]); + str, attr_options[index][i], attr_options[index][i]); if (format_flags & AFF_MULTI_LINE) rsprintf("
"); @@ -5594,8 +5505,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, /* display radio buttons */ rsprintf("
\n"); - for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; - i++) { + for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { if (strstr(attrib[index], attr_options[index][i])) rsprintf ("%s\n", @@ -5616,25 +5526,21 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, /* display icons */ rsprintf("\n"); - for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; - i++) { + for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { if (strstr(attrib[index], attr_options[index][i])) rsprintf ("", attr_list[index], attr_options[index][i]); else - rsprintf - ("", - attr_list[index], attr_options[index][i]); + rsprintf("", + attr_list[index], attr_options[index][i]); - sprintf(str, "Icon comment %s", - attr_options[index][i]); + sprintf(str, "Icon comment %s", attr_options[index][i]); getcfg_cond(lbs->name, condition, str, comment); if (comment[0]) - rsprintf - ("\"%s\"\n", - attr_options[index][i], comment); + rsprintf("\"%s\"\n", + attr_options[index][i], comment); else rsprintf("\n", attr_options[index][i]); @@ -5655,23 +5561,20 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, rsprintf(">\n"); /* display emtpy option */ - rsprintf("