1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/* only.c
*/
/* This software is copyrighted as detailed in the LICENSE file. */
#include "EXTERN.h"
#include "common.h"
#include "search.h"
#include "util.h"
#include "util2.h"
#include "final.h"
#include "list.h"
#include "term.h"
#include "ngdata.h"
#include "ngsrch.h"
#include "INTERN.h"
#include "only.h"
static int save_maxngtodo = 0;
void
only_init()
{
;
}
void
setngtodo(pat)
char* pat;
{
char* s;
register int i = maxngtodo + save_maxngtodo;
if (!*pat)
return;
if (i < MAXNGTODO) {
ngtodo[i] = savestr(pat);
#ifndef lint
compextodo[i] = (COMPEX*)safemalloc(sizeof(COMPEX));
#endif
init_compex(compextodo[i]);
compile(compextodo[i],pat,TRUE,TRUE);
if ((s = ng_comp(compextodo[i],pat,TRUE,TRUE)) != NULL) {
printf("\n%s\n",s) FLUSH;
finalize(1);
}
maxngtodo++;
}
}
/* if command line list is non-null, is this newsgroup wanted? */
bool
inlist(ngnam)
char* ngnam;
{
register int i;
if (maxngtodo == 0)
return TRUE;
for (i = save_maxngtodo; i < maxngtodo + save_maxngtodo; i++) {
if (execute(compextodo[i],ngnam))
return TRUE;
}
return FALSE;
}
void
end_only()
{
if (maxngtodo) { /* did they specify newsgroup(s) */
int i;
#ifdef VERBOSE
IF(verbose)
sprintf(msg, "Restriction %s%s removed.",ngtodo[0],
maxngtodo > 1 ? ", etc." : nullstr);
ELSE
#endif
#ifdef TERSE
sprintf(msg, "Exiting \"only\".");
#endif
for (i = save_maxngtodo; i < maxngtodo + save_maxngtodo; i++) {
free(ngtodo[i]);
free_compex(compextodo[i]);
#ifndef lint
free((char*)compextodo[i]);
#endif
}
maxngtodo = 0;
ng_min_toread = 1;
}
}
void
push_only()
{
save_maxngtodo = maxngtodo;
maxngtodo = 0;
}
void
pop_only()
{
ART_UNREAD save_ng_min_toread = ng_min_toread;
end_only();
maxngtodo = save_maxngtodo;
save_maxngtodo = 0;
ng_min_toread = save_ng_min_toread;
}
|