Changeset 574af7e for util.c


Ignore:
Timestamp:
2006-05-25T23:20:54Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
79b6213
Parents:
5d9b792
Message:

Require GLib 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r5d9b792 r574af7e  
    3939#include <glib.h>
    4040#include <time.h>
    41 #ifdef GLIB2
    42 #define iconv_t GIConv
    43 #define iconv_open g_iconv_open
    44 #define iconv_close g_iconv_close
    45 #define iconv g_iconv
    46 #else
    47 #include <iconv.h>
    48 #endif
    4941
    5042void strip_linefeed(gchar *text)
     
    465457signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf )
    466458{
    467         iconv_t cd;
     459        GIConv cd;
    468460        size_t res;
    469461        size_t inbytesleft, outbytesleft;
     
    471463        char *outbuf = dst;
    472464       
    473         cd = iconv_open( to_cs, from_cs );
    474         if( cd == (iconv_t) -1 )
     465        cd = g_iconv_open( to_cs, from_cs );
     466        if( cd == (GIConv) -1 )
    475467                return( -1 );
    476468       
    477469        inbytesleft = size ? size : strlen( src );
    478470        outbytesleft = maxbuf - 1;
    479         res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
     471        res = g_iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
    480472        *outbuf = '\0';
    481         iconv_close( cd );
     473        g_iconv_close( cd );
    482474       
    483475        if( res == (size_t) -1 )
     
    489481char *set_eval_charset( irc_t *irc, set_t *set, char *value )
    490482{
    491         iconv_t cd;
     483        GIConv cd;
    492484
    493485        if ( g_strncasecmp( value, "none", 4 ) == 0 )
    494486                return( value );
    495487
    496         cd = iconv_open( "UTF-8", value );
    497         if( cd == (iconv_t) -1 )
     488        cd = g_iconv_open( "UTF-8", value );
     489        if( cd == (GIConv) -1 )
    498490                return( NULL );
    499491
    500         iconv_close( cd );
     492        g_iconv_close( cd );
    501493        return( value );
    502494}
Note: See TracChangeset for help on using the changeset viewer.