diff -N -c -r -X exclude_files squid-1.0.beta5/src/ftpget.c squid-1.0.beta5.henrik/src/ftpget.c
*** squid-1.0.beta5/src/ftpget.c	Fri May  3 00:51:16 1996
--- squid-1.0.beta5.henrik/src/ftpget.c	Fri May  3 02:27:19 1996
***************
*** 127,132 ****
--- 127,133 ----
  #define F_TRYDIR	0x10
  #define F_NEEDACCEPT	0x20
  #define F_USEBASE	0x40
+ #define F_BASEDIR	0x80
  
  typedef enum {
      BEGIN,
***************
*** 468,473 ****
--- 469,475 ----
  	tv.tv_sec = o_timeout;
  	tv.tv_usec = 0;
  	FD_ZERO(&R);
+ 	FD_ZERO(&W);
  	FD_SET(fd, &W);
  	FD_SET(0, &R);
  	last_alarm_set = time(NULL);
***************
*** 1295,1301 ****
  
      Debug(26,10,("do_cwd: \"%s\"\n",r->path));
  
!     if (!strcmp(r->path, "."))
  	return CWD_OK;
  
      sprintf(cbuf, "CWD %s", r->path);
--- 1297,1303 ----
  
      Debug(26,10,("do_cwd: \"%s\"\n",r->path));
  
!     if (r->flags & F_BASEDIR)
  	return CWD_OK;
  
      sprintf(cbuf, "CWD %s", r->path);
***************
*** 1790,1801 ****
  	    write_with_timeout(r->cfd, l->ptr, strlen(l->ptr));
  	fprintf(wfp, "</PRE>\n");
  	fprintf(wfp, "<HR>\n");
!     } else if (r->readme_fp) {
  	fprintf(wfp, "<H4>README file from %s</H4>\n", r->title_url);
  	fprintf(wfp, "<PRE>\n");
  	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
  	    fputs(buf, wfp);
  	fclose(r->readme_fp);
  	fprintf(wfp, "</PRE>\n");
  	fprintf(wfp, "<HR>\n");
      }
--- 1792,1804 ----
  	    write_with_timeout(r->cfd, l->ptr, strlen(l->ptr));
  	fprintf(wfp, "</PRE>\n");
  	fprintf(wfp, "<HR>\n");
!     } else if (r->readme_fp && r->flags&F_BASEDIR) {
  	fprintf(wfp, "<H4>README file from %s</H4>\n", r->title_url);
  	fprintf(wfp, "<PRE>\n");
  	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
  	    fputs(buf, wfp);
  	fclose(r->readme_fp);
+ 	r->readme_fp=NULL;
  	fprintf(wfp, "</PRE>\n");
  	fprintf(wfp, "<HR>\n");
      }
***************
*** 1803,1809 ****
      fprintf(wfp, "FTP Directory: %s\n", r->title_url);
      fprintf(wfp, "</H2>\n");
      fprintf(wfp, "<PRE>\n");
