root / trunk / code / projects / colonet / server / Main.cpp @ 938
History | View | Annotate | Download (1.23 KB)
1 |
/**
|
---|---|
2 |
* @file Main.cpp
|
3 |
*
|
4 |
* @author Jason Knichel
|
5 |
*
|
6 |
*/
|
7 |
#include <stdio.h> |
8 |
#include <signal.h> |
9 |
#include <ColonetServer.h> |
10 |
#include <wireless.h> |
11 |
|
12 |
ColonetServer colonet_server; |
13 |
|
14 |
//TODO: what does the parameter a do?
|
15 |
/**
|
16 |
* @brief This function performs any cleanup needed to be done when the program dies.
|
17 |
*
|
18 |
* @return Void
|
19 |
*/
|
20 |
void cleanup(int a) { |
21 |
a = a; |
22 |
|
23 |
//wl_terminate();
|
24 |
printf("todo - close wl port\n");
|
25 |
|
26 |
exit(0);
|
27 |
} |
28 |
|
29 |
/**
|
30 |
* @brief The main function of the server
|
31 |
*
|
32 |
* @param argc The number of command line arguments passed to the program
|
33 |
* @param argv The command line arguments passed to the program
|
34 |
*
|
35 |
* @return 0 on success, negative error code on error
|
36 |
*/
|
37 |
int main(int argc, char** argv) { |
38 |
if (colonet_server.initialize_server(argc, argv) < 0) { |
39 |
fprintf(stderr, "\nThere was an error initializing the server.\n");
|
40 |
return -1; |
41 |
} |
42 |
|
43 |
//register a signal handler to be called when we get a SIGINT signal (killing the server by cntrl+c would generate this)
|
44 |
signal(SIGINT, cleanup); |
45 |
|
46 |
if (colonet_server.start_listening() < 0) { |
47 |
fprintf(stderr, "ColonetServer.start_listening failed.\n");
|
48 |
return -1; |
49 |
} |
50 |
|
51 |
colonet_server.run_position_monitor(); |
52 |
|
53 |
colonet_server.run_server(); |
54 |
|
55 |
colonet_server.run_loop(); |
56 |
|
57 |
return 0; |
58 |
} |