Changeset 539 for branches


Ignore:
Timestamp:
Jan 28, 2011, 11:00:37 AM (15 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.0: fix for ticket 130 thx komh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/lib/iconv.c

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