home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff220.lzh / DNet / client / dprint.c next >
C/C++ Source or Header  |  1989-06-04  |  860b  |  55 lines

  1.  
  2. /*
  3.  *  DPRINT.C
  4.  *
  5.  *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  6.  *
  7.  *  send files to the other computer's printer.
  8.  *
  9.  *  DPRINT [files]    (stdin if no files specified)
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include "../server/servers.h"
  14.  
  15. main(ac,av)
  16. char *av[];
  17. {
  18.     register short i;
  19.     long chan;
  20.  
  21.     chan = DOpen(NULL, PORT_PRINTER, -80, 126);
  22.     if (chan < 0) {
  23.     puts("Unable to connect");
  24.     exit(1);
  25.     }
  26.     for (i = 1; i < ac; ++i) {
  27.     FILE *fi;
  28.  
  29.     printf("%-20s ", av[i]);
  30.     fflush(stdout);
  31.     if (fi = fopen(av[i], "r")) {
  32.         printf("dumping ");
  33.         fflush(stdout);
  34.         dump_file(fi, chan);
  35.         fclose(fi);
  36.         puts("");
  37.     }
  38.     }
  39.     if (ac == 1)
  40.     dump_file(stdin, chan);
  41.     close(chan);
  42. }
  43.  
  44. dump_file(fi, chan)
  45. FILE *fi;
  46. {
  47.     int n;
  48.     char buf[256];
  49.  
  50.     while ((n = fread(buf, 1, sizeof(buf), fi)) > 0) {
  51.     gwrite(chan, buf, n);
  52.     }
  53. }
  54.  
  55.