mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
implement support for multiline responses
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28251 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d8ec9172f6
commit
d79eb3cab4
2 changed files with 42 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSFTPURLHandle.m: Implement full support for multiline
|
||||
responses. Fix for bug #26348
|
||||
|
||||
2009-04-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSTimeZone.h:
|
||||
|
|
|
@ -485,6 +485,7 @@ NSString * const GSTelnetTextKey = @"GSTelnetTextKey";
|
|||
NSFileHandle *dHandle;
|
||||
NSURL *url;
|
||||
NSData *wData;
|
||||
NSString *term;
|
||||
enum {
|
||||
idle,
|
||||
cConnect, // Establishing control connection
|
||||
|
@ -553,6 +554,7 @@ static NSLock *urlLock = nil;
|
|||
}
|
||||
RELEASE(url);
|
||||
RELEASE(wData);
|
||||
RELEASE(term);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -598,14 +600,46 @@ static NSLock *urlLock = nil;
|
|||
|
||||
text = [info objectForKey: GSTelnetTextKey];
|
||||
// NSLog(@"Ctl: %@", text);
|
||||
/*
|
||||
* Find first reply line which is not a continuation of another.
|
||||
/* Find first reply line which is not a continuation of another.
|
||||
*/
|
||||
enumerator = [text objectEnumerator];
|
||||
while ((line = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([line length] > 4 && [line characterAtIndex: 3] != '-')
|
||||
if (term == nil)
|
||||
{
|
||||
if ([line length] > 4)
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
buf[0] = (char)[line characterAtIndex: 0];
|
||||
buf[1] = (char)[line characterAtIndex: 1];
|
||||
buf[2] = (char)[line characterAtIndex: 2];
|
||||
buf[3] = (char)[line characterAtIndex: 3];
|
||||
if (isdigit(buf[0]) && isdigit(buf[1]) && isdigit(buf[2]))
|
||||
{
|
||||
if (buf[3] == '-')
|
||||
{
|
||||
/* Got start of a multiline block ...
|
||||
* set the terminator we need to look for.
|
||||
*/
|
||||
buf[3] = ' ';
|
||||
term = [[NSString alloc]
|
||||
initWithCString: buf length: 4];
|
||||
}
|
||||
else if (buf[3] == ' ')
|
||||
{
|
||||
/* Found single line response.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([line hasPrefix: term] == YES)
|
||||
{
|
||||
/* Found end of a multiline response.
|
||||
*/
|
||||
DESTROY(term);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue