1 /*
2  *
3  * XASTIR, Amateur Station Tracking and Information Reporting
4  * Copyright (C) 1999,2000  Frank Giannandrea
5  * Copyright (C) 2000-2019 The Xastir Group
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  * Look at the README for more information on the program.
22  */
23 
24 /* Note: this file should be called db.h, but was renamed to database.h
25  * to avoid conflicts with the Berkeley DB package.  */
26 
27 /*
28  * Database structures
29  *
30  */
31 
32 #ifndef XASTIR_DATABASE_H
33 #define XASTIR_DATABASE_H
34 
35 
36 #define MSG_INCREMENT 200
37 #define MAX_CALLSIGN 9       // Objects are up to 9 chars
38 #define MAX_TACTICAL_CALL 57 // Up to XX chars for tactical calls
39 #define MAX_COMMENT_LINES 20  // Save XX unique comment strings per station
40 #define MAX_STATUS_LINES 20   // Save XX unique status strings per station
41 
42 /* define max size of info field */
43 #define MAX_INFO_FIELD_SIZE 256
44 
45 // Number of times to send killed objects/items before ceasing to
46 // transmit them.
47 #define MAX_KILLED_OBJECT_RETRANSMIT 20
48 
49 // Check entire station list at this rate for objects/items that
50 // might need to be transmitted via the decaying algorithm.  This is
51 // the start rate, which gets doubled on each transmit.
52 #define OBJECT_CHECK_RATE 20
53 
54 // We should probably be using APRS_DF in extract_bearing_NRQ()
55 // and extract_omnidf() functions.  We aren't currently.
56 /* Define APRS Types */
57 enum APRS_Types
58 {
59   APRS_NULL,
60   APRS_MSGCAP,
61   APRS_FIXED,
62   APRS_DOWN,      // Not used anymore
63   APRS_MOBILE,
64   APRS_DF,
65   APRS_OBJECT,
66   APRS_ITEM,
67   APRS_STATUS,
68   APRS_WX1,
69   APRS_WX2,
70   APRS_WX3,
71   APRS_WX4,
72   APRS_WX5,
73   APRS_WX6,
74   QM_WX,
75   PEET_COMPLETE,
76   RSWX200,
77   GPS_RMC,
78   GPS_GGA,
79   GPS_GLL,
80   STATION_CALL_DATA,
81   OTHER_DATA,
82   APRS_MICE,
83   APRS_GRID,
84   DALLAS_ONE_WIRE,
85   DAVISMETEO,
86   DAVISAPRSDL
87 };
88 
89 
90 /* Define Record Types */
91 #define NORMAL_APRS     'N'
92 #define MOBILE_APRS     'M'
93 #define DF_APRS         'D'
94 #define DOWN_APRS       'Q'
95 #define NORMAL_GPS_RMC  'C'
96 #define NORMAL_GPS_GGA  'A'
97 #define NORMAL_GPS_GLL  'L'
98 #define APRS_WX1        '1'
99 #define APRS_WX2        '2'
100 #define APRS_WX3        '3'
101 #define APRS_WX4        '4'
102 #define APRS_WX5        '5'
103 #define APRS_WX6        '6'
104 
105 /* define RECORD ACTIVES */
106 #define RECORD_ACTIVE    'A'
107 #define RECORD_NOTACTIVE 'N'
108 #define RECORD_CLOSED     'C'
109 
110 /* define data from info type */
111 #define DATA_VIA_LOCAL 'L'
112 #define DATA_VIA_TNC   'T'
113 #define DATA_VIA_NET   'I'
114 #define DATA_VIA_FILE  'F'
115 #define DATA_VIA_DATABASE  'D'
116 
117 
118 /* define Heard info type */
119 #define VIA_TNC         'Y'
120 #define NOT_VIA_TNC     'N'
121 
122 /* define Message types */
123 #define MESSAGE_MESSAGE  'M'
124 #define MESSAGE_BULLETIN 'B'
125 #define MESSAGE_NWS      'W'
126 
127 // Define file info, string length are without trailing '\0'
128 #define MAX_TIME             20
129 #define MAX_LONG             12
130 #define MAX_LAT              11
131 #define MAX_ALTITUDE         10         //-32808.4 to 300000.0? feet
132 #define MAX_SPEED             9         /* ?? 3 in knots */
133 #define MAX_COURSE            7         /* ?? */
134 #define MAX_POWERGAIN         7
135 #define MAX_STATION_TIME     10         /* 6+1 */
136 #define MAX_SAT               4
137 #define MAX_DISTANCE         10
138 #define MAX_WXSTATION        50
139 #define MAX_TEMP            100
140 
141 #define MAX_MESSAGE_LENGTH  100
142 #define MAX_MESSAGE_ORDER    10
143 
144 // track export file formats
145 #define EXPORT_XASTIR_TRACK 0
146 #define EXPORT_KML_TRACK 1
147 
148 extern char *get_most_recent_ack(char *callsign);
149 
150 extern void Set_Del_Object(Widget w, XtPointer clientData, XtPointer calldata); // From main.c
151 
152 
153 extern char my_callsign[MAX_CALLSIGN+1];
154 extern char my_lat[MAX_LAT];
155 extern char my_long[MAX_LONG];
156 
157 
158 
159 // Used for messages and bulletins
160 typedef struct
161 {
162   char active;
163   char data_via;
164   char type;
165   char heard_via_tnc;
166   time_t sec_heard;
167   time_t last_ack_sent;
168   char packet_time[MAX_TIME];
169   char call_sign[MAX_CALLSIGN+1];
170   char from_call_sign[MAX_CALLSIGN+1];
171   char message_line[MAX_MESSAGE_LENGTH+1];
172   char seq[MAX_MESSAGE_ORDER+1];
173   char acked;
174   char position_known;
175   time_t interval;
176   int tries;
177 } Message;
178 
179 
180 
181 // Struct used to create linked list of most recent ack's
182 typedef struct _ack_record
183 {
184   char callsign[MAX_CALLSIGN+1];
185   char ack[5+1];
186   struct _ack_record *next;
187 } ack_record;
188 
189 
190 
191 #ifdef MSG_DEBUG
192 extern void msg_clear_data(Message *clear);
193 extern void msg_copy_data(Message *to, Message *from);
194 #else   // MSG_DEBUG
195 #define msg_clear_data(clear) memset((Message *)clear, 0, sizeof(Message))
196 #define msg_copy_data(to, from) memmove((Message *)to, (Message *)from, \
197                                         sizeof(Message))
198 #endif /* MSG_DEBUG */
199 
200 extern int message_update_time(void);
201 
202 
203 
204 enum AreaObjectTypes
205 {
206   AREA_OPEN_CIRCLE     = 0x0,
207   AREA_LINE_LEFT       = 0x1,
208   AREA_OPEN_ELLIPSE    = 0x2,
209   AREA_OPEN_TRIANGLE   = 0x3,
210   AREA_OPEN_BOX        = 0x4,
211   AREA_FILLED_CIRCLE   = 0x5,
212   AREA_LINE_RIGHT      = 0x6,
213   AREA_FILLED_ELLIPSE  = 0x7,
214   AREA_FILLED_TRIANGLE = 0x8,
215   AREA_FILLED_BOX      = 0x9,
216   AREA_MAX             = 0x9,
217   AREA_NONE            = 0xF
218 };
219 
220 
221 
222 enum AreaObjectColors
223 {
224   AREA_BLACK_HI  = 0x0,
225   AREA_BLUE_HI   = 0x1,
226   AREA_GREEN_HI  = 0x2,
227   AREA_CYAN_HI   = 0x3,
228   AREA_RED_HI    = 0x4,
229   AREA_VIOLET_HI = 0x5,
230   AREA_YELLOW_HI = 0x6,
231   AREA_GRAY_HI   = 0x7,
232   AREA_BLACK_LO  = 0x8,
233   AREA_BLUE_LO   = 0x9,
234   AREA_GREEN_LO  = 0xA,
235   AREA_CYAN_LO   = 0xB,
236   AREA_RED_LO    = 0xC,
237   AREA_VIOLET_LO = 0xD,
238   AREA_YELLOW_LO = 0xE,
239   AREA_GRAY_LO   = 0xF
240 };
241 
242 
243 
244 typedef struct
245 {
246   unsigned type : 4;
247   unsigned color : 4;
248   unsigned sqrt_lat_off : 8;
249   unsigned sqrt_lon_off : 8;
250   unsigned corridor_width : 16;
251 } AreaObject;
252 
253 
254 
255 typedef struct
256 {
257   char aprs_type;
258   char aprs_symbol;
259   char special_overlay;
260   AreaObject area_object;
261 } APRS_Symbol;
262 
263 
264 
265 // Struct for holding current weather data.
266 // This struct is pointed to by the DataRow structure.
267 // An empty string indicates undefined data.
268 typedef struct                  //                      strlen
269 {
270   time_t  wx_sec_time;
271   int     wx_storm;           // Set to one if severe storm
272   char    wx_time[MAX_TIME];
273   char    wx_course[4];       // in �                     3
274   char    wx_speed[4];        // in mph                   3
275   time_t  wx_speed_sec_time;
276   char    wx_gust[4];         // in mph                   3
277   char    wx_hurricane_radius[4];  //nautical miles       3
278   char    wx_trop_storm_radius[4]; //nautical miles       3
279   char    wx_whole_gale_radius[4]; // nautical miles      3
280   char    wx_temp[5];         // in �F                    3
281   char    wx_rain[10];        // in hundredths inch/h     3
282   char    wx_rain_total[10];  // in hundredths inch
283   char    wx_snow[6];         // in inches/24h            3
284   char    wx_prec_24[10];     // in hundredths inch/day   3
285   char    wx_prec_00[10];     // in hundredths inch       3
286   char    wx_hum[5];          // in %                     3
287   char    wx_baro[10];        // in hPa                   6
288   char    wx_fuel_temp[5];    // in �F                    3
289   char    wx_fuel_moisture[5];// in %                     2
290   char    wx_type;
291   char    wx_station[MAX_WXSTATION];
292   int     wx_compute_rain_rates;  //  Some stations provide rain rates
293   // directly, others require Xastir to
294   // compute from total rain.  Flag this,
295   // so we don't clobber useful info from
296   // a station.
297 } WeatherRow;
298 
299 
300 
301 // Struct for holding track data.  Keeps a dynamically allocated
302 // doubly-linked list of track points.  The first record should have its
303 // "prev" pointer set to NULL and the last record should have its "next"
304 // pointer set to NULL.  If no track storage exists then the pointers to
305 // these structs in the DataRow struct should be NULL.
306 typedef struct _TrackRow
307 {
308   long    trail_long_pos;     // coordinate of trail point
309   long    trail_lat_pos;      // coordinate of trail point
310   time_t  sec;                // date/time of position
311   long    speed;              // in 0.1 km/h   undefined: -1
312   int     course;             // in degrees    undefined: -1
313   long    altitude;           // in 0.1 m      undefined: -99999
314   char    flag;               // several flags, see below
315   struct  _TrackRow *prev;    // pointer to previous record in list
316   struct  _TrackRow *next;    // pointer to next record in list
317 } TrackRow;
318 
319 
320 
321 // trail flag definitions
322 #define TR_LOCAL        0x01    // heard direct (not via digis)
323 #define TR_NEWTRK       0x02    // start new track
324 
325 
326 
327 // Struct for holding comment/status data.  Will keep a dynamically
328 // allocated list of text.  Every different comment field will be
329 // stored in a separate line.
330 typedef struct _CommentRow
331 {
332   char   *text_ptr;           // Ptr to the comment text
333   time_t sec_heard;           // Latest timestamp for this comment/status
334   struct _CommentRow *next;   // Ptr to next record or NULL
335 } CommentRow;
336 
337 
338 
339 #define MAX_MULTIPOINTS 35
340 
341 
342 
343 // Struct for holding multipoint data.
344 typedef struct _MultipointRow
345 {
346   long multipoints[MAX_MULTIPOINTS][2];
347 } MultipointRow;
348 
349 
350 
351 // Break DataRow into several structures.  DataRow will contain the
352 // parameters that are common across all types of stations.  DataRow
353 // will contain a pointer to TrackRow if it is a moving station, and
354 // contain a pointer to WeatherRow if it is a weather station.  If no
355 // weather or track data existed, the pointers will be NULL.  This new
356 // way of storing station data will save a LOT of memory.  If a
357 // station suddenly starts moving or spitting out weather data the new
358 // structures will be allocated, filled in, and pointers to them
359 // installed in DataRow.
360 //
361 // Station storage now is organized as an ordered linked list. We have
362 // both sorting by name and by time last heard
363 //
364 // todo: check the string length!
365 //
366 typedef struct _DataRow
367 {
368 
369   struct _DataRow *n_next;    // pointer to next element in name ordered list
370   struct _DataRow *n_prev;    // pointer to previous element in name ordered
371   // list
372   struct _DataRow *t_newer;   // pointer to next element in time ordered
373   // list (newer)
374   struct _DataRow *t_older;   // pointer to previous element in time ordered
375   // list (older)
376 
377   char call_sign[MAX_CALLSIGN+1]; // call sign or name index or object/item
378   // name
379   char *tactical_call_sign;   // Tactical callsign.  NULL if not assigned
380   APRS_Symbol aprs_symbol;
381   long coord_lon;             // Xastir coordinates 1/100 sec, 0 = 180�W
382   long coord_lat;             // Xastir coordinates 1/100 sec, 0 =  90�N
383 
384   int  time_sn;               // serial number for making time index unique
385   time_t sec_heard;           // time last heard, used also for time index
386   time_t heard_via_tnc_last_time;
387   time_t direct_heard;        // KC2ELS - time last heard direct
388 
389 // Change into time_t structs?  It'd save us a bunch of space.
390   char packet_time[MAX_TIME];
391   char pos_time[MAX_TIME];
392 
393 //    char altitude_time[MAX_TIME];
394 //    char speed_time[MAX_TIME];
395 //    char station_time[MAX_STATION_TIME];
396 //    char station_time_type;
397 
398   short flag;                 // several flags, see below
399   char pos_amb;               // Position ambiguity, 0 = none,
400   // 1 = 0.1 minute...
401 
402   unsigned int error_ellipse_radius; // Degrades precision for this
403   // station, from 0 to 65535 cm or
404   // 655.35 meters.  Assigned when we
405   // decode each type of packet.
406   // Default is 6.0 meters (600 cm)
407   // unless we know the GPS position
408   // is augmented, or is degraded by
409   // less precision in the packet.
410 
411   unsigned int lat_precision; // In 100ths of a second latitude
412   unsigned int lon_precision; // In 100ths of a second longitude
413 
414   int trail_color;            // trail color (when assigned)
415   char record_type;
416   char data_via;              // L local, T TNC, I internet, F file
417 
418 // Change to char's to save space?
419   int  heard_via_tnc_port;
420   int  last_port_heard;
421   unsigned int  num_packets;
422   char *node_path_ptr;        // Pointer to path string
423   char altitude[MAX_ALTITUDE]; // in meters (feet gives better resolution ??)
424   char speed[MAX_SPEED+1];    // in knots (same as nautical miles/hour)
425   char course[MAX_COURSE+1];
426   char bearing[MAX_COURSE+1];
427   char NRQ[MAX_COURSE+1];
428   char power_gain[MAX_POWERGAIN+1];   // Holds the phgd values
429   char signal_gain[MAX_POWERGAIN+1];  // Holds the shgd values (for DF'ing)
430 
431   WeatherRow *weather_data;   // Pointer to weather data or NULL
432 
433   CommentRow *status_data;    // Ptr to status records or NULL
434   CommentRow *comment_data;   // Ptr to comment records or NULL
435 
436   // Below two pointers are NULL if only one position has been received
437   TrackRow *oldest_trackpoint; // Pointer to oldest track point in
438   // doubly-linked list
439   TrackRow *newest_trackpoint; // Pointer to newest track point in
440   // doubly-linked list
441 
442   // When the station is an object, it can include coordinates
443   // of related points. Currently these are being used to draw
444   // outlines of NWS severe weather watches and warnings, and
445   // storm regions. The coordinates are stored here in Xastir
446   // coordinate form. Element [x][0] is the latitude, and
447   // element [x][1] is the longitude.  --KG4NBB
448   //
449   // Is there anything preventing a multipoint string from being
450   // in other types of packets, in the comment field?  --WE7U
451   //
452   int num_multipoints;
453   char type;      // from '0' to '9'
454   char style;     // from 'a' to 'z'
455   MultipointRow *multipoint_data;
456 
457 
458 ///////////////////////////////////////////////////////////////////////
459 // Optional stuff for Objects/Items only (I think, needs to be
460 // checked).  These could be moved into an ObjectRow structure, with
461 // only a NULL pointer here if not an object/item.
462 ///////////////////////////////////////////////////////////////////////
463 
464   char origin[MAX_CALLSIGN+1]; // call sign originating an object
465   short object_retransmit;     // Number of times to retransmit object.
466   // -1 = forever
467   // Used currently to stop sending killed
468   // objects.
469   time_t last_transmit_time;   // Time we last transmitted an object/item.
470   // Used to implement decaying transmit time
471   // algorithm
472   short transmit_time_increment; // Seconds to add to transmit next time
473   // around.  Used to implement decaying
474   // transmit time algorithm
475 //    time_t last_modified_time;   // Seconds since the object/item
476   // was last modified.  We'll
477   // eventually use this for
478   // dead-reckoning.
479   char signpost[5+1];          // Holds signpost data
480   int  df_color;
481   char sats_visible[MAX_SAT];
482   char probability_min[10+1];  // Holds prob_min (miles)
483   char probability_max[10+1];  // Holds prob_max (miles)
484 
485 } DataRow;
486 
487 
488 
489 // Used to store one vertice in CADRow object
490 typedef struct _VerticeRow
491 {
492   long    latitude;           // Xastir coordinates 1/100sec, 0 = 180W
493   long    longitude;          // Xastir coordinates 1/100sec, 0 =  90N
494   struct  _VerticeRow *next;  // Pointer to next record in list
495 } VerticeRow;
496 
497 #define CAD_LABEL_MAX_SIZE 40
498 #define CAD_COMMENT_MAX_SIZE 256
499 
500 
501 // CAD Objects
502 typedef struct _CADRow
503 {
504   struct _CADRow *next;       // Pointer to next element in list
505   time_t creation_time;       // Time at which object was first created
506   VerticeRow *start;          // Pointer to first VerticeRow
507   int line_color;             // Border color
508   int line_type;              // Border linetype
509   int line_width;             // Border line width
510   float computed_area;        // Area in square kilometers
511   float raw_probability;      // Probability of area (POA) or probability of
512   // detection (POD) stored as probability
513   // with a value between 0 and 1.
514   // Set and get with CAD_object_get_raw_probability()
515   // and CAD_object_set_raw_probability(), rather
516   // than by a direct request for CADRow->raw_probability.
517   long label_latitude;        // Latitude for label placement
518   long label_longitude;       // Longitude for label placement
519   char label[CAD_LABEL_MAX_SIZE];             // Name of polygon
520   char comment[CAD_COMMENT_MAX_SIZE];          // Comments associated with polygon
521 } CADRow;
522 
523 
524 extern CADRow *CAD_list_head;
525 
526 
527 
528 // station flag definitions.  We have 16 bits available here as
529 // "flag" in "DataRow" is defined as a short.
530 //
531 #define ST_OBJECT       0x01    // station is an object
532 #define ST_ITEM         0x02    // station is an item
533 #define ST_ACTIVE       0x04    // station is active (deleted objects are
534 // inactive)
535 #define ST_MOVING       0x08    // station is moving
536 #define ST_DIRECT       0x10    // heard direct (not via digis)
537 #define ST_VIATNC       0x20    // station heard via TNC
538 #define ST_3RD_PT       0x40    // third party traffic
539 #define ST_MSGCAP       0x80    // message capable (not used yet)
540 #define ST_STATUS       0x100   // got real status message
541 #define ST_INVIEW       0x200   // station is in current screen view
542 #define ST_MYSTATION    0x400   // station is owned by my call-SSID
543 #define ST_MYOBJITEM    0x800   // object/item owned by me
544 
545 
546 #ifdef DATA_DEBUG
547 extern void clear_data(DataRow *clear);
548 extern void copy_data(DataRow *to, DataRow *from);
549 #else   // DATA_DEBUG
550 #define clear_data(clear) memset((DataRow *)clear, 0, sizeof(DataRow))
551 #define copy_data(to, from) memmove((DataRow *)to, (DataRow *)from, \
552                                     sizeof(DataRow))
553 #endif /* DATA_DEBUG */
554 
555 
556 extern void db_init(void);
557 extern void export_trail_as_kml(DataRow *p_station);   // export trail of one or all stations to kml file
558 
559 //
560 extern int is_my_call(char *call, int exact);
561 extern int is_my_station(DataRow *p_station);
562 extern int is_my_object_item(DataRow *p_station);
563 
564 void mscan_file(char msg_type, void (*function)(Message *fill));
565 extern void msg_record_ack(char *to_call_sign, char *my_call, char *seq,
566                            int timeout, int cancel);
567 extern void msg_record_interval_tries(char *to_call_sign, char *my_call,
568                                       char *seq, time_t interval, int tries);
569 extern void display_file(Widget w);
570 extern void clean_data_file(void);
571 extern void read_file_line(FILE *f);
572 extern void mdisplay_file(char msg_type);
573 extern void mem_display(void);
574 extern long sort_input_database(char *filename, char *fill, int size);
575 extern void sort_display_file(char *filename, int size);
576 extern void clear_sort_file(char *filename);
577 extern void display_packet_data(void);
578 extern int  redraw_on_new_packet_data;
579 extern int decode_ax25_header(unsigned char *data_string, int *length);
580 extern int decode_ax25_line(char *line, char from, int port, int dbadd);
581 
582 // utilities
583 extern void packet_data_add(char *from, char *line, int data_port);
584 extern void General_query(Widget w, XtPointer clientData, XtPointer calldata);
585 extern void IGate_query(Widget w, XtPointer clientData, XtPointer calldata);
586 extern void WX_query(Widget w, XtPointer clientData, XtPointer calldata);
587 extern unsigned long max_stations;
588 extern int  heard_via_tnc_in_past_hour(char *call);
589 
590 // messages
591 extern void update_messages(int force);
592 extern void mdelete_messages_from(char *from);
593 extern void mdelete_messages_to(char *to);
594 extern void init_message_data(void);
595 extern void check_message_remove(time_t curr_sec);
596 extern int  new_message_data;
597 extern time_t msg_data_add(char *call_sign, char *from_call, char *data,
598                            char *seq, char type, char from, long *record_out);
599 
600 // stations
601 extern int st_direct_timeout;   // Interval that ST_DIRECT flag stays set
602 extern int station_count;       // Count of stations in the database
603 extern int station_count_save;  // Old copy of the above
604 extern DataRow *n_first;  // pointer to first element in name ordered station
605 // list
606 extern DataRow *n_last;   // pointer to last element in name ordered station
607 // list
608 extern DataRow *t_oldest; // pointer to first element in time ordered station
609 // list
610 extern DataRow *t_newest; // pointer to last element in time ordered station
611 // list
612 extern void init_station_data(void);
613 extern void Station_data(Widget w, XtPointer clientData, XtPointer calldata);
614 extern int station_data_auto_update;
615 extern int  next_station_name(DataRow **p_curr);
616 extern int  prev_station_name(DataRow **p_curr);
617 extern int  next_station_time(DataRow **p_curr);
618 extern int  prev_station_time(DataRow **p_curr);
619 extern int  search_station_name(DataRow **p_name, char *call, int exact);
620 extern int  search_station_time(DataRow **p_time, time_t heard, int serial);
621 extern void check_station_remove(time_t curr_sec);
622 extern void delete_all_stations(void);
623 extern void station_del(char *callsign);
624 extern void my_station_add(char *my_call_sign, char my_group, char my_symbol,
625                            char *my_long, char *my_lat, char *my_phg,
626                            char *my_comment, char my_amb);
627 extern void my_station_gps_change(char *pos_long, char *pos_lat, char *course,
628                                   char *speed, char speedu, char *alt,
629                                   char *sats);
630 extern int  locate_station(Widget w, char *call, int follow_case,
631                            int get_match, int center_map);
632 extern void update_station_info(Widget w);
633 
634 // objects/items
635 extern time_t last_object_check;
636 
637 // trails
638 extern int  delete_trail(DataRow *fill);
639 
640 // weather
641 extern int  get_weather_record(DataRow *fill);
642 
643 extern void set_map_position(Widget w, long lat, long lon);
644 
645 
646 // just used for aloha calcs
647 typedef struct
648 {
649   double distance;
650   char call_sign[MAX_CALLSIGN+1]; // call sign or name index or object/item
651   // name
652   char is_mobile;
653   char is_other_mobile;
654   char is_wx;
655   char is_digi; // can only tell this if using a digi icon!
656   char is_home; // stationary stations that are not digis
657 } aloha_entry;
658 typedef struct
659 {
660   int digis;
661   int wxs;
662   int other_mobiles;
663   int mobiles_in_motion;
664   int homes;
665   int total;
666 } aloha_stats;
667 
668 double calc_aloha_distance(void); //meat
669 void calc_aloha(int curr_sec); // periodic function
670 void Show_Aloha_Stats(Widget w, XtPointer clientData,
671                       XtPointer callData); // popup window
672 
673 int comp_by_dist(const void *,const void *);// used only for qsort
674 DataRow * sanity_check_time_list(time_t); // used only for debugging
675 void dump_time_sorted_list(void);
676 
677 extern int store_trail_point(DataRow *p_station, long lon, long lat, time_t sec, char *alt, char *speed, char *course, short stn_flag);
678 
679 #ifdef HAVE_DB
680   extern int add_simple_station(DataRow *p_new_station,char *station, char *origin, char *symbol, char *overlay, char *aprs_type, char *latitude, char *longitude, char *record_type, char *node_path, char *transmit_time, char *timeformat);
681 
682 #endif /* HAVE_DB */
683 
684 #endif /* XASTIR_DATABASE_H */
685