mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-10-01 05:05:19 +00:00
Added -q flag for 'quote on reply'
SVN revision: 1931
This commit is contained in:
parent
f84440c061
commit
e2bad236c5
27
src/elog.c
27
src/elog.c
@ -507,6 +507,7 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
char *passwd,
|
char *passwd,
|
||||||
char *uname, char *upwd,
|
char *uname, char *upwd,
|
||||||
int reply,
|
int reply,
|
||||||
|
int quote_on_reply,
|
||||||
int edit,
|
int edit,
|
||||||
int suppress,
|
int suppress,
|
||||||
int encoding,
|
int encoding,
|
||||||
@ -611,9 +612,15 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
|
|
||||||
/* copy attributes */
|
/* copy attributes */
|
||||||
for (i = 0; i < MAX_N_ATTR && old_attrib_name[i][0]; i++) {
|
for (i = 0; i < MAX_N_ATTR && old_attrib_name[i][0]; i++) {
|
||||||
|
if (equal_ustring(old_attrib_name[i], "Reply to") ||
|
||||||
|
equal_ustring(old_attrib_name[i], "Date")) {
|
||||||
|
attrib_name[i][0] = 0;
|
||||||
|
attrib[i][0] = 0;
|
||||||
|
} else {
|
||||||
strlcpy(attrib_name[i], old_attrib_name[i], NAME_LENGTH);
|
strlcpy(attrib_name[i], old_attrib_name[i], NAME_LENGTH);
|
||||||
strlcpy(attrib[i], old_attrib[i], NAME_LENGTH);
|
strlcpy(attrib[i], old_attrib[i], NAME_LENGTH);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
n_attr = i;
|
n_attr = i;
|
||||||
|
|
||||||
@ -627,6 +634,7 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
if (i < n_attr)
|
if (i < n_attr)
|
||||||
old_encoding = attrib[i];
|
old_encoding = attrib[i];
|
||||||
|
|
||||||
|
if (quote_on_reply) {
|
||||||
strlcpy(new_text, text, sizeof(new_text));
|
strlcpy(new_text, text, sizeof(new_text));
|
||||||
|
|
||||||
/* precede old text with "> " */
|
/* precede old text with "> " */
|
||||||
@ -668,6 +676,7 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
|
|
||||||
strlcat(text, new_text, TEXT_SIZE);
|
strlcat(text, new_text, TEXT_SIZE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* get local host name */
|
/* get local host name */
|
||||||
gethostname(host_name, sizeof(host_name));
|
gethostname(host_name, sizeof(host_name));
|
||||||
@ -770,10 +779,12 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
|
|
||||||
for (i = 0; i < n_attr; i++) {
|
for (i = 0; i < n_attr; i++) {
|
||||||
strcpy(str, attrib_name[i]);
|
strcpy(str, attrib_name[i]);
|
||||||
|
if (str[0]) {
|
||||||
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, 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),
|
sprintf(content + strlen(content),
|
||||||
"%s\r\nContent-Disposition: form-data; name=\"Text\"\r\n\r\n%s\r\n%s\r\n",
|
"%s\r\nContent-Disposition: form-data; name=\"Text\"\r\n\r\n%s\r\n%s\r\n",
|
||||||
@ -896,10 +907,17 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
else if (strstr(response, "form name=form1"))
|
else if (strstr(response, "form name=form1"))
|
||||||
printf("Error: Missing or invalid user name/password\n");
|
printf("Error: Missing or invalid user name/password\n");
|
||||||
else if (strstr(response, "Error: Attribute")) {
|
else if (strstr(response, "Error: Attribute")) {
|
||||||
|
if (strstr(response, "not existing")) {
|
||||||
|
strncpy(str, strstr(response, "Error: Attribute") + 27, sizeof(str));
|
||||||
|
if (strchr(str, '<'))
|
||||||
|
*strchr(str, '<') = 0;
|
||||||
|
printf("Error: Non existing attribute option \"%s\"\n", str);
|
||||||
|
} else {
|
||||||
strncpy(str, strstr(response, "Error: Attribute") + 20, sizeof(str));
|
strncpy(str, strstr(response, "Error: Attribute") + 20, sizeof(str));
|
||||||
if (strchr(str, '<'))
|
if (strchr(str, '<'))
|
||||||
*strchr(str, '<') = 0;
|
*strchr(str, '<') = 0;
|
||||||
printf("Error: Missing required attribute \"%s\"\n", str);
|
printf("Error: Missing required attribute \"%s\"\n", str);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
printf("Error transmitting message\n");
|
printf("Error transmitting message\n");
|
||||||
|
|
||||||
@ -914,10 +932,10 @@ int main(int argc, char *argv[])
|
|||||||
char host_name[256], logbook[32], textfile[256], password[80], subdir[256];
|
char host_name[256], logbook[32], textfile[256], password[80], subdir[256];
|
||||||
char *buffer[MAX_ATTACHMENTS], attachment[MAX_ATTACHMENTS][256];
|
char *buffer[MAX_ATTACHMENTS], attachment[MAX_ATTACHMENTS][256];
|
||||||
INT att_size[MAX_ATTACHMENTS];
|
INT att_size[MAX_ATTACHMENTS];
|
||||||
INT i, n, fh, n_att, n_attr, port, reply, edit, encoding, suppress, size;
|
INT i, n, fh, n_att, n_attr, port, reply, quote_on_reply, edit, encoding, suppress, size;
|
||||||
char attr_name[MAX_N_ATTR][NAME_LENGTH], attrib[MAX_N_ATTR][NAME_LENGTH];
|
char attr_name[MAX_N_ATTR][NAME_LENGTH], attrib[MAX_N_ATTR][NAME_LENGTH];
|
||||||
|
|
||||||
text[0] = textfile[0] = uname[0] = upwd[0] = suppress = 0;
|
text[0] = textfile[0] = uname[0] = upwd[0] = suppress = quote_on_reply = 0;
|
||||||
host_name[0] = logbook[0] = password[0] = subdir[0] = 0;
|
host_name[0] = logbook[0] = password[0] = subdir[0] = 0;
|
||||||
n_att = n_attr = reply = edit = encoding = 0;
|
n_att = n_attr = reply = edit = encoding = 0;
|
||||||
port = 80;
|
port = 80;
|
||||||
@ -932,6 +950,8 @@ int main(int argc, char *argv[])
|
|||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] == '-' && argv[i][1] == 'v')
|
if (argv[i][0] == '-' && argv[i][1] == 'v')
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
else if (argv[i][0] == '-' && argv[i][1] == 'q')
|
||||||
|
quote_on_reply = 1;
|
||||||
else if (argv[i][0] == '-' && argv[i][1] == 'x')
|
else if (argv[i][0] == '-' && argv[i][1] == 'x')
|
||||||
suppress = 1;
|
suppress = 1;
|
||||||
else {
|
else {
|
||||||
@ -984,6 +1004,7 @@ int main(int argc, char *argv[])
|
|||||||
printf(" [-f <attachment>] (up to %d times)\n", MAX_ATTACHMENTS);
|
printf(" [-f <attachment>] (up to %d times)\n", 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(" [-q] Quote original text on reply\n");
|
||||||
printf(" [-e <id>] Edit existing message\n");
|
printf(" [-e <id>] Edit existing message\n");
|
||||||
printf(" [-x] Suppress email notification\n");
|
printf(" [-x] Suppress email notification\n");
|
||||||
printf(" [-n 0|1|2] Encoding: 0:ELcode,1:plain,2:HTML\n");
|
printf(" [-n 0|1|2] Encoding: 0:ELcode,1:plain,2:HTML\n");
|
||||||
@ -1089,7 +1110,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* now submit message */
|
/* now submit message */
|
||||||
submit_elog(host_name, port, subdir, logbook, password,
|
submit_elog(host_name, port, subdir, logbook, password,
|
||||||
uname, upwd, reply, edit, suppress, encoding, attr_name, attrib, n_attr, text,
|
uname, upwd, reply, quote_on_reply, edit, suppress, encoding, attr_name, attrib, n_attr, text,
|
||||||
attachment, buffer, att_size);
|
attachment, buffer, att_size);
|
||||||
|
|
||||||
for (i = 0; i < MAX_ATTACHMENTS; i++)
|
for (i = 0; i < MAX_ATTACHMENTS; i++)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user