| iMatix home page | << | < | > | >> |
SMT Version 2.81 |
#include "smtdefn.h" int smtftpc_init (char *p_rootdir) /* Server root directory */
Initialises the FTP control 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 "smtftpc.i" /* Include dialog interpreter */ /* Method name Event value Priority */ /* Shutdown event comes from Kernel */ method declare (agent, "SHUTDOWN", shutdown_event, SMT_PRIORITY_MAX); /* Restart can come from control panel and HTTP agent */ method declare (agent, "RESTART", restart_event, 0); method declare (agent, "RELOAD", reload_event, 0); /* Reply events from socket agent */ method declare (agent, "SOCK_INPUT_OK", input_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 timer agent */ method declare (agent, "TIME_ALARM", timeout_event, SMT_PRIORITY_LOW); /* Reply events from FTP data agent */ method declare (agent, "FTPD_CONNECTED", connected_event, SMT_PRIORITY_LOW); method declare (agent, "FTPD_ERROR", error_event, SMT_PRIORITY_LOW); method declare (agent, "FTPD_END", end_event, SMT_PRIORITY_HIGH); method declare (agent, "FTPD_PASS_OK", ok_event, SMT_PRIORITY_LOW); method declare (agent, "FTPD_ABORTED", aborted_event, SMT_PRIORITY_HIGH); /* Private methods used to pass initial thread events */ method declare (agent, "_MASTER", master_event, 0); method declare (agent, "_CLIENT", client_event, 0); /* Private methods used between threads */ method declare (agent, "_CANCEL", cancel_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 FTP data agent is running, else start it up */ smtftpd init (); if ((thread = thread lookup (SMT_FTPD, "")) != NULL) dataq = thread-> queue-> qid; else return (-1); /* Create initial thread to manage master port */ if ((thread = thread create (AGENT_NAME, "main")) != NULL) { SEND (&thread-> queue-> qid, "_MASTER", ""); ((TCB *) thread-> tcb)-> thread_type = master_event; ((TCB *) thread-> tcb)-> handle = 0; } else return (-1); this_agent = agent; /* Handle to ourselves */ ftp_initialise (); /* Get root directory */ rootdir = mem_strdup (p_rootdir); /* Get local host addresses table, which may be NULL */ hostaddrs = get_hostaddrs (); /* Signal to caller that we initialised okay */ return (0); }
| << | < | > | >> | Copyright © 1996-99 iMatix Corporation |