sumversion.c (f693153519607449d3e270d9e6af20b032543c05) | sumversion.c (f531c1b5de65bc687bdcca69e7649fe2db5b6d87) |
---|---|
1#include <netinet/in.h> 2#ifdef __sun__ 3#include <inttypes.h> 4#else 5#include <stdint.h> 6#endif 7#include <ctype.h> 8#include <errno.h> --- 378 unchanged lines hidden (view full) --- 387 free(dir); 388 free(cmd); 389 return ret; 390} 391 392/* Calc and record src checksum. */ 393void get_src_version(const char *modname, char sum[], unsigned sumlen) 394{ | 1#include <netinet/in.h> 2#ifdef __sun__ 3#include <inttypes.h> 4#else 5#include <stdint.h> 6#endif 7#include <ctype.h> 8#include <errno.h> --- 378 unchanged lines hidden (view full) --- 387 free(dir); 388 free(cmd); 389 return ret; 390} 391 392/* Calc and record src checksum. */ 393void get_src_version(const char *modname, char sum[], unsigned sumlen) 394{ |
395 void *file; 396 unsigned long len; | 395 char *buf, *pos, *firstline; |
397 struct md4_ctx md; | 396 struct md4_ctx md; |
398 char *sources, *end, *fname; | 397 char *fname; |
399 char filelist[PATH_MAX + 1]; 400 401 /* objects for a module are listed in the first line of *.mod file. */ 402 snprintf(filelist, sizeof(filelist), "%.*smod", 403 (int)strlen(modname) - 1, modname); 404 | 398 char filelist[PATH_MAX + 1]; 399 400 /* objects for a module are listed in the first line of *.mod file. */ 401 snprintf(filelist, sizeof(filelist), "%.*smod", 402 (int)strlen(modname) - 1, modname); 403 |
405 file = grab_file(filelist, &len); 406 if (!file) 407 /* not a module or .mod file missing - ignore */ 408 return; | 404 buf = read_text_file(filelist); |
409 | 405 |
410 sources = file; 411 412 end = strchr(sources, '\n'); 413 if (!end) { | 406 pos = buf; 407 firstline = get_line(&pos); 408 if (!firstline) { |
414 warn("bad ending versions file for %s\n", modname); | 409 warn("bad ending versions file for %s\n", modname); |
415 goto release; | 410 goto free; |
416 } | 411 } |
417 *end = '\0'; | |
418 419 md4_init(&md); | 412 413 md4_init(&md); |
420 while ((fname = strsep(&sources, " ")) != NULL) { | 414 while ((fname = strsep(&firstline, " "))) { |
421 if (!*fname) 422 continue; 423 if (!(is_static_library(fname)) && 424 !parse_source_files(fname, &md)) | 415 if (!*fname) 416 continue; 417 if (!(is_static_library(fname)) && 418 !parse_source_files(fname, &md)) |
425 goto release; | 419 goto free; |
426 } 427 428 md4_final_ascii(&md, sum, sumlen); | 420 } 421 422 md4_final_ascii(&md, sum, sumlen); |
429release: 430 release_file(file, len); | 423free: 424 free(buf); |
431} | 425} |