fgms 0.11.8
The
FlightGear MultiPlayer Server
project
server.c File Reference
#include "fgt_common.h"
#include "wrappers.h"
#include "fgt_error.h"
#include <libpq-fe.h>

Go to the source code of this file.

Macros

#define Collect(a)
 
#define DEF_DATABASE   "fgtracker"
 
#define DEF_IP_ADDRESS   "192.168.1.105"
 
#define DEF_PORT   "5432"
 
#define DEF_USER_LOGIN   "fgtracker"
 
#define DEF_USER_PWD   "fgtracker"
 
#define EatSpace
 
#define FGT_VERSION   "1.6"
 
#define ISUPPER(a)   (( a >= 'A' )&&( a <= 'Z' ))
 
#define PORT_SCAN_SPEED   20 /* 1000000/PORT_SCAN_SPEED must be integer*/
 
#define PQ_EXEC_SUCCESS(res)   ((PQresultStatus(res) == PGRES_COMMAND_OK)||(PQresultStatus(res) == PGRES_TUPLES_OK))
 

Enumerations

enum  MsgType {
  MT_UNKNOWN, MT_REPLY, MT_PING, MT_CONNECT,
  MT_DISCONNECT, MT_POSITION, MT_PONG, MT_NOWAIT
}
 

Functions

int check_tables (PGconn *conn)
 
int ConnectDB (PGconn **conn)
 
int daemon_init (void)
 
void doit (int fd)
 
char * get_base_name (char *name)
 
void give_help (char *name)
 
int logFlight (PGconn *conn, char *callsign, char *model, char *date, int connect)
 
int logPosition (PGconn *conn, char *callsign, char *date, char *lon, char *lat, char *alt)
 
int main (int argc, char **argv)
 
static void net_exit (void)
 
int net_init ()
 
int parse_commands (int argc, char **argv)
 
int parse_message (char *msg, char *event, char *callsign, char *passwd, char *model, char *lat, char *lon, char *alt, char *time1, char *time2)
 
void sigchld_handler (int s)
 
void signal_handler (int s)
 Signal handling. More...
 
void SQL_Error (PGconn *conn)
 
int test_db_connection ()
 

Variables

static pid_t childpid
 
static int connfd
 
static char * database = (char *)DEF_DATABASE
 
static char * ip_address = (char *)DEF_IP_ADDRESS
 
static int listenfd
 
static char * pgoptions = (char *)""
 
static char * pgtty = (char *)""
 
static pid_t pid
 
static char * port = (char *)DEF_PORT
 
static char * pwd = (char *)DEF_USER_PWD
 
static int run_as_daemon = 0
 
static char * server_addr = 0
 
static uint32_t server_port = SERVER_PORT
 
static char * user = (char *)DEF_USER_LOGIN
 

Macro Definition Documentation

#define Collect (   a)
Value:
off = 0;\
for ( ; i < len; i++ ) { \
c = msg[i]; \
if ( c <= ' ' ) break; \
a[off++] = (char)c; \
} \
a[off] = 0

Definition at line 483 of file server.c.

Referenced by parse_message().

#define DEF_DATABASE   "fgtracker"

Definition at line 57 of file server.c.

#define DEF_IP_ADDRESS   "192.168.1.105"

Definition at line 49 of file server.c.

#define DEF_PORT   "5432"

Definition at line 53 of file server.c.

#define DEF_USER_LOGIN   "fgtracker"

Definition at line 61 of file server.c.

#define DEF_USER_PWD   "fgtracker"

Definition at line 65 of file server.c.

#define EatSpace
Value:
for ( ; i < len; i++ ) { \
if (msg[i] > ' ') break; }

Definition at line 480 of file server.c.

Referenced by parse_message().

#define FGT_VERSION   "1.6"

Definition at line 38 of file server.c.

Referenced by give_help().

#define ISUPPER (   a)    (( a >= 'A' )&&( a <= 'Z' ))

Definition at line 491 of file server.c.

Referenced by parse_message().

#define PORT_SCAN_SPEED   20 /* 1000000/PORT_SCAN_SPEED must be integer*/

Definition at line 39 of file server.c.

Referenced by doit().

#define PQ_EXEC_SUCCESS (   res)    ((PQresultStatus(res) == PGRES_COMMAND_OK)||(PQresultStatus(res) == PGRES_TUPLES_OK))

