Changeset 900 for vendor/gnumake/current/arscan.c
- Timestamp:
- May 23, 2007, 5:13:11 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/arscan.c
r501 r900 26 26 27 27 #ifndef NO_ARCHIVES 28 29 28 30 29 #ifdef VMS … … 136 135 137 136 long int 138 ar_scan (c har *archive, long int (*function) PARAMS ((void)), long intarg)137 ar_scan (const char *archive, ar_member_func_t function, const void *arg) 139 138 { 140 139 char *p; … … 304 303 305 304 long int 306 ar_scan (c har *archive, long int (*function)(), long intarg)305 ar_scan (const char *archive, ar_member_func_t function, const void *arg) 307 306 { 308 307 #ifdef AIAMAG … … 316 315 #endif 317 316 char *namemap = 0; 318 registerint desc = open (archive, O_RDONLY, 0);317 int desc = open (archive, O_RDONLY, 0); 319 318 if (desc < 0) 320 319 return -1; … … 323 322 char buf[SARMAG]; 324 323 register int nread = read (desc, buf, SARMAG); 325 if (nread != SARMAG || bcmp (buf, ARMAG, SARMAG))324 if (nread != SARMAG || memcmp (buf, ARMAG, SARMAG)) 326 325 { 327 326 (void) close (desc); … … 332 331 #ifdef AIAMAG 333 332 { 334 register int nread = read (desc, (char *)&fl_header, FL_HSZ);333 register int nread = read (desc, &fl_header, FL_HSZ); 335 334 336 335 if (nread != FL_HSZ) … … 342 341 /* If this is a "big" archive, then set the flag and 343 342 re-read the header into the "big" structure. */ 344 if (! bcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG))343 if (!memcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG)) 345 344 { 346 345 big_archive = 1; … … 354 353 355 354 /* re-read the header into the "big" structure */ 356 nread = read (desc, (char *)&fl_header_big, FL_HSZ_BIG);355 nread = read (desc, &fl_header_big, FL_HSZ_BIG); 357 356 if (nread != FL_HSZ_BIG) 358 357 { … … 364 363 #endif 365 364 /* Check to make sure this is a "normal" archive. */ 366 if ( bcmp (fl_header.fl_magic, AIAMAG, SAIAMAG))365 if (memcmp (fl_header.fl_magic, AIAMAG, SAIAMAG)) 367 366 { 368 367 (void) close (desc); … … 458 457 if (big_archive) 459 458 { 460 nread = read (desc, (char *)&member_header_big,459 nread = read (desc, &member_header_big, 461 460 AR_MEMHDR_SZ(member_header_big) ); 462 461 … … 490 489 #endif 491 490 { 492 nread = read (desc, (char *)&member_header,491 nread = read (desc, &member_header, 493 492 AR_MEMHDR_SZ(member_header) ); 494 493 … … 528 527 529 528 #else /* Not AIAMAG. */ 530 nread = read (desc, (char *)&member_header, AR_HDR_SIZE);529 nread = read (desc, &member_header, AR_HDR_SIZE); 531 530 if (nread == 0) 532 531 /* No data left means end of file; that is OK. */ … … 537 536 || ( 538 537 # ifdef ARFMAG 539 bcmp (member_header.ar_fmag, ARFMAG, 2)538 memcmp (member_header.ar_fmag, ARFMAG, 2) 540 539 # else 541 540 1 … … 543 542 && 544 543 # ifdef ARFZMAG 545 bcmp (member_header.ar_fmag, ARFZMAG, 2)544 memcmp (member_header.ar_fmag, ARFZMAG, 2) 546 545 # else 547 546 1 … … 556 555 557 556 name = namebuf; 558 bcopy (member_header.ar_name,name, sizeof member_header.ar_name);557 memcpy (name, member_header.ar_name, sizeof member_header.ar_name); 559 558 { 560 559 register char *p = name + sizeof member_header.ar_name; … … 596 595 int namesize = atoi (name + 3); 597 596 598 name = (char *)alloca (namesize + 1);597 name = alloca (namesize + 1); 599 598 nread = read (desc, name, namesize); 600 599 if (nread != namesize) … … 667 666 char *limit; 668 667 669 namemap = (char *)alloca (eltsize);668 namemap = alloca (eltsize); 670 669 nread = read (desc, namemap, eltsize); 671 670 if (nread != eltsize) … … 710 709 711 710 int 712 ar_name_equal (c har *name,char *mem, int truncated)711 ar_name_equal (const char *name, const char *mem, int truncated) 713 712 { 714 c har *p;713 const char *p; 715 714 716 715 p = strrchr (name, '/'); … … 742 741 /* ARGSUSED */ 743 742 static long int 744 ar_member_pos (int desc UNUSED, c har *mem, int truncated,743 ar_member_pos (int desc UNUSED, const char *mem, int truncated, 745 744 long int hdrpos, long int datapos UNUSED, long int size UNUSED, 746 745 long int date UNUSED, int uid UNUSED, int gid UNUSED, 747 int mode UNUSED, c har*name)746 int mode UNUSED, const void *name) 748 747 { 749 748 if (!ar_name_equal (name, mem, truncated)) … … 760 759 761 760 int 762 ar_member_touch (c har *arname,char *memname)761 ar_member_touch (const char *arname, const char *memname) 763 762 { 764 long int pos = ar_scan (arname, ar_member_pos, (long int)memname);763 long int pos = ar_scan (arname, ar_member_pos, memname); 765 764 int fd; 766 765 struct ar_hdr ar_hdr; … … 780 779 if (lseek (fd, pos, 0) < 0) 781 780 goto lose; 782 if (AR_HDR_SIZE != read (fd, (char *)&ar_hdr, AR_HDR_SIZE))781 if (AR_HDR_SIZE != read (fd, &ar_hdr, AR_HDR_SIZE)) 783 782 goto lose; 784 783 /* Write back the header, thus touching the archive file. */ 785 784 if (lseek (fd, pos, 0) < 0) 786 785 goto lose; 787 if (AR_HDR_SIZE != write (fd, (char *)&ar_hdr, AR_HDR_SIZE))786 if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE)) 788 787 goto lose; 789 788 /* The file's mtime is the time we we want. */ … … 805 804 if (lseek (fd, pos, 0) < 0) 806 805 goto lose; 807 if (AR_HDR_SIZE != write (fd, (char *)&ar_hdr, AR_HDR_SIZE))806 if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE)) 808 807 goto lose; 809 808 close (fd); … … 822 821 823 822 long int 824 describe_member (int desc, c har *name, int truncated,823 describe_member (int desc, const char *name, int truncated, 825 824 long int hdrpos, long int datapos, long int size, 826 long int date, int uid, int gid, int mode )825 long int date, int uid, int gid, int mode, const void *arg) 827 826 { 828 827 extern char *ctime (); … … 840 839 main (int argc, char **argv) 841 840 { 842 ar_scan (argv[1], describe_member );841 ar_scan (argv[1], describe_member, NULL); 843 842 return 0; 844 843 }
Note:
See TracChangeset
for help on using the changeset viewer.