Skip to content

Commit

Permalink
#promptend fixed
Browse files Browse the repository at this point in the history
Теперь #promptend работает корректно - проверил в Аладоне и Былинах
  • Loading branch information
Rrahh committed Jul 15, 2017
1 parent 1153cbf commit c2cf4f7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sources/ttcoreex/TINTINX.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


#define END_OF_PROMPT_MARK L'\x01'
#define END_OF_PROMPT_DETECTOR L'\x03'
#define USER_INPUT_MARK L'\x01'
#define TINTIN_OUTPUT_MARK L'\x02'
#define ESC_SEQUENCE_MARK L'\x1B'
Expand Down Expand Up @@ -67,6 +68,7 @@ extern void DLLEXPORT reopen_bcast_socket();
extern wchar_t DLLEXPORT strPromptEndSequence[BUFFER_SIZE];
extern wchar_t DLLEXPORT strPromptEndReplace[BUFFER_SIZE];
extern BOOL DLLEXPORT bPromptEndEnabled;
extern int DLLEXPORT PromptDropCount;
//vls-begin// base dir
extern wchar_t DLLEXPORT szBASE_DIR[MAX_PATH];
extern wchar_t DLLEXPORT szSETTINGS_DIR[MAX_PATH];
Expand Down
5 changes: 3 additions & 2 deletions sources/ttcoreex/telnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ unsigned char strPromptEndSeqBytes[BUFFER_SIZE];
unsigned char strPromptEndReplBytes[BUFFER_SIZE];

BOOL DLLEXPORT bPromptEndEnabled = FALSE;
int PromptDropCount;
int DLLEXPORT PromptDropCount;

unsigned char State;
unsigned char CurrentSubnegotiation;
Expand Down Expand Up @@ -1029,7 +1029,8 @@ void do_telnet_protecol(const char* input, int length, int *used, char* output,
if (!strPromptEndSeqBytes[PromptEndIndex]) { //match!
for (char *copy = (char*)strPromptEndReplBytes; *copy; )
output[(*generated)++] = *(copy++);
output[(*generated)++] = END_OF_PROMPT_MARK;
//output[(*generated)++] = END_OF_PROMPT_MARK;
output[(*generated)++] = END_OF_PROMPT_DETECTOR;
PromptEndIndex = 0;
}
continue;
Expand Down
27 changes: 24 additions & 3 deletions sources/ttcoreex/ttcoreex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ wchar_t verbatim_char=DEFAULT_VERBATIM_CHAR;
int path_length;
int old_more_coming,more_coming;
wchar_t last_line[BUFFER_SIZE];
int lastprompt;
ofstream hLogFile;
UINT LogFileCodePage;
ofstream hOutputLogFile[MAX_OUTPUT];
Expand Down Expand Up @@ -1076,15 +1077,29 @@ static void process_incoming(wchar_t* buffer, BOOL FromServer)
continue;
}

if ( *cpsource == END_OF_PROMPT_DETECTOR) {
if (lastprompt < PromptDropCount)
lastprompt++;
else
lastprompt = PromptDropCount;
cpsource++;
continue;
}

if(*cpsource == L'\n' || *cpsource == END_OF_PROMPT_MARK) {
*cpdest = L'\0';

if (lastprompt) {
PromptDropCount = PromptDropCount - lastprompt;
lastprompt = 0;
}
else {
if ( !bLogAsUserSeen ) {
wcscpy(line_to_log, linebuffer);
}
if ( bProcess ) {
do_one_line(linebuffer);
if (*cpsource == END_OF_PROMPT_MARK)
if (*cpsource == END_OF_PROMPT_MARK || lastprompt)
do_multiline();
}
if ( bLogAsUserSeen ) {
Expand All @@ -1108,6 +1123,7 @@ static void process_incoming(wchar_t* buffer, BOOL FromServer)
linebuffer[n] = L'\0';
DirectOutputFunction(linebuffer, 0);// out to main window
}
}
last_line[0] = L'\0';

cpsource++;
Expand All @@ -1120,8 +1136,13 @@ static void process_incoming(wchar_t* buffer, BOOL FromServer)
*cpdest=L'\0';

if (wcscmp(linebuffer, L".")) {
wcscpy(last_line , linebuffer);
DirectOutputFunction(linebuffer, 0);// out to main window
if (lastprompt) {
PromptDropCount = PromptDropCount - lastprompt;
lastprompt = 0;
} else {
wcscpy(last_line , linebuffer);
DirectOutputFunction(linebuffer, 0);// out to main window
}
lastRecvd = GetTickCount();
} else {
last_line[0] = L'\0';
Expand Down

0 comments on commit c2cf4f7

Please sign in to comment.