2 #define ARMAG "!<arch>\n"
18 #define SAR_HDR (SARNAME+44)
22 static void atimes(char *);
23 static char *split(char*, char**);
26 atimeof(int force, char *name)
30 char *archive, *member, buf[512];
32 archive = split(name, &member);
37 sym = symlook(archive, S_AGG, 0);
39 if(force || (t > (long)sym->value)){
41 sym->value = (void *)t;
46 /* mark the aggegate as having been done */
47 symlook(strdup(archive), S_AGG, "")->value = (void *)t;
49 /* truncate long member name to sizeof of name field in archive header */
51 snprint(buf, sizeof(buf), "%s(%s)", archive, member);
53 snprint(buf, sizeof(buf), "%s(%.*s)", archive, SARNAME, member);
54 sym = symlook(buf, S_TIME, 0);
56 return (long)sym->value; /* uggh */
63 char *archive, *member;
68 archive = split(name, &member);
72 fd = open(archive, ORDWR);
74 fd = create(archive, OWRITE, 0666);
76 fprint(2, "create %s: %r\n", archive);
79 write(fd, ARMAG, SARMAG);
81 if(symlook(name, S_TIME, 0)){
82 /* hoon off and change it in situ */
84 while(read(fd, (char *)&h, sizeof(h)) == sizeof(h)){
85 for(i = SARNAME-1; i > 0 && h.name[i] == ' '; i--)
88 if(strcmp(member, h.name) == 0){
89 t = SARNAME-sizeof(h); /* ughgghh */
91 fprint(fd, "%-12ld", time(0));
109 char name[sizeof(h.name)+1];
111 fd = open(ar, OREAD);
115 if(read(fd, buf, SARMAG) != SARMAG){
119 while(read(fd, (char *)&h, sizeof(h)) == sizeof(h)){
121 if(t == 0) /* as it sometimes happens; thanks ken */
123 strncpy(name, h.name, sizeof(h.name));
124 for(i = sizeof(h.name)-1; i > 0 && name[i] == ' '; i--)
126 if(name[i] == '/') /* system V bug */
129 sprint(buf, "%s(%s)", ar, h.size);
130 symlook(strdup(buf), S_TIME, (void *)t)->value = (void *)t;
144 fd = open(file, OREAD);
146 if(symlook(file, S_BITCH, 0) == 0){
147 Bprint(&bout, "%s doesn't exist: assuming it will be an archive\n", file);
148 symlook(file, S_BITCH, (void *)file);
152 if(read(fd, buf, SARMAG) != SARMAG){
157 return !strncmp(ARMAG, buf, SARMAG);
161 split(char *name, char **member)
177 fprint(2, "mk: '%s' is not an archive\n", name);