|
| iMatix home page | << | < | > | >> |
SMTVersion 2.81 |
#include "smtdefn.h" int smtftpd_init (void)
Initialises the FTP data agent. Returns 0 if initialised okay, -1 if there was an error.
{
AGENT
*agent; /* Handle for our agent */
THREAD
*thread; /* Handle to various threads */
# include "smtftpd.i" /* Include dialog interpreter */
/* Method name Event value Priority */
/* Shutdown event comes from Kernel */
method declare (agent, "SHUTDOWN", shutdown_event, SMT_PRIORITY_MAX);
/* Reply events from socket agent */
method declare (agent, "SOCK_INPUT_OK", ok_event, 0);
method declare (agent, "SOCK_OUTPUT_OK", ok_event, 0);
method declare (agent, "SOCK_READ_OK", ok_event, 0);
method declare (agent, "SOCK_WRITE_OK", ok_event, 0);
method declare (agent, "SOCK_CLOSED", sock_closed_event, 0);
method declare (agent, "SOCK_ERROR", sock_error_event, 0);
method declare (agent, "SOCK_TIMEOUT", sock_timeout_event, 0);
/* Reply events from transfer agent */
method declare (agent, "TRAN_PUTF_OK", finished_event,
SMT_PRIORITY_HIGH);
method declare (agent, "TRAN_GETF_OK", finished_event,
SMT_PRIORITY_HIGH);
method declare (agent, "TRAN_CLOSED", sock_closed_event,
SMT_PRIORITY_HIGH);
method declare (agent, "TRAN_ERROR", sock_error_event,
SMT_PRIORITY_HIGH);
/* Public methods supported by this agent */
method declare (agent, "FTPD_PASSIVE", passive_event,
SMT_PRIORITY_LOW);
method declare (agent, "FTPD_PUT_FILE", put_file_event,
SMT_PRIORITY_NORMAL);
method declare (agent, "FTPD_GET_FILE", get_file_event,
SMT_PRIORITY_NORMAL);
method declare (agent, "FTPD_APPEND_FILE", append_file_event,
SMT_PRIORITY_NORMAL);
method declare (agent, "FTPD_ABORT", abort_event,
SMT_PRIORITY_HIGH);
method declare (agent, "FTPD_CLOSECTRL", close_control_event,
SMT_PRIORITY_HIGH);
/* Private method used to pass initial thread events */
method declare (agent, "_MASTER", master_event, 0);
/* Ensure that operator console is running, else start it up */
smtoper init ();
if ((thread = thread lookup (SMT_OPERATOR, "")) != NULL)
operq = thread-> queue-> qid;
else
return (-1);
/* Ensure that socket i/o agent is running, else start it up */
smtsock init ();
if ((thread = thread lookup (SMT_SOCKET, "")) != NULL)
sockq = thread-> queue-> qid;
else
return (-1);
/* Ensure that timer agent is running, else start it up */
smttime init ();
if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
timeq = thread-> queue-> qid;
else
return (-1);
/* Ensure that transfer agent is running, else start it up */
smttran init ();
if ((thread = thread lookup (SMT_TRANSFER, "")) != NULL)
tranq = thread-> queue-> qid;
else
return (-1);
/* Create initial thread to manage master port */
if ((thread = thread create (AGENT_NAME, "")) != NULL)
{
SEND (&thread-> queue-> qid, "_MASTER", "");
((TCB *) thread-> tcb)-> thread_type = master_event;
}
else
return (-1);
pasv_port = sym_create_table ();
/* Signal okay to caller that we initialised okay */
return (0);
}
| | << | < | > | >> |
|