!     if (strcmp(r->path, ".")) {
  	if ((t = htmlize_list_entry("..", r))) {
  	    fputs(t, wfp);
  	    xfree(t);
--- 1806,1812 ----
      fprintf(wfp, "FTP Directory: %s\n", r->title_url);
      fprintf(wfp, "</H2>\n");
      fprintf(wfp, "<PRE>\n");
!     if (!(r->flags&F_BASEDIR)) {
  	if ((t = htmlize_list_entry("..", r))) {
  	    fputs(t, wfp);
  	    xfree(t);
***************
*** 1836,1841 ****
--- 1839,1853 ----
      }
      fprintf(wfp, "</PRE>\n");
      fprintf(wfp, "<HR>\n");
+     if ( r->readme_fp) {
+ 	fprintf(wfp, "<H4>README file from %s</H4>\n", r->title_url);
+ 	fprintf(wfp, "<PRE>\n");
+ 	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
+ 	    fputs(buf, wfp);
+ 	fclose(r->readme_fp);
+ 	fprintf(wfp, "</PRE>\n");
+ 	fprintf(wfp, "<HR>\n");
+     }
      fprintf(wfp, "<ADDRESS>\n");
      fprintf(wfp, "Generated %s, by %s/%s@%s\n",
  	http_time(stamp), progname, SQUID_VERSION, getfullhostname());
***************
*** 1869,1874 ****
--- 1881,1891 ----
  	    break;
  	case CONNECTED:
  	    r->state = read_welcome(r);
+ 	    if ((r->flags & F_HTTPIFY) && (r->flags & F_BASEDIR) && cmd_msg) {
+ 		list_t *t = r->cmd_msg;
+ 		r->cmd_msg = cmd_msg;
+ 		cmd_msg = t;
+ 	    }
  	    break;
  	case FAIL_CONNECT:
  	    r->state = FAIL_SOFT;
***************
*** 1884,1889 ****
--- 1901,1911 ----
  	    r->state = do_passwd(r);
  	    break;
  	case LOGGED_IN:
+ 	    if ((r->flags & F_HTTPIFY) && (r->flags & F_BASEDIR) && cmd_msg) {
+ 		list_t *t = r->cmd_msg;
+ 		r->cmd_msg = cmd_msg;
+ 		cmd_msg = t;
+ 	    }
  	    r->state = do_type(r);
  	    break;
  	case FAIL_LOGIN:
***************
*** 1913,1932 ****
  	    if(!r->flags & F_ISDIR)
  		r->flags |= F_USEBASE;
  	    r->flags |= F_ISDIR;
! 	    if (strcmp(r->path, ".")) {
  		/* tack on the trailing slash now that we know its a dir */
  		strcat(r->url, "/");
  		strcat(r->title_url, "/");
  		strcat(r->url_escaped, "/");
  	    }
  	    if (r->flags & F_HTTPIFY) {
! 		if (cmd_msg) {
  		    r->cmd_msg = cmd_msg;
! 		    cmd_msg = NULL;
! 		} else {
! 		    if (o_readme)
! 			try_readme(r);
  		}
  	    }
  	    r->state = do_pasv(r);
  	    break;
--- 1935,1954 ----
  	    if(!r->flags & F_ISDIR)
  		r->flags |= F_USEBASE;
  	    r->flags |= F_ISDIR;
! 	    if (!(r->flags&F_BASEDIR)) {
  		/* tack on the trailing slash now that we know its a dir */
  		strcat(r->url, "/");
  		strcat(r->title_url, "/");
  		strcat(r->url_escaped, "/");
  	    }
  	    if (r->flags & F_HTTPIFY) {
! 		if (!(r->flags & F_BASEDIR) || cmd_msg) {
! 		    list_t *t = r->cmd_msg;
  		    r->cmd_msg = cmd_msg;
! 		    cmd_msg = t;
  		}
+ 		if (o_readme)
+ 		    try_readme(r);
  	    }
  	    r->state = do_pasv(r);
  	    break;
***************
*** 2013,2018 ****
--- 2035,2041 ----
  	if (*r->path == '\0') {
  	    t = r->path;
  	    r->path = xstrdup(".");
+ 	    r->flags |= F_BASEDIR;
  	    xfree(t);
  	    again = 1;
  	} else if ((l>=1) && (*(r->path + l - 1) == '/')) {
***************
*** 2403,2409 ****
      }
      strcat(r->url, r->host);
      strcat(r->url, "/");
!     if (strcmp(r->path, "."))
  	strcat(r->url, r->path);
  
      *r->title_url = '\0';
--- 2426,2432 ----
      }
      strcat(r->url, r->host);
      strcat(r->url, "/");
!     if (!(r->flags&F_BASEDIR))
  	strcat(r->url, r->path);
  
      *r->title_url = '\0';
***************
*** 2414,2420 ****
      }
      strcat(r->title_url, r->host);
      strcat(r->title_url, "/");
!     if (strcmp(r->path, "."))
  	strcat(r->title_url, r->path);
  
      /* Make a copy of the escaped URL with some room to grow at the end */
--- 2437,2443 ----
      }
      strcat(r->title_url, r->host);
      strcat(r->title_url, "/");
!     if (!(r->flags&F_BASEDIR))
  	strcat(r->title_url, r->path);
  
      /* Make a copy of the escaped URL with some room to grow at the end */
