From 655a60740c5e17a06919bbb39a8181b7732a8a8b Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 21 Nov 2007 20:42:35 +0000 Subject: [PATCH] removed a few cString calls git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1551 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-ldap/NGLdap/ChangeLog | 3 +++ sope-ldap/NGLdap/NGLdapConnection.m | 30 +++++++++++++---------------- sope-ldap/NGLdap/Version | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sope-ldap/NGLdap/ChangeLog b/sope-ldap/NGLdap/ChangeLog index fa806f48..1d4898a9 100644 --- a/sope-ldap/NGLdap/ChangeLog +++ b/sope-ldap/NGLdap/ChangeLog @@ -1,5 +1,8 @@ 2007-11-21 Helge Hess + * NGLdapConnection.m: replaced some -cString calls with -UTF8String + (v4.7.34) + * NGLdapURL.m: removed local URL escaping and replaced it with NSString+misc (v4.7.33) diff --git a/sope-ldap/NGLdap/NGLdapConnection.m b/sope-ldap/NGLdap/NGLdapConnection.m index 1d0248d5..a913afb4 100644 --- a/sope-ldap/NGLdap/NGLdapConnection.m +++ b/sope-ldap/NGLdap/NGLdapConnection.m @@ -93,7 +93,7 @@ static void freeMods(LDAPMod **mods) { self->handle = NULL; } - self->handle = ldap_init((char *)[self->hostName cString], self->port); + self->handle = ldap_init((char *)[self->hostName UTF8String], self->port); if (self->handle == NULL) return NO; @@ -259,7 +259,7 @@ static void freeMods(LDAPMod **mods) { else /* unknown method */ return NO; - + l = (char *)[_login UTF8String]; p = LDAPUseLatin1Creds ? (char *)[_cred cString] @@ -331,11 +331,11 @@ static void freeMods(LDAPMod **mods) { } else attrs = NULL; - + if (LDAPDebugEnabled) { - printf("%s: search with at base %s filter %s for attrs %s\n", - __PRETTY_FUNCTION__, [_base cString], [filter cString], - [[_attributes description] cString]); + NSLog(@"%s: search with at base %s filter %s for attrs %s\n", + __PRETTY_FUNCTION__, _base, filter, + _attributes); } /* apply limits */ @@ -557,10 +557,8 @@ static void freeMods(LDAPMod **mods) { values[j] = bv; } values[valCount] = NULL; - - /* TODO: use UTF-8, UNICODE */ - attrName = malloc([key cStringLength] + 1); - [key getCString:attrName]; + + attrName = strdup([key UTF8String]); attrBuf[i].mod_op = LDAP_MOD_BVALUES; attrBuf[i].mod_type = attrName; @@ -684,7 +682,6 @@ static void freeMods(LDAPMod **mods) { NGLdapModification *mod; NGLdapAttribute *attr; NSString *attrName; - unsigned attrLen; unsigned valCount; NSEnumerator *e; NSData *value; @@ -710,11 +707,9 @@ static void freeMods(LDAPMod **mods) { attr = [mod attribute]; attrName = [attr attributeName]; /* TODO: use UTF-8, UNICODE */ - attrLen = [attrName cStringLength]; - - modBuf[i].mod_type = malloc(attrLen + 1); - [attrName getCString:modBuf[i].mod_type]; - + + modBuf[i].mod_type = strdup(modBuf[i].mod_type); + valCount = [attr count]; values = calloc(valCount + 1, sizeof(struct berval *)); @@ -971,9 +966,10 @@ static void freeMods(LDAPMod **mods) { strDN = [[[NSString alloc] initWithUTF8String:dn] autorelease]; } NS_HANDLER { + // Note: this is not NSLog because of GCC crashers with exception handlers fprintf(stderr, "Got exception %s while NSUTF8StringEncoding, " "use defaultCStringEncoding", - [[localException description] cString]); + [[localException description] UTF8String]); strDN = nil; } NS_ENDHANDLER; diff --git a/sope-ldap/NGLdap/Version b/sope-ldap/NGLdap/Version index 5fd280f0..74309eac 100644 --- a/sope-ldap/NGLdap/Version +++ b/sope-ldap/NGLdap/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=4 MINOR_VERSION=7 -SUBMINOR_VERSION:=33 +SUBMINOR_VERSION:=34 -- 2.39.5