1 /*
2
3 silcmap.h
4
5 Author: Pekka Riikonen <priikone@silcnet.org>
6
7 Copyright (C) 2003 - 2004 Pekka Riikonen
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 */
19
20 #ifndef SILCMAP_H
21 #define SILCMAP_H
22
23 /* Font context */
24 typedef struct {
25 int height;
26 struct {
27 char width;
28 unsigned char data[16 * 16];
29 } font[94];
30 } MapFonts;
31
32 /* SilcMap command context. */
33 typedef struct {
34 /* Map command datas */
35 char *filename;
36 SilcInt32 x;
37 SilcInt32 y;
38 SilcInt32 x2;
39 SilcInt32 y2;
40 SilcUInt32 width;
41 SilcUInt32 height;
42 char *text;
43 SilcInt32 lposx;
44 SilcInt32 lposy;
45 char *alat;
46 char *alon;
47 char *blat;
48 char *blon;
49
50 SilcInt16 r;
51 SilcInt16 g;
52 SilcInt16 b;
53 SilcInt16 lr;
54 SilcInt16 lg;
55 SilcInt16 lb;
56 unsigned int color_set : 1;
57 unsigned int lcolor_set : 1;
58
59 /* Command */
60 unsigned int loadmap : 1;
61 unsigned int writemap : 1;
62 unsigned int writehtml : 1;
63 unsigned int writemaphtml : 1;
64 unsigned int writerel : 1;
65 unsigned int cut : 1;
66 unsigned int draw_line : 1;
67 unsigned int draw_text : 1;
68 unsigned int draw_circle : 1;
69 unsigned int draw_rectangle : 1;
70 } *SilcMapCommand, SilcMapCommandStruct;
71
72 /* The SilcMap context. */
73 typedef struct {
74 /* Connection data */
75 SilcClient client; /* SILC Client context */
76 char *conffile; /* Config file name */
77 SilcDList conns; /* Connections */
78 SilcUInt32 conns_num; /* Number of created connections */
79 SilcUInt32 conn_num; /* Current number of processed connections */
80
81 /* Bitmap data */
82 unsigned char *bitmap; /* Loaded bitmap image */
83 SilcUInt32 bitmap_size; /* Size of bitmap */
84 SilcUInt32 width; /* Bitmap width in pixels */
85 SilcUInt32 height; /* Bitmap height in pixels */
86 SilcUInt32 maxcolor; /* Max color value in bitmap */
87 MapFonts font; /* Current font */
88
89 /* Output methods */
90 SilcMapCommandStruct loadmap;
91 SilcMapCommandStruct writemap;
92 SilcMapCommandStruct writehtml;
93 SilcMapCommandStruct writerel;
94 SilcMapCommandStruct *writemaphtml;
95 SilcMapCommandStruct *cut;
96 SilcUInt32 writemaphtml_count;
97 SilcUInt32 cut_count;
98 } *SilcMap;
99
100 /* SilcMap connecetion context. */
101 typedef struct {
102 /* Server and connection details */
103 SilcDList hostnames;
104 SilcDList ips;
105 int port;
106 char *public_key;
107 char *country;
108 char *city;
109 char *admin;
110 char *description;
111 int connect_timeout;
112 char *html_url;
113
114 /* Flags */
115 unsigned int connect : 1;
116 unsigned int starttime : 1;
117 unsigned int uptime : 1;
118 unsigned int clients : 1;
119 unsigned int channels : 1;
120 unsigned int server_ops : 1;
121 unsigned int router_ops : 1;
122 unsigned int cell_clients : 1;
123 unsigned int cell_channels : 1;
124 unsigned int cell_servers : 1;
125 unsigned int all_clients : 1;
126 unsigned int all_channels : 1;
127 unsigned int all_servers : 1;
128 unsigned int all_routers : 1;
129 unsigned int all_server_ops : 1;
130 unsigned int all_router_ops : 1;
131 unsigned int motd : 1;
132 unsigned int down : 1;
133 unsigned int stats_received : 1;
134 unsigned int motd_received : 1;
135
136 /* Gathered data */
137 struct {
138 SilcUInt32 starttime;
139 SilcUInt32 uptime;
140 SilcUInt32 clients;
141 SilcUInt32 channels;
142 SilcUInt32 server_ops;
143 SilcUInt32 router_ops;
144 SilcUInt32 cell_clients;
145 SilcUInt32 cell_channels;
146 SilcUInt32 cell_servers;
147 SilcUInt32 all_clients;
148 SilcUInt32 all_channels;
149 SilcUInt32 all_servers;
150 SilcUInt32 all_routers;
151 SilcUInt32 all_server_ops;
152 SilcUInt32 all_router_ops;
153 char *motd;
154 } data;
155
156 /* Status colors */
157 char *up_color;
158 char *down_color;
159 char *up_text_color;
160 char *down_text_color;
161
162 /* Map commands */
163 SilcDList commands;
164
165 /* Back pointers */
166 SilcMap map;
167 SilcClientConnection conn;
168 } *SilcMapConnection;
169
170 extern SilcClientOperations silc_map_client_ops;
171
172 SilcMap silc_map_alloc(const char *conffile);
173 void silc_map_free(SilcMap map);
174 bool silc_map_commands_parse(SilcMap map, const char *filename);
175 void silc_map_connect(SilcMap map, SilcMapConnection mapconn);
176 bool silc_map_load_ppm(SilcMap map, const char *filename);
177 bool silc_map_write_ppm(SilcMap map, const char *filename);
178 bool silc_map_cut(SilcMap map, SilcInt32 x, SilcInt32 y,
179 SilcUInt32 width, SilcUInt32 height,
180 SilcMap *ret_map);
181 bool silc_map_draw(SilcMap map,
182 SilcInt32 x, SilcInt32 y,
183 const unsigned char *bitmap,
184 SilcUInt32 width, SilcUInt32 height);
185 bool silc_map_draw_raw(SilcMap map,
186 SilcInt32 x, SilcInt32 y,
187 const unsigned char *bitmap,
188 SilcUInt32 width, SilcUInt32 height,
189 SilcInt16 r, SilcInt16 g, SilcInt16 b);
190 bool silc_map_draw_line(SilcMap map, SilcUInt32 width,
191 SilcInt32 a_x, SilcInt32 a_y,
192 SilcInt32 b_x, SilcInt32 b_y,
193 SilcInt16 r, SilcInt16 g, SilcInt16 b);
194 bool silc_map_draw_text(SilcMap map, const char *text,
195 SilcInt32 x, SilcInt32 y,
196 SilcInt16 r, SilcInt16 g, SilcInt16 b);
197 bool silc_map_draw_circle(SilcMap map, SilcInt32 x, SilcInt32 y,
198 SilcInt16 r, SilcInt16 g, SilcInt16 b,
199 const char *label, SilcInt32 lposx, SilcInt32 lposy,
200 SilcInt16 lr, SilcInt16 lg, SilcInt16 lb);
201 bool silc_map_draw_rectangle(SilcMap map, SilcInt32 x, SilcInt32 y,
202 SilcInt16 r, SilcInt16 g, SilcInt16 b,
203 const char *label, SilcInt32 lposx,
204 SilcInt32 lposy,
205 SilcInt16 lr, SilcInt16 lg, SilcInt16 lb);
206 double silc_map_parse_pos(char *pos);
207 int silc_map_lon2x(SilcMap map, char *latitude);
208 int silc_map_lat2y(SilcMap map, char *longitude);
209 bool silc_map_parse_color(const char *color,
210 SilcInt16 *r, SilcInt16 *g, SilcInt16 *b);
211 bool silc_map_load_font(SilcMap map, const char *filename);
212 bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn);
213 bool silc_map_writehtml_index(SilcMap map);
214 bool silc_map_writemaphtml(SilcMap map);
215 bool silc_map_writerel(SilcMap map, SilcMapConnection mapconn);
216 bool silc_map_writerelhtml(SilcMap map);
217
218 #endif /* SILCMAP_H */
219
This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse