home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / printbit.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  1KB  |  66 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <assert.h>
  6. #include <stdarg.h>
  7. #include <math.h>
  8. #include <dos.h>
  9. #define true (!false)
  10. #define false 0
  11. FILE *inf;
  12. char put_out(char c);
  13. int status(void);
  14.  
  15. main(int argc, char **argv)
  16. {
  17.     char infile[80];
  18.     strcpy(infile,"OUT.BIT");
  19.     if (argc==2) strcpy(infile,argv[1]);
  20.     printf("Printing {%s} \n",infile);
  21. #ifdef ultrix
  22.     inf = fopen(infile,"r");
  23. #else
  24.     inf = fopen(infile,"rb");
  25. #endif
  26.     if (inf==NULL) {
  27.         printf("Unable to open input file \n");
  28.         exit(1);
  29.     }
  30.     send_file();
  31.     fclose(inf);
  32. }
  33. send_file(void)
  34. {
  35.     char c,lc;
  36.     int l=0;
  37.     do {
  38.         c = fgetc(inf);
  39.         if (lc=='*' && c=='r') printf("line %d \x0d",++l);
  40.         put_out(c);
  41.         lc = c;
  42.     } while (!feof(inf));
  43. }
  44. status(void)
  45. {
  46.     union REGS reg;
  47.  
  48.     reg.h.ah = 2;
  49.     reg.x.dx = 0;
  50.     int86(0x17, ®, ®);
  51.     return (reg.h.ah & 0x80);
  52. }
  53. char put_out(char c)
  54. {
  55.     union REGS reg;
  56.  
  57.     while (!status());
  58.     reg.h.ah = 0;
  59.     reg.h.al = c;
  60.     reg.x.dx = 0;
  61.     int86(0x17,®,®);
  62.     return (reg.h.ah);
  63. }
  64.  
  65.  
  66.