home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / modems / modem / readnews.lbr / READNEWS.CZ / READNEWS.C
Text File  |  1987-10-31  |  3KB  |  129 lines

  1.  
  2. /*  READNEWS.C
  3. *   
  4.  *  Bob Stephens, March 1987
  5. */ 
  6. /*  This program opens the file NEWS on drive m: and displays it on
  7. *   the screen.  The user enters keywords at the prompt which are
  8.  *  written to an appropriate MEX script file for automatic downloading
  9. *   from STARTEXT.
  10.  *
  11. */
  12. /*  Configured for EPSON QX-10
  13. *   at the end of this file are the screen functions which can be 
  14.  *  changed for other machines.
  15. */
  16.  
  17. #include "stdio"
  18. #define LINEBUF 82
  19.  
  20. main(argc, argv)
  21.     int  argc;
  22.     char *argv[];
  23. {
  24.     FILE  *in_file, *out_file, *hdr_file;
  25.     int   c, line, status;
  26.     char choice[30], dline[LINEBUF];
  27.     
  28. /* open the news file to read: */
  29.  
  30.     in_file = fopen("M:NEWS", "r");
  31.  
  32.     if (in_file == NULL) {
  33.       printf("M:NEWS could not be opened. ");
  34.         exit(0);
  35.      }
  36.  
  37. /* open the header file to copy: */
  38.  
  39.      hdr_file = fopen("A:GETNEWS.HDR", "r");
  40.  
  41.      if (hdr_file == NULL) {
  42.        printf("GETNEWS.HDR could not be opened. ");
  43.           exit(0);
  44.      }
  45.   
  46. /* open the output file: */
  47.  
  48.      out_file = fopen("A:GETNEWS.MEX","w");
  49.     if (out_file == NULL) {
  50.         printf("*** Can't open output file ***");
  51.         exit(0);
  52.     }
  53.  
  54. /* copy the header over to the output file: */
  55.  
  56.      while ((c = getc(hdr_file)) != EOF)
  57.         putc(c, out_file);
  58.  
  59. /* now begin processing the input file */
  60.   
  61.     /* main loop */
  62.  
  63.      status = '\1';
  64.   while (status != NULL) {
  65.  
  66.      clrscrn();  /* clears screen */
  67.      line = 0;
  68.      while ((line < 20) && (status != NULL)) {
  69.         status = fgets(dline, LINEBUF, in_file);
  70.         if (status != NULL) {
  71.            line++;
  72.            fputs(dline, stdout);
  73.         }
  74.      }
  75.      choice[0] = '1';
  76.      while (choice[0] != NULL) {
  77.       poscurs(22,0);  /* position cursor */
  78.       clr_eol();
  79.       screen_lo();
  80.       printf("Enter your choice or CR: ");
  81.       screen_hi();
  82.       gets(choice);
  83.       if (choice[0] != NULL && choice[0] != '\033') {
  84.           /* could use a confirmation routine here */
  85.         fprintf(out_file, "SENDOUT \"%s\"\n", choice);
  86.       }  
  87.       if (choice[0] == '\033') 
  88.         goto end;
  89.      }
  90.    }
  91.    end: fprintf(out_file, "SENDOUT \"BYE\"\nWRT\n");
  92. }
  93. screen_addr()
  94.     {
  95.         bdos(2, 0x1B);  /* Console Output ESC */
  96.     }
  97. clrscrn()
  98.     {
  99.         bdos(2, 0x1A);  /*  Console Output B  */
  100.     }
  101. clr_eol()
  102.     {
  103.         screen_addr();
  104.         bdos(2, 0x54);
  105.     }
  106. clr_eos()
  107.     {
  108.         screen_addr();
  109.         bdos(2, 0x59);
  110.     }
  111. screen_hi()
  112.     {
  113.         screen_addr();
  114.        bdos(2, 0x28);
  115.     }
  116. screen_lo()
  117.     {
  118.         screen_addr();
  119.         bdos(2, 0x29);
  120.     }
  121. poscurs(r,c)
  122.     {
  123.         screen_addr();
  124.         bdos(2, 0x3D);
  125.         bdos(2, 32+r);
  126.         bdos(2, 32+c);
  127.     }
  128.  
  129.