+Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m
+===================================================================
+--- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (révision 1546)
++++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (copie de travail)
+@@ -713,6 +713,39 @@
+ return ms;
+ }
+
++/* GCSEOAdaptorChannel protocol */
++static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \
++ @" c_name VARCHAR (256) NOT NULL,\n"
++ @" c_content VARCHAR (100000) NOT NULL,\n"
++ @" c_creationdate INT4 NOT NULL,\n"
++ @" c_lastmodified INT4 NOT NULL,\n"
++ @" c_version INT4 NOT NULL,\n"
++ @" c_deleted INT4 NULL\n"
++ @")");
++static NSString *sqlFolderACLFormat = (@"CREATE TABLE %@ (\n" \
++ @" c_uid VARCHAR (256) NOT NULL,\n"
++ @" c_object VARCHAR (256) NOT NULL,\n"
++ @" c_role VARCHAR (80) NOT NULL\n"
++ @")");
++
++- (NSException *) createGCSFolderTableWithName: (NSString *) tableName
++{
++ NSString *sql;
++
++ sql = [NSString stringWithFormat: sqlFolderFormat, tableName];
++
++ return [self evaluateExpressionX: sql];
++}
++
++- (NSException *) createGCSFolderACLTableWithName: (NSString *) tableName
++{
++ NSString *sql;
++
++ sql = [NSString stringWithFormat: sqlFolderACLFormat, tableName];
++
++ return [self evaluateExpressionX: sql];
++}
++
+ @end /* PostgreSQL72Channel */
+
+ @implementation PostgreSQL72Channel(PrimaryKeyGeneration)
+Index: sope-gdl1/Oracle8/GNUmakefile
+===================================================================
+--- sope-gdl1/Oracle8/GNUmakefile (révision 1546)
++++ sope-gdl1/Oracle8/GNUmakefile (copie de travail)
+@@ -28,15 +28,23 @@
+ SOPE_ROOT=../..
+ ORACLE_VERSION=10.2.0.3
+ #ORACLE_VERSION=11.1.0.1
+-ADDITIONAL_INCLUDE_DIRS += -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
++ADDITIONAL_INCLUDE_DIRS += -I../../sope-core -I../../sope-core/NGExtensions -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
+
++local_arch = $(subst 64,,$(shell uname -m))
++
++ifeq ($(local_arch),ppc)
++PPC_LDFLAGS=-L/opt/ibmcmp/lib -libmc++
++else
++PPC_LDFLAGS=
++endif
++
+ ifneq ($(frameworks),yes)
+-Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
+-otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
++common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -L../GDLAccess/obj -lGDLAccess -L../../sope-core/EOControl/obj -lEOControl $(PPC_LDFLAGS)
+ else
+-Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
+-otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
++common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl $(PPC_LDFLAGS)
+ endif
++Oracle8_BUNDLE_LIBS += $(common_LIBS)
++otest_TOOL_LIBS += $(common_LIBS)
+
+ # Bundle
+ BUNDLE_NAME = Oracle8
+Index: sope-gdl1/Oracle8/OracleAdaptorChannel.m
+===================================================================
+--- sope-gdl1/Oracle8/OracleAdaptorChannel.m (révision 1546)
++++ sope-gdl1/Oracle8/OracleAdaptorChannel.m (copie de travail)
+@@ -53,14 +53,17 @@
+ while (c--)
+ {
+ info = [[_row_buffer objectAtIndex: c] pointerValue];
+- [_row_buffer removeObjectAtIndex: c];
+
+ // We free our LOB object. If it fails, it likely mean it isn't a LOB
+ // so we just free the value instead.
+- if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
+- {
+- free(info->value);
+- }
++ if (info->value)
++ {
++ if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
++ free(info->value);
++ info->value = NULL;
++ }
++ free(info);
++ [_row_buffer removeObjectAtIndex: c];
+ }
+
+ OCIHandleFree(_current_stm, OCI_HTYPE_STMT);
+@@ -75,6 +78,30 @@
+ //
+ @implementation OracleAdaptorChannel
+
++static void
++DBTerminate()
++{
++ if (OCITerminate(OCI_DEFAULT))
++ NSLog(@"FAILED: OCITerminate()");
++ else
++ NSLog(@"Oracle8: environment shut down");
++}
++
+++ (void) initialize
++{
++ // We Initialize the OCI process environment.
++ if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0,
++ (dvoid * (*)(dvoid *, size_t)) 0,
++ (dvoid * (*)(dvoid *, dvoid *, size_t))0,
++ (void (*)(dvoid *, dvoid *)) 0 ))
++ NSLog(@"FAILED: OCIInitialize()");
++ else
++ {
++ NSLog(@"Oracle8: environment initialized");
++ atexit(DBTerminate);
++ }
++}
++
+ - (id) initWithAdaptorContext: (EOAdaptorContext *) theAdaptorContext
+ {
+ if ((self = [super initWithAdaptorContext: theAdaptorContext]))
+@@ -134,10 +161,14 @@
+ NSLog(@"FAILED: OCILogoff()");
+ }
+
+- if (OCITerminate(OCI_DEFAULT))
+- {
+- NSLog(@"FAILED: OCITerminate()");
+- }
++
++ OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
++ OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
++ // OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
++
++ _oci_ctx = (OCISvcCtx *)0;
++ _oci_err = (OCIError *)0;
++ _oci_env = (OCIEnv *)0;
+ }
+ }
+
+@@ -151,11 +182,6 @@
+ [self _cleanup];
+
+ RELEASE(_resultSetProperties);
+-
+- OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
+- OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
+- OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
+-
+ RELEASE(delegate);
+
+ [super dealloc];
+@@ -368,16 +394,7 @@
+ return NO;
+ }
+
+- // We Initialize the OCI process environment.
+- if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0,
+- (dvoid * (*)(dvoid *, size_t)) 0,
+- (dvoid * (*)(dvoid *, dvoid *, size_t))0,
+- (void (*)(dvoid *, dvoid *)) 0 ))
+- {
+- NSLog(@"FAILED: OCIInitialize()");
+- return NO;
+- }
+-
++
+ if (OCIEnvInit((OCIEnv **)&_oci_env, (ub4)OCI_DEFAULT, (size_t)0, (dvoid **)0))
+ {
+ NSLog(@"FAILED: OCIEnvInit()");
+Index: sope-gdl1/Oracle8/OracleAdaptorChannelController.m
+===================================================================
+--- sope-gdl1/Oracle8/OracleAdaptorChannelController.m (révision 1546)
++++ sope-gdl1/Oracle8/OracleAdaptorChannelController.m (copie de travail)
+@@ -155,7 +155,9 @@
+ OCILobFreeTemporary([theChannel serviceContext], [theChannel errorHandle], info->value);
+ OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB);
+ }
++ free(info);
+ }
++ [theColumns release];
+
+ OCIHandleFree(theStatement, OCI_HTYPE_STMT);
+ }
Index: sope-mime/NGImap4/NGImap4Connection.m
===================================================================
--- sope-mime/NGImap4/NGImap4Connection.m (révision 1546)
-
+
+ length = [_data length];
-+ bytes = [_data cString];
++ bytes = [_data cStringUsingEncoding: NSASCIIStringEncoding];
+
/* remove leading chars (skip to first digit, the day of the month) */
while (length > 0 && (!isdigit(*bytes))) {
contentType = ([ctype isKindOfClass:[NGMimeType class]])
? ctype
: [NGMimeType mimeType:[ctype stringValue]];
-Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m
+Index: sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m
===================================================================
---- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (révision 1546)
-+++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (copie de travail)
-@@ -713,6 +713,39 @@
- return ms;
- }
+--- sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m (révision 1546)
++++ sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m (copie de travail)
+@@ -20,6 +20,8 @@
+ 02111-1307, USA.
+ */
-+/* GCSEOAdaptorChannel protocol */
-+static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \
-+ @" c_name VARCHAR (256) NOT NULL,\n"
-+ @" c_content VARCHAR (100000) NOT NULL,\n"
-+ @" c_creationdate INT4 NOT NULL,\n"
-+ @" c_lastmodified INT4 NOT NULL,\n"
-+ @" c_version INT4 NOT NULL,\n"
-+ @" c_deleted INT4 NULL\n"
-+ @")");
-+static NSString *sqlFolderACLFormat = (@"CREATE TABLE %@ (\n" \
-+ @" c_uid VARCHAR (256) NOT NULL,\n"
-+ @" c_object VARCHAR (256) NOT NULL,\n"
-+ @" c_role VARCHAR (80) NOT NULL\n"
-+ @")");
++#include <unistd.h>
+
-+- (NSException *) createGCSFolderTableWithName: (NSString *) tableName
-+{
-+ NSString *sql;
+ #include <NGExtensions/NSString+Encoding.h>
+ #include <NGExtensions/NSObject+Logs.h>
+ #include "common.h"
+@@ -81,7 +83,6 @@
+
+ #else /* ! NeXT_Foundation_LIBRARY */
+
+-
+ @implementation NSString(Encoding)
+
+ #if GNUSTEP_BASE_LIBRARY
+@@ -192,17 +193,17 @@
+
+ memcpy(outbuf, _src, _srcLen);
+ *outLen_ = outlen;
+-
+
-+ sql = [NSString stringWithFormat: sqlFolderFormat, tableName];
+ return outbuf;
+ }
+ result = nil;
+ fromEncode = [_fromEncode cString];
+ toEncode = [_toEncode cString];
+-
+
-+ return [self evaluateExpressionX: sql];
-+}
+ type = iconv_open(toEncode, fromEncode);
+ inbuf = NULL;
+ outbuf = NULL;
+-
+
-+- (NSException *) createGCSFolderACLTableWithName: (NSString *) tableName
-+{
-+ NSString *sql;
+ if ((type == (iconv_t)-1)) {
+ [self logWithFormat:@"%s: Could not handle iconv encoding. FromEncoding:%@"
+ @" to encoding:%@", __PRETTY_FUNCTION__, _fromEncode, _toEncode];
+@@ -228,25 +229,25 @@
+ }
+ else if (errno == EINVAL) {
+ [self logWithFormat:@"Got incomplete multibyte sequence. ToEncode: %@"
+- @" FromEncode: %@", _toEncode, _fromEncode];
++ @" FromEncode: %@", _toEncode, _fromEncode];
+ if (IconvLogEnabled)
+ [self logWithFormat:@"ByteSequence:\n%s\n", _src];
+-
+
-+ sql = [NSString stringWithFormat: sqlFolderACLFormat, tableName];
+ }
+ else if (errno == E2BIG) {
+ [self logWithFormat:
+- @"Got to small outputbuffer (inbytesleft=%d, outbytesleft=%d, "
+- @"outlen=%d). ToEncode: %@ FromEncode: %@",
+- inbytesleft, outbytesleft, outlen,
+- _toEncode, _fromEncode];
++ @"Got to small outputbuffer (inbytesleft=%d, outbytesleft=%d, "
++ @"outlen=%d). ToEncode: %@ FromEncode: %@",
++ inbytesleft, outbytesleft, outlen,
++ _toEncode, _fromEncode];
+ if (IconvLogEnabled)
+ [self logWithFormat:@"ByteSequence:\n%s\n", _src];
+-
+
-+ return [self evaluateExpressionX: sql];
-+}
+ goto CLEAR_AND_RETURN;
+ }
+ else {
+ [self logWithFormat:@"Got unexpected error. ToEncode: %@"
+- @" FromEncode: %@", _toEncode, _fromEncode];
++ @" FromEncode: %@", _toEncode, _fromEncode];
+ goto CLEAR_AND_RETURN;
+ }
+ }
+@@ -255,45 +256,224 @@
+ #endif
+ if (type)
+ iconv_close(type);
+-
+
- @end /* PostgreSQL72Channel */
-
- @implementation PostgreSQL72Channel(PrimaryKeyGeneration)
-Index: sope-gdl1/Oracle8/GNUmakefile
-===================================================================
---- sope-gdl1/Oracle8/GNUmakefile (révision 1546)
-+++ sope-gdl1/Oracle8/GNUmakefile (copie de travail)
-@@ -28,15 +28,23 @@
- SOPE_ROOT=../..
- ORACLE_VERSION=10.2.0.3
- #ORACLE_VERSION=11.1.0.1
--ADDITIONAL_INCLUDE_DIRS += -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
-+ADDITIONAL_INCLUDE_DIRS += -I../../sope-core -I../../sope-core/NGExtensions -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
-
-+local_arch = $(subst 64,,$(shell uname -m))
+ *outLen_ = outlen - outbytesleft;
+-
+
-+ifeq ($(local_arch),ppc)
-+PPC_LDFLAGS=-L/opt/ibmcmp/lib -libmc++
-+else
-+PPC_LDFLAGS=
-+endif
+ return outbuf;
+-
+
- ifneq ($(frameworks),yes)
--Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
--otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
-+common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -L../GDLAccess/obj -lGDLAccess -L../../sope-core/EOControl/obj -lEOControl $(PPC_LDFLAGS)
- else
--Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
--otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
-+common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl $(PPC_LDFLAGS)
- endif
-+Oracle8_BUNDLE_LIBS += $(common_LIBS)
-+otest_TOOL_LIBS += $(common_LIBS)
+ CLEAR_AND_RETURN:
+ if (type)
+ iconv_close(type);
+-
++
+ if (outbuf) {
+ free(outbuf); outbuf = NULL;
+ }
+ return NULL;
+ }
- # Bundle
- BUNDLE_NAME = Oracle8
-Index: sope-gdl1/Oracle8/OracleAdaptorChannel.m
-===================================================================
---- sope-gdl1/Oracle8/OracleAdaptorChannel.m (révision 1546)
-+++ sope-gdl1/Oracle8/OracleAdaptorChannel.m (copie de travail)
-@@ -53,14 +53,17 @@
- while (c--)
- {
- info = [[_row_buffer objectAtIndex: c] pointerValue];
-- [_row_buffer removeObjectAtIndex: c];
+-+ (NSString *)stringWithData:(NSData *)_data
+- usingEncodingNamed:(NSString *)_encoding
+++ (int) encodingForCharset: (NSString *) theCharset
++ convertToNSStringEncoding: (BOOL) shouldConvert
+ {
+- void *inbuf, *res;
+- unsigned len, inbufLen;
+- NSString *result;
++ // We define some aliases for the string encoding.
++ static struct { NSString *name; int encoding; BOOL fromCoreFoundation; } encodings[] = {
++ {@"ascii" ,NSASCIIStringEncoding ,NO},
++ {@"us-ascii" ,NSASCIIStringEncoding ,NO},
++ {@"default" ,NSASCIIStringEncoding ,NO}, // Ah... spammers.
++ {@"utf-8" ,NSUTF8StringEncoding ,NO},
++ {@"iso-8859-1" ,NSISOLatin1StringEncoding ,NO},
++ {@"x-user-defined",NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Outlook.
++ {@"unknown" ,NSISOLatin1StringEncoding ,NO}, // Once more, blame Outlook.
++ {@"x-unknown" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Pine 4.21.
++ {@"unknown-8bit" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Mutt/1.3.28i
++ {@"0" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in QUALCOMM Windows Eudora Version 6.0.1.1
++ {@"" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Ximian Evolution
++ {@"iso8859_1" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Openwave WebEngine
++ {@"iso-8859-2" ,NSISOLatin2StringEncoding ,NO},
++#ifndef MACOSX
++ {@"iso-8859-3" ,NSISOLatin3StringEncoding ,NO},
++ {@"iso-8859-4" ,NSISOLatin4StringEncoding ,NO},
++ {@"iso-8859-5" ,NSISOCyrillicStringEncoding ,NO},
++ {@"iso-8859-6" ,NSISOArabicStringEncoding ,NO},
++ {@"iso-8859-7" ,NSISOGreekStringEncoding ,NO},
++ {@"iso-8859-8" ,NSISOHebrewStringEncoding ,NO},
++ {@"iso-8859-9" ,NSISOLatin5StringEncoding ,NO},
++ {@"iso-8859-10" ,NSISOLatin6StringEncoding ,NO},
++ {@"iso-8859-11" ,NSISOThaiStringEncoding ,NO},
++ {@"iso-8859-13" ,NSISOLatin7StringEncoding ,NO},
++ {@"iso-8859-14" ,NSISOLatin8StringEncoding ,NO},
++ {@"iso-8859-15" ,NSISOLatin9StringEncoding ,NO},
++ {@"koi8-r" ,NSKOI8RStringEncoding ,NO},
++ {@"big5" ,NSBIG5StringEncoding ,NO},
++ {@"gb2312" ,NSGB2312StringEncoding ,NO},
++ {@"utf-7" ,NSUTF7StringEncoding ,NO},
++ {@"unicode-1-1-utf-7", NSUTF7StringEncoding ,NO}, // To prever a bug (sort of) in MS Hotmail
++#endif
++ {@"windows-1250" ,NSWindowsCP1250StringEncoding ,NO},
++ {@"windows-1251" ,NSWindowsCP1251StringEncoding ,NO},
++ {@"cyrillic (windows-1251)", NSWindowsCP1251StringEncoding ,NO}, // To prevent a bug in MS Hotmail
++ {@"windows-1252" ,NSWindowsCP1252StringEncoding ,NO},
++ {@"windows-1253" ,NSWindowsCP1253StringEncoding ,NO},
++ {@"windows-1254" ,NSWindowsCP1254StringEncoding ,NO},
++ {@"iso-2022-jp" ,NSISO2022JPStringEncoding ,NO},
++ {@"euc-jp" ,NSJapaneseEUCStringEncoding ,NO},
++ };
++
++ NSString *name;
++ int i;
- // We free our LOB object. If it fails, it likely mean it isn't a LOB
- // so we just free the value instead.
-- if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
-- {
-- free(info->value);
-- }
-+ if (info->value)
+- if (![_encoding length])
+- return nil;
++ name = [theCharset lowercaseString];
+
+- inbufLen = [_data length];
+- inbuf = calloc(sizeof(char), inbufLen + 4);
+- [_data getBytes:inbuf];
++ for (i = 0; i < sizeof(encodings)/sizeof(encodings[0]); i++)
++ {
++ if ([name isEqualToString: encodings[i].name])
++ {
++ int enc = encodings[i].encoding;
++ // Under OS X, we use CoreFoundation if necessary to convert the encoding
++ // to a NSString encoding.
++#ifdef MACOSX
++ if (encodings[i].fromCoreFoundation)
++ {
++ if (shouldConvert)
++ {
++ return CFStringConvertEncodingToNSStringEncoding(enc);
++ }
++ else
++ {
++ return enc;
++ }
++ }
++ else
++ {
++ if (!shouldConvert)
++ {
++ return CFStringConvertNSStringEncodingToEncoding(enc);
++ }
++ else
++ {
++ return enc;
++ }
++ }
++#else
++ return enc;
++#endif
++ }
++ }
+
+- result = nil;
+- res = iconv_wrapper(self, inbuf, inbufLen, _encoding, unicharEncoding, &len);
+- if (res) {
+- result = [[NSString alloc] initWithCharacters:res length:(len / 2)];
+- free(res); res = NULL;
+- }
+- if (inbuf) free(inbuf); inbuf = NULL;
+- return [result autorelease];
++#ifdef MACOSX
++ // Last resort: try using CoreFoundation...
++ CFStringEncoding enc;
++
++ enc = CFStringConvertIANACharSetNameToEncoding((CFStringRef)name);
++ if (kCFStringEncodingInvalidId != enc)
++ {
++ if (shouldConvert)
+ {
-+ if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
-+ free(info->value);
-+ info->value = NULL;
++ return CFStringConvertEncodingToNSStringEncoding(enc);
+ }
-+ free(info);
-+ [_row_buffer removeObjectAtIndex: c];
- }
++ else
++ {
++ return enc;
++ }
++ }
++#endif
++
++ return -1;
+ }
- OCIHandleFree(_current_stm, OCI_HTYPE_STMT);
-@@ -138,6 +141,14 @@
- {
- NSLog(@"FAILED: OCITerminate()");
- }
+++ (int) encodingForCharset: (NSString *) theCharset
++{
++ return [self encodingForCharset: theCharset convertToNSStringEncoding: YES];
++}
+
-+ OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
-+ OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
-+ OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
+++ (NSString *) stringWithData: (NSData *) theData
++ usingEncodingNamed: (NSString *) theCharset
++{
++ int encoding;
++
++ if (theData == nil)
++ {
++ return nil;
++ }
++
++#ifdef MACOSX
++ encoding = [NSString encodingForCharset: theCharset
++ convertToNSStringEncoding: NO];
++#else
++ encoding = [NSString encodingForCharset: theCharset];
++#endif
+
-+ _oci_ctx = (OCISvcCtx *)0;
-+ _oci_err = (OCIError *)0;
-+ _oci_env = (OCIEnv *)0;
- }
- }
-
-@@ -151,11 +162,6 @@
- [self _cleanup];
-
- RELEASE(_resultSetProperties);
--
-- OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
-- OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
-- OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
--
- RELEASE(delegate);
-
- [super dealloc];
-Index: sope-gdl1/Oracle8/OracleAdaptorChannelController.m
++ if (encoding == -1)
++ {
++ NSString *aString;
++ const char *i_bytes;
++ char *o_bytes;
++
++ size_t i_length, o_length;
++ int total_length, ret;
++ iconv_t conv;
++
++ // Instead of calling cString directly on theCharset, we first try
++ // to obtain the ASCII string of the data object.
++ if (!theCharset)
++ {
++ return nil;
++ }
++
++ conv = iconv_open("UTF-8", [[theCharset uppercaseString] cStringUsingEncoding: NSISOLatin1StringEncoding]);
++
++ if ((int)conv < 0)
++ {
++ // Let's assume we got US-ASCII here.
++ return AUTORELEASE([[NSString alloc] initWithData: theData encoding: NSASCIIStringEncoding]);
++ }
++
++ i_bytes = [theData bytes];
++ i_length = [theData length];
++
++ total_length = o_length = sizeof(unichar)*i_length;
++ o_bytes = (char *)malloc(o_length);
++
++ if (o_bytes == NULL) return nil;
++
++ while (i_length > 0)
++ {
++ ret = iconv(conv, (char **)&i_bytes, &i_length, &o_bytes, &o_length);
++
++ if (ret == (size_t)-1)
++ {
++ iconv_close(conv);
++
++ total_length = total_length - o_length;
++ o_bytes -= total_length;
++ free(o_bytes);
++ return nil;
++ }
++ }
++
++ total_length = total_length - o_length;
++ o_bytes -= total_length;
++
++ // If we haven't used all our allocated buffer, we shrink it.
++ if (o_length > 0)
++ {
++ o_bytes = realloc(o_bytes, total_length);
++ }
++
++ aString = [[NSString alloc] initWithData: [NSData dataWithBytesNoCopy: o_bytes
++ length: total_length]
++ encoding: NSUTF8StringEncoding];
++ iconv_close(conv);
++
++ return AUTORELEASE(aString);
++ }
++
++#ifdef MACOSX
++ return AUTORELEASE((NSString *)CFStringCreateFromExternalRepresentation(NULL, (CFDataRef)theData, encoding));
++#else
++ return AUTORELEASE([[NSString alloc] initWithData: theData encoding: encoding]);
++#endif
++}
++
+ - (NSData *)dataUsingEncodingNamed:(NSString *)_encoding {
+ unichar *chars;
+ char *res;
+Index: sope-core/NGExtensions/ChangeLog
===================================================================
---- sope-gdl1/Oracle8/OracleAdaptorChannelController.m (révision 1546)
-+++ sope-gdl1/Oracle8/OracleAdaptorChannelController.m (copie de travail)
-@@ -155,7 +155,9 @@
- OCILobFreeTemporary([theChannel serviceContext], [theChannel errorHandle], info->value);
- OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB);
- }
-+ free(info);
- }
-+ [theColumns release];
+--- sope-core/NGExtensions/ChangeLog (révision 1546)
++++ sope-core/NGExtensions/ChangeLog (copie de travail)
+@@ -1,3 +1,10 @@
++2007-11-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
++
++ * FdExt.subproj/NSString+Encoding.m: replaced the code of
++ stringWithData:usingEncodingNamed: with the code from
++ Pantomime/NSString+Extensions.m/stringWithData:charset:, which in
++ turn was adapted to take the same argument types.
++
+ 2007-07-31 Marcus Mueller <znek@mulle-kybernetik.com>
- OCIHandleFree(theStatement, OCI_HTYPE_STMT);
- }
+ * FdExt.subproj/NSMethodSignature+misc.m: added warning and bogus
Index: sope-appserver/NGObjWeb/GNUmakefile.postamble
===================================================================
--- sope-appserver/NGObjWeb/GNUmakefile.postamble (révision 1546)