Fixed bug with not displaying inline images
SVN revision: 1081
This commit is contained in:
+11
-16
@@ -6,6 +6,9 @@
|
||||
Contents: Conversion program for ELOG messages
|
||||
|
||||
$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
|
||||
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;
|
||||
first = 0;
|
||||
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName,
|
||||
strlen(lpfdata->cFileName));
|
||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName, strlen(lpfdata->cFileName));
|
||||
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
||||
i++;
|
||||
while (FindNextFile(pffile, lpfdata)) {
|
||||
*plist = (char *) realloc(*plist, (i + 1) * MAX_PATH_LENGTH);
|
||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName,
|
||||
strlen(lpfdata->cFileName));
|
||||
strncpy(*plist + (i * MAX_PATH_LENGTH), lpfdata->cFileName, strlen(lpfdata->cFileName));
|
||||
*(*plist + (i * MAX_PATH_LENGTH) + strlen(lpfdata->cFileName)) = '\0';
|
||||
i++;
|
||||
}
|
||||
@@ -339,8 +340,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
||||
do {
|
||||
tms = localtime(<ime);
|
||||
|
||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100,
|
||||
tms->tm_mon + 1, tms->tm_mday);
|
||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||
lfh = open(file_name, O_RDWR | O_BINARY, 0644);
|
||||
|
||||
if (lfh < 0) {
|
||||
@@ -356,8 +356,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
||||
|
||||
/* set new tag */
|
||||
tms = localtime(<ime);
|
||||
sprintf(tag, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
||||
tms->tm_mday);
|
||||
sprintf(tag, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||
}
|
||||
|
||||
/* in forward direction, stop today */
|
||||
@@ -458,8 +457,7 @@ INT el_search_message(char *tag, int *fh, BOOL walk, BOOL first)
|
||||
do {
|
||||
lt -= 3600 * 24;
|
||||
tms = localtime(<);
|
||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
||||
tms->tm_mday);
|
||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||
|
||||
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 {
|
||||
lt += 3600 * 24;
|
||||
tms = localtime(<);
|
||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1,
|
||||
tms->tm_mday);
|
||||
sprintf(str, "%02d%02d%02d.0", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||
|
||||
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);
|
||||
tms = localtime(&now);
|
||||
|
||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1,
|
||||
tms->tm_mday);
|
||||
sprintf(file_name, "%s%02d%02d%02d.log", dir, tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday);
|
||||
|
||||
fh = open(file_name, O_CREAT | O_RDWR | O_BINARY, 0644);
|
||||
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);
|
||||
|
||||
if (tag != NULL && !bedit)
|
||||
sprintf(tag, "%02d%02d%02d.%d", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday,
|
||||
(int) (TELL(fh)));
|
||||
sprintf(tag, "%02d%02d%02d.%d", tms->tm_year % 100, tms->tm_mon + 1, tms->tm_mday, (int) (TELL(fh)));
|
||||
|
||||
sprintf(start_str, "$Start$: %6d\n", size);
|
||||
sprintf(end_str, "$End$: %6d\n\f", size);
|
||||
|
||||
+22
-38
@@ -6,6 +6,9 @@
|
||||
Contents: Electronic logbook utility
|
||||
|
||||
$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
|
||||
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,
|
||||
char *passwd, char *uname, char *upwd, int message_id,
|
||||
char attrib_name[MAX_N_ATTR][NAME_LENGTH],
|
||||
char attrib[MAX_N_ATTR][NAME_LENGTH], char *text)
|
||||
char attrib_name[MAX_N_ATTR][NAME_LENGTH], char attrib[MAX_N_ATTR][NAME_LENGTH], char *text)
|
||||
/********************************************************************\
|
||||
|
||||
Routine: retrive_elog
|
||||
@@ -782,42 +784,35 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
||||
|
||||
if (uname[0])
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"unm\"\r\n\r\n%s\r\n",
|
||||
boundary, uname);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"unm\"\r\n\r\n%s\r\n", boundary, uname);
|
||||
|
||||
if (upwd[0]) {
|
||||
base64_encode(upwd, str);
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"upwd\"\r\n\r\n%s\r\n",
|
||||
boundary, str);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"upwd\"\r\n\r\n%s\r\n", boundary, str);
|
||||
}
|
||||
|
||||
if (experiment[0])
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"exp\"\r\n\r\n%s\r\n",
|
||||
boundary, experiment);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"exp\"\r\n\r\n%s\r\n", boundary, experiment);
|
||||
|
||||
if (reply)
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"reply_to\"\r\n\r\n%d\r\n",
|
||||
boundary, reply);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"reply_to\"\r\n\r\n%d\r\n", boundary, reply);
|
||||
|
||||
if (edit)
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"edit_id\"\r\n\r\n%d\r\n",
|
||||
boundary, edit);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"edit_id\"\r\n\r\n%d\r\n", boundary, edit);
|
||||
|
||||
if (suppress)
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"suppress\"\r\n\r\n1\r\n",
|
||||
boundary);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"suppress\"\r\n\r\n1\r\n", boundary);
|
||||
|
||||
for (i = 0; i < n_attr; i++) {
|
||||
strcpy(str, attrib_name[i]);
|
||||
btou(str);
|
||||
sprintf(content + strlen(content),
|
||||
"%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary,
|
||||
str, attrib[i]);
|
||||
"%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary, str, attrib[i]);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
sprintf(request + strlen(request),
|
||||
"Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
|
||||
sprintf(request + strlen(request), "Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
|
||||
sprintf(request + strlen(request), "Host: %s\r\n", host_name);
|
||||
sprintf(request + strlen(request), "User-Agent: ELOG\r\n");
|
||||
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);
|
||||
n_attr++;
|
||||
} else {
|
||||
printf
|
||||
("Error: Attributes must be supplied in the form \"-a <attribute>=<value>\".\n");
|
||||
printf("Error: Attributes must be supplied in the form \"-a <attribute>=<value>\".\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (argv[i][1] == 'f')
|
||||
@@ -1023,28 +1016,20 @@ int main(int argc, char *argv[])
|
||||
usage:
|
||||
printf("\nusage: elog\n");
|
||||
printf(" -h <hostname> [-p port] [-s subdir]\n");
|
||||
printf
|
||||
(" Location where elogd is running\n");
|
||||
printf
|
||||
(" -l logbook/experiment Name of logbook or experiment\n");
|
||||
printf(" Location where elogd is running\n");
|
||||
printf(" -l logbook/experiment Name of logbook or experiment\n");
|
||||
printf(" [-v] for verbose output\n");
|
||||
printf
|
||||
(" [-w password] write password defined on server\n");
|
||||
printf(" [-w password] write password defined on server\n");
|
||||
printf(" [-u username password] user name and password\n");
|
||||
printf(" [-f <attachment>] (up to %d times)\n",
|
||||
MAX_ATTACHMENTS);
|
||||
printf(" -a <attribute>=<value> (up to %d times)\n",
|
||||
MAX_N_ATTR);
|
||||
printf(" [-f <attachment>] (up to %d times)\n", MAX_ATTACHMENTS);
|
||||
printf(" -a <attribute>=<value> (up to %d times)\n", MAX_N_ATTR);
|
||||
printf(" [-r <id>] Reply to existing message\n");
|
||||
printf(" [-e <id>] Edit existing message\n");
|
||||
printf
|
||||
(" [-x] Suppress email notification\n");
|
||||
printf(" [-x] Suppress email notification\n");
|
||||
printf(" -m <textfile>] | <text>\n");
|
||||
printf("\nArguments with blanks must be enclosed in quotes\n");
|
||||
printf
|
||||
("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("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("Multiple attributes and attachments can be supplied\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -1081,8 +1066,7 @@ int main(int argc, char *argv[])
|
||||
lseek(fh, 0, SEEK_SET);
|
||||
|
||||
if (size > (int) sizeof(text) - 1) {
|
||||
printf("Message file \"%s\" is too long (%d bytes max).\n", textfile,
|
||||
sizeof(text));
|
||||
printf("Message file \"%s\" is too long (%d bytes max).\n", textfile, sizeof(text));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -6,6 +6,9 @@
|
||||
Contents: Web server program for Electronic Logbook ELOG
|
||||
|
||||
$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
|
||||
Fixed problem with '/' in forgotten password
|
||||
|
||||
@@ -5026,7 +5029,10 @@ int is_ascii(char *file_name)
|
||||
|
||||
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) ;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user