diff -c -r -X exclude_files squid-1.0.alpha9/include/util.h squid-1.0.alpha9.henrik/include/util.h *** squid-1.0.alpha9/include/util.h Wed Mar 27 02:46:40 1996 --- squid-1.0.alpha9.henrik/include/util.h Mon Apr 8 18:14:54 1996 *************** *** 154,159 **** --- 154,160 ---- void debug_disable _PARAMS((int)); void debug_flag _PARAMS((char *)); int debug_ok _PARAMS((int, int)); + int debug_level _PARAMS((int)); #define HOST_CACHE_TTL 3600 diff -c -r -X exclude_files squid-1.0.alpha9/lib/debug.c squid-1.0.alpha9.henrik/lib/debug.c *** squid-1.0.alpha9/lib/debug.c Tue Mar 19 02:29:11 1996 --- squid-1.0.alpha9.henrik/lib/debug.c Mon Apr 8 18:14:38 1996 *************** *** 36,41 **** --- 36,42 ---- Log("Enabling debugging for Section %d, level %d.\n", s, l == -2 ? 99 : l); #endif } + /* * debug_disable() - Disables debugging output for section s, level l. */ *************** *** 46,51 **** --- 47,63 ---- return; Log("Disabling debugging for Section %d.\n", s); Harvest_debug_levels[s] = -1; + } + + /* + * debug_level() - Returns debug level for section s + */ + int debug_level(s) + int s; + { + if (s > MAX_DEBUG_LEVELS || s < 0) + return 0; + return Harvest_debug_levels[s]; } /* diff -c -r -X exclude_files squid-1.0.alpha9/src/debug.c squid-1.0.alpha9.henrik/src/debug.c *** squid-1.0.alpha9/src/debug.c Mon Apr 1 06:56:48 1996 --- squid-1.0.alpha9.henrik/src/debug.c Mon Apr 8 19:38:19 1996 *************** *** 121,126 **** --- 121,137 ---- } } + /* + * debug_level() - Returns debug level for section s + */ + int debug_level(s) + int s; + { + if (s > MAX_DEBUG_SECTIONS || s < 0) + return 0; + return debugLevels[s]; + } + void _db_init(logfile) char *logfile; { diff -c -r -X exclude_files squid-1.0.alpha9/src/ftp.c squid-1.0.alpha9.henrik/src/ftp.c *** squid-1.0.alpha9/src/ftp.c Thu Apr 4 20:41:24 1996 --- squid-1.0.alpha9.henrik/src/ftp.c Mon Apr 8 20:30:14 1996 *************** *** 21,26 **** --- 21,27 ---- char request[MAX_URL]; char user[MAX_URL]; char password[MAX_URL]; + int port; char *type; char *mime_hdr; int ftp_fd; *************** *** 42,65 **** xfree(data); } - /* XXX: this does not support FTP on a different port! */ int ftp_url_parser(url, data) char *url; FtpData *data; { static char atypebuf[MAX_URL]; static char hostbuf[MAX_URL]; char *tmp = NULL; int t; char *host = data->host; char *request = data->request; char *user = data->user; char *password = data->password; /* initialize everything */ atypebuf[0] = hostbuf[0] = '\0'; request[0] = host[0] = user[0] = password[0] = '\0'; t = sscanf(url, "%[a-zA-Z]://%[^/]%s", atypebuf, hostbuf, request); if ((t < 2) || !(!strcasecmp(atypebuf, "ftp") || !strcasecmp(atypebuf, "file"))) { --- 43,68 ---- xfree(data); } int ftp_url_parser(url, data) char *url; FtpData *data; { static char atypebuf[MAX_URL]; static char hostbuf[MAX_URL]; + char userbuf[MAX_URL]; char *tmp = NULL; int t; char *host = data->host; char *request = data->request; char *user = data->user; char *password = data->password; + int *port = &data->port; /* initialize everything */ atypebuf[0] = hostbuf[0] = '\0'; request[0] = host[0] = user[0] = password[0] = '\0'; + /* Split into type://hostinfo/path */ t = sscanf(url, "%[a-zA-Z]://%[^/]%s", atypebuf, hostbuf, request); if ((t < 2) || !(!strcasecmp(atypebuf, "ftp") || !strcasecmp(atypebuf, "file"))) { *************** *** 79,91 **** * * So we must try to make sense of it. */ ! /* XXX: this only support [user:passwd@]host */ ! t = sscanf(hostbuf, "%[^:]:%[^@]@%s", user, password, host); ! if (t < 3) { ! strcpy(host, user); /* no login/passwd information */ strcpy(user, "anonymous"); strcpy(password, getFtpUser()); } /* we need to convert user and password for URL encodings */ tmp = url_convert_hex(user); strcpy(user, tmp); --- 82,114 ---- * * So we must try to make sense of it. */ ! /* Get user information */ ! t = sscanf(hostbuf, "%[^@]@%s", userbuf, host); ! if (t == 2) { ! /* XXX: This does not support URLs with only password info. ! * URLs without username is handled as anonymous ! */ ! t = sscanf(userbuf, "%[^:]:%s", user, password); ! if (t < 2) { ! strcpy(password, ""); ! } ! if (t < 1) { ! /* XXX: Here we could use 401 */ ! goto nouser; ! } ! } else { ! nouser: ! strcpy(host, userbuf); /* no login/passwd information */ strcpy(user, "anonymous"); strcpy(password, getFtpUser()); } + + /* Get port number */ + t=sscanf(host,"%[^:]:%d",hostbuf,port); + if(t < 2) + *port=0; + strcpy(host,hostbuf); + /* we need to convert user and password for URL encodings */ tmp = url_convert_hex(user); strcpy(user, tmp); *************** *** 354,359 **** --- 377,386 ---- sprintf(tbuf, "-n %d ", getNegativeTTL()); strcat(buf, tbuf); } + if (data->port) { + sprintf(tbuf,"-P %d ", data->port); + strcat(buf, tbuf); + } strcat(buf, "-h "); /* httpify */ strcat(buf, "- "); /* stdout */ strcat(buf, data->host); *************** *** 476,482 **** int pid; int fd; int p[2]; ! static char pbuf[128]; char *ftpget = getFtpProgram(); if (pipe(p) < 0) { --- 503,510 ---- int pid; int fd; int p[2]; ! char pbuf[128]; ! char dbuf[10]; char *ftpget = getFtpProgram(); if (pipe(p) < 0) { *************** *** 503,509 **** for (fd = 3; fd < fdstat_biggest_fd(); fd++) (void) close(fd); sprintf(pbuf, "%d", 3131); ! execlp(ftpget, ftpget, "-D26,1", "-S", pbuf, NULL); debug(9, 0, "ftpInitialize: %s: %s\n", ftpget, xstrerror()); _exit(1); return (1); /* eliminate compiler warning */ --- 531,542 ---- for (fd = 3; fd < fdstat_biggest_fd(); fd++) (void) close(fd); sprintf(pbuf, "%d", 3131); ! if(debug_level(26)) { ! sprintf(dbuf,"-D26,%d",debug_level(26)); ! execlp(ftpget, ftpget, dbuf, "-S", pbuf, NULL); ! } else { ! execlp(ftpget, ftpget, "-S", pbuf, NULL); ! } debug(9, 0, "ftpInitialize: %s: %s\n", ftpget, xstrerror()); _exit(1); return (1); /* eliminate compiler warning */ diff -c -r -X exclude_files squid-1.0.alpha9/src/ftpget.c squid-1.0.alpha9.henrik/src/ftpget.c *** squid-1.0.alpha9/src/ftpget.c Thu Apr 4 21:03:36 1996 --- squid-1.0.alpha9.henrik/src/ftpget.c Mon Apr 8 20:12:27 1996 *************** *** 156,161 **** --- 156,162 ---- typedef struct _request { char *host; + int port; char *path; char *type; char *user; *************** *** 771,777 **** /* * do_connect() ! * Connect to the FTP server r->host on port 21. * * Returns states: * CONNECTED --- 772,778 ---- /* * do_connect() ! * Connect to the FTP server r->host on r->port. * * Returns states: * CONNECTED *************** *** 797,808 **** h = get_host(r->host); memcpy(&(S.sin_addr.s_addr), h->ipaddr, h->addrlen); S.sin_family = AF_INET; ! S.sin_port = htons(FTP_PORT); if (connect(sock, (struct sockaddr *) &S, sizeof(S)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "%s (port %d): %s", ! r->host, FTP_PORT, xstrerror()); r->rc = 3; return FAIL_CONNECT; } --- 798,809 ---- h = get_host(r->host); memcpy(&(S.sin_addr.s_addr), h->ipaddr, h->addrlen); S.sin_family = AF_INET; ! S.sin_port = htons(r->port); if (connect(sock, (struct sockaddr *) &S, sizeof(S)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "%s (port %d): %s", ! r->host, r->port, xstrerror()); r->rc = 3; return FAIL_CONNECT; } *************** *** 1935,1940 **** --- 1936,1942 ---- fprintf(stderr, "\t-w chars Filename width in directory listing\n"); fprintf(stderr, "\t-W Wrap long filenames\n"); fprintf(stderr, "\t-Ddbg Debug options\n"); + fprintf(stderr, "\t-P port FTP Port number\n"); fprintf(stderr, "\t-v Version\n"); fprintf(stderr, "\n"); fprintf(stderr, "usage: %s -S port\n", progname); *************** *** 1953,1958 **** --- 1955,1961 ---- int i; int len; int j, k; + int port = FTP_PORT; fullprogname = xstrdup(argv[0]); if ((t = strrchr(argv[0], '/'))) { *************** *** 2086,2100 **** o_readme = 0; } else if (!strcmp(*argv, "-W")) { o_list_wrap = 1; } else if (!strcmp(*argv, "-v")) { printf("%s version %s\n", progname, SQUID_VERSION); exit(0); } else { usage(); exit(1); ! } ! } ! if (argc != 6) { fprintf(stderr, "Too many arguments left (%d)\n", argc); usage(); --- 2089,2111 ---- o_readme = 0; } else if (!strcmp(*argv, "-W")) { o_list_wrap = 1; + } else if (!strcmp(*argv, "-P")) { + if (--argc < 1) + usage(); + argv++; + j = atoi(*argv); + if (j > 0) + port = j; + continue; } else if (!strcmp(*argv, "-v")) { printf("%s version %s\n", progname, SQUID_VERSION); exit(0); } else { usage(); exit(1); ! } ! } ! if (argc != 6) { fprintf(stderr, "Too many arguments left (%d)\n", argc); usage(); *************** *** 2113,2118 **** --- 2124,2130 ---- r->type = xstrdup(argv[3]); r->user = xstrdup(argv[4]); r->pass = xstrdup(argv[5]); + r->port = port; r->sfd = -1; r->dfd = -1; r->size = -1;