pidgin/pidgin

b73d179268e1
Parents ce30656a8486
Children 0d388fcfd3bf
Remove file descriptor argument from local IP getter functions.

Everything that's left calling it uses -1 and not a real socket.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/284/
--- a/ChangeLog.API Fri Dec 18 01:39:20 2020 -0600
+++ b/ChangeLog.API Fri Dec 18 01:39:49 2020 -0600
@@ -188,6 +188,10 @@
* PurpleLog, purple_log_new, purple_log_write and
PurpleLogLogger->write take a GDateTime instead of a time_t
and struct tm
+ * purple_network_get_local_system_ip no longer takes a file
+ descriptor as first parameter
+ * purple_network_get_my_ip no longer takes a file descriptor
+ as first parameter
* purple_network_listen now takes the protocol family as the second
parameter
* purple_network_listen now takes a boolean indicating external port
--- a/libpurple/core.c Fri Dec 18 01:39:20 2020 -0600
+++ b/libpurple/core.c Fri Dec 18 01:39:49 2020 -0600
@@ -188,7 +188,7 @@
* Call this early on to try to auto-detect our IP address and
* hopefully save some time later.
*/
- purple_network_get_my_ip(-1);
+ purple_network_get_my_ip();
if (ops != NULL && ops->ui_init != NULL)
ops->ui_init();
--- a/libpurple/network.c Fri Dec 18 01:39:20 2020 -0600
+++ b/libpurple/network.c Fri Dec 18 01:39:49 2020 -0600
@@ -105,8 +105,8 @@
return purple_prefs_get_string("/purple/network/public_ip");
}
-const char *
-purple_network_get_local_system_ip(int fd)
+const gchar *
+purple_network_get_local_system_ip(void)
{
struct ifreq buffer[100];
guchar *it, *it_end;
@@ -116,17 +116,17 @@
struct sockaddr_in *sinptr;
guint32 lhost = g_htonl((127 << 24) + 1); /* 127.0.0.1 */
long unsigned int add;
- int source = fd;
+ int source;
- if (fd < 0)
- source = socket(PF_INET,SOCK_STREAM, 0);
+ source = socket(PF_INET, SOCK_STREAM, 0);
ifc.ifc_len = sizeof(buffer);
ifc.ifc_req = buffer;
ioctl(source, SIOCGIFCONF, &ifc);
- if (fd < 0 && source >= 0)
+ if (source >= 0) {
close(source);
+ }
it = (guchar*)buffer;
it_end = it + ifc.ifc_len;
@@ -202,8 +202,8 @@
return g_hostname_is_ip_address(hostname);
}
-const char *
-purple_network_get_my_ip(int fd)
+const gchar *
+purple_network_get_my_ip(void)
{
const char *ip = NULL;
PurpleStunNatDiscovery *stun;
@@ -232,7 +232,7 @@
}
/* Just fetch the IP of the local system */
- return purple_network_get_local_system_ip(fd);
+ return purple_network_get_local_system_ip();
}
gchar *
--- a/libpurple/network.h Fri Dec 18 01:39:20 2020 -0600
+++ b/libpurple/network.h Fri Dec 18 01:39:49 2020 -0600
@@ -75,7 +75,6 @@
/**
* purple_network_get_local_system_ip:
- * @fd: The fd to use to help figure out the IP, or else -1.
*
* Returns the IP address of the local system.
*
@@ -87,11 +86,10 @@
*
* Returns: The local IP address.
*/
-const char *purple_network_get_local_system_ip(int fd);
+const gchar *purple_network_get_local_system_ip(void);
/**
* purple_network_get_my_ip:
- * @fd: The fd to use to help figure out the IP, or -1.
*
* Returns the IP address that should be used anywhere a
* public IP addresses is needed (listening for an incoming
@@ -108,7 +106,7 @@
*
* Returns: The local IP address to be used.
*/
-const char *purple_network_get_my_ip(int fd);
+const gchar *purple_network_get_my_ip(void);
/**
* purple_network_get_my_ip_from_gio:
--- a/pidgin/gtkprefs.c Fri Dec 18 01:39:20 2020 -0600
+++ b/pidgin/gtkprefs.c Fri Dec 18 01:39:49 2020 -0600
@@ -1778,7 +1778,7 @@
ip = purple_pmp_get_public_ip();
if (ip == NULL) {
/* Just fetch the IP of the local system */
- ip = purple_network_get_local_system_ip(-1);
+ ip = purple_network_get_local_system_ip();
}
}
}