Definition at line 1048 of file server.c.

Referenced by check_tables().

Enumeration Type Documentation

enum MsgType
Enumerator
MT_UNKNOWN 
MT_REPLY 
MT_PING 
MT_CONNECT 
MT_DISCONNECT 
MT_POSITION 
MT_PONG 
MT_NOWAIT 

Definition at line 468 of file server.c.

Function Documentation

int check_tables ( PGconn *  conn)

Definition at line 1049 of file server.c.

Referenced by test_db_connection().

int ConnectDB ( PGconn **  conn)

Definition at line 322 of file server.c.

Referenced by doit(), and test_db_connection().

int daemon_init ( void  )

Definition at line 107 of file server.c.

Referenced by main().

void doit ( int  fd)

Definition at line 588 of file server.c.

Referenced by main().

char* get_base_name ( char *  name)

Definition at line 883 of file server.c.

Referenced by give_help().

void give_help ( char *  name)

Definition at line 898 of file server.c.

Referenced by parse_commands().

int logFlight ( PGconn *  conn,
char *  callsign,
char *  model,
char *  date,
int  connect 
)

Definition at line 387 of file server.c.

Referenced by doit().

int logPosition ( PGconn *  conn,
char *  callsign,
char *  date,
char *  lon,
char *  lat,
char *  alt 
)

Definition at line 421 of file server.c.

Referenced by doit().

int main ( int  argc,
char **  argv 
)

Definition at line 1166 of file server.c.

static void net_exit ( void  )
static

Definition at line 1111 of file server.c.

Referenced by net_init().

int net_init ( )

Definition at line 1125 of file server.c.

Referenced by main().

int parse_commands ( int  argc,
char **  argv 
)

Definition at line 927 of file server.c.

Referenced by main().

int parse_message ( char *  msg,
char *  event,
char *  callsign,
char *  passwd,
char *  model,
char *  lat,
char *  lon,
char *  alt,
char *  time1,
char *  time2 
)

Definition at line 493 of file server.c.

Referenced by doit().

void sigchld_handler ( int  s)

Definition at line 129 of file server.c.

Referenced by main().

void signal_handler ( int  s)

Signal handling.

Parameters
sint with the signal

Definition at line 143 of file server.c.

Referenced by main().

void SQL_Error ( PGconn *  conn)

Definition at line 361 of file server.c.

Referenced by logFlight(), and logPosition().

int test_db_connection ( )

Definition at line 1099 of file server.c.

Referenced by main().

Variable Documentation

pid_t childpid
static

Definition at line 1142 of file server.c.

Referenced by sigchld_handler(), and cDaemon::SigHandler().

int connfd
static

Definition at line 1143 of file server.c.

char* database = (char *)DEF_DATABASE
static

Definition at line 70 of file server.c.

Referenced by ConnectDB(), give_help(), main(), and parse_commands().

char* ip_address = (char *)DEF_IP_ADDRESS
static

Definition at line 68 of file server.c.

Referenced by ConnectDB(), give_help(), main(), and parse_commands().

int listenfd
static

Definition at line 1143 of file server.c.

char* pgoptions = (char *)""
static

Definition at line 79 of file server.c.

Referenced by ConnectDB().

char* pgtty = (char *)""
static

Definition at line 80 of file server.c.

Referenced by ConnectDB().

pid_t pid
static

Definition at line 1142 of file server.c.

Referenced by daemon_init(), cDaemon::Daemonize(), and main().

char* port = (char *)DEF_PORT
static

Definition at line 69 of file server.c.

Referenced by ConnectDB(), FG_TRACKER::FG_TRACKER(), give_help(), main(), and parse_commands().

char* pwd = (char *)DEF_USER_PWD
static

Definition at line 72 of file server.c.

Referenced by ConnectDB(), give_help(), and parse_commands().

int run_as_daemon = 0
static

Definition at line 42 of file server.c.

Referenced by give_help(), main(), and parse_commands().

char* server_addr = 0
static

Definition at line 45 of file server.c.

Referenced by main(), and parse_commands().

uint32_t server_port = SERVER_PORT
static

Definition at line 44 of file server.c.

Referenced by give_help(), main(), and parse_commands().

char* user = (char *)DEF_USER_LOGIN
static

Definition at line 71 of file server.c.

Referenced by ConnectDB(), give_help(), and parse_commands().