+#ifdef DUMP_MACOSX
+int
+extractfinderinfoufs(char *name)
+{
+ int err;
+ char oFileRsrc[MAXPATHLEN];
+ int flags;
+ mode_t mode;
+ struct timeval timep[2];
+ u_int32_t uid;
+ u_int32_t gid;
+ char path[MAXPATHLEN], fname[MAXPATHLEN];
+ int toto;
+
+ curfile.name = name;
+ curfile.action = USING;
+ timep[0].tv_sec = curfile.dip->di_atime.tv_sec;
+ timep[0].tv_usec = curfile.dip->di_atime.tv_usec;
+ timep[1].tv_sec = curfile.dip->di_mtime.tv_sec;
+ timep[1].tv_usec = curfile.dip->di_mtime.tv_usec;
+ mode = curfile.dip->di_mode;
+ flags = curfile.dip->di_flags;
+ uid = curfile.dip->di_uid;
+ gid = curfile.dip->di_gid;
+
+ switch (mode & IFMT) {
+
+ default:
+ fprintf(stderr, "%s: (extr. finfoufs) unknown file mode 0%o\n", name, mode);
+ skipfile();
+ return (FAIL);
+
+ case IFDIR:
+ fprintf(stderr, "%s: (extr. finfoufs[IFDIR]) unknown file mode 0%o\n", name, mode);
+ skipfile();
+ return (FAIL);
+
+ case IFLNK:
+ skipfile();
+ return (GOOD);
+
+ case IFREG:
+ Vprintf(stdout, "extract finderinfo file %s\n", name);
+ if (Nflag) {
+ skipfile();
+ return (GOOD);
+ }
+ getfile(xtrfilefinderinfo, xtrskip);
+
+ GetPathFile(name, path, fname);
+ strcpy(oFileRsrc, path);
+ strcat(oFileRsrc, "._");
+ strcat(oFileRsrc, fname);
+
+ if ((err = CreateAppleDoubleFileRes(oFileRsrc, &gFndrInfo.fndrinfo,
+ mode, flags, timep, uid, gid)) != 0) {
+ fprintf(stderr, "%s: cannot create finderinfo: %s\n",
+ name, strerror(errno));
+ skipfile();
+ return (FAIL);
+ }
+ return (GOOD);
+ }
+ /* NOTREACHED */
+}
+
+
+int
+extractresourceufs(char *name)
+{
+ char oFileRsrc[MAXPATHLEN];
+ int flags;
+ mode_t mode;
+ struct timeval timep[2];
+ char path[MAXPATHLEN], fname[MAXPATHLEN];
+ ASDHeaderPtr hp;
+ ASDEntryPtr ep;
+ u_long loff;
+ u_int32_t uid;
+ u_int32_t gid;
+ u_int64_t di_size;
+ char *p;
+ char buf[1024];
+
+ curfile.name = name;
+ curfile.action = USING;
+ timep[0].tv_sec = curfile.dip->di_atime.tv_sec;
+ timep[0].tv_usec = curfile.dip->di_atime.tv_usec;
+ timep[1].tv_sec = curfile.dip->di_mtime.tv_sec;
+ timep[1].tv_usec = curfile.dip->di_mtime.tv_usec;
+ mode = curfile.dip->di_mode;
+ flags = curfile.dip->di_flags;
+ uid = curfile.dip->di_uid;
+ gid = curfile.dip->di_gid;
+ di_size = curfile.dip->di_size;
+
+ switch (mode & IFMT) {
+
+ default:
+ fprintf(stderr, "%s: (extr. resufs) unknown file mode 0%o\n", name, mode);
+ skipfile();
+ return (FAIL);
+
+ case IFDIR:
+ fprintf(stderr, "%s: (extr. resufs [IFDIR]) unknown file mode 0%o\n", name, mode);
+ skipfile();
+ return (FAIL);
+
+ case IFLNK:
+ skipfile();
+ return (GOOD);
+
+ case IFREG:
+ Vprintf(stdout, "extract resource file %s\n", name);
+ if (Nflag) {
+ skipfile();
+ return (GOOD);
+ }
+
+ GetPathFile(name, path, fname);
+ strcpy(oFileRsrc, path);
+ strcat(oFileRsrc, "._");
+ strcat(oFileRsrc, fname);
+
+ if ((ofile = open(oFileRsrc, O_RDONLY, 0)) < 0) {
+ fprintf(stderr, "%s: cannot read finderinfo: %s\n",
+ name, strerror(errno));
+ skipfile();
+ return (FAIL);
+ }
+ read(ofile, buf, 70);
+ (void) close(ofile);
+ p = buf;
+ hp = (ASDHeaderPtr)p;
+ /* the header */
+ hp->entries++;
+ p += sizeof(ASDHeader) - CORRECT;
+ ep = (ASDEntryPtr)p;
+ /* the finderinfo entry */
+ ep->offset += sizeof(ASDEntry);
+ loff = ep->offset;
+
+ p += sizeof(ASDEntry);
+ /* the finderinfo data */
+ bcopy(p, p + sizeof(ASDEntry), INFOLEN);
+ ep = (ASDEntryPtr)p;
+ /* the new resourcefork entry */
+ ep->entryID = EntryRSRCFork;
+ ep->offset = loff + INFOLEN;
+ ep->len = di_size;
+ /* write the new appledouble entries to the file */
+ if ((ofile = open(oFileRsrc, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
+ fprintf(stderr, "%s: cannot create resource file: %s\n",
+ name, strerror(errno));
+ skipfile();
+ return (FAIL);
+ }
+ write(ofile, buf, 70 + sizeof(ASDEntry));
+ /* and add the resource data from tape */
+ getfile(xtrfile, xtrskip);
+
+ (void) fchown(ofile, uid, gid);
+ (void) fchmod(ofile, mode);
+ (void) close(ofile);
+ (void) fsetflags(oFileRsrc, flags);
+ utimes(oFileRsrc, timep);
+ return (GOOD);
+ }
+ /* NOTREACHED */
+}
+#endif /* DUMP_MACOSX */
+