There are comments in the code whereever I have made changes.

FTP-GW.C - This is the only file affected for FTP-GW
---------------------------------------------------------------
* patched for PASV FTP.
* patched for -plug-to option (patch got thru FAQ)

I am describing only the PASV patch. I modified the file so that:

Client <----PASV-----> FTP-GW <----PASV-----> Server

Added a global variable 
static struct sockaddr_in	remotepasvport.
Modified functions:

cmd_pasv()
-----------
Accept a PASV connection request from a client
Create a socket for PASV connection from client.
Get the details of the new socket and create the response string for the client
	i.e. "Entering Passive mode (...)"
Get the remote port details and send a PASV request
Call peerreply function to get the response.
Connect to the remote PASV port
Send the PASV response to the client.

peerreply()
-----------
The modification applies only if the pasvport variable is not equal to -1

If the response matches a PASV response
Do necessary modifications of the received string and pass through porttoaddr function
	and store the details in the global variable remotepasvport.

If the response matches End of Transfer close boundport and pasvport.

pasvcallback()
---------------
Duplicate outgoing port to boundport so that boundport points to the server..
Accept the connection from the client on the pasvport and set the return value to incoming.

So now we have outgoing pointing to the PASV port of remote server and incoming pointing
from the client to the PASV port of the gateway.

main()
------
Did some logical modifications in the main loop so that PASV FTP is facilitated.

sayn()
-----
This function used to write n bytes to the descriptor specified and after that write a "\r\n".
Changed it to write the whole string with "\r\n" i.e. n+2 bytes at one attempt.


HTTP-GW.C - File modified are hmain.c, http-gw.c ftp.c http-gw.h
-----------------------------------------------------------------
* patched for PASV FTP.
* patched for -plug-to option.
* patched to accept !(NOT) in first field of "hosts" or "permit-hosts"
  in netperm-table.

oktotalkto()- hmain.c
---------------------
Patched for ! in the first field of "hosts" or "permit-hosts". This seems to be an unnecessary
patch since I am not using it. I could accomplish what I wanted without NOT itself. If you do
not need this patch overwrite the function oktotalkto() with the original one.
Added global variables
char	*plugdest; /* for -plug-to */
struct sockaddr_in remotepasvport; /* for PASV */


accept_setdest() - hmain.c
--------------------------
Patched for -plug-to functionality.

accept_setplug() - hmain.c (Added)
----------------------------------
Added this function for -plug-to functionality. 

process_request() - http-gw.c
-----------------------------
Patched for -plug-to functionality. If plugdest variable is non NULL the rem_server
variable is set to plugdest

get_ftp_reply() - ftp.c
-----------------------
Patched for PASV FTP.
When a PASV response is received from the remote server
i.e. "Entering Passive Mode (...)" the port addresses are stored in remotepasvport
global variable for later use.
When a PASV Error response is encountered the function returns the appropriate
error value i.e. '5'.

forward_ftp() - ftp.c
---------------------
Patched for PASV FTP. pasv_request() is called before RETR and NLST.
The new function pasv_request does the magic. If pasv_request fails
it continues with normal FTP.

pasv_request() - ftp.c (Added)
------------------------------
This function sends the PASV request to the remote server and calls
get_ftp_reply() to process the PASV response. In case of error this function
returns error otherwise connects to the remote port and returns the descriptor.

porttoaddr() - ftp.c (Added)
----------------------------
This function has been added from ftp-gw.c for parsing through the PASV
response and converting the ASCII address to struct sockaddr_in format.

