diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2007-05-20 23:13:29 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2007-05-20 23:13:29 +0000 |
commit | afa4292466c6de093d0cdf359a91160886933507 (patch) | |
tree | c75be7d3d2bc7309fb363c13cd557a406a9267e2 /src | |
parent | cb1287ab63549186e1841a7e63f7a7d5b4be3b4d (diff) | |
download | irssi-afa4292466c6de093d0cdf359a91160886933507.zip |
Farewell glib-1.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4509 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/network-openssl.c | 142 | ||||
-rw-r--r-- | src/core/nicklist.c | 8 | ||||
-rw-r--r-- | src/core/nicklist.h | 3 | ||||
-rw-r--r-- | src/core/recode.c | 20 | ||||
-rw-r--r-- | src/core/session.c | 48 | ||||
-rw-r--r-- | src/fe-common/core/fe-channels.c | 5 | ||||
-rw-r--r-- | src/fe-common/core/fe-recode.c | 8 | ||||
-rw-r--r-- | src/fe-common/core/formats.c | 26 | ||||
-rw-r--r-- | src/fe-common/core/keyboard.c | 5 | ||||
-rw-r--r-- | src/perl/perl-common.c | 5 |
10 files changed, 5 insertions, 265 deletions
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c index b2b00dc9..75d66050 100644 --- a/src/core/network-openssl.c +++ b/src/core/network-openssl.c @@ -94,146 +94,6 @@ static gboolean irssi_ssl_verify(SSL *ssl, SSL_CTX *ctx, X509 *cert) return TRUE; } - -#if GLIB_MAJOR_VERSION < 2 - -static GIOError ssl_errno(gint e) -{ - switch(e) - { - case EINVAL: - return G_IO_ERROR_INVAL; - case EINTR: - case EAGAIN: - return G_IO_ERROR_AGAIN; - default: - return G_IO_ERROR_INVAL; - } - /*UNREACH*/ - return G_IO_ERROR_INVAL; -} - -static GIOError irssi_ssl_cert_step(GIOSSLChannel *chan) -{ - X509 *cert; - gint err; - switch(err = SSL_do_handshake(chan->ssl)) - { - case 1: - if(!(cert = SSL_get_peer_certificate(chan->ssl))) - { - g_warning("SSL server supplied no certificate"); - return G_IO_ERROR_INVAL; - } - if (chan->verify && ! irssi_ssl_verify(chan->ssl, chan->ctx, cert)) { - X509_free(cert); - return G_IO_ERROR_INVAL; - } - X509_free(cert); - return G_IO_ERROR_NONE; - default: - if(SSL_get_error(chan->ssl, err) == SSL_ERROR_WANT_READ) - return G_IO_ERROR_AGAIN; - return ssl_errno(errno); - } - /*UNREACH*/ - return G_IO_ERROR_INVAL; -} - -static GIOError irssi_ssl_read(GIOChannel *handle, gchar *buf, guint len, guint *ret) -{ - GIOSSLChannel *chan = (GIOSSLChannel *)handle; - gint err; - - if(! chan->got_cert) - { - gint cert_err = irssi_ssl_cert_step(chan); - if(cert_err != G_IO_ERROR_NONE) - return cert_err; - } - - err = SSL_read(chan->ssl, buf, len); - if(err < 0) - { - *ret = 0; - if(SSL_get_error(chan->ssl, err) == SSL_ERROR_WANT_READ) - return G_IO_ERROR_AGAIN; - return ssl_errno(errno); - } - else - { - *ret = err; - return G_IO_ERROR_NONE; - } - /*UNREACH*/ - return -1; -} - -static GIOError irssi_ssl_write(GIOChannel *handle, gchar *buf, guint len, guint *ret) -{ - GIOSSLChannel *chan = (GIOSSLChannel *)handle; - gint err; - - if(chan->got_cert) - { - gint cert_err = irssi_ssl_cert_step(chan); - if(cert_err != G_IO_ERROR_NONE) - return cert_err; - } - - - err = SSL_write(chan->ssl, (const char *)buf, len); - if(err < 0) - { - *ret = 0; - if(SSL_get_error(chan->ssl, err) == SSL_ERROR_WANT_READ) - return G_IO_ERROR_AGAIN; - return ssl_errno(errno); - } - else - { - *ret = err; - return G_IO_ERROR_NONE; - } - /*UNREACH*/ - return G_IO_ERROR_INVAL; -} - -static GIOError irssi_ssl_seek(GIOChannel *handle, gint offset, GSeekType type) -{ - GIOSSLChannel *chan = (GIOSSLChannel *)handle; - GIOError e; - e = g_io_channel_seek(chan->giochan, offset, type); - return (e == G_IO_ERROR_NONE) ? G_IO_ERROR_NONE : G_IO_ERROR_INVAL; -} - -static void irssi_ssl_close(GIOChannel *handle) -{ - GIOSSLChannel *chan = (GIOSSLChannel *)handle; - g_io_channel_close(chan->giochan); -} - -static guint irssi_ssl_create_watch(GIOChannel *handle, gint priority, GIOCondition cond, - GIOFunc func, gpointer data, GDestroyNotify notify) -{ - GIOSSLChannel *chan = (GIOSSLChannel *)handle; - - return chan->giochan->funcs->io_add_watch(handle, priority, cond, func, data, notify); -} - -/* ssl function pointers */ -static GIOFuncs irssi_ssl_channel_funcs = -{ - irssi_ssl_read, - irssi_ssl_write, - irssi_ssl_seek, - irssi_ssl_close, - irssi_ssl_create_watch, - irssi_ssl_free -}; - -#else /* GLIB_MAJOR_VERSION < 2 */ - static GIOStatus ssl_errno(gint e) { switch(e) @@ -383,8 +243,6 @@ static GIOFuncs irssi_ssl_channel_funcs = { irssi_ssl_get_flags }; -#endif - static gboolean irssi_ssl_init(void) { SSL_library_init(); diff --git a/src/core/nicklist.c b/src/core/nicklist.c index ced72ccb..aa42b7fa 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -356,14 +356,6 @@ GSList *nicklist_get_same_unique(SERVER_REC *server, void *id) return rec.list; } -#if GLIB_MAJOR_VERSION < 2 -/* glib1 doesn't have g_slist_sort_with_data, so non-standard prefixes won't be sorted correctly */ -int nicklist_compare_glib1(NICK_REC *p1, NICK_REC *p2) -{ - return nicklist_compare(p1, p2, NULL); -} -#endif - /* nick record comparision for sort functions */ int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix) { diff --git a/src/core/nicklist.h b/src/core/nicklist.h index 1688fe58..7712af65 100644 --- a/src/core/nicklist.h +++ b/src/core/nicklist.h @@ -49,9 +49,6 @@ void nicklist_update_flags_unique(SERVER_REC *server, void *id, void nicklist_set_own(CHANNEL_REC *channel, NICK_REC *nick); /* Nick record comparison for sort functions */ -#if GLIB_MAJOR_VERSION < 2 -int nicklist_compare_glib1(NICK_REC *p1, NICK_REC *p2); -#endif int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix); /* Check is `msg' is meant for `nick'. */ diff --git a/src/core/recode.c b/src/core/recode.c index 65cf7e08..a2ff2e26 100644 --- a/src/core/recode.c +++ b/src/core/recode.c @@ -32,11 +32,7 @@ static gboolean recode_get_charset(const char **charset) /* we use the same test as in src/fe-text/term.c:123 */ return (g_strcasecmp(*charset, "utf-8") == 0); -#ifdef HAVE_GLIB2 return g_get_charset(charset); -#else - return FALSE; -#endif } gboolean is_utf8(void) @@ -46,7 +42,6 @@ gboolean is_utf8(void) return recode_get_charset(&charset); } -#ifdef HAVE_GLIB2 static gboolean is_translit(const char *charset) { char *pos; @@ -54,11 +49,9 @@ static gboolean is_translit(const char *charset) pos = stristr(charset, "//translit"); return (pos != NULL); } -#endif gboolean is_valid_charset(const char *charset) { -#ifdef HAVE_GLIB2 const char *from="UTF-8"; const char *str="irssi"; char *recoded, *to = NULL; @@ -75,11 +68,6 @@ gboolean is_valid_charset(const char *charset) g_free(recoded); g_free(to); return valid; -#else - if (!charset || *charset =='\0') - return FALSE; - return TRUE; -#endif } static char *find_conversion(const SERVER_REC *server, const char *target) @@ -100,7 +88,6 @@ static char *find_conversion(const SERVER_REC *server, const char *target) char *recode_in(const SERVER_REC *server, const char *str, const char *target) { -#ifdef HAVE_GLIB2 const char *from = NULL; const char *to = NULL; char *translit_to = NULL; @@ -162,14 +149,10 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target) } g_free(translit_to); return recoded; -#else - return g_strdup(str); -#endif } char *recode_out(const SERVER_REC *server, const char *str, const char *target) { -#ifdef HAVE_GLIB2 char *recoded = NULL; const char *from = NULL; const char *to = NULL; @@ -205,9 +188,6 @@ char *recode_out(const SERVER_REC *server, const char *str, const char *target) recoded = g_strdup(str); return recoded; -#else - return g_strdup(str); -#endif } void recode_init(void) diff --git a/src/core/session.c b/src/core/session.c index 5e0318da..d118e8f1 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -37,54 +37,6 @@ char *irssi_binary = NULL; static char **session_args; -#ifndef HAVE_GLIB2 -static char *g_find_program_in_path(const char *path) -{ - const char *envpath; - char **paths, **tmp; - char *str; - char *result = NULL; - - if (g_path_is_absolute(path)) { - /* full path - easy */ - if(access(path, X_OK) == -1) - return NULL; - else - return g_strdup(path); - } - - if (strchr(path, G_DIR_SEPARATOR) != NULL) { - /* relative path */ - str = g_get_current_dir(); - result = g_strconcat(str, G_DIR_SEPARATOR_S, path, NULL); - g_free(str); - if (access(result, X_OK) == -1) { - g_free(result); - return NULL; - } - else - return result; - } - - /* we'll need to find it from path. */ - envpath = g_getenv("PATH"); - if (envpath == NULL) return NULL; - - paths = g_strsplit(envpath, ":", -1); - for (tmp = paths; *tmp != NULL; tmp++) { - str = g_strconcat(*tmp, G_DIR_SEPARATOR_S, path, NULL); - if (access(str, X_OK) == 0) { - result = str; - break; - } - g_free(str); - } - g_strfreev(paths); - - return result; -} -#endif - void session_set_binary(const char *path) { g_free_and_null(irssi_binary); diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index 8a1208ab..a3325ef8 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -508,12 +508,7 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags) g_slist_free(nicklist); /* sort the nicklist */ -#if GLIB_MAJOR_VERSION < 2 - /* glib1 doesn't have g_slist_sort_with_data, so non-standard prefixes won't be sorted correctly */ - sorted = g_slist_sort(sorted, (GCompareFunc)nicklist_compare_glib1); -#else sorted = g_slist_sort_with_data(sorted, (GCompareDataFunc) nicklist_compare, (void *)nick_flags); -#endif /* display the nicks */ if ((flags & CHANNEL_NICKLIST_FLAG_COUNT) == 0) { diff --git a/src/fe-common/core/fe-recode.c b/src/fe-common/core/fe-recode.c index 08173af7..203e69f7 100644 --- a/src/fe-common/core/fe-recode.c +++ b/src/fe-common/core/fe-recode.c @@ -38,7 +38,6 @@ for ((var) = (head); \ (var); \ (var) = g_slist_next((var))) -#ifdef HAVE_GLIB2 char *recode_fallback = NULL; char *recode_out_default = NULL; char *term_charset = NULL; @@ -210,27 +209,20 @@ static void read_settings(void) g_free(old_recode_fallback); g_free(old_recode_out_default); } -#endif void fe_recode_init (void) { -/* FIXME: print this is not supported instead */ -#ifdef HAVE_GLIB2 command_bind("recode", NULL, (SIGNAL_FUNC) fe_recode_cmd); command_bind("recode add", NULL, (SIGNAL_FUNC) fe_recode_add_cmd); command_bind("recode remove", NULL, (SIGNAL_FUNC) fe_recode_remove_cmd); signal_add("setup changed", (SIGNAL_FUNC) read_settings); read_settings(); -#endif } void fe_recode_deinit (void) { -/* FIXME: print this is not supported instead */ -#ifdef HAVE_GLIB2 command_unbind("recode", (SIGNAL_FUNC) fe_recode_cmd); command_unbind("recode add", (SIGNAL_FUNC) fe_recode_add_cmd); command_unbind("recode remove", (SIGNAL_FUNC) fe_recode_remove_cmd); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); -#endif } diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index 2a10ad10..04fa5cb9 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -32,10 +32,8 @@ #include "formats.h" #include "themes.h" #include "translation.h" -#ifdef HAVE_GLIB2 #include "recode.h" #include "utf8.h" -#endif static const char *format_backs = "04261537"; static const char *format_fores = "kbgcrmyw"; @@ -299,7 +297,7 @@ void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, dest->window = window != NULL ? window : window_find_closest(server, target, level); } -#ifdef HAVE_GLIB2 + static int advance (char const **str, gboolean utf8) { if (utf8) { @@ -315,21 +313,17 @@ static int advance (char const **str, gboolean utf8) return 1; } } -#endif + /* Return length of text part in string (ie. without % codes) */ int format_get_length(const char *str) { GString *tmp; int len; -#ifdef HAVE_GLIB2 gboolean utf8; -#endif g_return_val_if_fail(str != NULL, 0); -#ifdef HAVE_GLIB2 utf8 = is_utf8() && g_utf8_validate(str, -1, NULL); -#endif tmp = g_string_new(NULL); len = 0; @@ -346,12 +340,8 @@ int format_get_length(const char *str) if (*str != '%') len++; } -#ifdef HAVE_GLIB2 + len += advance(&str, utf8); -#else - len++; - str++; -#endif } g_string_free(tmp, TRUE); @@ -365,16 +355,13 @@ int format_real_length(const char *str, int len) { GString *tmp; const char *start; -#ifdef HAVE_GLIB2 const char *oldstr; gboolean utf8; -#endif + g_return_val_if_fail(str != NULL, 0); g_return_val_if_fail(len >= 0, 0); -#ifdef HAVE_GLIB2 utf8 = is_utf8() && g_utf8_validate(str, -1, NULL); -#endif start = str; tmp = g_string_new(NULL); @@ -394,15 +381,10 @@ int format_real_length(const char *str, int len) } } -#ifdef HAVE_GLIB2 oldstr = str; len -= advance(&str, utf8); if (len < 0) str = oldstr; -#else - len--; - str++; -#endif } g_string_free(tmp, TRUE); diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c index 691f3742..d97f5c05 100644 --- a/src/fe-common/core/keyboard.c +++ b/src/fe-common/core/keyboard.c @@ -571,11 +571,8 @@ int key_pressed(KEYBOARD_REC *keyboard, const char *key) g_strconcat(keyboard->key_state, "-", key, NULL); g_free_and_null(keyboard->key_state); -#if GLIB_MAJOR_VERSION == 2 -# define GSearchFunc GCompareFunc -#endif rec = g_tree_search(key_states, - (GSearchFunc) key_states_search, + (GCompareFunc) key_states_search, combo); if (rec == NULL) { /* unknown key combo, eat the invalid key diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index 68a1631e..9fe8d587 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -584,13 +584,8 @@ static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) chat_type = chat_protocol_lookup(rec->name); g_return_if_fail(chat_type >= 0); -#if GLIB_MAJOR_VERSION < 2 - name = g_strdup(rec->name); - g_strdown(name+1); -#else name = g_ascii_strdown(rec->name,-1); *name = *(rec->name); -#endif /* window items: channel, query */ type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL"); |