mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
- Replaced read() with my_read() to be thread save
- Implemented $version and $revision in bottom text - Implemented "Hidden attributes = ..." - Fixed invalid link if searched in all logbooks SVN revision: 1669
This commit is contained in:
parent
fac1c1313b
commit
456675fc9d
4570
doc/config.html
4570
doc/config.html
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@ containing bug fixes or some new and not yet completely debugged code. This
|
|||||||
is usually the case if some user asks for some new features, which are then
|
is usually the case if some user asks for some new features, which are then
|
||||||
implemented and sent to the user for testing. The minor releases are named
|
implemented and sent to the user for testing. The minor releases are named
|
||||||
<b><code>x.y.z-r</code></b> where <b><code>r</code></b> is the release number.
|
<b><code>x.y.z-r</code></b> where <b><code>r</code></b> is the release number.
|
||||||
A <a href="http://savannah.psi.ch/viewcvs/trunk?root=elog">web access</a> to the
|
A <a href="http://savannah.psi.ch/websvn/listing.php?repname=elog&path=%2Ftrunk%2F">web access</a>
|
||||||
source code contains the complete development history of ELOG. To check out the complete
|
to the source code contains the complete development history of ELOG. To check out the complete
|
||||||
Subversion tree, use:<P>
|
Subversion tree, use:<P>
|
||||||
<code>
|
<code>
|
||||||
<b>svn checkout svn+ssh://svn@savannah.psi.ch/afs/psi.ch/project/meg/svn/elog/trunk elog</b><br>
|
<b>svn checkout svn+ssh://svn@savannah.psi.ch/afs/psi.ch/project/meg/svn/elog/trunk elog</b><br>
|
||||||
|
|||||||
14
doc/elog.css
14
doc/elog.css
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
.title { padding: 5px 10px;
|
.title { padding: 5px 10px;
|
||||||
background-color: rgb(72, 96, 144);
|
background-color: rgb(72, 96, 144);
|
||||||
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
|
||||||
font-size: x-large;
|
font-size: x-large;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -10,19 +9,17 @@
|
|||||||
|
|
||||||
.version { padding: 5px 10px;
|
.version { padding: 5px 10px;
|
||||||
color: rgb(72, 96, 144);
|
color: rgb(72, 96, 144);
|
||||||
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Sub { font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
.Sub {
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu { padding: 5px 10px;
|
.menu { padding: 5px 10px;
|
||||||
background-color: rgb(72, 96, 144);
|
background-color: rgb(72, 96, 144);
|
||||||
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -34,7 +31,6 @@
|
|||||||
|
|
||||||
.section { padding: 5px 10px;
|
.section { padding: 5px 10px;
|
||||||
background-color: rgb(72, 96, 144);
|
background-color: rgb(72, 96, 144);
|
||||||
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
|
||||||
font-size: large;
|
font-size: large;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@ -42,13 +38,17 @@
|
|||||||
|
|
||||||
.footer { padding: 5px 10px;
|
.footer { padding: 5px 10px;
|
||||||
background-color: rgb(72, 96, 144);
|
background-color: rgb(72, 96, 144);
|
||||||
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
|
||||||
font-size: small;
|
font-size: small;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
p { margin-left: 10px;
|
body {
|
||||||
|
font-family: Verdana,Arial,Helvetica,Sans-Serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
105
src/elogd.c
105
src/elogd.c
@ -251,6 +251,7 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = {
|
|||||||
#define AF_TIME (1<<10)
|
#define AF_TIME (1<<10)
|
||||||
#define AF_NUMERIC (1<<11)
|
#define AF_NUMERIC (1<<11)
|
||||||
#define AF_USERLIST (1<<12)
|
#define AF_USERLIST (1<<12)
|
||||||
|
#define AF_HIDDEN (1<<13)
|
||||||
|
|
||||||
/* attribute format flags */
|
/* attribute format flags */
|
||||||
#define AFF_SAME_LINE 1
|
#define AFF_SAME_LINE 1
|
||||||
@ -552,6 +553,32 @@ size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm * tm)
|
|||||||
return strftime(s, max, fmt, tm);
|
return strftime(s, max, fmt, tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* signal save read function */
|
||||||
|
int my_read(int fh, void *buffer, unsigned int bytes)
|
||||||
|
{
|
||||||
|
#ifdef OS_UNIX
|
||||||
|
int i, n = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
i = read(fh, buffer+n, bytes-n);
|
||||||
|
|
||||||
|
/* don't return if an alarm signal was cought */
|
||||||
|
if (i == -1 && errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (i == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
n += i;
|
||||||
|
|
||||||
|
} while (n < bytes);
|
||||||
|
#else
|
||||||
|
return read(fh, buffer, bytes);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*---- Compose RFC2822 compliant date ---*/
|
/*---- Compose RFC2822 compliant date ---*/
|
||||||
|
|
||||||
void get_rfc2822_date(char *date, int size, time_t ltime)
|
void get_rfc2822_date(char *date, int size, time_t ltime)
|
||||||
@ -4041,7 +4068,7 @@ int el_retrieve(LOGBOOK * lbs,
|
|||||||
message = malloc(TEXT_SIZE + 1000);
|
message = malloc(TEXT_SIZE + 1000);
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
i = read(fh, message, TEXT_SIZE + 1000 - 1);
|
i = my_read(fh, message, TEXT_SIZE + 1000 - 1);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
free(message);
|
free(message);
|
||||||
close(fh);
|
close(fh);
|
||||||
@ -4260,7 +4287,7 @@ int el_retrieve_attachment(LOGBOOK * lbs, int message_id, int n, char name[MAX_P
|
|||||||
}
|
}
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
i = read(fh, message, sizeof(message) - 1);
|
i = my_read(fh, message, sizeof(message) - 1);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
close(fh);
|
close(fh);
|
||||||
return EL_FILE_ERROR;
|
return EL_FILE_ERROR;
|
||||||
@ -4381,7 +4408,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
i = read(fh, message, TEXT_SIZE + 100);
|
i = my_read(fh, message, TEXT_SIZE + 100);
|
||||||
message[i] = 0;
|
message[i] = 0;
|
||||||
|
|
||||||
/* check for valid message */
|
/* check for valid message */
|
||||||
@ -4430,7 +4457,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit,
|
|||||||
buffer = xmalloc(tail_size);
|
buffer = xmalloc(tail_size);
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset + size, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset + size, SEEK_SET);
|
||||||
n = read(fh, buffer, tail_size);
|
n = my_read(fh, buffer, tail_size);
|
||||||
}
|
}
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
} else {
|
} else {
|
||||||
@ -4679,7 +4706,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id,
|
|||||||
message = xmalloc(TEXT_SIZE + 1000);
|
message = xmalloc(TEXT_SIZE + 1000);
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
i = read(fh, message, TEXT_SIZE + 1000 - 1);
|
i = my_read(fh, message, TEXT_SIZE + 1000 - 1);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
xfree(message);
|
xfree(message);
|
||||||
close(fh);
|
close(fh);
|
||||||
@ -4756,7 +4783,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id,
|
|||||||
buffer = xmalloc(tail_size);
|
buffer = xmalloc(tail_size);
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset + size, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset + size, SEEK_SET);
|
||||||
n = read(fh, buffer, tail_size);
|
n = my_read(fh, buffer, tail_size);
|
||||||
}
|
}
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
|
|
||||||
@ -6185,6 +6212,20 @@ void set_location(LOGBOOK * lbs, char *rel_path)
|
|||||||
char str[NAME_LENGTH], group[NAME_LENGTH], list[NAME_LENGTH], *p;
|
char str[NAME_LENGTH], group[NAME_LENGTH], list[NAME_LENGTH], *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (getcfg(lbs->name, "Relative redirect", str, sizeof(str)) &&
|
||||||
|
atoi(str) == 1) {
|
||||||
|
|
||||||
|
if (rel_path[0])
|
||||||
|
strlcpy(str, rel_path, sizeof(str));
|
||||||
|
else
|
||||||
|
strlcpy(str, ".", sizeof(str));
|
||||||
|
|
||||||
|
rsputs("Location: ");
|
||||||
|
rsputs(str);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* Absolute redirect */
|
||||||
|
|
||||||
/* if path contains http(s), go directly there */
|
/* if path contains http(s), go directly there */
|
||||||
if (strncmp(rel_path, "http://", 7) == 0) {
|
if (strncmp(rel_path, "http://", 7) == 0) {
|
||||||
rsputs("Location: ");
|
rsputs("Location: ");
|
||||||
@ -6320,6 +6361,7 @@ void set_location(LOGBOOK * lbs, char *rel_path)
|
|||||||
rsputs(str);
|
rsputs(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rsprintf("\r\n\r\n<html>redir</html>\r\n");
|
rsprintf("\r\n\r\n<html>redir</html>\r\n");
|
||||||
}
|
}
|
||||||
@ -6575,6 +6617,15 @@ and attr_flags arrays */
|
|||||||
attr_flags[j] |= AF_FIXED_REPLY;
|
attr_flags[j] |= AF_FIXED_REPLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if hidden attribute */
|
||||||
|
getcfg(logbook, "Hidden Attributes", list, sizeof(list));
|
||||||
|
m = strbreak(list, tmp_list, MAX_N_ATTR, ",");
|
||||||
|
for (i = 0; i < m; i++) {
|
||||||
|
for (j = 0; j < n; j++)
|
||||||
|
if (strieq(attr_list[j], tmp_list[i]))
|
||||||
|
attr_flags[j] |= AF_HIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
/* check for extendable options */
|
/* check for extendable options */
|
||||||
getcfg(logbook, "Extendable Options", list, sizeof(list));
|
getcfg(logbook, "Extendable Options", list, sizeof(list));
|
||||||
m = strbreak(list, tmp_list, MAX_N_ATTR, ",");
|
m = strbreak(list, tmp_list, MAX_N_ATTR, ",");
|
||||||
@ -7224,8 +7275,8 @@ void show_top_text(LOGBOOK * lbs)
|
|||||||
|
|
||||||
void show_bottom_text(LOGBOOK * lbs)
|
void show_bottom_text(LOGBOOK * lbs)
|
||||||
{
|
{
|
||||||
char str[NAME_LENGTH];
|
char str[NAME_LENGTH], slist[20][NAME_LENGTH], svalue[20][NAME_LENGTH];
|
||||||
int size;
|
int i, size;
|
||||||
|
|
||||||
if (getcfg(lbs->name, "bottom text", str, sizeof(str))) {
|
if (getcfg(lbs->name, "bottom text", str, sizeof(str))) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
@ -7246,15 +7297,23 @@ void show_bottom_text(LOGBOOK * lbs)
|
|||||||
size = TELL(fileno(f));
|
size = TELL(fileno(f));
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
buf = xmalloc(size + 1);
|
buf = xmalloc(size + 100);
|
||||||
fread(buf, 1, size, f);
|
fread(buf, 1, size, f);
|
||||||
buf[size] = 0;
|
buf[size] = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
i = build_subst_list(lbs, slist, svalue, NULL, TRUE);
|
||||||
|
strsubst_list(buf, size+100, slist, svalue, i);
|
||||||
|
|
||||||
rsputs(buf);
|
rsputs(buf);
|
||||||
} else
|
xfree(buf);
|
||||||
|
} else {
|
||||||
|
i = build_subst_list(lbs, slist, svalue, NULL, TRUE);
|
||||||
|
strsubst_list(str, sizeof(str), slist, svalue, i);
|
||||||
|
|
||||||
rsputs(str);
|
rsputs(str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
/* add little logo */
|
/* add little logo */
|
||||||
rsprintf
|
rsprintf
|
||||||
@ -7661,6 +7720,13 @@ int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_
|
|||||||
sprintf(str, "%d", (int) t);
|
sprintf(str, "%d", (int) t);
|
||||||
strcpy(value[i++], str);
|
strcpy(value[i++], str);
|
||||||
|
|
||||||
|
/* add ELOG version and revision */
|
||||||
|
strcpy(list[i], "version");
|
||||||
|
strcpy(value[i++], VERSION);
|
||||||
|
|
||||||
|
strcpy(list[i], "revision");
|
||||||
|
sprintf(value[i++], "%d", atoi(svn_revision + 13));
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8919,6 +8985,10 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
|||||||
|
|
||||||
index = attr_index[aindex];
|
index = attr_index[aindex];
|
||||||
|
|
||||||
|
/* if attribute is hidden, skip it */
|
||||||
|
if (attr_flags[index] & AF_HIDDEN)
|
||||||
|
continue;
|
||||||
|
|
||||||
strcpy(class_name, "attribname");
|
strcpy(class_name, "attribname");
|
||||||
strcpy(class_value, "attribvalue");
|
strcpy(class_value, "attribvalue");
|
||||||
input_size = 80;
|
input_size = 80;
|
||||||
@ -9973,7 +10043,7 @@ void show_find_form(LOGBOOK * lbs)
|
|||||||
|
|
||||||
if (i > 2) {
|
if (i > 2) {
|
||||||
if (!getcfg(lbs->name, "Search all logbooks", str, sizeof(str)) || atoi(str) == 1) {
|
if (!getcfg(lbs->name, "Search all logbooks", str, sizeof(str)) || atoi(str) == 1) {
|
||||||
rsprintf("<input type=checkbox id=all name=all value=1>\n");
|
rsprintf("<input type=checkbox id=all name=all value=1>");
|
||||||
rsprintf("<label for=\"all\">%s</label><br>\n", loc("Search all logbooks"));
|
rsprintf("<label for=\"all\">%s</label><br>\n", loc("Search all logbooks"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12081,7 +12151,7 @@ int show_download_page(LOGBOOK * lbs, char *path)
|
|||||||
return EL_FILE_ERROR;
|
return EL_FILE_ERROR;
|
||||||
|
|
||||||
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
lseek(fh, lbs->el_index[index].offset, SEEK_SET);
|
||||||
i = read(fh, message, sizeof(message) - 1);
|
i = my_read(fh, message, sizeof(message) - 1);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
close(fh);
|
close(fh);
|
||||||
return EL_FILE_ERROR;
|
return EL_FILE_ERROR;
|
||||||
@ -14488,7 +14558,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode,
|
|||||||
ref[0] = 0;
|
ref[0] = 0;
|
||||||
if (absolute_link)
|
if (absolute_link)
|
||||||
compose_base_url(lbs, ref, sizeof(ref));
|
compose_base_url(lbs, ref, sizeof(ref));
|
||||||
sprintf(ref + strlen(ref), "%d", message_id);
|
sprintf(ref + strlen(ref), "../%s/%d", lbs->name_enc, message_id);
|
||||||
|
|
||||||
if (strieq(mode, "Summary")) {
|
if (strieq(mode, "Summary")) {
|
||||||
if (highlight_mid == message_id) {
|
if (highlight_mid == message_id) {
|
||||||
@ -17997,7 +18067,7 @@ void format_email_attachments(LOGBOOK * lbs, int message_id, int attachment_type
|
|||||||
fh = open(file_name, O_RDONLY | O_BINARY);
|
fh = open(file_name, O_RDONLY | O_BINARY);
|
||||||
if (fh > 0) {
|
if (fh > 0) {
|
||||||
do {
|
do {
|
||||||
n = read(fh, buffer, 45);
|
n = my_read(fh, buffer, 45);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -20638,7 +20708,7 @@ BOOL convert_password_file(char *file_name)
|
|||||||
lseek(fh, 0, SEEK_SET);
|
lseek(fh, 0, SEEK_SET);
|
||||||
buf = malloc(len + 1);
|
buf = malloc(len + 1);
|
||||||
assert(buf);
|
assert(buf);
|
||||||
i = read(fh, buf, len);
|
i = my_read(fh, buf, len);
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
close(fh);
|
close(fh);
|
||||||
|
|
||||||
@ -21142,7 +21212,6 @@ BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir)
|
|||||||
if (user == NULL)
|
if (user == NULL)
|
||||||
status = 1;
|
status = 1;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
status = get_user_line(lbs, user, upwd, full_name, email, NULL, NULL);
|
status = get_user_line(lbs, user, upwd, full_name, email, NULL, NULL);
|
||||||
|
|
||||||
if (status == 1 && user[0])
|
if (status == 1 && user[0])
|
||||||
@ -24378,7 +24447,7 @@ int ss_getchar(BOOL reset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(c, 0, 3);
|
memset(c, 0, 3);
|
||||||
i = read(fd, c, 1);
|
i = my_read(fd, c, 1);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -24524,7 +24593,7 @@ void create_password(char *logbook, char *name, char *pwd)
|
|||||||
length = lseek(fh, 0, SEEK_END);
|
length = lseek(fh, 0, SEEK_END);
|
||||||
lseek(fh, 0, SEEK_SET);
|
lseek(fh, 0, SEEK_SET);
|
||||||
cfgbuffer = xmalloc(length + 1);
|
cfgbuffer = xmalloc(length + 1);
|
||||||
length = read(fh, cfgbuffer, length);
|
length = my_read(fh, cfgbuffer, length);
|
||||||
cfgbuffer[length] = 0;
|
cfgbuffer[length] = 0;
|
||||||
close(fh);
|
close(fh);
|
||||||
fh = open(config_file, O_TRUNC | O_WRONLY, 0640);
|
fh = open(config_file, O_TRUNC | O_WRONLY, 0640);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user