home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / exitcmd.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  1KB  |  68 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. #include <process.h>
  10. #define true (!false)
  11. #define false 0
  12. FILE *inf;
  13. char put_out(char c);
  14. int status(void);
  15.  
  16. main(int argc, char **argv)
  17. {
  18.     char infile[80];
  19.  
  20.     execlp("cgle",argv[0]);
  21.  
  22.     strcpy(infile,"OUT.BIT");
  23.     if (argc==2) strcpy(infile,argv[1]);
  24.     printf("Printing {%s} \n",infile);
  25. #ifdef ultrix
  26.     inf = fopen(infile,"r");
  27. #else
  28.     inf = fopen(infile,"rb");
  29. #endif
  30.     if (inf==NULL) {
  31.         printf("Unable to open input file \n");
  32.         exit(1);
  33.     }
  34.     send_file();
  35.     fclose(inf);
  36. }
  37. send_file(void)
  38. {
  39.     char c,lc;
  40.     int l=0;
  41.     do {
  42.         c = fgetc(inf);
  43.         if (lc=='*' && c=='r') printf("line %d \x0d",++l);
  44.         put_out(c);
  45.         lc = c;
  46.     } while (!feof(inf));
  47. }
  48. status(void)
  49. {
  50.     union REGS reg;
  51.  
  52.     reg.h.ah = 2;
  53.     reg.x.dx = 0;
  54.     int86(0x17, ®, ®);
  55.     return (reg.h.ah & 0x80);
  56. }
  57. char put_out(char c)
  58. {
  59.     union REGS reg;
  60.  
  61.     while (!status());
  62.     reg.h.ah = 0;
  63.     reg.h.al = c;
  64.     reg.x.dx = 0;
  65.     int86(0x17,®,®);
  66.     return (reg.h.ah);
  67. }
  68.