From 7c35be965ccbafd4ebf85567e3c6e77f6dad0f6c Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 12 Sep 2011 22:08:45 +0200 Subject: [PATCH] Update to recent ObjFW changes. --- src/XMPPConnection.m | 24 +++++++++++------------ src/XMPPJID.m | 12 ++++++------ src/XMPPPLAINAuth.m | 8 ++++---- src/XMPPSCRAMAuth.m | 45 ++++++++++++++++++++++---------------------- src/XMPPSRVLookup.m | 9 ++++++--- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index bae86d2..11c1614 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -96,7 +96,7 @@ char *node; Stringprep_rc rc; - if ((rc = stringprep_profile([username_ cString], &node, + if ((rc = stringprep_profile([username_ UTF8String], &node, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self @@ -104,7 +104,7 @@ string: username_]; @try { - username = [[OFString alloc] initWithCString: node]; + username = [[OFString alloc] initWithUTF8String: node]; } @finally { free(node); } @@ -123,7 +123,7 @@ char *res; Stringprep_rc rc; - if ((rc = stringprep_profile([resource_ cString], &res, + if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa @@ -132,7 +132,7 @@ string: resource_]; @try { - resource = [[OFString alloc] initWithCString: res]; + resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } @@ -151,7 +151,7 @@ char *srv; Idna_rc rc; - if ((rc = idna_to_ascii_8z([server_ cString], + if ((rc = idna_to_ascii_8z([server_ UTF8String], &srv, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException newWithClass: isa @@ -160,7 +160,7 @@ string: server_]; @try { - server = [[OFString alloc] initWithCString: srv]; + server = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } @@ -179,7 +179,7 @@ char *srv; Stringprep_rc rc; - if ((rc = stringprep_profile([domain_ cString], &srv, + if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self @@ -187,7 +187,7 @@ string: domain_]; @try { - domain = [[OFString alloc] initWithCString: srv]; + domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } @@ -206,7 +206,7 @@ char *pass; Stringprep_rc rc; - if ((rc = stringprep_profile([password_ cString], &pass, + if ((rc = stringprep_profile([password_ UTF8String], &pass, "SASLprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: self @@ -214,7 +214,7 @@ string: password_]; @try { - password = [[OFString alloc] initWithCString: pass]; + password = [[OFString alloc] initWithUTF8String: pass]; } @finally { free(pass); } @@ -241,7 +241,7 @@ [sock connectToHost: server port: port]; else { - if ((rc = idna_to_ascii_8z([domain cString], &cDomainToASCII, + if ((rc = idna_to_ascii_8z([domain UTF8String], &cDomainToASCII, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS) @throw [XMPPIDNATranslationFailedException newWithClass: isa @@ -251,7 +251,7 @@ @try { domainToASCII = [OFString - stringWithCString: cDomainToASCII]; + stringWithUTF8String: cDomainToASCII]; } @finally { free(cDomainToASCII); } diff --git a/src/XMPPJID.m b/src/XMPPJID.m index 7fca6af..90d1d98 100644 --- a/src/XMPPJID.m +++ b/src/XMPPJID.m @@ -110,7 +110,7 @@ return; } - if ((rc = stringprep_profile([node_ cString], &nodepart, + if ((rc = stringprep_profile([node_ UTF8String], &nodepart, "Nodeprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: nil @@ -118,7 +118,7 @@ string: node_]; @try { - node = [[OFString alloc] initWithCString: nodepart]; + node = [[OFString alloc] initWithUTF8String: nodepart]; } @finally { free(nodepart); } @@ -137,7 +137,7 @@ char *srv; Stringprep_rc rc; - if ((rc = stringprep_profile([domain_ cString], &srv, + if ((rc = stringprep_profile([domain_ UTF8String], &srv, "Nameprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa connection: nil @@ -145,7 +145,7 @@ string: domain_]; @try { - domain = [[OFString alloc] initWithCString: srv]; + domain = [[OFString alloc] initWithUTF8String: srv]; } @finally { free(srv); } @@ -170,7 +170,7 @@ return; } - if ((rc = stringprep_profile([resource_ cString], &res, + if ((rc = stringprep_profile([resource_ UTF8String], &res, "Resourceprep", 0)) != STRINGPREP_OK) @throw [XMPPStringPrepFailedException newWithClass: isa @@ -179,7 +179,7 @@ string: resource_]; @try { - resource = [[OFString alloc] initWithCString: res]; + resource = [[OFString alloc] initWithUTF8String: res]; } @finally { free(res); } diff --git a/src/XMPPPLAINAuth.m b/src/XMPPPLAINAuth.m index e671ed7..2c2d987 100644 --- a/src/XMPPPLAINAuth.m +++ b/src/XMPPPLAINAuth.m @@ -56,15 +56,15 @@ [message addItem: ""]; /* authcid */ - [message addNItems: [authcid cStringLength] - fromCArray: [authcid cString]]; + [message addNItems: [authcid UTF8StringLength] + fromCArray: [authcid UTF8String]]; /* separator */ [message addItem: ""]; /* passwd */ - [message addNItems: [password cStringLength] - fromCArray: [password cString]]; + [message addNItems: [password UTF8StringLength] + fromCArray: [password UTF8String]]; return message; } diff --git a/src/XMPPSCRAMAuth.m b/src/XMPPSCRAMAuth.m index e6a3bc5..9d1b091 100644 --- a/src/XMPPSCRAMAuth.m +++ b/src/XMPPSCRAMAuth.m @@ -168,11 +168,11 @@ authcid, cNonce]; - [ret addNItems: [GS2Header cStringLength] - fromCArray: [GS2Header cString]]; + [ret addNItems: [GS2Header UTF8StringLength] + fromCArray: [GS2Header UTF8String]]; - [ret addNItems: [clientFirstMessageBare cStringLength] - fromCArray: [clientFirstMessageBare cString]]; + [ret addNItems: [clientFirstMessageBare UTF8StringLength] + fromCArray: [clientFirstMessageBare UTF8String]]; return ret; } @@ -198,9 +198,9 @@ ret = [OFDataArray dataArrayWithItemSize: 1]; authMessage = [OFDataArray dataArrayWithItemSize: 1]; - OFString *chal = [OFString stringWithCString: [challenge cArray] - length: [challenge count] * - [challenge itemSize]]; + OFString *chal = [OFString stringWithUTF8String: [challenge cArray] + length: [challenge count] * + [challenge itemSize]]; enumerator = [[chal componentsSeparatedByString: @","] objectEnumerator]; @@ -232,8 +232,8 @@ // Add c= tmpArray = [OFDataArray dataArrayWithItemSize: 1]; - [tmpArray addNItems: [GS2Header cStringLength] - fromCArray: [GS2Header cString]]; + [tmpArray addNItems: [GS2Header UTF8StringLength] + fromCArray: [GS2Header UTF8String]]; if (plusAvailable && [connection encrypted]) { OFDataArray *channelBinding = [((SSLSocket*)[connection socket]) channelBindingDataWithType: @"tls-unique"]; @@ -243,19 +243,19 @@ tmpString = [tmpArray stringByBase64Encoding]; [ret addNItems: 2 fromCArray: "c="]; - [ret addNItems: [tmpString cStringLength] - fromCArray: [tmpString cString]]; + [ret addNItems: [tmpString UTF8StringLength] + fromCArray: [tmpString UTF8String]]; // Add r= [ret addItem: ","]; [ret addNItems: 2 fromCArray: "r="]; - [ret addNItems: [sNonce cStringLength] - fromCArray: [sNonce cString]]; + [ret addNItems: [sNonce UTF8StringLength] + fromCArray: [sNonce UTF8String]]; tmpArray = [OFDataArray dataArrayWithItemSize: 1]; - [tmpArray addNItems: [password cStringLength] - fromCArray: [password cString]]; + [tmpArray addNItems: [password UTF8StringLength] + fromCArray: [password UTF8String]]; /* * IETF RFC 5802: @@ -271,8 +271,8 @@ * server-first-message + "," + * client-final-message-without-proof */ - [authMessage addNItems: [clientFirstMessageBare cStringLength] - fromCArray: [clientFirstMessageBare cString]]; + [authMessage addNItems: [clientFirstMessageBare UTF8StringLength] + fromCArray: [clientFirstMessageBare UTF8String]]; [authMessage addItem: ","]; [authMessage addNItems: [challenge count] * [challenge itemSize] fromCArray: [challenge cArray]]; @@ -344,8 +344,8 @@ [ret addNItems: 2 fromCArray: "p="]; tmpString = [tmpArray stringByBase64Encoding]; - [ret addNItems: [tmpString cStringLength] - fromCArray: [tmpString cString]]; + [ret addNItems: [tmpString UTF8StringLength] + fromCArray: [tmpString UTF8String]]; [ret retain]; [pool release]; @@ -356,9 +356,9 @@ - (void)parseServerFinalMessage: (OFDataArray*)message { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFString *mess = [OFString stringWithCString: [message cArray] - length: [message count] * - [message itemSize]]; + OFString *mess = [OFString stringWithUTF8String: [message cArray] + length: [message count] * + [message itemSize]]; OFString *value = [mess substringWithRange: of_range(2, [mess length] - 2)]; @@ -393,6 +393,7 @@ } return [OFString stringWithCString: (char*)buf + encoding: OF_STRING_ENCODING_ASCII length: 64]; } diff --git a/src/XMPPSRVLookup.m b/src/XMPPSRVLookup.m index 132b11d..df19c30 100644 --- a/src/XMPPSRVLookup.m +++ b/src/XMPPSRVLookup.m @@ -102,7 +102,9 @@ @throw [OFInitializationFailedException newWithClass: isa]; - target = [[OFString alloc] initWithCString: buffer]; + target = [[OFString alloc] + initWithCString: buffer + encoding: OF_STRING_ENCODING_NATIVE]; } @catch (id e) { [self release]; @throw e; @@ -213,8 +215,9 @@ host: domain]; answer = [self allocMemoryWithSize: of_pagesize]; - answerLen = res_nsearch(&resState, [request cString], ns_c_in, - ns_t_srv, answer, (int)of_pagesize); + answerLen = res_nsearch(&resState, [request cStringWithEncoding: + OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer, + (int)of_pagesize); if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) || (h_errno == NO_DATA)))