]>
Commit | Line | Data |
---|---|---|
5c1c6879 JB |
1 | --- ggz-grubby-0.0.14.1/grubby/src/netsilc.c 2013-01-31 15:56:42.079528848 +0100 |
2 | +++ grubby/grubby/src/netsilc.c 2013-01-31 19:04:55.052626802 +0100 | |
3 | @@ -7,8 +7,16 @@ | |
4 | * | |
5 | ********************************************************************/ | |
6 | ||
7 | +/* Definition to switch between 1.0 and 1.1 API of SILC */ | |
8 | +/*#define SILC_COMPAT 1*/ | |
9 | +#undef SILC_COMPAT | |
10 | + | |
11 | #include "net.h" | |
12 | +#ifdef SILC_COMPAT | |
13 | #include <silcincludes.h> | |
14 | +#else | |
15 | +#include <silc.h> | |
16 | +#endif | |
17 | #include <silcclient.h> | |
18 | ||
19 | /* Prototypes */ | |
20 | @@ -19,11 +27,19 @@ | |
21 | static void silc_private_message(SilcClient client, SilcClientConnection conn, SilcClientEntry sender, | |
22 | SilcMessagePayload payload, SilcMessageFlags flags, const unsigned char *message, SilcUInt32 message_len); | |
23 | static void silc_notify(SilcClient client, SilcClientConnection conn, SilcNotifyType type, ...); | |
24 | + | |
25 | +#ifdef SILC_COMPAT | |
26 | static void silc_connected(SilcClient client, SilcClientConnection conn, SilcClientConnectionStatus status); | |
27 | static void silc_disconnected(SilcClient client, SilcClientConnection conn, SilcStatus status, const char *message); | |
28 | static void silc_failure(SilcClient client, SilcClientConnection conn, SilcProtocol protocol, void *failure); | |
29 | +#else | |
30 | +static void silc_connected(SilcClient client, SilcClientConnection conn, SilcClientConnectionStatus status, | |
31 | + SilcStatus error, const char *message, void *context); | |
32 | +static void silc_running(SilcClient client, void *application); | |
33 | +#endif | |
34 | ||
35 | /* Unused prototypes */ | |
36 | +#ifdef SILC_COMPAT | |
37 | static void no_silc_command(SilcClient client, SilcClientConnection conn, SilcClientCommandContext cmd_context, | |
38 | bool success, SilcCommand command, SilcStatus status); | |
39 | static void no_silc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommandPayload cmd_payload, | |
40 | @@ -32,14 +48,30 @@ | |
41 | SilcGetAuthMeth completion, void *context); | |
42 | static void no_silc_verify_public_key(SilcClient client, SilcClientConnection conn, SilcSocketType conn_type, | |
43 | unsigned char *pk, SilcUInt32 pk_len, SilcSKEPKType pk_type, SilcVerifyPublicKey completion, void *context); | |
44 | -static void no_silc_ask_passphrase(SilcClient client, SilcClientConnection conn, SilcAskPassphrase completion, | |
45 | - void *context); | |
46 | static bool no_silc_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
47 | const char *hostname, SilcUInt16 port, SilcKeyAgreementCallback *completion, void **context); | |
48 | +#else | |
49 | +static void no_silc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommand command, | |
50 | + SilcStatus status, SilcStatus error, va_list ap); | |
51 | +static void no_silc_command(SilcClient client, SilcClientConnection conn, | |
52 | + bool success, SilcCommand command, SilcStatus status, SilcUInt32 argc, unsigned char **argv); | |
53 | +static void no_silc_get_auth_method(SilcClient client, SilcClientConnection conn, char *hostname, SilcUInt16 port, | |
54 | + SilcAuthMethod method, SilcGetAuthMeth completion, void *context); | |
55 | +static void no_silc_verify_public_key(SilcClient client, SilcClientConnection conn, SilcConnectionType conn_type, | |
56 | + SilcPublicKey public_key, SilcVerifyPublicKey completion, void *context); | |
57 | +static void no_silc_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
58 | + const char *hostname, SilcUInt16 protocol, SilcUInt16 port); | |
59 | +#endif | |
60 | + | |
61 | +static void no_silc_ask_passphrase(SilcClient client, SilcClientConnection conn, SilcAskPassphrase completion, | |
62 | + void *context); | |
63 | static void no_silc_ftp(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
64 | SilcUInt32 session_id, const char *hostname, SilcUInt16 port); | |
65 | + | |
66 | +#ifdef SILC_COMPAT | |
67 | static void no_silc_detach(SilcClient client, SilcClientConnection conn, const unsigned char *detach_data, | |
68 | SilcUInt32 detach_data_len); | |
69 | +#endif | |
70 | ||
71 | /* Globals */ | |
72 | int status = NET_NOOP; | |
73 | @@ -52,7 +84,9 @@ | |
74 | ||
75 | static SilcClient client; | |
76 | static SilcClientConnection connection; | |
77 | +#ifdef SILC_COMPAT | |
78 | static SilcPKCS pkcs; | |
79 | +#endif | |
80 | static SilcPublicKey pubkey; | |
81 | static SilcPrivateKey privkey; | |
82 | static SilcChannelEntry lastchannel; | |
83 | @@ -65,15 +99,21 @@ | |
84 | silc_notify, | |
85 | no_silc_command, | |
86 | no_silc_command_reply, | |
87 | +#ifdef SILC_COMPAT | |
88 | silc_connected, | |
89 | silc_disconnected, | |
90 | +#endif | |
91 | no_silc_get_auth_method, | |
92 | no_silc_verify_public_key, | |
93 | no_silc_ask_passphrase, | |
94 | +#ifdef SILC_COMPAT | |
95 | silc_failure, | |
96 | +#endif | |
97 | no_silc_key_agreement, | |
98 | no_silc_ftp, | |
99 | +#ifdef SILC_COMPAT | |
100 | no_silc_detach | |
101 | +#endif | |
102 | }; | |
103 | ||
104 | /* Set up the logfile or close it again */ | |
105 | @@ -106,7 +146,7 @@ | |
106 | /* Add dummy field on dummy messages */ | |
107 | if((message) && (type == GURU_PRIVMSG)) | |
108 | { | |
109 | - sprintf(realmessage, "%s %s", guruname, message); | |
110 | + snprintf(realmessage, sizeof(realmessage), "%s %s", guruname, message); | |
111 | message = realmessage; | |
112 | } | |
113 | ||
114 | @@ -209,7 +249,11 @@ | |
115 | fprintf(stderr, "(SILC) >> silc_hmac_register_default returns %i\n", ret); | |
116 | if(!ret) status = NET_ERROR; | |
117 | ||
118 | +#ifdef SILC_COMPAT | |
119 | ret = silc_create_key_pair(NULL, 0, NULL, NULL, NULL, NULL, &pkcs, &pubkey, &privkey, FALSE); | |
120 | +#else | |
121 | + ret = silc_create_key_pair(NULL, 0, NULL, NULL, NULL, NULL, &pubkey, &privkey, FALSE); | |
122 | +#endif | |
123 | fprintf(stderr, "(SILC) >> silc_create_key_pair returns %i\n", ret); | |
124 | if(!ret) status = NET_ERROR; | |
125 | ||
126 | @@ -217,15 +261,31 @@ | |
127 | fprintf(stderr, "(SILC) >> silc_pkcs_alloc returns %i\n", ret); | |
128 | if(!ret) status = NET_ERROR;*/ | |
129 | ||
130 | +#ifdef SILC_COMPAT | |
131 | client->pkcs = pkcs; | |
132 | client->public_key = pubkey; | |
133 | client->private_key = privkey; | |
134 | +#endif | |
135 | ||
136 | +#ifdef SILC_COMPAT | |
137 | ret = silc_client_init(client); | |
138 | +#else | |
139 | + ret = silc_client_init(client, client->username, client->hostname, client->realname, silc_running, NULL); | |
140 | +#endif | |
141 | fprintf(stderr, "(SILC) >> silc_client_init returns %i\n", ret); | |
142 | if(!ret) status = NET_ERROR; | |
143 | ||
144 | +#ifdef SILC_INIT | |
145 | silc_client_connect_to_server(client, NULL, 706, strdup(host), NULL); | |
146 | +#else | |
147 | + ret = silc_load_key_pair(NULL, NULL, NULL, &pubkey, &privkey); | |
148 | + fprintf(stderr, "(SILC) >> silc_load_key_pair returns %i\n", ret); | |
149 | + if(!ret) status = NET_ERROR; | |
150 | + | |
151 | + silc_client_run(client); | |
152 | + | |
153 | + silc_client_free(client); | |
154 | +#endif | |
155 | ||
156 | /*status = NET_GOTREADY;*/ | |
157 | } | |
158 | @@ -278,13 +338,23 @@ | |
159 | { | |
160 | case GURU_CHAT: | |
161 | printf("> %s\n", token); | |
162 | +#ifdef SILC_COMPAT | |
163 | silc_client_send_channel_message(client, connection, | |
164 | lastchannel, NULL, 0, (unsigned char*)token, strlen(token), TRUE); | |
165 | +#else | |
166 | + silc_client_send_channel_message(client, connection, | |
167 | + lastchannel, NULL, 0, NULL, (unsigned char*)token, strlen(token)); | |
168 | +#endif | |
169 | break; | |
170 | case GURU_PRIVMSG: | |
171 | printf("-> %s: %s\n", output->player, token); | |
172 | +#ifdef SILC_COMPAT | |
173 | silc_client_send_channel_message(client, connection, | |
174 | lastchannel, NULL, 0, (unsigned char*)token, strlen(token), TRUE); | |
175 | +#else | |
176 | + silc_client_send_channel_message(client, connection, | |
177 | + lastchannel, NULL, 0, NULL, (unsigned char*)token, strlen(token)); | |
178 | +#endif | |
179 | break; | |
180 | case GURU_ADMIN: | |
181 | printf(">> %s\n", token); | |
182 | @@ -393,7 +463,12 @@ | |
183 | va_end(ap); | |
184 | } | |
185 | ||
186 | +#ifdef SILC_COMPAT | |
187 | static void silc_connected(SilcClient client, SilcClientConnection conn, SilcClientConnectionStatus status) | |
188 | +#else | |
189 | +static void silc_connected(SilcClient client, SilcClientConnection conn, SilcClientConnectionStatus status, | |
190 | + SilcStatus error, const char *message, void *context) | |
191 | +#endif | |
192 | { | |
193 | char *statusstr; | |
194 | ||
195 | @@ -421,6 +496,7 @@ | |
196 | /*status = NET_LOGIN;*/ | |
197 | } | |
198 | ||
199 | +#ifdef SILC_COMPAT | |
200 | static void silc_disconnected(SilcClient client, SilcClientConnection conn, SilcStatus status, const char *message) | |
201 | { | |
202 | fprintf(stderr, "(SILC) disconnected\n"); | |
203 | @@ -434,21 +510,37 @@ | |
204 | ||
205 | status = NET_ERROR; | |
206 | } | |
207 | +#endif | |
208 | ||
209 | +#ifdef SILC_COMPAT | |
210 | static void no_silc_command(SilcClient client, SilcClientConnection conn, SilcClientCommandContext cmd_context, | |
211 | bool success, SilcCommand command, SilcStatus status) | |
212 | +#else | |
213 | +static void no_silc_command(SilcClient client, SilcClientConnection conn, | |
214 | + bool success, SilcCommand command, SilcStatus status, SilcUInt32 argc, unsigned char **argv) | |
215 | +#endif | |
216 | { | |
217 | fprintf(stderr, "(SILC) (NO) command\n"); | |
218 | } | |
219 | ||
220 | +#ifdef SILC_COMPAT | |
221 | static void no_silc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommandPayload cmd_payload, | |
222 | bool success, SilcCommand command, SilcStatus status, ...) | |
223 | +#else | |
224 | +static void no_silc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommand command, | |
225 | + SilcStatus status, SilcStatus error, va_list ap) | |
226 | +#endif | |
227 | { | |
228 | fprintf(stderr, "(SILC) (NO) command reply\n"); | |
229 | } | |
230 | ||
231 | +#ifdef SILC_COMPAT | |
232 | static void no_silc_get_auth_method(SilcClient client, SilcClientConnection conn, char *hostname, SilcUInt16 port, | |
233 | SilcGetAuthMeth completion, void *context) | |
234 | +#else | |
235 | +static void no_silc_get_auth_method(SilcClient client, SilcClientConnection conn, char *hostname, SilcUInt16 port, | |
236 | + SilcAuthMethod method, SilcGetAuthMeth completion, void *context) | |
237 | +#endif | |
238 | { | |
239 | /*InternalGetAuthMethod internal;*/ | |
240 | ||
241 | @@ -463,12 +555,21 @@ | |
242 | ||
243 | silc_client_request_authentication_method(client, conn, | |
244 | silc_get_auth_method_callback, internal);*/ | |
245 | - | |
246 | + | |
247 | +#ifdef SILC_COMPAT | |
248 | (completion)(TRUE, SILC_AUTH_NONE, NULL, 0, context); | |
249 | +#else | |
250 | + (completion)(SILC_AUTH_NONE, NULL, 0, context); | |
251 | +#endif | |
252 | } | |
253 | ||
254 | +#ifdef SILC_COMPAT | |
255 | static void no_silc_verify_public_key(SilcClient client, SilcClientConnection conn, SilcSocketType conn_type, | |
256 | unsigned char *pk, SilcUInt32 pk_len, SilcSKEPKType pk_type, SilcVerifyPublicKey completion, void *context) | |
257 | +#else | |
258 | +static void no_silc_verify_public_key(SilcClient client, SilcClientConnection conn, SilcConnectionType conn_type, | |
259 | + SilcPublicKey public_key, SilcVerifyPublicKey completion, void *context) | |
260 | +#endif | |
261 | { | |
262 | fprintf(stderr, "(SILC) (NO) verify public key\n"); | |
263 | ||
264 | @@ -481,12 +582,15 @@ | |
265 | fprintf(stderr, "(SILC) (NO) ask passphrase\n"); | |
266 | } | |
267 | ||
268 | +#ifdef SILC_COMPAT | |
269 | static bool no_silc_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
270 | const char *hostname, SilcUInt16 port, SilcKeyAgreementCallback *completion, void **context) | |
271 | +#else | |
272 | +static void no_silc_key_agreement(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
273 | + const char *hostname, SilcUInt16 protocol, SilcUInt16 port) | |
274 | +#endif | |
275 | { | |
276 | fprintf(stderr, "(SILC) (NO) key agreement\n"); | |
277 | - | |
278 | - return TRUE; | |
279 | } | |
280 | ||
281 | static void no_silc_ftp(SilcClient client, SilcClientConnection conn, SilcClientEntry client_entry, | |
282 | @@ -495,9 +599,19 @@ | |
283 | fprintf(stderr, "(SILC) (NO) ftp\n"); | |
284 | } | |
285 | ||
286 | +#ifdef SILC_COMPAT | |
287 | static void no_silc_detach(SilcClient client, SilcClientConnection conn, const unsigned char *detach_data, | |
288 | SilcUInt32 detach_data_len) | |
289 | { | |
290 | fprintf(stderr, "(SILC) (NO) detach\n"); | |
291 | } | |
292 | +#endif | |
293 | + | |
294 | +#ifndef SILC_COMPAT | |
295 | +static void silc_running(SilcClient client, void *application) | |
296 | +{ | |
297 | + silc_client_connect_to_server(client, NULL, pubkey, privkey, | |
298 | + client->hostname, 706, silc_connected, NULL); | |
299 | +} | |
300 | +#endif | |
301 | ||
302 | --- ggz-grubby-0.0.14.1/configure.ac.orig 2008-02-14 19:22:07.000000000 +0100 | |
303 | +++ ggz-grubby-0.0.14.1/configure.ac 2013-02-01 15:00:31.881131582 +0100 | |
304 | @@ -213,22 +213,18 @@ | |
305 | echo -n "Extra check: SILC... " | |
306 | ||
307 | incs="/usr/include/silc" | |
308 | - libs="/usr/lib" | |
309 | ||
310 | AC_GGZ_FIND_FILE("silcclient.h", $incs, silc_incdir) | |
311 | silc_includes="$silc_incdir" | |
312 | ||
313 | - AC_GGZ_FIND_FILE("libsilcclient.so", $libs, silc_libdir) | |
314 | - silc_libraries="$silc_libdir" | |
315 | - | |
316 | if test "x$silc_includes" = "xNO" || test "x$silc_libraries" = "xNO"; then | |
317 | AC_MSG_RESULT(no.) | |
318 | silc_includes="" | |
319 | silc_libraries="" | |
320 | enable_silc=no | |
321 | else | |
322 | - SILC_INCLUDES="-I $silc_includes" | |
323 | - SILC_LDFLAGS="-L $silc_libraries" | |
324 | + SILC_INCLUDES="-I$silc_includes" | |
325 | + SILC_LDFLAGS= | |
326 | LIB_SILC="-lsilcclient -lsilc" | |
327 | AC_MSG_RESULT(ok.) | |
328 | AC_SUBST(SILC_INCLUDES) |