1001 char str[1000], uname[80], upwd[80];
1002 char host_name[256], logbook[32], textfile[256], subdir[256];
1005 INT i,
n, fh, n_att, n_attr, port, reply, quote_on_reply, edit, download, encoding, suppress, size, ssl,
1009 text[0] = textfile[0] = uname[0] = upwd[0] = suppress = quote_on_reply = 0;
1010 host_name[0] = logbook[0] = subdir[0] = 0;
1011 n_att = n_attr = reply = edit = download = encoding = 0;
1017 attachment[i][0] = 0;
1023 for (i = 1; i < argc; i++) {
1024 if (argv[i][0] ==
'-' && argv[i][1] ==
'v')
1026 else if (argv[i][0] ==
'-' && argv[i][1] ==
's')
1028 else if (argv[i][0] ==
'-' && argv[i][1] ==
'q')
1030 else if (argv[i][0] ==
'-' && argv[i][1] ==
'x')
1033 if (argv[i][0] ==
'-') {
1034 if (i + 1 >= argc || argv[i + 1][0] ==
'-')
1036 if (argv[i][1] ==
'h')
1037 strcpy(host_name, argv[++i]);
1038 else if (argv[i][1] ==
'p')
1039 port = atoi(argv[++i]);
1040 else if (argv[i][1] ==
'l')
1041 strcpy(logbook, argv[++i]);
1042 else if (argv[i][1] ==
'd')
1043 strcpy(subdir, argv[++i]);
1044 else if (argv[i][1] ==
'u') {
1045 strcpy(uname, argv[++i]);
1046 strcpy(upwd, argv[++i]);
1047 }
else if (argv[i][1] ==
'a') {
1048 strcpy(str, argv[++i]);
1049 if (strchr(str,
'=')) {
1050 strcpy(attrib[n_attr], strchr(str,
'=') + 1);
1051 *strchr(str,
'=') = 0;
1052 strcpy(attr_name[n_attr], str);
1055 printf(
"Error: Attributes must be supplied in the form \"-a <attribute>=<value>\".\n");
1058 }
else if (argv[i][1] ==
'f')
1059 strcpy(attachment[n_att++], argv[++i]);
1060 else if (argv[i][1] ==
'r')
1061 reply = atoi(argv[++i]);
1062 else if (argv[i][1] ==
'e')
1063 edit = atoi(argv[++i]);
1064 else if (argv[i][1] ==
'w') {
1065 if (argv[i+1][0] ==
'l')
1068 download = atoi(argv[++i]);
1069 }
else if (argv[i][1] ==
'n')
1070 encoding = atoi(argv[++i]);
1071 else if (argv[i][1] ==
'm') {
1072 strcpy(textfile, argv[++i]);
1078 printf(
"\nusage: elog\n");
1079 printf(
"elog -h <hostname> [-p port] [-d subdir]\n");
1080 printf(
" Location where elogd is running\n");
1081 printf(
" -l logbook/experiment Name of logbook or experiment\n");
1082 printf(
" -s Use SSL for communication\n");
1083 printf(
" [-v] For verbose output\n");
1084 printf(
" [-u username password] Wser name and password\n");
1085 printf(
" [-f <attachment>] (up to %d attachments)\n",
MAX_ATTACHMENTS);
1086 printf(
" -a <attribute>=<value> (up to %d attributes)\n",
MAX_N_ATTR);
1087 printf(
" [-r <id>] Reply to existing message\n");
1088 printf(
" [-q] Quote original text on reply\n");
1089 printf(
" [-e <id>] Edit existing message\n");
1090 printf(
" [-w <id>|last] Download existing message (last message)\n");
1091 printf(
" [-x] Suppress email notification\n");
1092 printf(
" [-n 0|1|2] Encoding: 0:ELcode,1:plain,2:HTML\n");
1093 printf(
" -m <textfile>] | <text>\n");
1094 printf(
"\nArguments with blanks must be enclosed in quotes\n");
1095 printf(
"The elog message can either be submitted on the command line, piped in like\n");
1096 printf(
"\"cat text | elog -h ... -l ... -a ...\" or in a file with the -m flag.\n");
1097 printf(
"Multiple attributes and attachments can be supplied\n");
1101 strcpy(
text, argv[i]);
1110 printf(
"SLL support not compiled into this program\n");
1115 #if defined( _MSC_VER )
1120 if (WSAStartup(MAKEWORD(1, 1), &WSAData) != 0)
1125 if (host_name[0] == 0) {
1126 printf(
"Please specify hostname.\n");
1130 if (logbook[0] == 0) {
1131 printf(
"Please specify logbook with the \"-l\" flag.\n");
1135 if (n_attr == 0 && !edit && !reply && !download) {
1136 printf(
"Please specify attribute(s) with the \"-a\" flag.\n");
1145 printf(
"Message file \"%s\" does not exist.\n", textfile);
1149 size = (
INT) lseek(fh, 0, SEEK_END);
1150 lseek(fh, 0, SEEK_SET);
1152 if (size > (
INT) (
sizeof(
text) - 1)) {
1153 printf(
"Message file \"%s\" is too long (%zd bytes max).\n", textfile,
sizeof(
text));
1160 printf(
"Cannot fully read message from file %s.\n", textfile);
1167 if (text_flag == 0 && !edit && !download) {
1189 if (!attachment[i][0])
1194 printf(
"Attachment file \"%s\" does not exist.\n", attachment[i]);
1198 att_size[i] = lseek(fh, 0, SEEK_END);
1199 lseek(fh, 0, SEEK_SET);
1201 buffer[i] = (
char *)malloc(att_size[i] + 1);
1203 n =
read(fh, buffer[i], att_size[i]);
1204 if (
n < att_size[i]) {
1205 printf(
"Cannot fully read attachment file \"%s\".\n", attachment[i]);
1214 submit_elog(host_name, port, ssl, subdir, logbook,
1215 uname, upwd, reply, quote_on_reply, edit, download, suppress, encoding, attr_name, attrib, n_attr,
text,
1216 attachment, buffer, att_size);
static const char ELOGID[]
void convert_crlf(char *buffer, int bufsize)
const char * git_revision()
void add_crlf(char *buffer, int bufsize)
INT submit_elog(char *host, int port, int ssl, char *subdir, char *experiment, char *uname, char *upwd, int reply, int quote_on_reply, int edit, int download, int suppress, int encoding, char attrib_name[MAX_N_ATTR][NAME_LENGTH], char attrib[MAX_N_ATTR][NAME_LENGTH], int n_attr, char *text, char afilename[MAX_ATTACHMENTS][256], char *buffer[MAX_ATTACHMENTS], INT buffer_size[MAX_ATTACHMENTS])
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter=' ')
Read test summary.
void close(std::istream *pf)
Close file.
T * open(const std::string &file_name)
Open file.