home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / trn_12.zip / src / cheat.c < prev    next >
C/C++ Source or Header  |  1993-12-04  |  4KB  |  192 lines

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