Changeset 537


Ignore:
Timestamp:
Jan 28, 2011, 10:58:48 AM (14 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: fix for ticket 130 thx komh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/server/source3/lib/iconv.c

    r454 r537  
    128128}
    129129
    130 #ifdef __OS2__
    131 // i could have done a static variable w/o this function. but i feel it's nicer this way.
    132 // the purpose of this function is to save the to_name to get the korean and japanese code set working
    133 char * save_toname(char *toname, bool what)
    134 {
    135    static char *to_name=NULL;
    136 
    137    if ( what == 0 )
    138         to_name = SMB_STRDUP(toname);
    139 
    140         return to_name;
    141 }
     130#if defined(__OS2__) && defined(__INNOTEK_LIBC__)
     131#include <uconv.h>
     132
     133typedef struct os2_iconv_t
     134{
     135    UconvObject from;
     136} os2_iconv_t;
     137
     138iconv_t os2_iconv_open (const char *tocode, const char *fromcode)
     139{
     140    os2_iconv_t *os2_cd = (os2_iconv_t *)iconv_open(tocode, fromcode);
     141
     142    if (os2_cd != (iconv_t)(-1))
     143       {
     144        /* Assume strings contain pathnames */
     145        uconv_attribute_t attr;
     146
     147        UniQueryUconvObject(os2_cd->from, &attr,
     148                            sizeof(uconv_attribute_t),
     149                            NULL, NULL, NULL );
     150        attr.converttype |= CVTTYPE_PATH;
     151        UniSetUconvObject(os2_cd->from, &attr);
     152        }
     153
     154    return (iconv_t)os2_cd;
     155}
     156
     157#define iconv_open  os2_iconv_open
    142158#endif
    143159
     
    150166                        char **outbuf, size_t *outbytesleft)
    151167{
    152 #ifdef __OS2__
    153         uint16 *outbuf_uc = ( uint16 * )*outbuf;
    154         char *to_name = save_toname(NULL, 1);
    155 #endif
    156 
    157168        size_t ret = iconv((iconv_t)cd,
    158169                           (void *)inbuf, inbytesleft,
     
    163174                errno = saved_errno;
    164175        }
    165 #ifdef __OS2__
    166         /* Workaround for path separator on OS/2 */
    167         else
    168         {
    169                 if( (strstr(to_name, "949") != NULL) ||     /* Korean CP */
    170                    (strstr(to_name, "932") != NULL) ||      /* Japanese CP */
    171                    (strstr(to_name, "942") != NULL) ||      /* Japanese CP */
    172                    (strstr(to_name, "943") != NULL) )       /* Japanese CP */
    173                 {
    174                          while(( char * )outbuf_uc < *outbuf )
    175                         {
    176                             if( *outbuf_uc == 0x20a9 ||     /* Korean WON */
    177                                 *outbuf_uc == 0x00a5 )      /* Japanese YEN */
    178                                 *outbuf_uc = '\\';
    179 
    180                             outbuf_uc++;
    181                         }
    182                 }
    183         }
    184 #endif
    185176
    186177        return ret;
     
    201192        char *bufp = cvtbuf;
    202193        size_t bufsize;
    203 #ifdef __OS2__
    204         save_toname(cd->to_name, 0);
    205 #endif
    206194
    207195        /* in many cases we can go direct */
Note: See TracChangeset for help on using the changeset viewer.