- unsigned long zlen;
-
- x = line->s; xlen = line->len;
-
- type = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- uidstr = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- gidstr = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- modestr = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- mid = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- name = x;
- i = byte_chr(x,xlen,':'); if (i == xlen) return;
- x[i++] = 0; x += i; xlen -= i;
-
- if (!stralloc_copys(&target,to)) nomem();
- if (!stralloc_cats(&target,mid)) nomem();
- if (!stralloc_cats(&target,name)) nomem();
- if (!stralloc_0(&target)) nomem();
-
- uid = -1; if (*uidstr) scan_ulong(uidstr,&uid);
- gid = -1; if (*gidstr) scan_ulong(gidstr,&gid);
- scan_8long(modestr,&mode);
-
- switch(*type) {
- case 'z':
- scan_ulong(type + 1,&zlen);
-
- fdout = open_trunc(target.s);
- if (fdout == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof(outbuf));
-
- while (zlen--)
- if (substdio_put(&ssout,"",1) == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
-
- if (substdio_flush(&ssout) == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- if (fsync(fdout) == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- close(fdout);
- break;
-
- case 'p':
- if (fifo_make(target.s,0700) == -1)
- if (errno != error_exist)
- strerr_die4sys(111,FATAL,"unable to mkfifo ",target.s,": ");
- break;
-
- case 'd':
- if (mkdir(target.s,0700) == -1)
- if (errno != error_exist)
- strerr_die4sys(111,FATAL,"unable to mkdir ",target.s,": ");
- break;
-
- case 'c':
- fdin = open_read(name);
- if (fdin == -1)
- strerr_die4sys(111,FATAL,"unable to read ",name,": ");
- substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof(inbuf));
-
- fdout = open_trunc(target.s);
- if (fdout == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof(outbuf));
-
- switch(substdio_copy(&ssout,&ssin)) {
- case -2:
- strerr_die4sys(111,FATAL,"unable to read ",name,": ");
- case -3:
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- }
-
- close(fdin);
- if (substdio_flush(&ssout) == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- if (fsync(fdout) == -1)
- strerr_die4sys(111,FATAL,"unable to write ",target.s,": ");
- close(fdout);
- break;
-
- default:
- return;
+
+ if (fchdir(fdsourcedir) == -1)
+ strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
+
+ fdin = open_read(file);
+ if (fdin == -1)
+ strerr_die4sys(111,FATAL,"unable to read ",file,": ");
+ substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof inbuf);
+
+ if (chdir(home) == -1)
+ strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
+ if (chdir(subdir) == -1)
+ strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
+
+ fdout = open_trunc(file);
+ if (fdout == -1)
+ strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
+ substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
+
+ switch(substdio_copy(&ssout,&ssin)) {
+ case -2:
+ strerr_die4sys(111,FATAL,"unable to read ",file,": ");
+ case -3:
+ strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");