2 * fgcom - VoIP-Client for the FlightGear-Radio-Infrastructure
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 #include <iaxclient.h>
32 #pragma warning ( disable : 4244 ) // from double to float
33 #pragma warning ( disable : 4996 ) // depreciaed, really
34 #include <io.h> // for open. read, ...
40 #define DEFAULT_USER "guest"
41 #define DEFAULT_PASSWORD "guest"
42 #define DEFAULT_FG_SERVER "localhost"
43 #define DEFAULT_FG_PORT 16661
44 #define DEFAULT_CODE 1
46 #define DEFAULT_VOIP_SERVER "fgcom.flightgear.org"
47 #define DEFAULT_CODEC 'u'
48 #define DEFAULT_IAX_CODEC IAXC_FORMAT_ULAW
49 #define DEFAULT_IAX_AUDIO AUDIO_INTERNAL
50 #define DEFAULT_MAX_CALLS 2
51 #define DEFAULT_MILLISLEEP 100
52 #define DEFAULT_RANGE 100.0
53 #define DEFAULT_LOWER_FRQ_LIMIT 108.0
54 #define DEFAULT_UPPER_FRQ_LIMIT 140.0
55 #define MAXBUFLEN 1024
56 #define DEFAULT_ALARM_TIMER 5
57 #define ALLOC_CHUNK_SIZE 5 //Size of a memory chunk to allocate
58 #define MX_REPORT_BUF 1024
59 #define MX_PATH_SIZE 2000
62 /* avoid name clash with winerror.h */
63 #define FGC_SUCCESS(__x__) (__x__ == 0)
64 #define FGC_FAILED(__x__) (__x__ < 0)
66 #ifndef SPECIAL_FREQUENCIES_FILE
67 #define SPECIAL_FREQUENCIES_FILE "fgcom-data\\special_frequencies.txt"
69 #ifndef DEFAULT_POSITIONS_FILE
70 #define DEFAULT_POSITIONS_FILE "fgcom-data\\positions.txt"
74 #define snprintf _snprintf
75 #define inline __inline
77 typedef __int64 ssize_t;
84 #ifndef FLIGHTGEAR_VERSION
85 #define FGCOM_VERSION FLIGHTGEAR_VERSION
87 #define FGCOM_VERSION "2.99"
131 /* function declaratons */
132 void quit (int signal);
133 void alarm_handler (int signal);
134 void strtoupper (const char *str, char *buf, size_t len);
135 void usage (char *prog);
136 int create_socket (int port);
137 void fatal_error (const char *err);
138 int iaxc_callback (iaxc_event e);
139 void event_state (int state, char *remote, char *remote_name, char *local,
140 char *local_context);
141 void event_text (int type, char *message);
142 void event_register (int id, int reply, int count);
143 void report (char *text);
144 const char *map_state (int state);
145 void event_unknown (int type);
146 void event_netstats (struct iaxc_ev_netstats stat);
147 void event_level (double in, double out);
148 void icao2number (char *icao, float frequency, char *buf);
149 void icao2atisnumber (char *icao, float frequency, char *buf);
151 double distance (double lat1, double lon1, double lat2, double lon2);
152 int split (char *string, char *fields[], int nfields, const char *sep);
153 char *readln (FILE * fp, char *buf, int len);
154 double *read_special_frequencies(const char *file);
155 struct airport *read_airports (const char *file);
156 const char *icaobypos (struct airport *airports, double frequency,
157 double plane_lat, double plane_lon, double range);
158 void vor (char *icao, double frequency, int mode);
159 char *report_devices (int in);
160 int set_device (const char *name, int out);
161 struct pos posbyicao (struct airport *airports, char *icao);
162 void parse_fgdata (struct fgdata *data, char *buf);
163 int check_special_frq (double frq);
164 void do_iaxc_call (const char *username, const char *password,
165 const char *voipserver, char *number);