Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'utils/x11_parse_ip.c')
-rw-r--r--utils/x11_parse_ip.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/x11_parse_ip.c b/utils/x11_parse_ip.c
new file mode 100644
index 00000000..8f6a7bfb
--- /dev/null
+++ b/utils/x11_parse_ip.c
@@ -0,0 +1,21 @@
+/*
+ * Try to make sense of a string as an IPv4 address, for
+ * XDM-AUTHORIZATION-1 purposes.
+ */
+
+#include <stdio.h>
+
+#include "putty.h"
+#include "ssh.h"
+
+bool x11_parse_ip(const char *addr_string, unsigned long *ip)
+{
+ int i[4];
+ if (addr_string &&
+ 4 == sscanf(addr_string, "%d.%d.%d.%d", i+0, i+1, i+2, i+3)) {
+ *ip = (i[0] << 24) | (i[1] << 16) | (i[2] << 8) | i[3];
+ return true;
+ } else {
+ return false;
+ }
+}