… | |
… | |
33 | * things like all the structures as globals. |
33 | * things like all the structures as globals. |
34 | */ |
34 | */ |
35 | |
35 | |
36 | #include <global.h> |
36 | #include <global.h> |
37 | #include <sproto.h> |
37 | #include <sproto.h> |
|
|
38 | |
|
|
39 | #include "crc.h" |
38 | |
40 | |
39 | #define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */ |
41 | #define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */ |
40 | |
42 | |
41 | /** Information about one image */ |
43 | /** Information about one image */ |
42 | typedef struct FaceInfo |
44 | typedef struct FaceInfo |
… | |
… | |
280 | LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf); |
282 | LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf); |
281 | abort (); |
283 | abort (); |
282 | } |
284 | } |
283 | |
285 | |
284 | /* Skip accross the number data */ |
286 | /* Skip accross the number data */ |
285 | for (cp = buf + 6; *cp != ' '; cp++); |
287 | for (cp = buf + 6; *cp != ' '; cp++) |
|
|
288 | ; |
|
|
289 | |
286 | len = atoi (cp); |
290 | len = atoi (cp); |
287 | if (len == 0 || len > MAX_IMAGE_SIZE) |
291 | if (len == 0 || len > MAX_IMAGE_SIZE) |
288 | { |
292 | { |
289 | LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf); |
293 | LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf); |
290 | abort (); |
294 | abort (); |
… | |
… | |
299 | { |
303 | { |
300 | LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf); |
304 | LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf); |
301 | abort (); |
305 | abort (); |
302 | } |
306 | } |
303 | |
307 | |
304 | facesets[fileno].faces[num].checksum = 0; |
308 | crc32 chksum; |
|
|
309 | |
305 | for (i = 0; i < len; i++) |
310 | for (i = 0; i < len; i++) |
306 | { |
311 | chksum (facesets[fileno].faces[num].data[i]); |
307 | ROTATE_RIGHT (facesets[fileno].faces[num].checksum); |
312 | |
308 | facesets[fileno].faces[num].checksum += facesets[fileno].faces[num].data[i]; |
|
|
309 | facesets[fileno].faces[num].checksum &= 0xffffffff; |
313 | facesets[fileno].faces[num].checksum = chksum; |
310 | } |
|
|
311 | } |
314 | } |
312 | |
315 | |
313 | close_and_delete (infile, compressed); |
316 | close_and_delete (infile, compressed); |
314 | } /* For fileno < MAX_FACE_SETS */ |
317 | } /* For fileno < MAX_FACE_SETS */ |
315 | } |
318 | } |
… | |
… | |
414 | void |
417 | void |
415 | send_image_info (client *ns, char *params) |
418 | send_image_info (client *ns, char *params) |
416 | { |
419 | { |
417 | packet sl; |
420 | packet sl; |
418 | |
421 | |
419 | sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); |
422 | sl.printf ("replyinfo image_info\n%d\n%u\n", nrofpixmaps - 1, (unsigned int)bmaps_checksum); |
420 | |
423 | |
421 | for (int i = 0; i < MAX_FACE_SETS; i++) |
424 | for (int i = 0; i < MAX_FACE_SETS; i++) |
422 | if (facesets[i].prefix) |
425 | if (facesets[i].prefix) |
423 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", i, |
426 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", i, |
424 | facesets[i].prefix, facesets[i].fullname , facesets[i].fallback, |
427 | facesets[i].prefix, facesets[i].fullname , facesets[i].fallback, |
… | |
… | |
438 | */ |
441 | */ |
439 | void |
442 | void |
440 | send_image_sums (client *ns, char *params) |
443 | send_image_sums (client *ns, char *params) |
441 | { |
444 | { |
442 | int start, stop; |
445 | int start, stop; |
443 | char *cp, buf[MAX_BUF]; |
446 | char *cp; |
444 | |
447 | |
445 | packet sl; |
448 | packet sl; |
446 | |
449 | |
447 | start = atoi (params); |
450 | start = atoi (params); |
448 | for (cp = params; *cp != '\0'; cp++) |
451 | for (cp = params; *cp != '\0'; cp++) |