Re: UTF-N support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 22 Jan 2004 at 20:15:39 +0100, Rhialto wrote:
> I've done it already - and I probably sent patches somewhere...

Index: nntpinit.c
===================================================================
RCS file: /cvsroot/trn/trn4/nntpinit.c,v
retrieving revision 1.1
diff -u -r1.1 nntpinit.c
--- nntpinit.c	25 May 2000 05:11:42 -0000	1.1
+++ nntpinit.c	22 Jan 2004 19:16:05 -0000
@@ -135,6 +135,56 @@
 char* machine;
 {
     int s;
+#if INET6
+    struct addrinfo hints, *res, *res0;
+    char portstr[8] = "nntp";
+    char *cause = NULL;
+    int error;
+
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = PF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+    hints.ai_flags = 0;
+    if (nntplink.port_number)
+	sprintf(portstr, "%d", nntplink.port_number);
+    error = getaddrinfo(machine, portstr, &hints, &res0);
+    if (error) {
+	fprintf(stderr, "%s", gai_strerror(error));
+	return -1;
+    }
+    for (res = res0; res; res = res->ai_next) {
+	char buf[64] = "";
+	s = socket(res->ai_family, res->ai_socktype,
+		res->ai_protocol);
+	if (s < 0) {
+	    cause = "socket";
+	    continue;
+	}
+
+	inet_ntop(res->ai_family, res->ai_addr, buf, sizeof(buf));
+	if (res != res0)
+	    fprintf(stderr, "trying %s...", buf);
+
+	if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+	    fprintf(stderr, "connection to %s: ", buf);
+	    perror("");
+	    cause = "connect";
+	    close(s);
+	    s = -1;
+	    continue;
+	}
+
+	break;  /* okay we got one */
+
+    }
+    if (s < 0) {
+	fprintf(stderr, "giving up... ");
+	perror(cause);
+    }
+    freeaddrinfo(res0);
+
+    return s;
+#else	/* INET6 */
     struct sockaddr_in sin;
 #ifdef __hpux
     int socksize = 0;
@@ -268,6 +318,7 @@
 
 #endif /* !EXCELAN */
 #endif /* !h_addr */
+#endif /* INET6 */
 #ifdef __hpux	/* recommended by raj@cup.hp.com */
 #define	HPSOCKSIZE 0x8000
     getsockopt(s, SOL_SOCKET, SO_SNDBUF, (caddr_t)&socksize, (caddr_t)&socksizelen);
Index: rt-ov.ih
===================================================================
RCS file: /cvsroot/trn/trn4/rt-ov.ih,v
retrieving revision 1.1
diff -u -r1.1 rt-ov.ih
--- rt-ov.ih	25 May 2000 05:11:42 -0000	1.1
+++ rt-ov.ih	22 Jan 2004 19:16:05 -0000
@@ -14,7 +14,8 @@
 #define OV_XREF 	8
 
 /* How many overview lines to read with one NNTP call */
-#define OV_CHUNK_SIZE	40
+/* #define OV_CHUNK_SIZE	40 */
+#define OV_CHUNK_SIZE	40000
 
 static int hdrnum[] = {
     0, SUBJ_LINE, FROM_LINE, DATE_LINE, MSGID_LINE,
Index: url.c
===================================================================
RCS file: /cvsroot/trn/trn4/url.c,v
retrieving revision 1.1
diff -u -r1.1 url.c
--- url.c	25 May 2000 05:11:42 -0000	1.1
+++ url.c	22 Jan 2004 19:16:05 -0000
@@ -43,12 +43,57 @@
 static int  url_port;
 static char url_path[1024];
 
+/*
+ * Why does this not use get_tcp_socket() from nntpinit.c, or vice versa?
+ */
 static int
 get_url_socket(machine,port)
 char* machine;
 int port;
 {
     int s;
+#if INET6
+    struct addrinfo hints, *res, *res0;
+    char portstr[8] = "nntp";
+    char *cause = NULL;
+    int error;
+
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = PF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+    hints.ai_flags = 0;
+    sprintf(portstr, "%d", port);
+    error = getaddrinfo(hostnam, portstr, &hints, &res0);
+    if (error) {
+	fprintf(stderr, "%s", gai_strerror(error));
+	return -1;
+    }
+    nsock = 0;
+    for (res = res0; res; res = res->ai_next) {
+	s = socket(res->ai_family, res->ai_socktype,
+		res->ai_protocol);
+	if (s < 0) {
+	    cause = "socket";
+	    continue;
+	}
+
+	if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+	    cause = "connect";
+	    close(s);
+	    s = -1;
+	    continue;
+	}
+
+	break;  /* okay we got one */
+
+    }
+    if (s < 0) {
+	perror(cause);
+    }
+    freeaddrinfo(res0);
+
+    return s;
+#else	/* INET6 */
     struct sockaddr_in sin;
 #ifdef __hpux
     int socksize = 0;
@@ -153,6 +198,7 @@
 	return -1;
     }
 #endif /* !h_addr */
+#endif /* INET6 */
 #ifdef __hpux	/* recommended by raj@cup.hp.com */
 #define	HPSOCKSIZE 0x8000
     getsockopt(s, SOL_SOCKET, SO_SNDBUF, (caddr_t)&socksize, (caddr_t)&socksizelen);
@@ -316,7 +362,18 @@
 	/* normal URL type, will have host (optional portnum) */
 	s += 2;
 	p = url_host;
-	while (*s && *s != '/' && *s != ':') *p++ = *s++;
+	/* check for address literal: news://[ip:v6:address]:port/ */
+	if (*s == '[') {
+	    while (*s && *s != ']')
+		*p++ = *s++;
+	    if (!*s) {
+		printf("Bad address literal: %s\n",url) FLUSH;
+		return FALSE;
+	    }
+	    s++;	/* skip ] */
+	} else {
+	    while (*s && *s != '/' && *s != ':') *p++ = *s++;
+	}
 	*p = '\0';
 	if (!*s) {
 	    printf("Incomplete URL: %s\n",url) FLUSH;

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert
\X/ rhialto/at/xs4all.nl        -- Cetero censeo "authored" delendum esse.


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

[Index of Archives]     [Photo]     [Yosemite]     [Epson Inkjet]     [Mhonarc]     [Nntpcache]

  Powered by Linux