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 #ifndef XASTIR_OBJECTS_H
25 #define XASTIR_OBJECTS_H
26 
27 #include <X11/Intrinsic.h>
28 #include <stdint.h>
29 
30 
31 // For mutex debugging with Linux threads only
32 #ifdef __linux__
33   #define MUTEX_DEBUG 1
34 #endif  // __linux__
35 
36 
37 #ifdef __LCLINT__
38   #define PACKAGE "xastir"
39   #define VERSION "lclint"
40   #define VERSIONTXT "xastir lclint debug version"
41 #else   // __LCLINT__
42   #define VERSIONTXT PACKAGE " " VERSION
43 #endif  // __LCLINT__
44 
45 
46 extern Widget object_dialog;
47 extern Widget object_group_data;
48 extern Widget object_symbol_data;
49 extern void updateObjectPictureCallback(Widget w,XtPointer clientData,XtPointer callData);
50 
51 extern void Draw_All_CAD_Objects(Widget w);
52 extern void Draw_CAD_Objects_erase_dialog(Widget w, XtPointer clientData, XtPointer callData);
53 extern void Draw_CAD_Objects_list_dialog(Widget w, XtPointer clientData, XtPointer callData);
54 extern int draw_CAD_objects_flag;
55 extern int polygon_last_x;
56 extern int polygon_last_y;
57 extern int doing_move_operation;
58 extern char last_object[9+1];
59 extern char last_obj_grp;
60 extern char last_obj_sym;
61 extern int CAD_draw_objects;
62 extern int CAD_show_label;
63 extern int CAD_show_raw_probability;
64 extern int CAD_show_comment;
65 extern int CAD_show_area;
66 
67 /* JMT - works in FreeBSD */
68 // Note: weird conditional thing is there just to shut up
69 // "ignoring return value" warnings from GCC on newer Linux systems
70 #define DISABLE_SETUID_PRIVILEGE do { \
71 if (seteuid(getuid())==0){/* all is well*/} \
72 if (setegid(getgid())==0){/* all is well*/} \
73 if (debug_level & 4) { fprintf(stderr, "Changing euid to %d and egid to %d\n", (int)getuid(), (int)getgid()); } \
74 } while(0)
75 #define ENABLE_SETUID_PRIVILEGE do { \
76 if (seteuid(euid)==0){/* all is well*/}     \
77 if (setegid(egid)==0){/* all is well*/} \
78 if (debug_level & 4) { fprintf(stderr, "Changing euid to %d and egid to %d\n", (int)euid, (int)egid); } \
79 } while(0)
80 
81 // --------------------------------------------------------------------
82 //
83 // Function protypes and globals to support predefined SAR/Public service
84 // objects.
85 //
86 //
87 // MAX_NUMBER_OF_PREDEFINED_OBJECTS is the maximum number of predefined
88 // objects that can appear on the Create/Move Here popup menu.
89 #define MAX_NUMBER_OF_PREDEFINED_OBJECTS  11
90 //
91 // PREDEFINED_OBJECT_DATA_LENGTH is the maximum length of a string
92 // that can follow the symbol specifier in a predefined object (such
93 // as a probability circle definition) plus one (for the terminator).
94 #define PREDEFINED_OBJECT_DATA_LENGTH 44
95 //
96 // number_of_predefined_objects holds the actual number of predefined
97 // objects available to display on the Create/Move popup menu.
98 extern int number_of_predefined_objects;
99 // File name of ~/.xastir/config file containing definitions for
100 // a predefined object menu.
101 extern char predefined_object_definition_filename[256];
102 // Flag to indicate whether or not to load the predefined objects menu
103 // from the file specified by predefined_object_definition_filename or
104 // to use the hardcoded SAR object set.  0=use hardcoded SAR
105 // 1=use predefined_object_definition_filename
106 extern int predefined_menu_from_file;
107 
108 //extern void Set_Del_Object(Widget w, XtPointer clientData, XtPointer calldata);
109 extern void Create_SAR_Object(Widget w, XtPointer clientData, XtPointer calldata);
110 
111 typedef struct
112 {
113   char call[MAX_CALLSIGN+1];  // Callsign = object name.
114   char page[2];               // APRS symbol code page.
115   char symbol[2];             // APRS symbol specifier.
116   char data[PREDEFINED_OBJECT_DATA_LENGTH];
117   // Data following the symbol.
118   char menu_call[26];         // Name to display on menu.
119   intptr_t index;             // Index of this object
120   // in the predefinedObjects array.
121   int show_on_menu;           // !=1 to hide on menu.
122   int index_of_child;         // > -1 to create two objects
123   // in the same place at the
124   // same time, value is the
125   // index of the second object
126   // in the predefinedObjects array.
127 } predefinedObject;
128 
129 
130 // predefinedObjects is an array of predefined object definitions,
131 // once filled using Populate_predefined_objects it can be traversed
132 // to build a list of predefined objects for menus, picklists, or
133 // other user interface controls.
134 //
135 extern predefinedObject predefinedObjects[MAX_NUMBER_OF_PREDEFINED_OBJECTS];
136 extern void Populate_predefined_objects(predefinedObject *predefinedObjects);
137 
138 // --------------------------------------------------------------------
139 
140 extern int valid_object(char *name);
141 extern int valid_item(char *name);
142 extern void Object_History_Refresh( Widget w, XtPointer clientData, XtPointer callData);
143 extern void Object_History_Clear( Widget w, XtPointer clientData, XtPointer callData);
144 extern void  Move_Object( Widget widget, XtPointer clientData, XtPointer callData);
145 extern void Draw_CAD_Objects_mode( Widget widget, XtPointer clientData, XtPointer callData);
146 extern void Draw_CAD_Objects_close_polygon(Widget w, XtPointer clientData, XtPointer calldata);
147 extern void Draw_CAD_Objects_erase(Widget w, XtPointer clientData, XtPointer calldata);
148 extern void CAD_vertice_allocate(long latitude, long longitude);
149 extern void CAD_object_allocate(long latitude, long longitude);
150 extern void Modify_object( Widget w, XtPointer clientData, XtPointer calldata);
151 extern void Restore_CAD_Objects_from_file(void);
152 extern void disown_object_item(char *call_sign, char *new_owner);
153 extern void log_object_item(char *line, int disable_object, char *object_name);
154 extern void reload_object_item(void);
155 extern void check_and_transmit_objects_items(time_t time);
156 
157 #endif /* XASTIR_OBJECTS_H */
158 
159 
160