ID: 6032 Updated by: joey Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Sybase-ct (ctlib) related Assigned To: Comments: Actually, this patch has been in 4.0 since 4.0.2...this is a patch against 3.0 to do the same thing. Previous Comments: --------------------------------------------------------------------------- [2001-02-10 14:57:26] [EMAIL PROTECTED] refiled against 4.0. --------------------------------------------------------------------------- [2000-08-08 21:45:54] [EMAIL PROTECTED] I had a problem with sybase-dblib a couple of days ago, and fixed it sending an extra parameter (character set) in the connection information. It turned out I _actually_ needed it with ct-lib, not dblib. Following patch does the same for dblib. (See description in bug #5996). -+-+-cut from next line. file php3_sybase-ct_charsets.patch-+-+- --- functions/sybase-ct.c.orig Mon Feb 7 18:54:51 2000 +++ functions/sybase-ct.c Tue Aug 8 20:15:03 2000 @@ -349,8 +349,10 @@ } -static int _php3_sybct_really_connect(sybct_link *sybct, char *host, char *user, char *passwd) +static int _php3_sybct_really_connect(sybct_link *sybct, char *host, char *user, char +*passwd, char *charset) { + CS_LOCALE *tmp_locale; + /* set a CS_CONNECTION record */ if (ct_con_alloc(context, &sybct->connection)!=CS_SUCCEED) { php3_error(E_WARNING,"Sybase: Unable to allocate connection record"); @@ -371,7 +373,25 @@ ct_con_props(sybct->connection, CS_SET, CS_PASSWORD, passwd, CS_NULLTERM, NULL); } ct_con_props(sybct->connection, CS_SET, CS_APPNAME, php3_sybct_module.appname, CS_NULLTERM, NULL); - + + if (charset) { + if (cs_loc_alloc(context, &tmp_locale)!=CS_SUCCEED) { + php3_error(E_WARNING,"Sybase: Unable to allocate locale +information."); + } else { + if (cs_locale(context, CS_SET, tmp_locale, CS_LC_ALL, NULL, +CS_NULLTERM, NULL)!=CS_SUCCEED) { + php3_error(E_WARNING,"Sybase: Unable to load default +locale data."); + } else { + if (cs_locale(context, CS_SET, tmp_locale, +CS_SYB_CHARSET, charset, CS_NULLTERM, NULL)!=CS_SUCCEED) { + php3_error(E_WARNING,"Sybase: Unable to +update character set."); + } else { + if (ct_con_props(sybct->connection, CS_SET, +CS_LOC_PROP, tmp_locale, CS_UNUSED, NULL)!=CS_SUCCEED) { + php3_error(E_WARNING,"Sybase: Unable +to update connection properties."); + } + } + } + } + } + if (php3_sybct_module.hostname) { ct_con_props(sybct->connection, CS_SET, CS_HOSTNAME, php3_sybct_module.hostname, CS_NULLTERM, NULL); } @@ -399,7 +419,7 @@ static void php3_sybct_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) { - char *user,*passwd,*host; + char *user,*passwd,*host,*charset; char *hashed_details; int hashed_details_length; sybct_link *sybct_ptr; @@ -409,7 +429,7 @@ switch(ARG_COUNT(ht)) { case 0: /* defaults */ - host=user=passwd=NULL; + host=user=passwd=charset=NULL; hashed_details_length=5+3; hashed_details = (char *) emalloc(hashed_details_length+1); strcpy(hashed_details,"sybct___"); @@ -422,7 +442,7 @@ } convert_to_string(yyhost); host = yyhost->value.str.val; - user=passwd=NULL; + user=passwd=charset=NULL; hashed_details_length = yyhost->value.str.len+5+3; hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"sybct_%s__",yyhost->value.str.val); @@ -438,7 +458,7 @@ convert_to_string(yyuser); host = yyhost->value.str.val; user = yyuser->value.str.val; - passwd=NULL; + passwd=charset=NULL; hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+5+3; hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"sybct_%s_%s_",yyhost->value.str.val,yyuser->value.str.val); @@ -456,11 +476,31 @@ host = yyhost->value.str.val; user = yyuser->value.str.val; passwd = yypasswd->value.str.val; + charset = NULL; hashed_details_length = yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+5+3; hashed_details = (char *) emalloc(hashed_details_length+1); sprintf(hashed_details,"sybct_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val); /* SAFE */ } break; + case 4: { + pval *yyhost,*yyuser,*yypasswd,*yycharset; + + if (getParameters(ht, 4, &yyhost, &yyuser, &yypasswd, +&yycharset) == FAILURE) { + RETURN_FALSE; + } + convert_to_string(yyhost); + convert_to_string(yyuser); + convert_to_string(yypasswd); + convert_to_string(yycharset); + host = yyhost->value.str.val; + user = yyuser->value.str.val; + passwd = yypasswd->value.str.val; + charset = yycharset->value.str.val; + hashed_details_length = +yyhost->value.str.len+yyuser->value.str.len+yypasswd->value.str.len+yycharset->value.str.len+5+3; + + hashed_details = (char *) +emalloc(hashed_details_length+1); + +sprintf(hashed_details,"sybct_%s_%s_%s",yyhost->value.str.val,yyuser->value.str.val,yypasswd->value.str.val,yycharset->value.str.val); + /* SAFE */ + } + break; default: WRONG_PARAM_COUNT; break; @@ -489,7 +529,7 @@ } sybct_ptr = (sybct_link *) malloc(sizeof(sybct_link)); - if (!_php3_sybct_really_connect(sybct_ptr, host, user, passwd)) { + if (!_php3_sybct_really_connect(sybct_ptr, host, user, passwd, +charset)) { free(sybct_ptr); efree(hashed_details); RETURN_FALSE; @@ -543,7 +583,7 @@ * NULL before trying to use it elsewhere . . .) */ memcpy(&sybct,sybct_ptr,sizeof(sybct_link)); - if (!_php3_sybct_really_connect(sybct_ptr, host, user, passwd)) { + if (!_php3_sybct_really_connect(sybct_ptr, host, user, +passwd, charset)) { memcpy(sybct_ptr,&sybct,sizeof(sybct_link)); efree(hashed_details); RETURN_FALSE; @@ -587,7 +627,7 @@ } sybct_ptr = (sybct_link *) emalloc(sizeof(sybct_link)); - if (!_php3_sybct_really_connect(sybct_ptr, host, user, passwd)) { + if (!_php3_sybct_really_connect(sybct_ptr, host, user, passwd, +charset)) { efree(sybct_ptr); efree(hashed_details); RETURN_FALSE; --- functions/php3_sybase-ct.h.orig Mon Feb 7 18:54:51 2000 +++ functions/php3_sybase-ct.h Tue Aug 8 20:26:09 2000 @@ -72,6 +72,7 @@ #include <ctpublic.h> +#include <cstypes.h> typedef struct { long default_link; -+-+-cut to previous line. file php3_sybase-ct_charsets.patch-+-+- patch with: patch -p0 < php3_sybase-ct_charsets.patch from the php directory (/wherever/php-3.0.16) --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=6032&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]