
This is a patch to the unix gopher server, gopherd.c and ftp.c (version 1.01),
that will turn more documents into type 9 binary files based on their 
pathname suffix.  

This patch basically just adds more file suffixes to gopherd.c and ftp.c
for turning them into binary types.
We all agree that a better method would be to have a lookup file
(see doc/TODO) which doesn't require patching the source for each
new file suffix.  

Also, I think that the binary type 9 should be the general type for 
all binary files, whether from MSDOS, Macintosh, Unix,  or wherever.  
This patch change ftp.c to type those files with MSDos binary suffixes 
as type 9, rather than type 5.

You can apply this patch with Larry Wall's patch program (available at 
many unix ftp sites), in this way, at the directory containing gopher1.01/
   % patch -p < bintypes.patch

-- Don Gilbert


diff -bwcr gopher1.01/gopherd/ftp.c biogoph/gopherd/ftp.c
*** gopher1.01/gopherd/ftp.c	Tue Jun 23 12:33:00 1992
--- biogoph/gopherd/ftp.c	Wed Jul  8 07:42:33 1992
***************
*** 29,35 ****
  #define GFILE	0		/* Gopher item types */
  #define GDIR	1
  #define GBINHEX	4
! #define GDOSB	5
  #define GUNIXB	9
  
  #define SLEN	255	/* Generic small buffer length */
--- 29,35 ----
  #define GFILE	0		/* Gopher item types */
  #define GDIR	1
  #define GBINHEX	4
! #define GDOSB	9   /* was 5 -- dgg change, pass this as binary */
  #define GUNIXB	9
  
  #define SLEN	255	/* Generic small buffer length */
***************
*** 191,204 ****
  IsBinaryType(thing)
    char *thing;
  {
       static char *binExt[] = {
! 	  ".zip", ".zoo", ".arj", ".arc", ".lzh", ".hyp", ".pak", ".exe", ".com",
! 	  ".ps", ".gif", ".pict", ".pct", ".tiff", ".tif", ".tar", ".Z"
  	  };
       
       int extType, i;
       
!      for (extType = 0; extType < 17; extType++) { 
  	  i = strcasecmp(thing + strlen(thing) - strlen(binExt[extType]),
  			 binExt[extType]);
  	  if (i == 0) return(1);
--- 191,207 ----
  IsBinaryType(thing)
    char *thing;
  {
+ #define NEXT  21 
       static char *binExt[] = {
! 	  ".zip", ".zoo", ".arj", ".arc", ".lzh", ".hyp", ".pak", 
! 	  ".exe", ".com", ".ps", ".gif", ".pict", ".pct", ".tiff", 
! 	  ".jfif", ".jpeg", ".jpg",
! 	  ".tif", ".tar", ".Z", ".tar-z"
  	  };
       
       int extType, i;
       
!      for (extType = 0; extType < NEXT; extType++) { 
  	  i = strcasecmp(thing + strlen(thing) - strlen(binExt[extType]),
  			 binExt[extType]);
  	  if (i == 0) return(1);
***************
*** 229,238 ****
    
  {
       static char ext4[] = ".hqx";
       static char *ext5[] = {".zip", ".zoo", ".arj", ".arc", ".lzh", ".hyp", 
  				 ".pak", ".exe", ".com", ".ps", ".gif", ".pict", 
  				 ".pct", ".tiff", ".tif"};
!      static char *ext9[] = {".tar", ".Z"};
       int extType, i, last;
       char	tmpName[SLEN];	
       
--- 232,243 ----
    
  {
       static char ext4[] = ".hqx";
+ /* dgg -- I think these should all be type 9 == standard binary, 
+    not weird PC-Hqx -- see GDOS change */
       static char *ext5[] = {".zip", ".zoo", ".arj", ".arc", ".lzh", ".hyp", 
  		".pak", ".exe", ".com", ".ps", ".gif", ".pict", 
  		 ".pct", ".tiff", ".tif"};
!      static char *ext9[] = {".tar", ".Z", ".tar-z"};
       int extType, i, last;
       char	tmpName[SLEN];	
       
***************
*** 263,269 ****
  	  }
       }
       
!      for (extType = 0; extType < 2; extType++) {				/* unix binary? */ 
  	  i = strcasecmp(buf + strlen(buf) - strlen(ext9[extType]), 
  			 ext9[extType]);
  	  if (i == 0) {
--- 268,274 ----
  	  }
       }
       
!      for (extType = 0; extType < 3; extType++) {				/* unix binary? */ 
  	  i = strcasecmp(buf + strlen(buf) - strlen(ext9[extType]), 
  			 ext9[extType]);
  	  if (i == 0) {
diff -bwcr gopher1.01/gopherd/gopherd.c biogoph1/gopherd/gopherd.c
*** gopher1.01/gopherd/gopherd.c	Wed Jun 24 18:31:51 1992
--- biogoph/gopherd/gopherd.c	Wed Jul  8 07:43:08 1992
***************
*** 1061,1070 ****
       boolean dirresult;
       int Zefilefd;
       static char Zebuf[64];
       char *cp;
       static char Selstr[512];
  
       
       if (ServerPath != NULL)	     /* Don't overwrite existing path if any */
  	  *ServerPath = Selstr; 
  
--- 1063,1080 ----
       boolean dirresult;
       int Zefilefd;
       static char Zebuf[64];
       char *cp;
       static char Selstr[512];
  
       
+ #define NEXTBIN   23
+      static char *extBin[] = { ".arc", ".arj", ".bck", ".bin",  ".exe", 
+            ".com", ".hyp", ".lzh", ".pak",".pct",  /* << ?? msdos only? */
+            ".gif", ".pict", ".ps", ".tiff", ".tif", 
+ 	     ".jfif", ".jpeg", ".jpg",
+            ".tar", ".Z", ".tar-z", ".zip", ".zoo"};
+      int  extType;
+ 
       if (ServerPath != NULL)	     /* Don't overwrite existing path if any */
  	  *ServerPath = Selstr; 
  
***************
*** 1113,1118 ****
--- 1123,1129 ----
  	  }
  #endif
  
+ /*----- dgg replaced this
  	  else if ((strcmp((char*)filename+strlen(filename)-6,".tar.Z"))== 0){
  	       *ObjType = "9";
  	       *Selstr = '9';
***************
*** 1119,1125 ****
--- 1130,1158 ----
  	       strcpy(Selstr + 1, newpath);
  	       return;
  	  }
+ ---------*/
+ /* dgg: add more types based on name suffix: */
+      for (extType = 0; extType < NEXTBIN; extType++) {    
+ 	    int match;
+           match = strcasecmp(filename+strlen(filename) 
+ 			- strlen(extBin[extType]), extBin[extType]);
+           if (match == 0) {
+               *ObjType = "9";
+               *Selstr = '9';
+               strcpy(Selstr + 1, newpath);
+               return;
+           }
+      }
  
+ 	 if ((strcmp(filename+strlen(filename)-4, ".uue")) == 0) {
+                *ObjType = "6";
+                *Selstr = '6';
+                strcpy(Selstr + 1, newpath);
+                return;
+           }
+ 
+ /* end dgg addons */
+ 
  	  /*** Test and see if the thing exists... ***/
  	  
  	  if ((Zefilefd = ropen(filename, O_RDONLY)) < 0) {
