Added \n to error display during cloning

SVN revision: 1007
This commit is contained in:
Stefan Ritt 2004-08-04 07:47:56 +00:00
parent 325223da37
commit 68e23de922

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.423 2004/08/04 07:47:56 midas
Added \n to error display during cloning
Revision 1.422 2004/08/03 14:16:11 midas Revision 1.422 2004/08/03 14:16:11 midas
Fixed problem with {..} in attributes Fixed problem with {..} in attributes
@ -538,7 +541,7 @@ char http_host[256];
#define TEXT_SIZE 250000 #define TEXT_SIZE 250000
#define MAX_PATH_LENGTH 256 #define MAX_PATH_LENGTH 256
#define MAX_CONTENT_LENGTH 10000000 #define MAX_CONTENT_LENGTH 10*1024*1024
char _param[MAX_PARAM][NAME_LENGTH]; char _param[MAX_PARAM][NAME_LENGTH];
char _value[MAX_PARAM][NAME_LENGTH]; char _value[MAX_PARAM][NAME_LENGTH];
@ -7944,7 +7947,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
loc("Submit as HTML text")); loc("Submit as HTML text"));
else else
rsprintf("<input type=checkbox name=html value=1>%s\n", rsprintf("<input type=checkbox name=html value=1>%s\n",
loc("Submit as HTML text")); \ loc("Submit as HTML text"));
} else if (atoi(str) == 3) { } else if (atoi(str) == 3) {
rsprintf("<input type=hidden name=html value=1>\n"); rsprintf("<input type=hidden name=html value=1>\n");
} }
@ -11423,11 +11426,12 @@ void receive_config(LOGBOOK * lbs, char *server, char *error_str)
if (verbose) if (verbose)
puts(buffer); puts(buffer);
strlcpy(str, p+10, 10); strlcpy(str, p + 10, 10);
if (strchr(str, '\r')) if (strchr(str, '\r'))
*strchr(str, '\r') = 0; *strchr(str, '\r') = 0;
sprintf(error_str, "Incorrect remote ELOG server version %s, must be 2.5.4 or later", str); sprintf(error_str,
"Incorrect remote ELOG server version %s, must be 2.5.4 or later", str);
free(buffer); free(buffer);
return; return;
} }
@ -11590,7 +11594,7 @@ int adjust_config(char *url)
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
void receive_pwdfile(LOGBOOK *lbs, char *server, char *error_str) void receive_pwdfile(LOGBOOK * lbs, char *server, char *error_str)
{ {
char str[256], pwd[256], url[256], *buffer, *p; char str[256], pwd[256], url[256], *buffer, *p;
int i, status, version, fh; int i, status, version, fh;
@ -11618,11 +11622,12 @@ void receive_pwdfile(LOGBOOK *lbs, char *server, char *error_str)
} }
version = atoi(p + 10) * 100 + atoi(p + 12) * 10 + atoi(p + 14); version = atoi(p + 10) * 100 + atoi(p + 12) * 10 + atoi(p + 14);
if (version < 254) { if (version < 254) {
strlcpy(str, p+10, 10); strlcpy(str, p + 10, 10);
if (strchr(str, '\r')) if (strchr(str, '\r'))
*strchr(str, '\r') = 0; *strchr(str, '\r') = 0;
sprintf(error_str, "Incorrect remote ELOG server version %s, must be 2.5.4 or later", str); sprintf(error_str,
"Incorrect remote ELOG server version %s, must be 2.5.4 or later", str);
free(buffer); free(buffer);
return; return;
} }
@ -11668,7 +11673,8 @@ void receive_pwdfile(LOGBOOK *lbs, char *server, char *error_str)
eprintf("\nInvalid username or password."); eprintf("\nInvalid username or password.");
if (strstr(p, loc("Please login")) == NULL && strstr(p, "GetPwdFile")) if (strstr(p, loc("Please login")) == NULL && strstr(p, "GetPwdFile"))
eprintf("\nUser \"%s\" has no admin rights on remote server.", getparam("unm")); eprintf("\nUser \"%s\" has no admin rights on remote server.",
getparam("unm"));
/* ask for username and password */ /* ask for username and password */
eprintf("\nPlease enter admin username to access\n%s: ", url); eprintf("\nPlease enter admin username to access\n%s: ", url);
@ -11698,7 +11704,6 @@ void receive_pwdfile(LOGBOOK *lbs, char *server, char *error_str)
strcat(error_str, strerror(errno)); strcat(error_str, strerror(errno));
return; return;
} }
#ifdef OS_UNIX #ifdef OS_UNIX
/* under unix, convert CRLF to CR */ /* under unix, convert CRLF to CR */
remove_crlf(buffer); remove_crlf(buffer);
@ -12104,12 +12109,15 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
/* not that submit_message() may have changed attr_list !!! */ /* not that submit_message() may have changed attr_list !!! */
if (error_str[0]) if (error_str[0])
sprintf(str, "%s: %s", loc("Error sending local entry"), error_str); sprintf(str, "%s: %s", loc("Error sending local entry"),
error_str);
else else
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); sprintf(str, "ID%d:\t%s", message_id,
loc("Local entry submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); sprintf(str, "ID%d:\t%s", message_id,
loc("Local entry should be submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12159,7 +12167,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry should be received")); sprintf(str, "ID%d:\t%s", message_id,
loc("Remote entry should be received"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12244,10 +12253,12 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
sprintf(str, "%s: %s", loc("Error sending local message"), sprintf(str, "%s: %s", loc("Error sending local message"),
error_str); error_str);
else else
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); sprintf(str, "ID%d:\t%s", message_id,
loc("Local entry submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); sprintf(str, "ID%d:\t%s", message_id,
loc("Local entry should be submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12267,7 +12278,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
sprintf(loc_ref, "<a href=\"../%s/%d\">%s</a>", lbs->name_enc, sprintf(loc_ref, "<a href=\"../%s/%d\">%s</a>", lbs->name_enc,
message_id, loc("local")); message_id, loc("local"));
else else
sprintf(loc_ref, "<a href=\"%d\">%s</a>", message_id, loc("Local entry")); sprintf(loc_ref, "<a href=\"%d\">%s</a>", message_id,
loc("Local entry"));
sprintf(str, loc("%s should be deleted"), loc_ref); sprintf(str, loc("%s should be deleted"), loc_ref);
rsprintf("ID%d:\t%s\n", message_id, str); rsprintf("ID%d:\t%s\n", message_id, str);
@ -12290,7 +12302,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
/* message got deleted from local message list, so redo current index */ /* message got deleted from local message list, so redo current index */
i_msg--; i_msg--;
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted locally")); sprintf(str, "ID%d:\t%s", message_id,
loc("Entry should be deleted locally"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12332,7 +12345,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted")); sprintf(str, "ID%d:\t%s", message_id, loc("Local entry submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Local entry should be submitted")); sprintf(str, "ID%d:\t%s", message_id,
loc("Local entry should be submitted"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
} }
@ -12382,8 +12396,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
i_msg--; i_msg--;
} else { } else {
sprintf(str, "ID%d:\t", message_id); sprintf(str, "ID%d:\t", message_id);
sprintf(str + strlen(str), loc("Local entry ID should be changed to %d"), sprintf(str + strlen(str),
max_id + 1); loc("Local entry ID should be changed to %d"), max_id + 1);
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
} }
@ -12438,11 +12452,13 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
} else if (mode == SYNC_CLONE) { } else if (mode == SYNC_CLONE) {
eprintf("%s\n", loc("Remote entry received")); eprintf("%s\n", loc("Remote entry received"));
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry received")); sprintf(str, "ID%d:\t%s", message_id,
loc("Remote entry received"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry should be received")); sprintf(str, "ID%d:\t%s", message_id,
loc("Remote entry should be received"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12473,7 +12489,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
rsprintf("%s\n", loc("Remote entry received")); rsprintf("%s\n", loc("Remote entry received"));
} }
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Remote entry should be received")); sprintf(str, "ID%d:\t%s", message_id,
loc("Remote entry should be received"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12524,7 +12541,8 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
free(buffer); free(buffer);
} else { } else {
sprintf(str, "ID%d:\t%s", message_id, loc("Entry should be deleted remotely")); sprintf(str, "ID%d:\t%s", message_id,
loc("Entry should be deleted remotely"));
mprint(lbs, mode, str); mprint(lbs, mode, str);
} }
@ -12573,12 +12591,15 @@ void synchronize_logbook(LOGBOOK * lbs, int mode, BOOL sync_all)
if (mode == SYNC_HTML && n_delete) { if (mode == SYNC_HTML && n_delete) {
if (getcfg_topgroup()) if (getcfg_topgroup())
rsprintf("<br><b><a href=\"../%s/?cmd=Synchronize&confirm=1\">", lbs->name_enc); rsprintf("<br><b><a href=\"../%s/?cmd=Synchronize&confirm=1\">",
lbs->name_enc);
else { else {
if (sync_all) if (sync_all)
rsprintf("<br><b><a href=\"%s/?cmd=Synchronize&confirm=1\">", lbs->name_enc); rsprintf("<br><b><a href=\"%s/?cmd=Synchronize&confirm=1\">",
lbs->name_enc);
else else
rsprintf("<br><b><a href=\"../%s/?cmd=Synchronize&confirm=1\">", lbs->name_enc); rsprintf("<br><b><a href=\"../%s/?cmd=Synchronize&confirm=1\">",
lbs->name_enc);
} }
if (n_delete > 1) if (n_delete > 1)
@ -19394,7 +19415,6 @@ void server_loop(int tcp_port)
eprintf("Resource dir : %s\n", resource_dir[0] ? resource_dir : "current dir"); eprintf("Resource dir : %s\n", resource_dir[0] ? resource_dir : "current dir");
eprintf("Logbook dir : %s\n", logbook_dir[0] ? logbook_dir : "current dir"); eprintf("Logbook dir : %s\n", logbook_dir[0] ? logbook_dir : "current dir");
} }
#ifdef OS_UNIX #ifdef OS_UNIX
/* create PID file if given as command line parameter or if running under root */ /* create PID file if given as command line parameter or if running under root */
@ -20918,7 +20938,7 @@ int main(int argc, char *argv[])
/* contact remote server */ /* contact remote server */
receive_config(NULL, clone_url, error_str); receive_config(NULL, clone_url, error_str);
if (error_str[0]) { if (error_str[0]) {
eprintf(error_str); eputs(error_str);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else { } else {
printf("\nRemote configuration successfully received.\n\n"); printf("\nRemote configuration successfully received.\n\n");
@ -20981,7 +21001,8 @@ int main(int argc, char *argv[])
#endif #endif
eprintf("Logbook directory \"%s\" successfully created.\n", logbook_dir); eprintf("Logbook directory \"%s\" successfully created.\n", logbook_dir);
else { else {
eprintf("Cannot create logbook directory \"%s\":%s.\n", logbook_dir, strerror(errno)); eprintf("Cannot create logbook directory \"%s\":%s.\n", logbook_dir,
strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -21012,7 +21033,7 @@ int main(int argc, char *argv[])
synchronize(NULL, SYNC_CLONE); synchronize(NULL, SYNC_CLONE);
/* check for retrieving password files */ /* check for retrieving password files */
for (i = n = 0; lb_list[i].name[0] ; i++) for (i = n = 0; lb_list[i].name[0]; i++)
if (getcfg(lb_list[i].name, "Password file", str, sizeof(str))) if (getcfg(lb_list[i].name, "Password file", str, sizeof(str)))
n++; n++;
@ -21020,11 +21041,11 @@ int main(int argc, char *argv[])
eprintf("\nRetrieve remote password files? [y]/n: "); eprintf("\nRetrieve remote password files? [y]/n: ");
fgets(str, sizeof(str), stdin); fgets(str, sizeof(str), stdin);
if (str[0] != 'n' && str[0] != 'N') { if (str[0] != 'n' && str[0] != 'N') {
for (i = n = 0; lb_list[i].name[0] ; i++) for (i = n = 0; lb_list[i].name[0]; i++)
if (getcfg(lb_list[i].name, "Password file", file_name, sizeof(file_name))) { if (getcfg(lb_list[i].name, "Password file", file_name, sizeof(file_name))) {
/* check if this file has not already been retrieved */ /* check if this file has not already been retrieved */
for (j=0 ; j<i; j++) for (j = 0; j < i; j++)
if (getcfg(lb_list[j].name, "Password file", str, sizeof(str)) && if (getcfg(lb_list[j].name, "Password file", str, sizeof(str)) &&
stricmp(file_name, str) == 0) stricmp(file_name, str) == 0)
break; break;
@ -21032,7 +21053,7 @@ int main(int argc, char *argv[])
if (j == i) { if (j == i) {
receive_pwdfile(&lb_list[i], clone_url, error_str); receive_pwdfile(&lb_list[i], clone_url, error_str);
if (error_str[0]) { if (error_str[0]) {
eprintf(error_str); eputs(error_str);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else } else
eprintf("File \"%s\" received successfully.\n", file_name); eprintf("File \"%s\" received successfully.\n", file_name);