home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / trn / part02 / cheat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-02  |  3.4 KB  |  163 lines

  1. /* $Id: cheat.c,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 sob $
  2.  *
  3.  * $Log: cheat.c,v $
  4.  * Revision 4.4.2.1  1991/12/01  18:05:42  sob
  5.  * Patchlevel 2 changes
  6.  *
  7.  * Revision 4.4  1991/09/09  20:18:23  sob
  8.  * release 4.4
  9.  *
  10.  *
  11.  * 
  12.  */
  13. /* This software is Copyright 1991 by Stan Barber. 
  14.  *
  15.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  16.  * use this software as long as: there is no monetary profit gained
  17.  * specifically from the use or reproduction of this software, it is not
  18.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  19.  * included prominently in any copy made. 
  20.  *
  21.  * The author make no claims as to the fitness or correctness of this software
  22.  * for any use whatsoever, and it is provided as is. Any use of this software
  23.  * is at the user's own risk. 
  24.  */
  25.  
  26. #include "EXTERN.h"
  27. #include "common.h"
  28. #include "intrp.h"
  29. #include "search.h"
  30. #include "ng.h"
  31. #include "bits.h"
  32. #include "artio.h"
  33. #include "term.h"
  34. #include "artsrch.h"
  35. #include "head.h"
  36. #include "INTERN.h"
  37. #include "cheat.h"
  38.  
  39. /* see what we can do while they are reading */
  40.  
  41. #ifdef PENDING
  42. #   ifdef ARTSEARCH
  43.     COMPEX srchcompex;        /* compiled regex for searchahead */
  44. #   endif
  45. #endif
  46.  
  47. void
  48. cheat_init()
  49. {
  50.     ;
  51. }
  52.  
  53. #ifdef PENDING
  54. void
  55. look_ahead()
  56. {
  57. #ifdef ARTSEARCH
  58.     register char *h, *s;
  59.  
  60. #ifdef DEBUGGING
  61.     if (debug && srchahead) {
  62.     printf("(%ld)",(long)srchahead);
  63.     fflush(stdout);
  64.     }
  65. #endif
  66.     if (srchahead && srchahead < art) {    /* in ^N mode? */
  67.     char *pattern;
  68.  
  69.     pattern = buf+1;
  70.     strcpy(pattern,": *");
  71.     h = pattern + strlen(pattern);
  72.     interp(h,(sizeof buf) - (h-buf),"%\\s");
  73.     {            /* compensate for notesfiles */
  74.         register int i;
  75.         for (i = 24; *h && i--; h++)
  76.         if (*h == '\\')
  77.             h++;
  78.         *h = '\0';
  79.     }
  80. #ifdef DEBUGGING
  81.     if (debug & DEB_SEARCH_AHEAD) {
  82.         fputs("(hit CR)",stdout);
  83.         fflush(stdout);
  84.         gets(buf+128);
  85.         printf("\npattern = %s\n",pattern);
  86.     }
  87. #endif
  88.     if ((s = compile(&srchcompex,pattern,TRUE,TRUE)) != Nullch) {
  89.                     /* compile regular expression */
  90.         printf("\n%s\n",s);
  91.         srchahead = 0;
  92.     }
  93.     if (srchahead) {
  94.         srchahead = art;
  95.         for (;;) {
  96.         srchahead++;    /* go forward one article */
  97.         if (srchahead > lastart) { /* out of articles? */
  98. #ifdef DEBUGGING
  99.             if (debug)
  100.             fputs("(not found)",stdout);
  101. #endif
  102.             break;
  103.         }
  104.         if (!was_read(srchahead) &&
  105.             wanted(&srchcompex,srchahead,0)) {
  106.                     /* does the shoe fit? */
  107. #ifdef DEBUGGING
  108.             if (debug)
  109.             printf("(%ld)",(long)srchahead);
  110. #endif
  111. #ifdef SERVER
  112.             nntpopen(srchahead,GET_HEADER);
  113. #else
  114.             artopen(srchahead);
  115. #endif
  116.             break;
  117.         }
  118.         if (input_pending())
  119.             break;
  120.         }
  121.         fflush(stdout);
  122.     }
  123.     }
  124.     else
  125. #endif
  126.     {
  127.     if (art+1 <= lastart)/* how about a pre-fetch? */
  128. #ifdef SERVER
  129.         nntpopen(art+1,GET_HEADER);    /* look for the next article */
  130. #else
  131.         artopen(art+1);    /* look for the next article */
  132. #endif
  133.     }
  134. }
  135. #endif
  136.  
  137. /* see what else we can do while they are reading */
  138.  
  139. void
  140. collect_subjects()
  141. {
  142. #ifdef PENDING
  143. # ifdef CACHESUBJ
  144.     ART_NUM oldart = openart;
  145.     ART_POS oldartpos;
  146.  
  147.     if (!in_ng || !srchahead)
  148.     return;
  149.     if (oldart)            /* remember where we were in art */
  150.     oldartpos = ftell(artfp);
  151.     if (srchahead >= subj_to_get)
  152.     subj_to_get = srchahead+1;
  153.     while (!input_pending() && subj_to_get <= lastart)
  154.     fetchsubj(subj_to_get++,FALSE,FALSE);
  155.     if (oldart) {
  156.     artopen(oldart);
  157.     fseek(artfp,oldartpos,0);    /* do not screw the pager */
  158.     }
  159. # endif
  160. #endif
  161. }
  162.  
  163.