mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-10 18:23:28 +00:00
Fixed bug with not displaying inline images
SVN revision: 1081
This commit is contained in:
parent
a5c8b51c3d
commit
fa6bef3ecb
27
src/elconv.c
27
src/elconv.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Conversion program for ELOG messages
|
Contents: Conversion program for ELOG messages
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.7 2004/09/18 04:42:46 midas
|
||||||
|
Fixed bug with not displaying inline images
|
||||||
|
|
||||||
Revision 1.6 2004/07/28 18:51:57 midas
|
Revision 1.6 2004/07/28 18:51:57 midas
|
||||||
Fixed error with gcc 3.4, thanks to Recai Oktas
|
Fixed error with gcc 3.4, thanks to Recai Oktas
|
||||||
|
|
||||||
@ -272,14 +275,12 @@ INT ss_file_find(char *path, char *pattern, char **plist)
|
|||||||
return 0;
|
return 0;
|
||||||
first = 0;
|
first = 0;
|
||||||
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
||||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName,
|
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName, strlen(lpfdata->cFileName));
|
||||||
strlen(lpfdata->cFileName));
|
|
||||||
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
||||||
i++;
|
i++;
|
||||||
while (FindNextFile(pffile, lpfdata)) {
|
while (FindNextFile(pffile, lpfdata)) {
|
||||||
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
||||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName,
|
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName, strlen(lpfdata->cFileName));
|
||||||
strlen(lpfdata->cFileName));
|
|
||||||
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -339,8 +340,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
|||||||
do {
|
do {
|
||||||
tms = localtime(<ime);
|
tms = localtime(<ime);
|
||||||
|
|
||||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100,
|
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||||
tms->tm_mon + 1, tms->tm_mday);
|
|
||||||
lfh = open(file_name, O_RDWR | O_BINARY, 0644);
|
lfh = open(file_name, O_RDWR | O_BINARY, 0644);
|
||||||
|
|
||||||
if (lfh < 0) {
|
if (lfh < 0) {
|
||||||
@ -356,8 +356,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
|||||||
|
|
||||||
/* set new tag */
|
/* set new tag */
|
||||||
tms = localtime(<ime);
|
tms = localtime(<ime);
|
||||||
sprintf(tag, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
sprintf(tag, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||||
tms->tm_mday);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in forward direction, stop today */
|
/* in forward direction, stop today */
|
||||||
@ -458,8 +457,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
|||||||
do {
|
do {
|
||||||
lt -= 3600 * 24;
|
lt -= 3600 * 24;
|
||||||
tms = localtime(<);
|
tms = localtime(<);
|
||||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||||
tms->tm_mday);
|
|
||||||
|
|
||||||
status = el_search_message(str, &lfh, FALSE, FALSE);
|
status = el_search_message(str, &lfh, FALSE, FALSE);
|
||||||
|
|
||||||
@ -532,8 +530,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
|||||||
do {
|
do {
|
||||||
lt += 3600 * 24;
|
lt += 3600 * 24;
|
||||||
tms = localtime(<);
|
tms = localtime(<);
|
||||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||||
tms->tm_mday);
|
|
||||||
|
|
||||||
status = el_search_message(str, &lfh, FALSE, FALSE);
|
status = el_search_message(str, &lfh, FALSE, FALSE);
|
||||||
|
|
||||||
@ -710,8 +707,7 @@ INT el_submit(char attr_name[MAX_N_ATTR][NAME_LENGTH],
|
|||||||
time(&now);
|
time(&now);
|
||||||
tms = localtime(&now);
|
tms = localtime(&now);
|
||||||
|
|
||||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1,
|
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||||
tms->tm_mday);
|
|
||||||
|
|
||||||
fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644);
|
fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644);
|
||||||
if (fh < 0)
|
if (fh < 0)
|
||||||
@ -788,8 +784,7 @@ INT el_submit(char attr_name[MAX_N_ATTR][NAME_LENGTH],
|
|||||||
size = strlen(message) + strlen(start_str) + strlen(end_str);
|
size = strlen(message) + strlen(start_str) + strlen(end_str);
|
||||||
|
|
||||||
if (tag != NULL && !bedit)
|
if (tag != NULL && !bedit)
|
||||||
sprintf(tag, "%02d%02d%02d.%d", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday,
|
sprintf(tag, "%02d%02d%02d.%d", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday, (int) (TELL(fh)));
|
||||||
(int) (TELL(fh)));
|
|
||||||
|
|
||||||
sprintf(start_str, "$Start$: %6d\n", size);
|
sprintf(start_str, "$Start$: %6d\n", size);
|
||||||
sprintf(end_str, "$End$: %6d\n\f", size);
|
sprintf(end_str, "$End$: %6d\n\f", size);
|
||||||
|
|||||||
60
src/elog.c
60
src/elog.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Electronic logbook utility
|
Contents: Electronic logbook utility
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.21 2004/09/18 04:42:46 midas
|
||||||
|
Fixed bug with not displaying inline images
|
||||||
|
|
||||||
Revision 1.20 2004/03/28 10:41:05 midas
|
Revision 1.20 2004/03/28 10:41:05 midas
|
||||||
Fixed problem with logbooks containing blanks
|
Fixed problem with logbooks containing blanks
|
||||||
|
|
||||||
@ -308,8 +311,7 @@ char request[100000], response[100000], *content;
|
|||||||
|
|
||||||
INT retrieve_elog(char *host, int port, char *subdir, char *experiment,
|
INT retrieve_elog(char *host, int port, char *subdir, char *experiment,
|
||||||
char *passwd, char *uname, char *upwd, int message_id,
|
char *passwd, char *uname, char *upwd, int message_id,
|
||||||
char attrib_name[MAX_N_ATTR][NAME_LENGTH],
|
char attrib_name[MAX_N_ATTR][NAME_LENGTH], char attrib[MAX_N_ATTR][NAME_LENGTH], char *text)
|
||||||
char attrib[MAX_N_ATTR][NAME_LENGTH], char *text)
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
|
|
||||||
Routine: retrive_elog
|
Routine: retrive_elog
|
||||||
@ -782,42 +784,35 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
|
|
||||||
if (uname[0])
|
if (uname[0])
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"unm\"\r\n\r\n%s\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"unm\"\r\n\r\n%s\r\n", boundary, uname);
|
||||||
boundary, uname);
|
|
||||||
|
|
||||||
if (upwd[0]) {
|
if (upwd[0]) {
|
||||||
base64_encode(upwd, str);
|
base64_encode(upwd, str);
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"upwd\"\r\n\r\n%s\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"upwd\"\r\n\r\n%s\r\n", boundary, str);
|
||||||
boundary, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (experiment[0])
|
if (experiment[0])
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"exp\"\r\n\r\n%s\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"exp\"\r\n\r\n%s\r\n", boundary, experiment);
|
||||||
boundary, experiment);
|
|
||||||
|
|
||||||
if (reply)
|
if (reply)
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"reply_to\"\r\n\r\n%d\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"reply_to\"\r\n\r\n%d\r\n", boundary, reply);
|
||||||
boundary, reply);
|
|
||||||
|
|
||||||
if (edit)
|
if (edit)
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"edit_id\"\r\n\r\n%d\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"edit_id\"\r\n\r\n%d\r\n", boundary, edit);
|
||||||
boundary, edit);
|
|
||||||
|
|
||||||
if (suppress)
|
if (suppress)
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"suppress\"\r\n\r\n1\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"suppress\"\r\n\r\n1\r\n", boundary);
|
||||||
boundary);
|
|
||||||
|
|
||||||
for (i = 0; i < n_attr; i++) {
|
for (i = 0; i < n_attr; i++) {
|
||||||
strcpy(str, attrib_name[i]);
|
strcpy(str, attrib_name[i]);
|
||||||
btou(str);
|
btou(str);
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary,
|
"%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary, str, attrib[i]);
|
||||||
str, attrib[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(content + strlen(content),
|
sprintf(content + strlen(content),
|
||||||
@ -855,8 +850,7 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
}
|
}
|
||||||
strcat(request, " HTTP/1.0\r\n");
|
strcat(request, " HTTP/1.0\r\n");
|
||||||
|
|
||||||
sprintf(request + strlen(request),
|
sprintf(request + strlen(request), "Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
|
||||||
"Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
|
|
||||||
sprintf(request + strlen(request), "Host: %s\r\n", host_name);
|
sprintf(request + strlen(request), "Host: %s\r\n", host_name);
|
||||||
sprintf(request + strlen(request), "User-Agent: ELOG\r\n");
|
sprintf(request + strlen(request), "User-Agent: ELOG\r\n");
|
||||||
sprintf(request + strlen(request), "Content-Length: %d\r\n", content_length);
|
sprintf(request + strlen(request), "Content-Length: %d\r\n", content_length);
|
||||||
@ -1007,8 +1001,7 @@ int main(int argc, char *argv[])
|
|||||||
strcpy(attr_name[n_attr], str);
|
strcpy(attr_name[n_attr], str);
|
||||||
n_attr++;
|
n_attr++;
|
||||||
} else {
|
} else {
|
||||||
printf
|
printf("Error: Attributes must be supplied in the form \"-a <attribute>=<value>\".\n");
|
||||||
("Error: Attributes must be supplied in the form \"-a <attribute>=<value>\".\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (argv[i][1] == 'f')
|
} else if (argv[i][1] == 'f')
|
||||||
@ -1023,28 +1016,20 @@ int main(int argc, char *argv[])
|
|||||||
usage:
|
usage:
|
||||||
printf("\nusage: elog\n");
|
printf("\nusage: elog\n");
|
||||||
printf(" -h <hostname> [-p port] [-s subdir]\n");
|
printf(" -h <hostname> [-p port] [-s subdir]\n");
|
||||||
printf
|
printf(" Location where elogd is running\n");
|
||||||
(" Location where elogd is running\n");
|
printf(" -l logbook/experiment Name of logbook or experiment\n");
|
||||||
printf
|
|
||||||
(" -l logbook/experiment Name of logbook or experiment\n");
|
|
||||||
printf(" [-v] for verbose output\n");
|
printf(" [-v] for verbose output\n");
|
||||||
printf
|
printf(" [-w password] write password defined on server\n");
|
||||||
(" [-w password] write password defined on server\n");
|
|
||||||
printf(" [-u username password] user name and password\n");
|
printf(" [-u username password] user name and password\n");
|
||||||
printf(" [-f <attachment>] (up to %d times)\n",
|
printf(" [-f <attachment>] (up to %d times)\n", MAX_ATTACHMENTS);
|
||||||
MAX_ATTACHMENTS);
|
printf(" -a <attribute>=<value> (up to %d times)\n", MAX_N_ATTR);
|
||||||
printf(" -a <attribute>=<value> (up to %d times)\n",
|
|
||||||
MAX_N_ATTR);
|
|
||||||
printf(" [-r <id>] Reply to existing message\n");
|
printf(" [-r <id>] Reply to existing message\n");
|
||||||
printf(" [-e <id>] Edit existing message\n");
|
printf(" [-e <id>] Edit existing message\n");
|
||||||
printf
|
printf(" [-x] Suppress email notification\n");
|
||||||
(" [-x] Suppress email notification\n");
|
|
||||||
printf(" -m <textfile>] | <text>\n");
|
printf(" -m <textfile>] | <text>\n");
|
||||||
printf("\nArguments with blanks must be enclosed in quotes\n");
|
printf("\nArguments with blanks must be enclosed in quotes\n");
|
||||||
printf
|
printf("The elog message can either be submitted on the command line, piped in like\n");
|
||||||
("The elog message can either be submitted on the command line, piped in like\n");
|
printf("\"cat text | elog -h ... -l ... -a ...\" or in a file with the -m flag.\n");
|
||||||
printf
|
|
||||||
("\"cat text | elog -h ... -l ... -a ...\" or in a file with the -m flag.\n");
|
|
||||||
printf("Multiple attributes and attachments can be supplied\n");
|
printf("Multiple attributes and attachments can be supplied\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1081,8 +1066,7 @@ int main(int argc, char *argv[])
|
|||||||
lseek(fh, 0, SEEK_SET);
|
lseek(fh, 0, SEEK_SET);
|
||||||
|
|
||||||
if (size > (int) sizeof(text) - 1) {
|
if (size > (int) sizeof(text) - 1) {
|
||||||
printf("Message file \"%s\" is too long (%d bytes max).\n", textfile,
|
printf("Message file \"%s\" is too long (%d bytes max).\n", textfile, sizeof(text));
|
||||||
sizeof(text));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.475 2004/09/18 04:42:46 midas
|
||||||
|
Fixed bug with not displaying inline images
|
||||||
|
|
||||||
Revision 1.474 2004/09/18 03:27:34 midas
|
Revision 1.474 2004/09/18 03:27:34 midas
|
||||||
Fixed problem with '/' in forgotten password
|
Fixed problem with '/' in forgotten password
|
||||||
|
|
||||||
@ -5026,7 +5029,10 @@ int is_ascii(char *file_name)
|
|||||||
|
|
||||||
int is_image(char *att)
|
int is_image(char *att)
|
||||||
{
|
{
|
||||||
return strstr(att, ".GIF") || strstr(att, ".JPG") || strstr(att, ".JPEG") || strstr(att, ".PNG");
|
return (stristr(att, ".GIF") != NULL) ||
|
||||||
|
(stristr(att, ".JPG") != NULL) ||
|
||||||
|
(stristr(att, ".JPEG") != NULL) ||
|
||||||
|
(stristr(att, ".PNG") != NULL) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user