mirror of
https://github.com/irssi/irssi.git
synced 2026-08-18 08:02:13 +02:00
Farewell glib-1.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4509 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
cb1287ab63
commit
afa4292466
13 changed files with 9 additions and 507 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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'. */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue