+
+ if ((xfermode == '1') || (xfermode == '8')) { /* receive text */
+ while(serv_gets(buf), strcmp(buf, "000")) {
+ printf("%s\n", buf);
+ }
+ }
+
+ if (xfermode == '6') { /* receive binary */
+ size_t len = atoi(&buf[4]);
+ size_t bytes_remaining = len;
+
+ while (bytes_remaining > 0) {
+ size_t this_block = bytes_remaining;
+ if (this_block > SIZ) this_block = SIZ;
+ serv_read(buf, this_block);
+ fwrite(buf, this_block, 1, stdout);
+ bytes_remaining -= this_block;
+ }
+ }
+
+ close(serv_sock);
+ alarm(0); /* cancel the watchdog timer */
+