Santronics Software, Inc.,
wcBASIC FTPLOGON Hook Example

For Wildcat! FTP session, if the special ftplogon.wcx application exist, it will be executed after the user enters the password.

In normal FTP sessions, the FTP client sends the following sequence of commands for logging in the user:

FTP> USER username
331 Password required for username
FTP> PASS password
230 User username logged in.

WcFTP will login the user once the PASS password command is received. If successful, the 230 response code is sent to the FTP client.

If the compiled ftplogon.wcx exist when the FTP user logs in, it will be executed in response to the PASS command.

The following is an example FTPLOGON application:

//------------------------------------------------------------------
// File:  ftplogon.wcc
// About: FTP server LOGON hook
//
// How to use this wcBASIC module:
// -------------------------------
//
// In FTP, the FTP client sends the the following sequence for
// logging in:
//
//  FTP> USER username
//  331 Password required for username
//  FTP> PASS password
//  230 User username logged in.
//
// WcFTP will login the user once the PASS password command is
// received.  If successful, the 230 response code is sent to
// the FTP client.
//
// If the compiled ftplogon.wcx exist when the FTP user logs in,
// it will be executed in response to the PASS command.
//
// VERY IMPORTANT:
//
// If GlobalResult is set to FALSE, then what is expected
// is a passive (quiet) operation which means no PRINT command
// is used to send output.  The FTP server will complete the
// PASS command by sending the 230 response code.
//
// If GlobalResult is set to TRUE, then the FTP server will
// expect the WCX to send the 230 response code or any other
// response code expected for the PASS command.
//
// One of the main goals of this ftplogon program is to give
// you the opportunity to provide logic to set the current
// user folder by setting the user's extended variables in
// section "FtpDataNode#" where # is the current node number:
//
// [FtpDataNode#]
// Group=filegroup#
// Area=filearea#
// ListFormat=directory list format
//
//------------------------------------------------------------------

dim sect as string        = "FtpDataNode"+Str(GetNode)
dim group as integer      = Val(User.Variable(sect,"Group"))
dim area  as integer      = Val(User.Variable(sect,"Area"))
dim listfmt  as boolean   = Val(User.Variable(sect,"listformat")) <> 0
dim fspec as string       = paramstr(1)

Sub SetDirectoryChange(g as integer, a as integer)
    SetUserVariable(sect,"Group",g)
    SetUserVariable(sect,"Area",a)
End Sub

Sub SetUnixFormat
    SetUserVariable(sect,"ListFormat",0)
End Sub

Sub SetMsDosFormat
    SetUserVariable(sect,"ListFormat",1)
End Sub

Sub NonSilentWelcome
    //
    // If you print something, you must EXIT with
    // GlobalResult = TRUE
    //
    print "230-hello there!"
    print "230-we now have a extended FTP system!"
    print "230-file group : ";group
    print "230-file area  : ";area
    print "230-list format: ";listfmt
    print "230 Successful Login"
    GlobalResult = TRUE
End Sub


//------------------------------------------------------
// Main
//------------------------------------------------------

   //SetDirectoryChange()
   //SetUnixFormat()
   //SetMsDosFormat()
   NonSilentWelcome()