Debian Codegraph @

utils/fgcom/fgcom_external.hxx

raw
1 /*
2 * fgcom - VoIP-Client for the FlightGear-Radio-Infrastructure
3 *
4 * This program realizes the usage of the VoIP infractructure based
5 * on flight data which is send from FlightGear with an external
6 * protocol to this application.
7 *
8 * Clement de l'Hamaide - Jan 2014
9 * Re-writting of FGCom standalone
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of the
14 * License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 * MA 02110-1301, USA.
25 *
26 */
27
28 #ifndef __FGCOM_H__
29 #define __FGCOM_H__
30
31 // avoid name clash with winerror.h
32 #define FGC_SUCCESS(__x__) (__x__ == 0)
33 #define FGC_FAILED(__x__) (__x__ < 0)
34
35 #ifdef _MSC_VER
36 #define snprintf _snprintf
37 #ifdef WIN64
38 typedef __int64 ssize_t;
39 #else
40 typedef int ssize_t;
41 #endif
42 #endif
43
44
45 #include <map>
46 #include <fstream>
47 #include <iostream>
48 #include <algorithm>
49 #include <stdlib.h>
50 #include <signal.h>
51 #include <stdio.h>
52 #include <string.h>
53
54 #ifndef FGCOM_VERSION
55 #ifdef FLIGHTGEAR_VERSION
56 #define FGCOM_VERSION FLIGHTGEAR_VERSION
57 #else
58 #define FGCOM_VERSION "unknown"
59 #endif
60 #endif
61
62 #define MAXBUFLEN 1024
63
64 enum Modes {
65 ATC,
66 PILOT,
67 OBS,
68 TEST
69 };
70
71 enum ActiveComm {
72 COM1,
73 COM2
74 };
75
76 struct Data
77 {
78 int ptt;
79 float com1;
80 float com2;
81 double lon;
82 double lat;
83 double alt;
84 float outputVol;
85 float silenceThd;
86 std::string callsign;
87 };
88
89 struct Airport
90 {
91 double frequency;
92 double latitude;
93 double longitude;
94 double distanceNm;
95 std::string icao;
96 std::string type;
97 std::string name;
98 };
99
100 // Internal functions
101 int usage();
102 int version();
103 void quit(int state);
104 bool isInRange(std::string icao, double acftLat, double acftLon, double acftAlt);
105 std::string computePhoneNumber(double freq, std::string icao, bool atis = false);
106 std::string getClosestAirportForFreq(double freq, double acftLat, double acftLon, double acftAlt);
107 std::multimap<int, Airport> getAirportsData();
108
109 // Library functions
110 bool lib_init();
111 bool lib_hangup();
112 bool lib_shutdown();
113 bool lib_call(std::string icao, double freq);
114 bool lib_directCall(std::string icao, double freq, std::string num);
115
116 int lib_registration();
117 int iaxc_callback(iaxc_event e);
118
119 void lib_setSilenceThreshold(double thd);
120 void lib_setCallerId(std::string callsign);
121 void lib_setVolume(double input, double output);
122
123 #endif