This patch adds a possibility to save dirlist and content of log window into file (pftpfxp-v0.11.4mew6) 1. Apply this patch and make new pftp binary wget -c http://pftpmew.tanesha.net/content/pftpfxp-v0.11.4mew6.tgz tar xvzf pftpfxp-v0.11.4mew6.tgz cd pftpfxp-v0.11.4mew6 patch -p1 < ../pftpfxp-v0.11.4mew6-ynezz.patch cd pftpfxp-mew ./configure make 2. You'll need to define two new keymaps (usually placed ~/.pftp/keymaps file): FUNCTION_SAVE_DIRLIST for key with which you'll be able to save actual dirlist FUNCTION_SAVE_LOG for key with which you'll be able to save actual server log 3. Enjoy -- ynezz at true dot cz, June 2007 diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/.pftp/keymap pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/.pftp/keymap --- pftpfxp-v0.11.4mew6/pftpfxp-mew/.pftp/keymap 2003-10-28 23:57:55.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/.pftp/keymap 2007-06-30 12:26:58.000000000 +0200 @@ -193,8 +193,8 @@ FUNCTION_CWD_DIALOG=W FUNCTION_CWD_1=w FUNCTION_CWD_ROOT=q -FUNCTION_CWD_SEC01=u,U -FUNCTION_CWD_SEC02=g,G +FUNCTION_CWD_SEC01= +FUNCTION_CWD_SEC02= FUNCTION_CWD_SEC03= FUNCTION_CWD_SEC04= FUNCTION_CWD_SEC05= @@ -235,9 +235,12 @@ FUNCTION_SWITCH_TRANSFER_MODE=Z FUNCTION_SWITCH_CHAIN_MODE=z +FUNCTION_SAVE_DIRLIST=u,U +FUNCTION_SAVE_LOG=g,G + ########################################################################## # _QUIT - if you forget to set a valid key here, you are lost ########################################################################## FUNCTION_QUIT=Q -########################################################################## \ No newline at end of file +########################################################################## diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/include/defines.h pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/include/defines.h --- pftpfxp-v0.11.4mew6/pftpfxp-mew/include/defines.h 2003-11-09 20:53:07.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/include/defines.h 2007-06-30 13:21:54.000000000 +0200 @@ -99,6 +99,8 @@ #define INPUT_DO_WIPE 105 #define INPUT_DO_UNDUPE 106 #define INPUT_DO_RENAME_CHAINED 107 +#define INPUT_DO_SAVE_DIRLIST 108 +#define INPUT_DO_SAVE_LOG 109 #define SERVER_TYPE_LOCAL 1 #define SERVER_TYPE_REMOTE 2 @@ -195,6 +197,9 @@ #define FOR_SERVER_MSG_WIPE 82 #define FOR_SERVER_MSG_UNDUPE 83 +#define FOR_SERVER_MSG_SAVE_DIRLIST 84 +#define FOR_SERVER_MSG_SAVE_LOG 85 + #define FOR_SERVER_MSG_NOT_IMPLEMENTED 999 diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/include/server.h pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/include/server.h --- pftpfxp-v0.11.4mew6/pftpfxp-mew/include/server.h 2003-11-09 00:00:00.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/include/server.h 2007-06-30 13:19:10.000000000 +0200 @@ -105,6 +105,9 @@ void StartTime(void); bool stop_transfer; CServer *destsrv; + void SaveDirList(char *to); + void SaveLog(char *to); + public: CServer(); ~CServer(); diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/src/displayhandler.cc pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/displayhandler.cc --- pftpfxp-v0.11.4mew6/pftpfxp-mew/src/displayhandler.cc 2003-11-09 20:49:37.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/displayhandler.cc 2007-06-30 13:22:04.000000000 +0200 @@ -1050,6 +1050,21 @@ break; */ + // FUNCTION_SAVE_DIRLIST + case 72: + strcpy(this->input_temp, ""); + this->internal_state = DISPLAY_STATE_INPUT; + this->internal_state_previous = INPUT_DO_SAVE_DIRLIST; + this->DialogInput("enter filename for dirlist:", this->input_temp, INPUT_TEMP_MAX, FALSE); + break; + + // FUNCTION_SAVE_LOG + case 73: + strcpy(this->input_temp, ""); + this->internal_state = DISPLAY_STATE_INPUT; + this->internal_state_previous = INPUT_DO_SAVE_LOG; + this->DialogInput("enter filename for log:", this->input_temp, INPUT_TEMP_MAX, FALSE); + break; default: if ((extended >= '1') && (extended <= '9')) { //fast server switch this->JumpSwitch(extended - '1'); @@ -1155,6 +1170,14 @@ this->PostToServers(FOR_SERVER_MSG_RENTO, this->input_temp); break; + case INPUT_DO_SAVE_DIRLIST: + this->PostToServer(FOR_SERVER_MSG_SAVE_DIRLIST, TRUE, + MSG_TYPE_INPUT); + break; + case INPUT_DO_SAVE_LOG: + this->PostToServer(FOR_SERVER_MSG_SAVE_LOG, TRUE, + MSG_TYPE_INPUT); + break; } } break; diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/src/main.cc pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/main.cc --- pftpfxp-v0.11.4mew6/pftpfxp-mew/src/main.cc 2003-11-09 21:20:00.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/main.cc 2007-06-30 12:44:28.000000000 +0200 @@ -813,6 +813,8 @@ if (strcasecmp(keychar, "FUNCTION_SCROLLFILELIST_RIGHT") == 0) return (69); if (strcasecmp(keychar, "FUNCTION_SWITCH_REVERSE_DIRSORTING") == 0) return (70); if (strcasecmp(keychar, "FUNCTION_SWITCH_REVERSE_FILESORTING") == 0) return (71); + if (strcasecmp(keychar, "FUNCTION_SAVE_DIRLIST") == 0) return (72); + if (strcasecmp(keychar, "FUNCTION_SAVE_LOG") == 0) return (73); //if (strcasecmp(keychar, "FUNCTION_CHANGE_PASSWORD") == 0) return (70); // normal keys @@ -1204,7 +1206,7 @@ puts("Display thread was Unable to init..."); exit( -1); } - sprintf(msg, "pftp %s edt %s (c) pftp_team / tanesha team", + sprintf(msg, "pftp %s edt %s (c) pftp_team / tanesha team / ynezz", PFTP_EDITION, PFTP_VERSION); display->PostStatusLine(msg, TRUE); diff -uNr pftpfxp-v0.11.4mew6/pftpfxp-mew/src/server.cc pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/server.cc --- pftpfxp-v0.11.4mew6/pftpfxp-mew/src/server.cc 2003-11-09 20:51:19.000000000 +0100 +++ pftpfxp-v0.11.4mew6-ynezz/pftpfxp-mew/src/server.cc 2007-06-30 14:31:45.000000000 +0200 @@ -871,6 +871,13 @@ case FOR_SERVER_MSG_CLOSE: this->KillMe(FALSE); break; + + case FOR_SERVER_MSG_SAVE_DIRLIST: + this->SaveDirList(param); + break; + case FOR_SERVER_MSG_SAVE_LOG: + this->SaveLog(param); + break; } } @@ -1836,6 +1843,81 @@ return (fl_start); } +void CServer::SaveDirList(char *to) { + FILELIST *fl_temp = this->actual_filelist; + FILE *file; + + file = fopen(to, "w"); + if (file == NULL) { + sprintf(this->temp_string, "[%7.7s]: can't open '%s'", this->prefs.label, to); + display->PostStatusLine(this->temp_string, FALSE); + return; + } + + while(fl_temp) { + fprintf(file, "%s\n", fl_temp->name); + fl_temp = fl_temp->next; + } + fclose(file); + + sprintf(this->temp_string, "[%7.7s]: dirlist saved to '%s'", this->prefs.label, to); + display->PostStatusLine(this->temp_string, FALSE); +} + +void CServer::SaveLog(char *to) { + int n; + char *log[LOG_LINES]; + FILE *file; + + file = fopen(to, "w"); + if (file == NULL) { + sprintf(this->temp_string, "[%7.7s]: can't open '%s'", this->prefs.label, to); + display->PostStatusLine(this->temp_string, FALSE); + return; + } + + if (this->GetMagic() != SERVER_MAGIC_START) { + // obtain log from server + this->GetTCP()->ObtainLog((log)); + // fixup lines + for (n = 0; n < LOG_LINES; n++) { + if (log[n]) { + if (strrchr(log[n], '\r')) + *(strrchr(log[n], '\r')) = '\0'; + else if (strrchr(log[n], '\n')) + *(strrchr(log[n], '\n')) = '\0'; + + fprintf(file, "%s\n", log[n]); + } + } + } else { + pthread_mutex_lock(&(localwindowloglock)); + for (n = 0; n < LOG_LINES; n++) { + if (localwindowlog[n]) { + log[n] = new(char[strlen(localwindowlog[n]) + 1]); + strcpy(log[n], localwindowlog[n]); + } else + log[n] = NULL; + } + pthread_mutex_unlock(&(localwindowloglock)); + // fixup lines + for (n = 0; n < LOG_LINES; n++) { + if (log[n]) { + if (strrchr(log[n], '\r')) + *(strrchr(log[n], '\r')) = '\0'; + else if (strrchr(log[n], '\n')) + *(strrchr(log[n], '\n')) = '\0'; + + fprintf(file, "%s\n", log[n]); + } + } + } + + sprintf(this->temp_string, "[%7.7s]: log saved to '%s'", this->prefs.label, to); + display->PostStatusLine(this->temp_string, FALSE); + fclose(file); +} + void CServer::LocalRenFrom(char *from) { strcpy(this->rename_temp, from); } @@ -5357,8 +5439,8 @@ finished = FALSE; int f, d; FILELIST **dir_list, **file_list; - dir_list = new (FILELIST *)[dir_count]; - file_list = new (FILELIST *)[file_count]; + dir_list = new FILELIST *[dir_count]; + file_list = new FILELIST *[file_count]; //make arrays for the sorting fl_temp = this->internal_filelist;