Patch #: 190 Type: operational change Priority: none Modification: add builddt program for rebuilding AUFS DeskTop files Submitted: David Hornsby Submitted: Tim Leamy Archived: munnari.OZ.AU mac/cap.patches/cap60.patch190 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch190' File: cap60/contrib/DeskTop/Makefile File: cap60/contrib/DeskTop/README File: cap60/contrib/DeskTop/builddt.c File: cap60/contrib/DeskTop/dt.h File: cap60/contrib/DeskTop/dtmisc.c File: cap60/contrib/DeskTop/dumpdt.c *** contrib/DeskTop/Makefile.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/Makefile Sat Feb 5 14:23:10 1994 *************** *** 0 **** --- 1,22 ---- + all: builddt dumpdt + + builddt: builddt.o dtmisc.o + ${CC} -o builddt builddt.o dtmisc.o + + dumpdt: dumpdt.o dtmisc.o + ${CC} -o dumpdt dumpdt.o dtmisc.o + + builddt.o: builddt.c dt.h + ${CC} ${CFLAGS} -c builddt.c + + dumpdt.o: dumpdt.c dt.h + ${CC} ${CFLAGS} -c dumpdt.c + + dtmisc.o: dtmisc.c dt.h + ${CC} ${CFLAGS} -c dtmisc.c + + shar: + /usr/local/bin/shar README Makefile *.h *.c > capdt.1.0.shar + + clean: + rm -rf builddt dumpdt *.o a.out core *** contrib/DeskTop/README.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/README Sat Feb 5 14:23:10 1994 *************** *** 0 **** --- 1,50 ---- + dumpdt/builddt + CAP DeskTop Handling Tools + + The University of Melbourne + djh@munnari.OZ.AU + February, 1993 + version 1.0.2 + + + 'dumpdt' dumps the content of the .IDeskTop and .ADeskTop files in the + specified volume. usage: + + dumpdt volumename + + ie: + + dumpdt ~/mac + + + 'builddt' traverses the specified volume and builds new .IDeskTop and + .ADeskTop files based on the current volume contents. The -w flag must + be used explicitly to cause new .?DeskTop files to be written. The -q + flag sets 'quiet' mode, otherwise a message is printed for each file + examined. The -d flag can be used to obtain a verbose debug listing. + + usage: + + builddt [ -d ] [ -w ] [ -q ] volumename + + ie: + + builddt -w ~/mac + + WARNING: The CAP .?DeskTop file contents are cached within running AUFS + processes. To make effective changes for global volumes (afpvols specified + with the -V option), the parent AUFS server should be killed, the DeskTop + rebuilt and the server restarted. For personal volumes, the volume should + be unmounted from all Macintoshes before the DeskTop is rebuilt. + + WARNING: this is beta software. Run without -w and check the output + for sensible data first. Always keep copies of existing .?DeskTop files. + + + Copyright (c) 1993, The University of Melbourne. + All Rights Reserved. Permission to publicly redistribute this + package (other than as part of CAP) or use any part of this software + for any purpose other than as part of the original distribution must + be obtained in writing from the copyright owner. + + Please report problems to djh@munnari.OZ.AU *** contrib/DeskTop/builddt.c.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/builddt.c Sat Feb 5 14:23:11 1994 *************** *** 0 **** --- 1,606 ---- + /* + * (re)build CAP desktop files .IDeskTop and .ADeskTop + * + * Copyright (c) 1993, The University of Melbourne. + * All Rights Reserved. Permission to publicly redistribute this + * package (other than as a component of CAP) or to use any part + * of this software for any purpose, other than that intended by + * the original distribution, *must* be obtained in writing from + * the copyright owner. + * + * djh@munnari.OZ.AU + * 15 February 1993 + * 30 November 1993 + * + * Refer: "Inside Macintosh", Volume 1, page I-128 "Format of a Resource File" + * + * $Author: djh $ + * $Revision: 2.1 $ + * + */ + + #include "dt.h" + + /* variables */ + + int fdi, fda; + int debug = 0; + int quiet = 0; + int writing = 0; + int totfiles = 0; + int idesk = 0, adesk = 0; + long iconlen, bndllen, freflen; + short iconnum, bndlnum, frefnum; + long iconoffset, bndloffset, frefoffset; + long listoffset; + u_char icon[1024]; + + struct adt adt; + struct idt idt; + struct finfo finfo; + struct rhdr rhdr; + struct rmap rmap; + struct tlist tlist; + struct rlist rlist; + struct bhdr bhdr; + struct bdata bdata; + struct bids bids; + struct fdata fdata; + + main(argc, argv) + int argc; + char *argv[]; + { + int c; + extern char *optarg; + extern int optind, opterr; + void enumerate(); + + opterr = 0; + + while ((c = getopt(argc, argv, "qdw")) != -1) { + switch (c) { + case 'd': + debug = 1; + break; + case 'w': + writing = 1; + break; + case 'q': + quiet = 1; + break; + case '?': + usage(); + break; + } + } + + if (optind >= argc) + usage(); + + if (chdir(argv[optind]) < 0) { + perror(argv[optind]); + exit(1); + } + + if (writing) { + if ((fdi = open(IFILE, O_RDWR | O_TRUNC | O_CREAT, 0644)) < 0) { + perror(IFILE); + exit(1); + } + if ((fda = open(AFILE, O_RDWR | O_TRUNC | O_CREAT, 0644)) < 0) { + perror(AFILE); + exit(1); + } + } + + enumerate("."); /* handle recursively */ + + if (writing) { + close(fdi); + close(fda); + } + + printf("\n"); + printf("wrote %d .ADeskTop entries\n", adesk); + printf("wrote %d .IDeskTop entries\n", idesk); + printf("from a total of %d files\n", totfiles); + if (adesk == 0 && idesk == 0) + printf("(nothing written to .?DeskTop, did you use the -w flag ?)\n"); + } + + /* + * print a usage message and exit + * + */ + + usage() + { + fprintf(stderr, "usage: builddt [ -d ] [ -w ] [ -q ] volname\n"); + exit(1); + } + + /* + * check files in directory 'dir' + * + */ + + void + enumerate(dir) + char *dir; + { + DIR *dirp; + int dirlen; + struct stat sbuf; + char path[MAXPATHLEN]; + char resource[MAXPATHLEN]; + char finderinfo[MAXPATHLEN]; + struct direct *dp, *readdir(); + void makeEntry(); + + if ((dirp = opendir(dir)) == NULL) { + perror(dir); + return; + } + + strcpy(path, dir); + dirlen = strlen(path); + + for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { + if (skip(dp->d_name)) + continue; + strcpy(path+dirlen, "/"); + strcpy(path+dirlen+1, dp->d_name); + if (stat(path, &sbuf) < 0) + continue; + if (S_ISDIR(sbuf.st_mode)) { + enumerate(path); + continue; + } + /* must be a file then */ + sprintf(resource, "%s/%s/%s", dir, RSRCF, dp->d_name); + sprintf(finderinfo, "%s/%s/%s", dir, FNDRI, dp->d_name); + if (access(resource, F_OK) < 0) + continue; + if (access(finderinfo, F_OK) < 0) + continue; + strcpy(path, dir); + if (path[0] == '.' && path[1] == '\0') + strcpy(path, "./"); + else + path[dirlen] = '\0'; + makeEntry(path, dp->d_name, resource, finderinfo); + if (debug) + printf("\n"); + } + + closedir(dirp); + + return; + } + + /* + * skip subdirectory and file names we aren't interested in + * + */ + + int + skip(name) + char *name; + { + if (strcmp(name, ".") == 0) + return(1); + if (strcmp(name, "..") == 0) + return(1); + if (strcmp(name, FNDRI) == 0) + return(1); + if (strcmp(name, RSRCF) == 0) + return(1); + if (strcmp(name, AFILE) == 0) + return(1); + if (strcmp(name, IFILE) == 0) + return(1); + if (strcmp(name, "afpvols") == 0) + return(1); + if (strcmp(name, ".afpvols") == 0) + return(1); + if (strcmp(name, "afpfile") == 0) + return(1); + if (strcmp(name, ".afpfile") == 0) + return(1); + + return(0); + } + + /* + * grope around in the resource file ... :-( + * + */ + + void + makeEntry(path, file, resource, finderinfo) + char *path, *file, *resource, *finderinfo; + { + int i; + int j; + int k; + int fd; + char *p; + long len; + short ilen; + long offset; + short numres; + char *ic, *findICN(); + struct fdata *ff, *findFREF(); + + totfiles++; + + if (!quiet) + printf("Checking file \"%s%s%s\"\n", path+2, + (*(path+2) == '\0') ? "" : "/", file); + + if ((fd = open(finderinfo, O_RDONLY, 0644)) < 0) { + perror(finderinfo); + return; + } + if (read(fd, &finfo, sizeof(finfo)) != sizeof(finfo)) { + if (debug) printf("\"%s\": too small, ignoring\n", finderinfo+2); + close(fd); + return; + } + close(fd); + + /* handle .ADeskTop file (Application Mapping) */ + + if (bcmp(finfo.fi.ftype, "APPL", 4) == 0) { + bcopy(finfo.fi.creat, adt.creat, 4); + bzero(adt.userb, 4); + adt.magic = htonl(MAGIC); + adt.dlen = htonl(strlen(path+2)+1); /* ignore leading "./" */ + adt.flen = htonl(strlen(file)+1); /* but include trailing null */ + + if (debug) { + printf("creat"); + printsig(adt.creat); + printf("userb"); + printsig(adt.userb); + printf("path :%s: ", path+2); + printf("file :%s:\n", file); + } + + if (writing) { + write(fda, &adt, sizeof(adt)); + write(fda, path+2, ntohl(adt.dlen)); + write(fda, file, ntohl(adt.flen)); + adesk++; + } + } + + /* handle .IDeskTop file (ICON/creator/type mapping) */ + + if (debug) { + printf("ftype"); + printsig(finfo.fi.ftype); + printf("icon ID %d ", (short)ntohs(finfo.fi.iconID)); + printf("path :%s: ", path+2); + printf("file :%s: ", file); + printf("\n"); + } + + if ((fd = open(resource, O_RDONLY, 0644)) < 0) { + perror(resource); + return; + } + + /* get resource header */ + if (read(fd, &rhdr, sizeof(rhdr)) != sizeof(rhdr)) { + if (debug) printf("\"%s\": too small, ignoring\n", resource+2); + close(fd); + return; + } + + /* get resource map */ + if (lseek(fd, ntohl(rhdr.rmapOffset), SEEK_SET) < 0) { + perror("SEEK_SET"); + close(fd); + return; + } + if (read(fd, &rmap, sizeof(rmap)) != sizeof(rmap)) { + if (debug) printf("\"%s\": too small, ignoring\n", resource+2); + close(fd); + return; + } + + /* file pointer now at start of resource map + sizeof(rmap) */ + + if (lseek(fd, ntohs(rmap.listOffset)-sizeof(rmap), SEEK_CUR) < 0) { + perror("SEEK_CUR"); + close(fd); + return; + } + + listoffset = ntohl(rhdr.rmapOffset) + ntohs(rmap.listOffset); + + /* get number of resource types */ + if (read(fd, &numres, 2) != 2) { + if (debug) printf("failed to read resource type list qty\n"); + close(fd); + return; + } + + numres = ntohs(numres) + 1; + + if (debug) + printf("found %d distinct resource type%s\n", + numres, (numres == 1) ? "" : "s"); + + /* (in)sanity check */ + if (numres > 1000) { + if (debug) printf("that's a lot of resources, probably bogus\n"); + close(fd); + return; + } + + bndlnum = iconnum = frefnum = 0; + + for (j = 0; j < numres; j++) { + /* read resource type list */ + if (read(fd, &tlist, sizeof(tlist)) != sizeof(tlist)) { + if (debug) printf("bad resource type list\n"); + close(fd); + return; + } + + if (debug) { + printf("type"); + printsig(tlist.rtype); + printf("num %d off %d\n", + ntohs(tlist.rnum)+1, ntohs(tlist.roff)); + } + + if (bcmp(tlist.rtype, "BNDL", 4) == 0) { + bndlnum = ntohs(tlist.rnum)+1; + bndloffset = ntohs(tlist.roff); + } + if (bcmp(tlist.rtype, "ICN#", 4) == 0) { + iconnum = ntohs(tlist.rnum)+1; + iconoffset = ntohs(tlist.roff); + } + if (bcmp(tlist.rtype, "FREF", 4) == 0) { + frefnum = ntohs(tlist.rnum)+1; + frefoffset = ntohs(tlist.roff); + } + } + + /* check for BNDL/ICN#/FREF resources */ + if (bndlnum == 0 || iconnum == 0 || frefnum == 0) { + if (debug) printf("no BNDL/ICN#/FREF resources\n"); + close(fd); + return; + } + + /* handle each BNDL present */ + for (j = 0; j < bndlnum; j++) { + /* move to NBDL reference list */ + if (lseek(fd, listoffset+bndloffset, SEEK_SET) < 0) { + perror("SEEK_SET"); + close(fd); + return; + } + if (read(fd, &rlist, sizeof(rlist)) != sizeof(rlist)) { + if (debug) printf("bundle reference list too small\n"); + close(fd); + return; + } + + if (debug) { + printf("found BNDL rsrc ID %d ", (short)ntohs(rlist.rsrcID)); + printf("offset %d\n", (long)ntohl(rlist.attrOff) & 0xffffff); + } + + offset = ntohl(rhdr.rdataOffset)+(ntohl(rlist.attrOff) & 0xffffff); + + /* move to beginning of BNDL resource data */ + if (lseek(fd, offset, SEEK_SET) < 0) { + perror("SEEK_SET"); + close(fd); + return; + } + /* get BNDL resource length */ + if (read(fd, &bndllen, 4) != 4) { + if (debug) printf("failed to read BNDL resource length\n"); + close(fd); + return; + } + + bndllen = ntohl(bndllen); + + /* get BNDL resource header */ + if (read(fd, &bhdr, sizeof(bhdr)) != sizeof(bhdr)) { + if (debug) printf("bundle header too small\n"); + close(fd); + return; + } + + bndllen -= sizeof(bhdr); + + if (debug) { + printf("signature"); + printsig(bhdr.creat); + printf("version %d ", (short)ntohs(bhdr.version)); + printf("numtypes %d\n", (short)ntohs(bhdr.numType)+1); + } + + for (i = 0; i < ntohs(bhdr.numType)+1; i++) { + /* get BNDL resource data */ + if (read(fd, &bdata, sizeof(bdata)) != sizeof(bdata)) { + if (debug) printf("bundle data too short\n"); + close(fd); + return; + } + + if (debug) { + printf("type"); + printsig(bdata.btype); + printf("has %d ID(s)\n", (short)ntohs(bdata.numID)+1); + } + + for (k = 0; k < ntohs(bdata.numID)+1; k++) { + /* scan BNDL ID array */ + if (read(fd, &bids, sizeof(bids)) != sizeof(bids)) { + if (debug) printf("bundle data too short\n"); + close(fd); + return; + } + + if (debug) + printf("local ID %d, actual ID %d\n", + (short)ntohs(bids.localID), (short)ntohs(bids.actualID)); + + if (bcmp(bdata.btype, "ICN#", 4) == 0) { + if ((ic = findICN(fd, ntohs(bids.actualID), &ilen)) != NULL) { + if ((ff = findFREF(fd, ntohs(bids.localID))) != NULL) { + idt.magic = htonl(MAGIC); + idt.isize = htonl(ilen); + bcopy(bhdr.creat, idt.creat, 4); + bcopy(ff->ftype, idt.ftype, 4); + idt.itype = 1; /* ICN# */ + idt.pad1 = 0; + bzero(idt.userb, 4); + idt.pad2[0] = 0; + idt.pad2[1] = 0; + + if (debug) { + printf("creator"); + printsig(idt.creat); + printf("type"); + printsig(idt.ftype); + printf("found ICN# of length %d\n", ilen); + printicn(ic, ilen); + } + + if (writing) { + write(fdi, &idt, sizeof(idt)); + write(fdi, ic, ilen); + idesk++; + } + } + } + } + } + } + } + + close(fd); + + return; + } + + /* + * find the ICN# with the specified resource number, + * return a pointer to the ICN# data and it's length + * + */ + + char * + findICN(fd, rsrcID, len) + int fd; + short rsrcID; + short *len; + { + int i; + long offset; + long curpos; + struct rlist rlist; + + *len = 0; + + /* keep current file pointer position */ + if ((curpos = lseek(fd, 0, SEEK_CUR)) >= 0) { + /* move to start of ICN# resource reference list */ + if (lseek(fd, listoffset+iconoffset, SEEK_SET) >= 0) { + for (i = 0; i < iconnum; i++) { + /* get resource reference list for each ICN# */ + if (read(fd, &rlist, sizeof(rlist)) == sizeof(rlist)) { + if (debug) { + printf("found ICN# rsrc ID %d ", (short)ntohs(rlist.rsrcID)); + printf("offset %d\n", (long)ntohl(rlist.attrOff) & 0xffffff); + } + if ((short)ntohs(rlist.rsrcID) == rsrcID) + break; + } + } + if (i < iconnum) { + offset = ntohl(rhdr.rdataOffset)+(ntohl(rlist.attrOff)&0xffffff); + /* move to beginning of ICN# resource data */ + if (lseek(fd, offset, SEEK_SET) >= 0) { + /* get ICN# resource length */ + if (read(fd, &iconlen, 4) == 4) { + if ((iconlen = ntohl(iconlen)) <= sizeof(icon)) { + /* read ICN# data */ + if (read(fd, icon, iconlen) == iconlen) { + /* restore original pointer */ + lseek(fd, curpos, SEEK_SET); + *len = iconlen; + return((char *)icon); + } + } + } + } + } + } + } + lseek(fd, curpos, SEEK_SET); + return(NULL); + } + + /* + * find the FREF with the specified local ID + * + */ + + struct fdata * + findFREF(fd, localID) + int fd; + short localID; + { + int i; + long offset; + long curpos; + struct rlist rlist; + + /* keep current file pointer position */ + if ((curpos = lseek(fd, 0, SEEK_CUR)) >= 0) { + for (i = 0; i < frefnum; i++) { + /* move to start of FREF resource reference list */ + if (lseek(fd, listoffset+frefoffset+i*sizeof(rlist),SEEK_SET)>=0){ + /* get resource reference list for each FREF */ + if (read(fd, &rlist, sizeof(rlist)) == sizeof(rlist)) { + if (debug) { + printf("found FREF rsrc ID %d ", (short)ntohs(rlist.rsrcID)); + printf("offset %d\n", (long)ntohl(rlist.attrOff) & 0xffffff); + } + offset=ntohl(rhdr.rdataOffset)+(ntohl(rlist.attrOff)&0xffffff); + /* move to beginning of FREF resource data */ + if (lseek(fd, offset, SEEK_SET) >= 0) { + /* get FREF resource length */ + if (read(fd, &freflen, 4) == 4) { + if ((freflen = ntohl(freflen)) >= sizeof(fdata)) { + /* read FREF data */ + if (read(fd, &fdata, sizeof(fdata)) == sizeof(fdata)) { + if (ntohs(fdata.localID) != localID) + continue; + /* restore original pointer */ + lseek(fd, curpos, SEEK_SET); + return(&fdata); + } + } + } + } + } + } + } + } + lseek(fd, curpos, SEEK_SET); + return(NULL); + } *** contrib/DeskTop/dt.h.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/dt.h Sat Feb 5 14:23:11 1994 *************** *** 0 **** --- 1,164 ---- + /* + * (re)build/dump CAP desktop files .IDeskTop and .ADeskTop + * + * Copyright (c) 1993, The University of Melbourne. + * All Rights Reserved. Permission to publicly redistribute this + * package (other than as a component of CAP) or to use any part + * of this software for any purpose, other than that intended by + * the original distribution, *must* be obtained in writing from + * the copyright owner. + * + * djh@munnari.OZ.AU + * 15 February 1993 + * 30 November 1993 + * + * Refer: "Inside Macintosh", Volume 1, page I-128 "Format of a Resource File" + * + * $Author: djh $ + * $Revision: 2.1 $ + * + */ + + #include + #include + #include + #include + #include + #include + #include + #include + + #ifdef hpux + # include + #endif hpux + + /* + * header for .ADeskTop + * + */ + + struct adt { + long magic; + u_char creat[4]; + u_char userb[4]; + long dlen; + long flen; + /* names follow */ + }; + + /* + * header for .IDeskTop + * + */ + + struct idt { + long magic; + long isize; + u_char creat[4]; + u_char ftype[4]; + u_char itype; + u_char pad1; + u_char userb[4]; + u_char pad2[2]; + /* bitmap follows */ + }; + + /* + * headers for .finderinfo files + * + */ + + struct fi { + u_char ftype[4]; + u_char creat[4]; + u_short flags; + u_short locn[2]; + u_short win; + u_short iconID; + u_short pad[4]; + u_short commID; + u_long dirID; + }; + + struct finfo { + struct fi fi; + u_short attr; + #define FMAGIC1 255 + u_char magic1; + #define FVERS 0x10 + u_char version; + #define FMAGIC2 0xda + u_char magic2; + u_char pad1; + /* ignore rest */ + }; + + /* + * headers for .resource files + * + */ + + /* resource hdr */ + struct rhdr { + long rdataOffset; + long rmapOffset; + long rdataLength; + long rmapLength; + u_char filler[240]; + }; + + /* resource map */ + struct rmap { + u_char filler[24]; + short listOffset; + short nameOffset; + }; + + /* resource type list */ + struct tlist { + u_char rtype[4]; + short rnum; + short roff; + }; + + /* resource reference list */ + struct rlist { + short rsrcID; + short nameOffset; + u_long attrOff; + u_long handle; + }; + + /* bundle header */ + struct bhdr { + u_char creat[4]; + u_short version; + short numType; + }; + + /* bundle data */ + struct bdata { + u_char btype[4]; + short numID; + }; + + /* bundle IDs */ + struct bids { + short localID; + short actualID; + }; + + /* FREF header */ + struct fdata { + u_char ftype[4]; + short localID; + /* ignore filename */ + }; + + /* defines */ + + #define MAGIC 0x00010002 + #define IFILE ".IDeskTop" + #define AFILE ".ADeskTop" + #define RSRCF ".resource" + #define FNDRI ".finderinfo" *** contrib/DeskTop/dtmisc.c.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/dtmisc.c Sat Feb 5 14:23:12 1994 *************** *** 0 **** --- 1,81 ---- + /* + * Miscellaneous DeskTop routines + * + * Copyright (c) 1993, The University of Melbourne. + * All Rights Reserved. Permission to publicly redistribute this + * package (other than as a component of CAP) or to use any part + * of this software for any purpose, other than that intended by + * the original distribution, *must* be obtained in writing from + * the copyright owner. + * + * djh@munnari.OZ.AU + * 15 February 1993 + * + * Refer: "Inside Macintosh", Volume 1, page I-128 "Format of a Resource File" + * + * $Author: djh $ + * $Revision: 2.1 $ + * + */ + + #include "dt.h" + + /* + * print 4 byte signatures in hex and ascii representations + * + */ + + int + printsig(sig) + u_char *sig; + { + int i; + + printf(" :"); + for (i = 0; i < 4; i++) + printf("%02x", sig[i]); + printf(":("); + for (i = 0; i < 4; i++) + printf("%c", isprint(sig[i]) ? sig[i] : '.'); + printf(") "); + } + + /* + * print out a representation of the ICN# and it's mask + * + */ + + int + printicn(icn, len) + u_char *icn; + short len; + { + u_char *p; + int i, j, k; + u_long data1, data2, mask; + + if (len != 256) + return; + + for (i = 0, p = icn; i < 32; i += 2, p += 8) { + for (j = 0; j < 2; j++) { + if (j == 1) printf(" "); + bcopy(p+(j*128), &data1, 4); + bcopy(p+4+(j*128), &data2, 4); + for (k = 0; k < 32; k++) { + mask = ((u_long)0x80000000 >> k); + if (data1 & mask && data2 & mask) + printf("8"); + else + if (data1 & mask) + printf("\""); + else + if (data2 & mask) + printf("o"); + else + printf(" "); + } + } + printf("\n"); + } + } *** contrib/DeskTop/dumpdt.c.orig Sat Feb 5 14:25:36 1994 --- contrib/DeskTop/dumpdt.c Sat Feb 5 14:23:12 1994 *************** *** 0 **** --- 1,131 ---- + /* + * dump CAP desktop files .IDeskTop and .ADeskTop + * + * Copyright (c) 1993, The University of Melbourne. + * All Rights Reserved. Permission to publicly redistribute this + * package (other than as a component of CAP) or to use any part + * of this software for any purpose, other than that intended by + * the original distribution, *must* be obtained in writing from + * the copyright owner. + * + * djh@munnari.OZ.AU + * 15 February 1993 + * + * Refer: "Inside Macintosh", Volume 1, page I-128 "Format of a Resource File" + * + * $Author: djh $ + * $Revision: 2.1 $ + * + */ + + #include "dt.h" + + struct adt adt; + struct idt idt; + + main(argc, argv) + int argc; + char *argv[]; + { + int len; + int fd, i; + u_char zero[4]; + u_char icon[1024]; + char path[MAXPATHLEN], file[MAXPATHLEN]; + + if (argc != 2) { + fprintf(stderr, "usage: dumpdt volname\n"); + exit(1); + } + + if (chdir(argv[1]) < 0) { + perror(argv[1]); + exit(1); + } + + bzero(zero, sizeof(zero)); + + if ((fd = open(AFILE, O_RDONLY, 0644)) < 0) { + perror(AFILE); + exit(1); + } + + printf("APPL Mappings from %s/%s\n\n", argv[1], AFILE); + + for ( ; ; ) { + if (read(fd, &adt, sizeof(adt)) < sizeof(adt)) + break; + + if (ntohl(adt.magic) != MAGIC) { + fprintf(stderr, "bad magic in %s/%s\n", argv[1], AFILE); + break; + } + + printf("creat"); + printsig(adt.creat); + if (bcmp(adt.userb, zero, sizeof(zero))) { + printf("userb"); + printsig(adt.userb); + } + + path[0] = '\0'; + file[0] = '\0'; + + if (read(fd, path, ntohl(adt.dlen)) != ntohl(adt.dlen)) { + fprintf(stderr, "bad path length %d\n", ntohl(adt.dlen)); + break; + } + if (read(fd, file, ntohl(adt.flen)) != ntohl(adt.flen)) { + fprintf(stderr, "bad file length %d\n", ntohl(adt.dlen)); + break; + } + if (path[0] != '\0') + strcat(path, "/"); + strcat(path, file); + printf("file :%s:", path); + if (access(path, F_OK)) + printf(" (not found)"); + printf("\n"); + } + + close(fd); + + if ((fd = open(IFILE, O_RDONLY, 0644)) < 0) { + perror(IFILE); + exit(1); + } + + printf("\nICN# Mappings from %s/%s\n\n", argv[1], IFILE); + + for ( ; ; ) { + if (read(fd, &idt, sizeof(idt)) < sizeof(idt)) + break; + + if (ntohl(idt.magic) != MAGIC) { + fprintf(stderr, "bad magic in %s/%s\n", argv[1], IFILE); + break; + } + + printf("creat"); + printsig(idt.creat); + printf("ftype"); + printsig(idt.ftype); + printf("itype %d ", idt.itype); + if (bcmp(idt.userb, zero, sizeof(zero))) { + printf("userb"); + printsig(idt.userb); + } + printf("\n"); + + if ((len = read(fd, icon, ntohl(idt.isize))) != ntohl(idt.isize)) { + fprintf(stderr, "bad icon length %d\n", ntohl(idt.isize)); + break; + } + + printf("\n"); + printicn(icon, len); + printf("\n"); + } + + close(fd); + } *** lib/cap/abversion.c.orig Fri Feb 4 15:38:19 1994 --- lib/cap/abversion.c Sat Feb 5 14:34:40 1994 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/02/04 04:38:13 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.89 1994/02/04 04:38:13 djh Rel djh $ ! * $Revision: 2.89 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1994/02/05 03:34:35 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.90 1994/02/05 03:34:35 djh Rel djh $ ! * $Revision: 2.90 $ * */ *************** *** 32,38 **** myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 189; myversion.cv_rmonth = "February"; myversion.cv_ryear = "1994"; switch (lap_proto) { --- 32,38 ---- myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 190; myversion.cv_rmonth = "February"; myversion.cv_ryear = "1994"; switch (lap_proto) { *** README.orig Fri Feb 4 15:43:49 1994 --- README Sat Feb 5 14:35:35 1994 *************** *** 2,8 **** CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 189, February 1994 Notice ------ --- 2,8 ---- CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 190, February 1994 Notice ------