[w3m-dev 03964] IPv4/IPv6 only option patch

"KONDOU, Kazuhiro" <[email protected]>
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>


w3m  IPv4/IPv6 


-4/-6 option  patch 

w3m-0.4.1-m17n-20030308.tar.gz 
 cvs  w3m 


# ports  www/w3m/files 
# ;)

IPv6  build 


global IPv6 


#  w3m-m17n (+ image) -m17n 
# merge 


-- 
KONDOU, Kazuhiro @ Ancient library
site top URL : http://www.alib.jp/
mail address : [email protected]
fingerprint = 18CA 90A9 FDEE FBE1 F69A  D124 9F95 9289 E665 4D2B


--- main.c.orig	Sun Sep 14 02:15:14 2003
+++ main.c	Sun Sep 14 02:15:54 2003
@@ -102,6 +102,9 @@
 #define help() fusage(stdout, 0)
 #define usage() fusage(stderr, 1)
 
+int ipv4_only = 0;
+int ipv6_only = 0;
+
 static void
 fversion(FILE * f)
 {
@@ -239,6 +242,10 @@
     fprintf(f,
 	    "    -title[=TERM]    set buffer name to terminal title string\n");
     fprintf(f, "    -o opt=value     assign value to config option\n");
+#ifdef INET6
+    fprintf(f, "    -4               IPv4 only\n");
+    fprintf(f, "    -6               IPv6 only\n");
+#endif
     fprintf(f, "    -show-option     print all config options\n");
     fprintf(f, "    -config file     specify config file\n");
     fprintf(f, "    -help            print this usage message\n");
@@ -498,6 +505,16 @@
 		    usage();
 		if (atoi(argv[i]) > 0)
 		    PagerMax = atoi(argv[i]);
+	    }
+	    else if (!strcmp("-4", argv[i])){
+		if (ipv6_only)
+		    ipv6_only = 0;
+		ipv4_only = 1;
+	    }
+	    else if (!strcmp("-6", argv[i])) {
+		if (ipv4_only)
+		    ipv4_only = 0;
+		ipv6_only = 1;
 	    }
 #ifdef USE_M17N
 #ifndef DEBIAN			/* XXX: use -o kanjicode={S|J|E} */
--- etc.c.orig	Sun Sep 14 02:15:22 2003
+++ etc.c	Sun Sep 14 01:21:43 2003
@@ -31,6 +31,8 @@
 };
 
 struct auth_pass *passwords = NULL;
+extern int ipv4_only;
+extern int ipv6_only;
 
 int
 columnSkip(Buffer *buf, int offset)
@@ -1965,7 +1967,13 @@
 	char *namebuf;
 
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = *af;
+	if (ipv4_only) {
+	    hints.ai_family = AF_INET;
+	} else if (ipv6_only) {
+	    hints.ai_family = AF_INET6;
+	} else {
+	    hints.ai_family = *af;
+	}
 	hints.ai_socktype = SOCK_STREAM;
 	error = getaddrinfo(host, NULL, &hints, &res0);
 	if (error) {
--- url.c.orig	Sun Sep 14 02:15:31 2003
+++ url.c	Sun Sep 14 01:46:09 2003
@@ -38,7 +38,13 @@
     {PF_INET, PF_INET6, PF_UNSPEC},	/* 1:inet inet6 */
     {PF_INET6, PF_INET, PF_UNSPEC}	/* 2:inet6 inet */
 };
+int ai_family_order_table_only[2][1] = {
+    {PF_INET}, /* 0: IPv4 only */
+    {PF_INET6} /* 1: IPv6 only */
+};
 #endif				/* INET6 */
+extern int ipv4_only;
+extern int ipv6_only;
 
 static JMP_BUF AbortLoading;
 
@@ -481,7 +487,13 @@
     }
     for (af = ai_family_order_table[DNS_order];; af++) {
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = *af;
+ 	if (ipv4_only) {
+	    hints.ai_family = PF_INET;
+	} else if (ipv6_only) {
+	    hints.ai_family = PF_INET6;
+	} else {
+	    hints.ai_family = *af;
+	}
 	hints.ai_socktype = SOCK_STREAM;
 	if (remoteport_num != 0) {
 	    Str portbuf = Sprintf("%d", remoteport_num);
@@ -1956,8 +1968,16 @@
 	struct addrinfo *res, *res0;
 	char addr[4 * 16];
 	int *af;
+	int *af_start;
 
-	for (af = ai_family_order_table[DNS_order];; af++) {
+	if (ipv4_only) {
+	    af_start = ai_family_order_table_only[0];
+	} else if (ipv6_only) {
+	    af_start = ai_family_order_table_only[0];
+	} else {
+	    af_start = ai_family_order_table[DNS_order];
+	}
+	for (af = af_start;; af++) {
 	    memset(&hints, 0, sizeof(hints));
 	    hints.ai_family = *af;
 	    error = getaddrinfo(domain, NULL, &hints, &res0);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.