home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / trn_12.zip / src / only.c < prev    next >
C/C++ Source or Header  |  1992-09-22  |  3KB  |  142 lines

  1. /* $Id: only.c,v 4.4 1991/09/09 20:23:31 sob Exp sob $
  2.  *
  3.  * $Log: only.c,v $
  4.  * Revision 4.4  1991/09/09  20:23:31  sob
  5.  * release 4.4
  6.  *
  7.  *
  8.  * 
  9.  */
  10. /* This software is Copyright 1991 by Stan Barber. 
  11.  *
  12.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  13.  * use this software as long as: there is no monetary profit gained
  14.  * specifically from the use or reproduction of this software, it is not
  15.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  16.  * included prominently in any copy made. 
  17.  *
  18.  * The author make no claims as to the fitness or correctness of this software
  19.  * for any use whatsoever, and it is provided as is. Any use of this software
  20.  * is at the user's own risk. 
  21.  */
  22.  
  23. #include "EXTERN.h"
  24. #include "common.h"
  25. #include "search.h"
  26. #include "util.h"
  27. #include "final.h"
  28. #include "ngsrch.h"
  29. #include "INTERN.h"
  30. #include "only.h"
  31.  
  32. void
  33. only_init()
  34. {
  35.     ;
  36. }
  37.  
  38. void
  39. setngtodo(pat)
  40. char *pat;
  41. {
  42.     char *s;
  43.  
  44. #ifdef ONLY
  45.     if (!*pat)
  46.     return;
  47.     if (maxngtodo < NGMAX) {
  48.     ngtodo[maxngtodo] = savestr(pat);
  49. #ifdef SPEEDOVERMEM
  50. #ifndef lint
  51.     compextodo[maxngtodo] = (COMPEX*)safemalloc(sizeof(COMPEX));
  52. #endif /* lint */
  53.     init_compex(compextodo[maxngtodo]);
  54.     compile(compextodo[maxngtodo],pat,TRUE,TRUE);
  55.     if ((s = ng_comp(compextodo[maxngtodo],pat,TRUE,TRUE)) != Nullch) {
  56.                         /* compile regular expression */
  57.         printf("\n%s\n",s) ; FLUSH;
  58.         finalize(1);
  59.     }
  60. #endif
  61.     maxngtodo++;
  62.     }
  63. #else
  64.     notincl("o");
  65. #endif
  66. }
  67.  
  68. /* if command line list is non-null, is this newsgroup wanted? */
  69.  
  70. bool
  71. inlist(ngnam)
  72. char *ngnam;
  73. {
  74. #ifdef ONLY
  75.     register int i;
  76. #ifdef SPEEDOVERMEM
  77.  
  78.     if (maxngtodo == 0)
  79.     return TRUE;
  80.     for (i=0; i<maxngtodo; i++) {
  81.     if (execute(compextodo[i],ngnam))
  82.         return TRUE;
  83.     }
  84.     return FALSE;
  85. #else
  86.     COMPEX ilcompex;
  87.     char *s;
  88.  
  89.     if (maxngtodo == 0)
  90.     return TRUE;
  91.     init_compex(&ilcompex);
  92.     for (i=0; i<maxngtodo; i++) {
  93.     if ((s = ng_comp(&ilcompex,ngtodo[i],TRUE,TRUE)) != Nullch) {
  94.                         /* compile regular expression */
  95.         printf("\n%s\n",s) ; FLUSH;
  96.         finalize(1);
  97.     }
  98.     
  99.     if (execute(&ilcompex,ngnam) != Nullch) {
  100.         free_compex(&ilcompex);
  101.         return TRUE;
  102.     }
  103.     }
  104.     free_compex(&ilcompex);
  105.     return FALSE;
  106. #endif
  107. #else
  108.     return TRUE;
  109. #endif
  110. }
  111.  
  112. #ifdef ONLY
  113. void
  114. end_only()
  115. {
  116.     if (maxngtodo) {            /* did they specify newsgroup(s) */
  117.     int whicharg;
  118.  
  119. #ifdef VERBOSE
  120.     IF(verbose) {
  121.         printf("\nRestriction %s%s removed.\n",ngtodo[0],
  122.         maxngtodo > 1 ? ", etc." : nullstr) ; FLUSH;
  123.     }
  124.     ELSE
  125. #endif
  126. #ifdef TERSE
  127.         fputs("\nExiting \"only\".\n",stdout) ; FLUSH;
  128. #endif
  129.     for (whicharg = 0; whicharg < maxngtodo; whicharg++) {
  130.         free(ngtodo[whicharg]);
  131. #ifdef SPEEDOVERMEM
  132.         free_compex(compextodo[whicharg]);
  133. #ifndef lint
  134.         free((char*)compextodo[whicharg]);
  135. #endif /* lint */
  136. #endif
  137.     }
  138.     maxngtodo = 0;
  139.     }
  140. }
  141. #endif
  142.