#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/cmd/ftpfs /sys/src/cmd/ftpfs # srcdir: /n/juke/plan_9/sys/src/cmd/ftpfs # version: 816029425 # date: Fri Nov 10 13:50:25 EST 1995 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 816029425 exit interrupt } while(~ $1 -*){ switch($1){ case -X doextract=yes case -* usage } shift } switch($#*){ case 0 srcdir=/sys/src/cmd/ftpfs case 1 srcdir=$1 case * usage } if(! ~ $doextract yes){ echo This shell file contains a bundle of diffs representing changes echo to original source files in the Plan 9 distribution. It will run echo against the files in echo ' ' $srcdir echo '(unless overridden by the optional source directory argument)' echo and create a directory 816029425 containing the updated files. echo It will NOT automatically update the original files. echo echo Invoke with argument -X to perform the actual extraction. exit 0 } rm -rf 816029425 mkdir 816029425 target=816029425/ftpfs.c echo -n '816029425/ftpfs.c: ' if(! test -f $srcdir/ftpfs.c || ! test -r $srcdir/ftpfs.c){ echo $srcdir/ftpfs.c unreadable exit unreadable } sum=`{sum < $srcdir/ftpfs.c} if(! ~ d79f339c11903 $sum(1)^$sum(2)){ echo $srcdir/ftpfs.c is not the original distribution file exit original } cp $srcdir/ftpfs.c 816029425/ftpfs.c chmod +w 816029425/ftpfs.c ed 816029425/ftpfs.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ftpfs.c' 67c { NT, "Windows_NT", }, /* DOS like interface */ { NT, "WINDOWS_NT", }, /* Unix like interface */ . wq //GO.SYSIN DD VADIM ftpfs.c sum=`{sum < 816029425/ftpfs.c} if(~ 4e0f31b411979 $sum(1)^$sum(2)) echo if not{ echo 816029425/ftpfs.c checksum error creating updated file exit checksum } target=816029425/proto.c echo -n '816029425/proto.c: ' if(! test -f $srcdir/proto.c || ! test -r $srcdir/proto.c){ echo $srcdir/proto.c unreadable exit unreadable } sum=`{sum < $srcdir/proto.c} if(! ~ e164c5ae24384 $sum(1)^$sum(2)){ echo $srcdir/proto.c is not the original distribution file exit original } cp $srcdir/proto.c 816029425/proto.c chmod +w 816029425/proto.c ed 816029425/proto.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM proto.c' 1188a } /* * call out for a data connection */ static int passive(int mode, Biobuf **bpp, char *cmd) { char msg[1024]; char *f[6]; char *p; int x, fd; if(nopassive) return Impossible; sendrequest("PASV"); if(getreply(&ctlin, msg, sizeof(msg), 0) != Success){ nopassive = 1; return Impossible; } /* get address and port number from reply, this is AI */ p = strchr(msg, '('); if(p == 0){ for(p = msg+3; *p; p++) if(isdigit(*p)) break; } else p++; setfields(","); if(getfields(p, f, 6) < 6){ if(debug) fprint(2, "passive mode protocol botch: %s\n", msg); werrstr("ftp protocol botch"); nopassive = 1; return Impossible; } snprint(msg, sizeof(msg), "%s!%s.%s.%s.%s!%d", net, f[0], f[1], f[2], f[3], ((atoi(f[4])&0xff)<<8) + (atoi(f[5])&0xff)); /* open data connection */ fd = dial(msg, 0, 0, 0); if(fd < 0){ if(debug) fprint(2, "passive mode connect to %s failed: %r\n", msg); nopassive = 1; return TempFail; } /* tell remote to send a file */ sendrequest("%s", cmd); x = getreply(&ctlin, msg, sizeof(msg), 0); if(x != Extra){ close(fd); if(debug) fprint(2, "passive mode retrieve failed: %s\n", msg); werrstr(msg); return x; } Binit(&dbuf, fd, mode); *bpp = &dbuf; return Extra; } static int data(int mode, Biobuf **bpp, char *fmt, ...) { char cmd[8*1024]; int x; doprint(cmd, cmd + (sizeof(cmd)-4) / sizeof(*cmd), fmt, &fmt + 1); x = passive(mode, bpp, cmd); if(x != Impossible) return x; return active(mode, bpp, cmd); . 1167a if(port() < 0) return TempFail; sendrequest("%s", cmd); . 1162c active(int mode, Biobuf **bpp, char *cmd) . 1159c * have server call back for a data connection . 1108a /* tell user about continuations */ if(!debug && !quiet && !printreply) write(2, line, n); . 974,977d 972c if(data(OWRITE, &bp, "STOR %s", node->longname) != Extra) . 899,903c switch(data(OREAD, &bp, "RETR %s", node->longname)){ . 755a */ . 754c /* case TempFail: . 746,751c x = data(OREAD, &bp, "NLST"); else if(os == Unix && !uselist) x = data(OREAD, &bp, "LIST -l"); else x = data(OREAD, &bp, "LIST"); switch(x){ . 742,744d 735c int i, tries, x; . 713a if(strcmp(longname, ".") == 0 || strcmp(longname, "..") == 0) return 0; . 702a case 4: /* a Windows_NT version */ safecpy(longname, field[3], sizeof(longname)); strcpy(dp->uid, "NT"); strcpy(dp->gid, "NT"); if(strcmp("", field[2]) == 0){ dp->length = 0; dp->mode = CHDIR|0777; } else { dp->mode = 0666; dp->length = atoi(field[2]); } setfields("/-"); dn = getmfields(field[0], dfield, 4); if(dn == 3) dp->atime = cracktime(dfield[0], dfield[1], dfield[2], field[1]); break; . 366a if(tolower(*p) == 'p') tm.hour += 12; . 365c tm.sec = strtol(p+1, &p, 0); . 360,362c tm.hour = strtol(hms, &p, 0); if(*p == ':'){ . 344c tm.mon = atoi(month) - 1; . 335d 198a if(os == Unknown) os = defos; . 193a if(os == NT) os = Unix; . 65,68c p = strrchr(dir+1, '/'); if(p == 0) fatal("wrong dial(2) linked with ftp"); *p = 0; safecpy(net, dir, sizeof(net)); . 52a char *p; . 38c static int active(int, Biobuf**, char*); static int passive(int, Biobuf**, char*); static int data(int, Biobuf**, char*, ...); . 34a int nopassive; . 28c char net[NETPATHLEN]; /* network for connections */ . 17a Impossible= 6, . wq //GO.SYSIN DD VADIM proto.c sum=`{sum < 816029425/proto.c} if(~ 43991a5926730 $sum(1)^$sum(2)) echo if not{ echo 816029425/proto.c checksum error creating updated file exit checksum }