mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
fix(portability): replace POSIX-only string funcs and legacy hostent fields
This commit is contained in:
2
Makefile
2
Makefile
@@ -2,7 +2,9 @@ PREFIX ?= /usr/local
|
||||
BUILD_DIR ?= build
|
||||
MESON ?= meson
|
||||
NINJA ?= ninja
|
||||
C_STD ?= c17
|
||||
MESON_SETUP_ARGS ?=
|
||||
MESON_SETUP_ARGS += -Dc_std=$(C_STD)
|
||||
MESON_COMPILE_ARGS ?=
|
||||
MESON_INSTALL_ARGS ?=
|
||||
|
||||
|
||||
@@ -323,8 +323,8 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
|
||||
h = gethostbyname (host);
|
||||
if (h != NULL && h->h_length == 4 && h->h_addr_list[0] != NULL)
|
||||
{
|
||||
memcpy (&addr->sin_addr, h->h_addr, 4);
|
||||
memcpy (&cache_addr, h->h_addr, 4);
|
||||
memcpy (&addr->sin_addr, h->h_addr_list[0], 4);
|
||||
memcpy (&cache_addr, h->h_addr_list[0], 4);
|
||||
cache_host = g_strdup (host);
|
||||
/* cppcheck-suppress memleak */
|
||||
return TRUE;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <glib.h>
|
||||
/* X-Chat
|
||||
* Copyright (C) 1998 Peter Zelezny.
|
||||
*
|
||||
@@ -24,7 +25,7 @@ void
|
||||
history_add (struct history *his, char *text)
|
||||
{
|
||||
free (his->lines[his->realpos]);
|
||||
his->lines[his->realpos] = strdup (text);
|
||||
his->lines[his->realpos] = g_strdup(text);
|
||||
his->realpos++;
|
||||
if (his->realpos == HISTORY_SIZE)
|
||||
his->realpos = 0;
|
||||
|
||||
@@ -1424,9 +1424,9 @@ inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data)
|
||||
HostAddr = gethostbyname (ip);
|
||||
if (HostAddr)
|
||||
{
|
||||
sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr)->s_addr;
|
||||
sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr_list[0])->s_addr;
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session,
|
||||
inet_ntoa (*((struct in_addr *) HostAddr->h_addr)),
|
||||
inet_ntoa (*((struct in_addr *) HostAddr->h_addr_list[0])),
|
||||
NULL, NULL, NULL, 0, tags_data->timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
*/
|
||||
|
||||
/* ipv4 and ipv6 networking functions with a common interface */
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#include <netdb.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -121,11 +124,11 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host)
|
||||
ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (ns->ip6_hostent->ai_canonname)
|
||||
*real_host = strdup (ns->ip6_hostent->ai_canonname);
|
||||
*real_host = g_strdup(ns->ip6_hostent->ai_canonname);
|
||||
else
|
||||
*real_host = strdup (hostname);
|
||||
*real_host = g_strdup(hostname);
|
||||
|
||||
return strdup (ipstring);
|
||||
return g_strdup(ipstring);
|
||||
}
|
||||
|
||||
/* the only thing making this interface unclean, this shitty sok4, sok6 business */
|
||||
|
||||
@@ -1353,29 +1353,29 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
||||
switch (t)
|
||||
{
|
||||
case WORDL('C','A','P','\0'):
|
||||
if (strncasecmp (word[4], "ACK", 3) == 0)
|
||||
if (g_ascii_strncasecmp(word[4], "ACK", 3) == 0)
|
||||
{
|
||||
inbound_cap_ack (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (strncasecmp (word[4], "LS", 2) == 0 || strncasecmp (word[4], "NEW", 3) == 0)
|
||||
else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0 || g_ascii_strncasecmp(word[4], "NEW", 3) == 0)
|
||||
{
|
||||
inbound_cap_ls (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (strncasecmp (word[4], "NAK", 3) == 0)
|
||||
else if (g_ascii_strncasecmp(word[4], "NAK", 3) == 0)
|
||||
{
|
||||
inbound_cap_nak (serv, word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data);
|
||||
}
|
||||
else if (strncasecmp (word[4], "LIST", 4) == 0)
|
||||
else if (g_ascii_strncasecmp(word[4], "LIST", 4) == 0)
|
||||
{
|
||||
inbound_cap_list (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
tags_data);
|
||||
}
|
||||
else if (strncasecmp (word[4], "DEL", 3) == 0)
|
||||
else if (g_ascii_strncasecmp(word[4], "DEL", 3) == 0)
|
||||
{
|
||||
inbound_cap_del (serv, word[1],
|
||||
word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5],
|
||||
|
||||
@@ -1184,7 +1184,7 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
|
||||
if (!len)
|
||||
return 1;
|
||||
|
||||
if (strcasecmp(d1, "auto") == 0)
|
||||
if (g_ascii_strcasecmp(d1, "auto") == 0)
|
||||
{
|
||||
/* Auto switch makes no sense in detached sessions */
|
||||
if (!sess->gui->is_tab)
|
||||
|
||||
Reference in New Issue
Block a user