home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XT.ZIP / RN / CHEAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-21  |  4.1 KB  |  197 lines

  1. /* $Header: E:\SRC\UUPC\RN\RCS/CHEAT.C 1.1 1992/11/21 06:14:58 ahd Exp $
  2.  *
  3.  * $Log: CHEAT.C $
  4.  * Revision 1.1  1992/11/21  06:14:58  ahd
  5.  * Initial
  6.  *
  7.  *
  8.  *    Rev 1.0   18 Nov 1990  0:22:18
  9.  * Initial revision.
  10.  * Revision 4.3.2.2  89/11/27  01:30:18  sob
  11.  * Altered NNTP code per ideas suggested by Bela Lubkin
  12.  * <filbo@gorn.santa-cruz.ca.us>
  13.  *
  14.  * Revision 4.3.2.1  89/11/26  22:54:21  sob
  15.  * Added RRN support
  16.  *
  17.  * Revision 4.3  85/05/01  11:36:46  lwall
  18.  * Baseline for release with 4.3bsd.
  19.  *
  20.  */
  21.  
  22. #include <conio.h>
  23. #include <string.h>
  24.  
  25. #include "EXTERN.h"
  26. #include "common.h"
  27. #include "intrp.h"
  28. #include "search.h"
  29. #include "ng.h"
  30. #include "bits.h"
  31. #include "artio.h"
  32. #include "term.h"
  33. #include "artsrch.h"
  34. #include "head.h"
  35. #include "INTERN.h"
  36. #include "cheat.h"
  37.  
  38. /* see what we can do while they are reading */
  39.  
  40. #ifdef PENDING
  41.  
  42. #ifdef ARTSEARCH
  43. COMPEX srchcompex;           /* compiled regex for
  44.                               * searchahead */
  45.  
  46. #endif
  47.  
  48. #endif
  49.  
  50. void
  51.   cheat_init()
  52. {
  53.    ;
  54. }
  55.  
  56. #ifdef PENDING
  57. void
  58.   look_ahead()
  59. {
  60.  
  61. #ifdef ARTSEARCH
  62.    register char *h, *s;
  63.  
  64. #ifdef DEBUGGING
  65.    if (debug && srchahead)
  66.    {
  67.       printf("(%ld)", (long) srchahead);
  68.       fflush(stdout);
  69.    }
  70. #endif
  71.  
  72.    if (srchahead && srchahead < art)
  73.    {                         /* in ^N mode? */
  74.       char *pattern;
  75.  
  76.       pattern = buf + 1;
  77.       strcpy(pattern, ": *");
  78.       h = pattern + strlen(pattern);
  79.       interp(h, (sizeof buf) - (h - buf), "%s");
  80.       h[24] = '\0';          /* compensate for
  81.                               * notesfiles */
  82.       while (*h)
  83.       {
  84.          if (index("\\[.^*$'\"", *h) != Nullch)
  85.             *h++ = '.';
  86.          else
  87.             h++;
  88.       }
  89.  
  90. #ifdef DEBUGGING
  91.       if (debug & DEB_SEARCH_AHEAD)
  92.       {
  93.          fputs("(hit CR)", stdout);
  94.          fflush(stdout);
  95.          gets(buf + 128);
  96.          printf("\npattern = %s\n", pattern);
  97.       }
  98. #endif
  99.  
  100.       if ((s = compile(&srchcompex, pattern, TRUE, TRUE)) != Nullch)
  101.       {
  102.          /* compile regular expression */
  103.          printf("\n%s\n", s);
  104.          srchahead = 0;
  105.       }
  106.       if (srchahead)
  107.       {
  108.          srchahead = art;
  109.          for (;;)
  110.          {
  111.             srchahead++;     /* go forward one
  112.                               * article */
  113.             if (srchahead > lastart)
  114.             {                /* out of articles? */
  115.  
  116. #ifdef DEBUGGING
  117.                if (debug)
  118.                   fputs("(not found)", stdout);
  119. #endif
  120.  
  121.                break;
  122.             }
  123.             if (!was_read(srchahead) &&
  124.                   wanted(&srchcompex, srchahead, 0))
  125.             {
  126.                /* does the shoe fit? */
  127.  
  128. #ifdef DEBUGGING
  129.                if (debug)
  130.                   printf("(%ld)", (long) srchahead);
  131. #endif
  132.  
  133. #ifdef SERVER
  134.                nntpopen(srchahead, HEAD);
  135. #else
  136.                artopen(srchahead);
  137. #endif
  138.  
  139.                break;
  140.             }
  141.             if (input_pending())
  142.                break;
  143.          }
  144.          fflush(stdout);
  145.       }
  146.    }
  147.    else
  148. #endif
  149.  
  150.    {
  151.       if (art + 1 <= lastart)/* how about a
  152.                               * pre-fetch? */
  153.  
  154. #ifdef SERVER
  155.          nntpopen(art + 1, HEAD);       /* look for the next
  156.                                          * article */
  157. #else
  158.          artopen(art + 1);   /* look for the next
  159.                               * article */
  160. #endif
  161.    }
  162. }
  163.  
  164. #endif
  165.  
  166. /* see what else we can do while they are reading */
  167.  
  168. void
  169.   collect_subjects()
  170. {
  171.  
  172. #ifdef PENDING
  173.  
  174. #ifdef CACHESUBJ
  175.    ART_NUM oldart = openart;
  176.    ART_POS oldartpos;
  177.  
  178.    if (!in_ng || !srchahead)
  179.       return;
  180.    if (oldart)               /* remember where we
  181.                               * were in art */
  182.       oldartpos = ftell(artfp);
  183.    if (srchahead >= subj_to_get)
  184.       subj_to_get = srchahead + 1;
  185.    while (!input_pending() && subj_to_get <= lastart)
  186.       fetchsubj(subj_to_get++, FALSE, FALSE);
  187.    if (oldart)
  188.    {
  189.       artopen(oldart);
  190.       fseek(artfp, oldartpos, 0);       /* do not screw the
  191.                                          * pager */
  192.    }
  193. #endif
  194.  
  195. #endif
  196. }
  197.