[w3m-dev-en 00085] port of W3M 0.16 to DJGPP

From: Ken Yap (ken@nlc.net.au)
Date: Wed Feb 23 2000 - 21:53:36 CST


Hi, I did a port to DJGPP. You can get the patched sources from
http://members.xoom.com/ken_yap

However here are some patches which I think should be applied to all
platforms. The fdopen changes are due to the fact that DOS has text/binary
files. The getservbyname call was removed because all it was doing was
making a unsigned short to store the port number. An alternative to
SIGWINCH is needed for platforms that don't have SIGWINCH. The lstat
call should be surrounded by a ifdef READLINK.

        Ken

--- file.c.old Fri Jan 21 18:18:57 2000
+++ file.c Thu Feb 24 03:20:07 2000
@@ -4969,7 +4969,7 @@
   }
   close(fd1[1]);
   fclose(infp);
- return fdopen(fd1[0], "r");
+ return fdopen(fd1[0], "rb");
 }
 
 static FILE *
--- form.c.old Fri Jan 14 17:13:29 2000
+++ form.c Tue Feb 22 00:00:00 2000
@@ -498,8 +498,10 @@
         name, mybasename(file));
   fprintf(f, "Content-Type: text/plain\r\n\r\n");
 
+#ifdef READLINK
   if (lstat(file, &st) < 0)
     goto write_end;
+#endif
   if (S_ISDIR(st.st_mode))
     goto write_end;
   fd = fopen(file, "r");
--- ftp.c.old Wed Jan 12 15:23:33 2000
+++ ftp.c Thu Feb 24 03:19:30 2000
@@ -104,8 +104,8 @@
   fd = openSocket(host,"ftp",21);
   if (fd < 0)
     return -1;
- ftp->rcontrol = fdopen(fd,"r");
- ftp->wcontrol = fdopen(dup(fd),"w");
+ ftp->rcontrol = fdopen(fd,"rb");
+ ftp->wcontrol = fdopen(dup(fd),"wb");
   ftp->data = NULL;
   tmp = read_response(ftp);
   if (atoi(tmp->ptr) != 220)
@@ -158,7 +158,7 @@
   data_s = openSocket(tmp->ptr,"",p1*256+p2);
   if (data_s < 0)
     return -1;
- ftp->data = fdopen(data_s,"r");
+ ftp->data = fdopen(data_s,"rb");
   return 0;
 }
 
--- main.c.old Fri Jan 21 18:18:58 2000
+++ main.c Thu Feb 24 03:20:58 2000
@@ -433,7 +433,7 @@
     }
     if (!isatty(0)) { /* redirected input */
       fmInit();
- redin = fdopen(dup(0), "r");
+ redin = fdopen(dup(0), "rb");
       newbuf = openGeneralPagerBuffer(redin);
       dup2(1, 0);
       Firstbuf = Currentbuf = newbuf;
@@ -493,6 +493,9 @@
   }
 #ifdef SIGWINCH
   signal(SIGWINCH, resize_hook);
+#else
+ setlinescols();
+ setupscreen();
 #endif
   Currentbuf = Firstbuf;
   displayBuffer(Currentbuf, B_NORMAL);
--- url.c.old Fri Jan 14 18:21:24 2000
+++ url.c Thu Feb 24 03:19:43 2000
@@ -212,8 +212,8 @@
 #else
   struct sockaddr_in hostaddr;
   struct hostent *entry;
- struct servent *serv;
   struct protoent *proto;
+ unsigned short s_port;
   int a1, a2, a3, a4;
   unsigned long adr;
 #endif
@@ -276,10 +276,7 @@
       break;
   }
 #else
- if ((serv = getservbyname(remoteport_name, "tcp")) == NULL) {
- serv = New(struct servent);
- }
- serv->s_port = htons(remoteport_num);
+ s_port = htons(remoteport_num);
   bzero((char *) &hostaddr, sizeof(struct sockaddr_in));
   if ((proto = getprotobyname("tcp")) == NULL) {
     /* protocol number of TCP is 6 */
@@ -295,7 +292,7 @@
     adr = htonl((a1<<24)|(a2<<16)|(a3<<8)|a4);
     bcopy((void*)&adr,(void*)&hostaddr.sin_addr,sizeof(long));
     hostaddr.sin_family = AF_INET;
- hostaddr.sin_port = serv->s_port;
+ hostaddr.sin_port = s_port;
     if (connect(sock, (struct sockaddr *) & hostaddr,
                 sizeof(struct sockaddr_in)) < 0) {
       goto error;
@@ -308,7 +305,7 @@
       goto error;
     }
     hostaddr.sin_family = AF_INET;
- hostaddr.sin_port = serv->s_port;
+ hostaddr.sin_port = s_port;
     for ( h_addr_list = entry->h_addr_list ; *h_addr_list ; h_addr_list ++ )
     {
       bcopy((void*)h_addr_list[0], (void*)&hostaddr.sin_addr, entry->h_length);
@@ -1056,8 +1053,8 @@
     sock = openSocket(p, "nntp", pu->port);
     if (sock < 0)
       return uf;
- f = fdopen(sock, "r");
- fw = fdopen(sock, "w");
+ f = fdopen(sock, "rb");
+ fw = fdopen(sock, "wb");
     if (f == NULL || fw == NULL)
       return uf;
     tmp = Strfgets(f);
@@ -1084,7 +1081,7 @@
   case SCM_UNKNOWN:
     return uf;
   }
- uf.stream.f = fdopen(sock, "r");
+ uf.stream.f = fdopen(sock, "rb");
   uf.close = (void(*)())fclose;
   return uf;
 }



This archive was generated by hypermail 2b29 : Wed Jul 19 2000 - 10:30:43 CDT