home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 1 / FishNMoreVol1.bin / more / code_examples / librar / set_prin.c < prev    next >
Text File  |  1989-02-08  |  796b  |  39 lines

  1. /*--------------------------------------*/
  2. /*                    */
  3. /*           SET_PRINTER(X,X)        */
  4. /*                    */
  5. /* Opens output for printing.  The    */
  6. /* first argument is the file descriptor*/
  7. /* for output.  The second is the flag    */
  8. /* used in determining where the output    */
  9. /* is going to.                */
  10. /*                    */
  11. /*--------------------------------------*/
  12. # include "stdio.h"
  13. set_printer(fd,flag)
  14. int flag;
  15. FILE *fd;
  16. {
  17.     char r[8];
  18.     int j;
  19.     if (!flag){
  20.             fd=fopen("LPT1","w");
  21.             return(0);
  22.     }
  23.     j=1;
  24.     putstring("p  .out",r,8);
  25.     r[7]=0;
  26.  
  27. J00100:    if (j>99)
  28.             return(-1);
  29.     r[1]=(j/10)+48;
  30.     r[2]=j-((r[1]-48)*10)+48;
  31.     fd=fopen(r,"r");
  32.     if (fd!=NULL){
  33.             fclose(fd);
  34.             j++;
  35.             goto J00100;
  36.     }
  37.     fd=fopen(r,"w");
  38.     return(j);
  39. }