mirror of
https://github.com/proxytunnel/proxytunnel.git
synced 2026-07-17 16:34:53 +00:00
Correct way to temporarily chop linebreak and generate debug output.
This commit is contained in:
parent
b8c2189ff3
commit
eb92cf8f11
1 changed files with 14 additions and 5 deletions
19
io.c
19
io.c
|
|
@ -56,12 +56,21 @@ int readline(PTSTREAM *pts) {
|
|||
*p = 0;
|
||||
|
||||
if( args_info.verbose_flag ) {
|
||||
/* Copy line of data into dstr without trailing newline */
|
||||
int len = strlen(buf);
|
||||
buf[len - 2] = 0;
|
||||
if (strcmp(buf, ""))
|
||||
/* Move i to end of line, ignoring line break ('\n' or '\r\n') */
|
||||
if (i > 0)
|
||||
if (buf[i-1] == '\n') {
|
||||
i--;
|
||||
if (i > 0)
|
||||
if (buf[i-1] == '\r')
|
||||
i--;
|
||||
}
|
||||
/* Output non-empty line, temporarily choping line break */
|
||||
if (i > 0) {
|
||||
c = buf[i];
|
||||
buf[i] = '\0';
|
||||
message( " <- %s\n", buf );
|
||||
buf[len - 2] = '\r';
|
||||
buf[i] = c;
|
||||
}
|
||||
}
|
||||
return strlen( buf );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue