1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2001 Mark Wedel |
5 | * Copyright (C) 2001 Mark Wedel |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * 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 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /** \file |
25 | /** \file |
25 | * Image related communication |
26 | * Image related communication |
26 | * |
27 | * |
27 | * \date 2003-12-02 |
28 | * \date 2003-12-02 |
… | |
… | |
33 | */ |
34 | */ |
34 | |
35 | |
35 | #include <global.h> |
36 | #include <global.h> |
36 | #include <sproto.h> |
37 | #include <sproto.h> |
37 | |
38 | |
38 | #include <newclient.h> |
|
|
39 | #include <newserver.h> |
|
|
40 | #include <loader.h> |
|
|
41 | |
|
|
42 | #define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */ |
39 | #define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */ |
43 | |
40 | |
44 | /** Information about one image */ |
41 | /** Information about one image */ |
45 | typedef struct FaceInfo |
42 | typedef struct FaceInfo |
46 | { |
43 | { |
47 | |
|
|
48 | uint8 *data; /**< image data */ |
44 | uint8 *data; /**< image data */ |
49 | |
|
|
50 | uint16 datalen; /**< length of the xpm data */ |
45 | uint16 datalen; /**< length of the xpm data */ |
51 | |
|
|
52 | uint32 checksum; /**< Checksum of face data */ |
46 | uint32 checksum; /**< Checksum of face data */ |
53 | } FaceInfo; |
47 | } FaceInfo; |
54 | |
48 | |
55 | /** Information about one face set */ |
49 | /** Information about one face set */ |
56 | typedef struct |
50 | typedef struct |
57 | { |
51 | { |
58 | |
|
|
59 | char *prefix; /**< */ |
52 | char *prefix; /**< */ |
60 | char *fullname; |
53 | char *fullname; |
61 | |
54 | |
62 | uint8 fallback; /**< faceset to use when an image is not found in this faceset */ |
55 | uint8 fallback; /**< faceset to use when an image is not found in this faceset */ |
63 | char *size; |
56 | char *size; |
… | |
… | |
94 | if (facesets[num].prefix) |
87 | if (facesets[num].prefix) |
95 | { |
88 | { |
96 | for (q = 0; q < nrofpixmaps; q++) |
89 | for (q = 0; q < nrofpixmaps; q++) |
97 | if (facesets[num].faces[q].data) |
90 | if (facesets[num].faces[q].data) |
98 | free (facesets[num].faces[q].data); |
91 | free (facesets[num].faces[q].data); |
|
|
92 | |
99 | free (facesets[num].prefix); |
93 | free (facesets[num].prefix); |
100 | free (facesets[num].fullname); |
94 | free (facesets[num].fullname); |
101 | free (facesets[num].size); |
95 | free (facesets[num].size); |
102 | free (facesets[num].extension); |
96 | free (facesets[num].extension); |
103 | free (facesets[num].comment); |
97 | free (facesets[num].comment); |
… | |
… | |
133 | if (!facesets[faceset].prefix) |
127 | if (!facesets[faceset].prefix) |
134 | { |
128 | { |
135 | LOG (llevError, "get_face_fallback called with unused set (%d)?\n", faceset); |
129 | LOG (llevError, "get_face_fallback called with unused set (%d)?\n", faceset); |
136 | return 0; /* use default set */ |
130 | return 0; /* use default set */ |
137 | } |
131 | } |
|
|
132 | |
138 | if (facesets[faceset].faces[imageno].data) |
133 | if (facesets[faceset].faces[imageno].data) |
139 | return faceset; |
134 | return faceset; |
|
|
135 | |
140 | return get_face_fallback (facesets[faceset].fallback, imageno); |
136 | return get_face_fallback (facesets[faceset].fallback, imageno); |
141 | } |
137 | } |
142 | |
138 | |
143 | /** |
139 | /** |
144 | * Checks fallback are correctly defined. |
140 | * Checks fallback are correctly defined. |
… | |
… | |
160 | if (!facesets[fallback].prefix) |
156 | if (!facesets[fallback].prefix) |
161 | { |
157 | { |
162 | LOG (llevError, "Face set %d falls to non set faceset %d\n", faceset, fallback); |
158 | LOG (llevError, "Face set %d falls to non set faceset %d\n", faceset, fallback); |
163 | abort (); |
159 | abort (); |
164 | } |
160 | } |
|
|
161 | |
165 | togo--; |
162 | togo--; |
166 | if (togo == 0) |
163 | if (togo == 0) |
167 | { |
164 | { |
168 | LOG (llevError, "Infinite loop found in facesets. aborting.\n"); |
165 | LOG (llevError, "Infinite loop found in facesets. aborting.\n"); |
169 | abort (); |
166 | abort (); |
170 | } |
167 | } |
|
|
168 | |
171 | check_faceset_fallback (fallback, togo); |
169 | check_faceset_fallback (fallback, togo); |
172 | } |
170 | } |
173 | |
171 | |
174 | #define MAX_IMAGE_SIZE 10000 |
172 | #define MAX_IMAGE_SIZE 10000 |
175 | |
173 | |
… | |
… | |
187 | * Function largely rewritten May 2000 to be more general purpose. |
185 | * Function largely rewritten May 2000 to be more general purpose. |
188 | * The server itself does not care what the image data is - to the server, |
186 | * The server itself does not care what the image data is - to the server, |
189 | * it is just data it needs to allocate. As such, the code is written |
187 | * it is just data it needs to allocate. As such, the code is written |
190 | * to do such. |
188 | * to do such. |
191 | */ |
189 | */ |
192 | |
|
|
193 | void |
190 | void |
194 | read_client_images (void) |
191 | read_client_images (void) |
195 | { |
192 | { |
196 | char filename[400]; |
193 | char filename[400]; |
197 | char buf[HUGE_BUF]; |
194 | char buf[HUGE_BUF]; |
… | |
… | |
204 | if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) |
201 | if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) |
205 | { |
202 | { |
206 | LOG (llevError, "Unable to open %s\n", filename); |
203 | LOG (llevError, "Unable to open %s\n", filename); |
207 | abort (); |
204 | abort (); |
208 | } |
205 | } |
|
|
206 | |
209 | while (fgets (buf, HUGE_BUF - 1, infile) != NULL) |
207 | while (fgets (buf, HUGE_BUF - 1, infile) != NULL) |
210 | { |
208 | { |
211 | badline = 0; |
209 | badline = 0; |
212 | |
210 | |
213 | if (buf[0] == '#') |
211 | if (buf[0] == '#') |
214 | continue; |
212 | continue; |
|
|
213 | |
215 | if (!(cps[0] = strtok (buf, ":"))) |
214 | if (!(cps[0] = strtok (buf, ":"))) |
216 | badline = 1; |
215 | badline = 1; |
|
|
216 | |
217 | for (i = 1; i < 7; i++) |
217 | for (i = 1; i < 7; i++) |
218 | { |
|
|
219 | if (!(cps[i] = strtok (NULL, ":"))) |
218 | if (!(cps[i] = strtok (NULL, ":"))) |
220 | badline = 1; |
219 | badline = 1; |
221 | } |
220 | |
222 | if (badline) |
221 | if (badline) |
223 | { |
|
|
224 | LOG (llevError, "Bad line in image_info file, ignoring line:\n %s", buf); |
222 | LOG (llevError, "Bad line in image_info file, ignoring line:\n %s", buf); |
225 | } |
|
|
226 | else |
223 | else |
227 | { |
224 | { |
228 | len = atoi (cps[0]); |
225 | len = atoi (cps[0]); |
229 | if (len >= MAX_FACE_SETS) |
226 | if (len >= MAX_FACE_SETS) |
230 | { |
227 | { |
231 | LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS); |
228 | LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS); |
232 | abort (); |
229 | abort (); |
233 | } |
230 | } |
234 | facesets[len].prefix = strdup_local (cps[1]); |
231 | facesets[len].prefix = strdup (cps[1]); |
235 | facesets[len].fullname = strdup_local (cps[2]); |
232 | facesets[len].fullname = strdup (cps[2]); |
236 | facesets[len].fallback = atoi (cps[3]); |
233 | facesets[len].fallback = atoi (cps[3]); |
237 | facesets[len].size = strdup_local (cps[4]); |
234 | facesets[len].size = strdup (cps[4]); |
238 | facesets[len].extension = strdup_local (cps[5]); |
235 | facesets[len].extension = strdup (cps[5]); |
239 | facesets[len].comment = strdup_local (cps[6]); |
236 | facesets[len].comment = strdup (cps[6]); |
240 | } |
237 | } |
241 | } |
238 | } |
|
|
239 | |
242 | close_and_delete (infile, compressed); |
240 | close_and_delete (infile, compressed); |
|
|
241 | |
243 | for (i = 0; i < MAX_FACE_SETS; i++) |
242 | for (i = 0; i < MAX_FACE_SETS; i++) |
244 | { |
243 | { |
245 | if (facesets[i].prefix) |
244 | if (facesets[i].prefix) |
246 | check_faceset_fallback (i, MAX_FACE_SETS); |
245 | check_faceset_fallback (i, MAX_FACE_SETS); |
247 | } |
246 | } |
|
|
247 | |
248 | /* Loaded the faceset information - now need to load up the |
248 | /* Loaded the faceset information - now need to load up the |
249 | * actual faces. |
249 | * actual faces. |
250 | */ |
250 | */ |
251 | |
251 | |
252 | for (fileno = 0; fileno < MAX_FACE_SETS; fileno++) |
252 | for (fileno = 0; fileno < MAX_FACE_SETS; fileno++) |
253 | { |
253 | { |
254 | /* if prefix is not set, this is not used */ |
254 | /* if prefix is not set, this is not used */ |
255 | if (!facesets[fileno].prefix) |
255 | if (!facesets[fileno].prefix) |
256 | continue; |
256 | continue; |
|
|
257 | |
257 | facesets[fileno].faces = (FaceInfo *) calloc (nrofpixmaps, sizeof (FaceInfo)); |
258 | facesets[fileno].faces = (FaceInfo *) calloc (nrofpixmaps, sizeof (FaceInfo)); |
258 | |
259 | |
259 | sprintf (filename, "%s/crossfire.%d", settings.datadir, fileno); |
260 | sprintf (filename, "%s/crossfire.%d", settings.datadir, fileno); |
260 | LOG (llevDebug, "Loading image file %s\n", filename); |
261 | LOG (llevDebug, "Loading image file %s\n", filename); |
261 | |
262 | |
262 | if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) |
263 | if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) |
263 | { |
264 | { |
264 | LOG (llevError, "Unable to open %s\n", filename); |
265 | LOG (llevError, "Unable to open %s\n", filename); |
265 | abort (); |
266 | abort (); |
266 | } |
267 | } |
|
|
268 | |
267 | while (fgets (buf, HUGE_BUF - 1, infile) != NULL) |
269 | while (fgets (buf, HUGE_BUF - 1, infile) != NULL) |
268 | { |
270 | { |
269 | if (strncmp (buf, "IMAGE ", 6) != 0) |
271 | if (strncmp (buf, "IMAGE ", 6) != 0) |
270 | { |
272 | { |
271 | LOG (llevError, "read_client_images:Bad image line - not IMAGE, instead\n%s", buf); |
273 | LOG (llevError, "read_client_images:Bad image line - not IMAGE, instead\n%s", buf); |
272 | abort (); |
274 | abort (); |
273 | } |
275 | } |
|
|
276 | |
274 | num = atoi (buf + 6); |
277 | num = atoi (buf + 6); |
275 | if (num < 0 || num >= nrofpixmaps) |
278 | if (num < 0 || num >= nrofpixmaps) |
276 | { |
279 | { |
277 | LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf); |
280 | LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf); |
278 | abort (); |
281 | abort (); |
279 | } |
282 | } |
|
|
283 | |
280 | /* Skip accross the number data */ |
284 | /* Skip accross the number data */ |
281 | for (cp = buf + 6; *cp != ' '; cp++); |
285 | for (cp = buf + 6; *cp != ' '; cp++); |
282 | len = atoi (cp); |
286 | len = atoi (cp); |
283 | if (len == 0 || len > MAX_IMAGE_SIZE) |
287 | if (len == 0 || len > MAX_IMAGE_SIZE) |
284 | { |
288 | { |
285 | LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf); |
289 | LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf); |
286 | abort (); |
290 | abort (); |
287 | } |
291 | } |
|
|
292 | |
288 | /* We don't actualy care about the name of the image that |
293 | /* We don't actualy care about the name of the image that |
289 | * is embedded in the image file, so just ignore it. |
294 | * is embedded in the image file, so just ignore it. |
290 | */ |
295 | */ |
291 | facesets[fileno].faces[num].datalen = len; |
296 | facesets[fileno].faces[num].datalen = len; |
292 | facesets[fileno].faces[num].data = (uint8 *) malloc (len); |
297 | facesets[fileno].faces[num].data = (uint8 *) malloc (len); |
293 | if ((i = fread (facesets[fileno].faces[num].data, len, 1, infile)) != 1) |
298 | if ((i = fread (facesets[fileno].faces[num].data, len, 1, infile)) != 1) |
294 | { |
299 | { |
295 | LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf); |
300 | LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf); |
296 | abort (); |
301 | abort (); |
297 | } |
302 | } |
|
|
303 | |
298 | facesets[fileno].faces[num].checksum = 0; |
304 | facesets[fileno].faces[num].checksum = 0; |
299 | for (i = 0; i < len; i++) |
305 | for (i = 0; i < len; i++) |
300 | { |
306 | { |
301 | ROTATE_RIGHT (facesets[fileno].faces[num].checksum); |
307 | rotate_right (facesets[fileno].faces[num].checksum); |
302 | facesets[fileno].faces[num].checksum += facesets[fileno].faces[num].data[i]; |
308 | facesets[fileno].faces[num].checksum += facesets[fileno].faces[num].data[i]; |
303 | facesets[fileno].faces[num].checksum &= 0xffffffff; |
309 | facesets[fileno].faces[num].checksum &= 0xffffffff; |
304 | } |
310 | } |
305 | } |
311 | } |
|
|
312 | |
306 | close_and_delete (infile, compressed); |
313 | close_and_delete (infile, compressed); |
307 | } /* For fileno < MAX_FACE_SETS */ |
314 | } /* For fileno < MAX_FACE_SETS */ |
308 | } |
315 | } |
309 | |
316 | |
310 | /** |
317 | /** |
311 | * Client tells us what type of faces it wants. Also sets |
318 | * Client tells us what type of faces it wants. Also sets |
312 | * the caching attribute. |
319 | * the caching attribute. |
313 | * |
320 | * |
314 | */ |
321 | */ |
315 | |
|
|
316 | void |
322 | void |
317 | SetFaceMode (char *buf, int len, NewSocket *ns) |
323 | SetFaceMode (char *buf, int len, client *ns) |
318 | { |
324 | { |
319 | int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); |
325 | int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); |
320 | |
326 | |
321 | if (mode == CF_FACE_NONE) |
327 | if (mode == CF_FACE_NONE) |
322 | ns->facecache = 1; |
328 | ns->facecache = 1; |
323 | else if (mode != CF_FACE_PNG) |
329 | else if (mode != CF_FACE_PNG) |
324 | { |
|
|
325 | packet sl; |
|
|
326 | sl.printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); |
330 | ns->send_packet_printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); |
327 | ns->send_packet (sl); |
|
|
328 | } |
|
|
329 | |
331 | |
330 | if (mask) |
332 | if (mask) |
331 | ns->facecache = 1; |
333 | ns->facecache = 1; |
332 | } |
334 | } |
333 | |
335 | |
334 | /** |
336 | /** |
335 | * Client has requested pixmap that it somehow missed getting. |
337 | * Client has requested pixmap that it somehow missed getting. |
336 | * This will be called often if the client is |
338 | * This will be called often if the client is |
337 | * caching images. |
339 | * caching images. |
338 | */ |
340 | */ |
339 | |
|
|
340 | void |
341 | void |
341 | SendFaceCmd (char *buff, int len, NewSocket * ns) |
342 | SendFaceCmd (char *buf, int len, client *ns) |
342 | { |
343 | { |
343 | long tmpnum = atoi (buff); |
344 | uint16 facenum = atoi (buf); |
344 | short facenum = tmpnum & 0xffff; |
|
|
345 | |
345 | |
346 | if (facenum != 0) |
346 | if (facenum != 0) |
347 | esrv_send_face (ns, facenum, 1); |
347 | esrv_send_face (ns, facenum, 1); |
348 | } |
348 | } |
349 | |
349 | |
… | |
… | |
353 | * If nocache is true (nonzero), ignore the cache setting from the client - |
353 | * If nocache is true (nonzero), ignore the cache setting from the client - |
354 | * this is needed for the askface, in which we really do want to send the |
354 | * this is needed for the askface, in which we really do want to send the |
355 | * face (and askface is the only place that should be setting it). Otherwise, |
355 | * face (and askface is the only place that should be setting it). Otherwise, |
356 | * we look at the facecache, and if set, send the image name. |
356 | * we look at the facecache, and if set, send the image name. |
357 | */ |
357 | */ |
358 | |
|
|
359 | void |
358 | void |
360 | esrv_send_face (NewSocket *ns, short face_num, int nocache) |
359 | esrv_send_face (client *ns, short face_num, int nocache) |
361 | { |
360 | { |
362 | char fallback; |
361 | char fallback; |
363 | |
362 | |
364 | if (face_num <= 0 || face_num >= nrofpixmaps) |
363 | if (face_num <= 0 || face_num >= nrofpixmaps) |
365 | { |
364 | { |
… | |
… | |
385 | sl << uint8 (fallback); |
384 | sl << uint8 (fallback); |
386 | |
385 | |
387 | sl << uint32 (facesets[fallback].faces[face_num].checksum) |
386 | sl << uint32 (facesets[fallback].faces[face_num].checksum) |
388 | << new_faces[face_num].name; |
387 | << new_faces[face_num].name; |
389 | |
388 | |
390 | Send_With_Handling (ns, &sl); |
389 | ns->send_packet (sl); |
391 | } |
390 | } |
392 | else |
391 | else |
393 | { |
392 | { |
394 | sl << (ns->image2 ? "image2 " : "image ") |
393 | sl << (ns->image2 ? "image2 " : "image ") |
395 | << uint32 (face_num); |
394 | << uint32 (face_num); |
… | |
… | |
398 | sl << uint8 (fallback); |
397 | sl << uint8 (fallback); |
399 | |
398 | |
400 | sl << uint32 (facesets[fallback].faces[face_num].datalen) |
399 | sl << uint32 (facesets[fallback].faces[face_num].datalen) |
401 | << data (facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen); |
400 | << data (facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen); |
402 | |
401 | |
403 | Send_With_Handling (ns, &sl); |
402 | ns->send_packet (sl); |
404 | } |
403 | } |
405 | |
404 | |
406 | ns->faces_sent[face_num] |= NS_FACESENT_FACE; |
405 | ns->faces_sent[face_num] |= NS_FACESENT_FACE; |
407 | } |
406 | } |
408 | |
407 | |
… | |
… | |
411 | * and the image_info file information. See the doc/Developers/protocol |
410 | * and the image_info file information. See the doc/Developers/protocol |
412 | * if you want further detail. |
411 | * if you want further detail. |
413 | */ |
412 | */ |
414 | |
413 | |
415 | void |
414 | void |
416 | send_image_info (NewSocket * ns, char *params) |
415 | send_image_info (client *ns, char *params) |
417 | { |
416 | { |
418 | packet sl; |
417 | packet sl; |
419 | |
418 | |
420 | sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); |
419 | sl.printf ("replyinfo image_info\n%d\n%u\n", nrofpixmaps - 1, (unsigned int)bmaps_checksum); |
421 | |
420 | |
422 | for (int i = 0; i < MAX_FACE_SETS; i++) |
421 | for (int i = 0; i < MAX_FACE_SETS; i++) |
423 | if (facesets[i].prefix) |
422 | if (facesets[i].prefix) |
424 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", |
423 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", i, |
425 | i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback, |
424 | facesets[i].prefix, facesets[i].fullname , facesets[i].fallback, |
426 | facesets[i].size, facesets[i].extension, facesets[i].comment); |
425 | facesets[i].size , facesets[i].extension, facesets[i].comment); |
427 | |
426 | |
428 | Send_With_Handling (ns, &sl); |
427 | ns->send_packet (sl); |
429 | } |
428 | } |
430 | |
429 | |
431 | /** |
430 | /** |
432 | * Sends requested face information. |
431 | * Sends requested face information. |
433 | * \param ns socket to send to |
432 | * \param ns socket to send to |
… | |
… | |
436 | * For each image in [start..stop] sends |
435 | * For each image in [start..stop] sends |
437 | * - checksum |
436 | * - checksum |
438 | * - name |
437 | * - name |
439 | */ |
438 | */ |
440 | void |
439 | void |
441 | send_image_sums (NewSocket * ns, char *params) |
440 | send_image_sums (client *ns, char *params) |
442 | { |
441 | { |
443 | int start, stop; |
442 | int start, stop; |
444 | char *cp, buf[MAX_BUF]; |
443 | char *cp, buf[MAX_BUF]; |
445 | |
444 | |
446 | packet sl; |
445 | packet sl; |
… | |
… | |
476 | /* It would make more sense to catch this pre-emptively in the code above. |
475 | /* It would make more sense to catch this pre-emptively in the code above. |
477 | * however, if this really happens, we probably just want to cut down the |
476 | * however, if this really happens, we probably just want to cut down the |
478 | * size to less than 1000, since that is what we claim the protocol would |
477 | * size to less than 1000, since that is what we claim the protocol would |
479 | * support. |
478 | * support. |
480 | */ |
479 | */ |
481 | if (sl.len >= MAXSOCKBUF) |
480 | if (sl.length () >= MAXSOCKBUF) |
482 | { |
481 | { |
483 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.len, MAXSOCKBUF); |
482 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF); |
484 | abort (); |
483 | abort (); |
485 | } |
484 | } |
486 | |
485 | |
487 | Send_With_Handling (ns, &sl); |
486 | ns->send_packet (sl); |
488 | } |
487 | } |
489 | |
488 | |