ObjIRC  Check-in [88eea97f3d]

Overview
Comment:Adjust to recent ObjFW changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 88eea97f3d869fb6bfd245c629c1871a30695be78d65754ce1679819a3b178fa
User & Date: js on 2011-09-12 23:17:01
Other Links: manifest | tags
Context
2011-09-14
23:13
Add ObjIRC.h. check-in: 3934bad84c user: js tags: trunk
2011-09-12
23:17
Adjust to recent ObjFW changes. check-in: 88eea97f3d user: js tags: trunk
2011-09-10
23:21
Add support for changing the nickname. check-in: 117cdc960f user: js tags: trunk
Changes

Modified src/IRCUser.h from [b29fb96a4b] to [353088c1af].

27
28
29
30
31
32
33
34
35
36
	OFString *nickname;
	OFString *username;
	OFString *hostname;
}

@property (copy, readonly) OFString *nickname, *username, *hostname;

+ IRCUserWithString: (OFString*)str;
- initWithString: (OFString*)str;
@end







|
|

27
28
29
30
31
32
33
34
35
36
	OFString *nickname;
	OFString *username;
	OFString *hostname;
}

@property (copy, readonly) OFString *nickname, *username, *hostname;

+ IRCUserWithString: (OFString*)string;
- initWithString: (OFString*)string;
@end

Modified src/IRCUser.m from [9f03255a1e] to [a1343091ca].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import <ObjFW/OFInvalidFormatException.h>
#import <ObjFW/OFOutOfMemoryException.h>

#import "IRCUser.h"

@implementation IRCUser
@synthesize username, nickname, hostname;
+ IRCUserWithString: (OFString*)str
{
	return [[[self alloc] initWithString: str] autorelease];
}

- initWithString: (OFString*)str
{
	char *tmp2 = NULL;

	self = [super init];

	@try {
		char *tmp;

		if ((tmp2 = strdup(str.cString)) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: str.cStringLength];

		if ((tmp = strchr(tmp2, '@')) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];

		*tmp = '\0';
		hostname = [[OFString alloc] initWithCString: tmp + 1];

		if ((tmp = strchr(tmp2, '!')) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];

		*tmp = '\0';
		username = [[OFString alloc] initWithCString: tmp + 1];

		nickname = [[OFString alloc] initWithCString: tmp2];
	} @catch (id e) {
		[self release];
		@throw e;
	} @finally {
		if (tmp2 != NULL)
			free(tmp2);
	}







|

|


|








|


|





|





|

|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import <ObjFW/OFInvalidFormatException.h>
#import <ObjFW/OFOutOfMemoryException.h>

#import "IRCUser.h"

@implementation IRCUser
@synthesize username, nickname, hostname;
+ IRCUserWithString: (OFString*)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

- initWithString: (OFString*)string
{
	char *tmp2 = NULL;

	self = [super init];

	@try {
		char *tmp;

		if ((tmp2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: [string UTF8StringLength]];

		if ((tmp = strchr(tmp2, '@')) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];

		*tmp = '\0';
		hostname = [[OFString alloc] initWithUTF8String: tmp + 1];

		if ((tmp = strchr(tmp2, '!')) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];

		*tmp = '\0';
		username = [[OFString alloc] initWithUTF8String: tmp + 1];

		nickname = [[OFString alloc] initWithUTF8String: tmp2];
	} @catch (id e) {
		[self release];
		@throw e;
	} @finally {
		if (tmp2 != NULL)
			free(tmp2);
	}