changeset 8239:5220e0898252

[gaim-migrate @ 8962] Methinks prpl's should be able to specify a range of ports. Also, I don't think Gaim should ever try to bind to ports below 1024... Maybe that should be allowed though, I don't know? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 12 Feb 2004 17:23:17 +0000
parents 32625c0dbba6
children 609a62b8e748
files src/network.c src/network.h
diffstat 2 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/network.c	Thu Feb 12 17:02:35 2004 +0000
+++ b/src/network.c	Thu Feb 12 17:23:17 2004 +0000
@@ -197,15 +197,15 @@
 	return listenfd;
 }
 
-int gaim_network_listen(short portnum)
+int gaim_network_listen(short start, short end)
 {
-	int ret = 0, start, end;
+	int ret = 0;
 
-	if (!gaim_prefs_get_bool("/core/network/ports_range_use") || portnum)
-		return gaim_network_do_listen(portnum);
-
-	start = gaim_prefs_get_int("/core/network/ports_range_start");
-	end = gaim_prefs_get_int("/core/network/ports_range_end");
+	if (gaim_prefs_get_bool("/core/network/ports_range_use") ||
+		(start > end) || (start < 1024) || (end < 1024)) {
+		start = gaim_prefs_get_int("/core/network/ports_range_start");
+		end = gaim_prefs_get_int("/core/network/ports_range_end");
+	}
 
 	for (; start <= end; start++) {
 		ret = gaim_network_do_listen(start);
--- a/src/network.h	Thu Feb 12 17:02:35 2004 +0000
+++ b/src/network.h	Thu Feb 12 17:23:17 2004 +0000
@@ -96,13 +96,14 @@
  * the listening socket, and add a new watcher on the new socket accept
  * returned.
  *
- * @param portnum The port number to bind to, or 0, to let the core decide.
- *                By default, the core will let the kernel pick one at random,
- *                but users are allowed to specify a range.
- *
+ * @param start The port number to bind to, or 0 to let the core decide.
+ *              By default, the core will let the kernel pick one at random,
+ *              but users are allowed to specify a range.
+ * @param end The highest possible port in the range of ports to listen on,
+ *            or 0 to let the core decide.
  * @return The file descriptor of the listening socket.
  */
-int gaim_network_listen(short portnum);
+int gaim_network_listen(short start, short end);
 
 /**
  * Gets a port number from a file descriptor.