45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
|
#include <stdlib.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include "pbx.h"
|
||
|
#include "server.h"
|
||
|
#include "debug.h"
|
||
|
|
||
|
static void terminate(int status);
|
||
|
|
||
|
/*
|
||
|
* "PBX" telephone exchange simulation.
|
||
|
*
|
||
|
* Usage: pbx <port>
|
||
|
*/
|
||
|
int main(int argc, char* argv[]){
|
||
|
// Option processing should be performed here.
|
||
|
// Option '-p <port>' is required in order to specify the port number
|
||
|
// on which the server should listen.
|
||
|
|
||
|
// Perform required initialization of the PBX module.
|
||
|
debug("Initializing PBX...");
|
||
|
pbx = pbx_init();
|
||
|
|
||
|
// TODO: Set up the server socket and enter a loop to accept connections
|
||
|
// on this socket. For each connection, a thread should be started to
|
||
|
// run function pbx_client_service(). In addition, you should install
|
||
|
// a SIGHUP handler, so that receipt of SIGHUP will perform a clean
|
||
|
// shutdown of the server.
|
||
|
|
||
|
fprintf(stderr, "You have to finish implementing main() "
|
||
|
"before the PBX server will function.\n");
|
||
|
|
||
|
terminate(EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
* Function called to cleanly shut down the server.
|
||
|
*/
|
||
|
static void terminate(int status) {
|
||
|
debug("Shutting down PBX...");
|
||
|
pbx_shutdown(pbx);
|
||
|
debug("PBX server terminating");
|
||
|
exit(status);
|
||
|
}
|