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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
|
/* $Id: ngdata.c,v 3.0 1992/02/01 03:09:32 davison Trn $
*/
/* This software is Copyright 1991 by Stan Barber.
*
* Permission is hereby granted to copy, reproduce, redistribute or otherwise
* use this software as long as: there is no monetary profit gained
* specifically from the use or reproduction of this software, it is not
* sold, rented, traded or otherwise marketed, and this copyright notice is
* included prominently in any copy made.
*
* The authors make no claims as to the fitness or correctness of this software
* for any use whatsoever, and it is provided as is. Any use of this software
* is at the user's own risk.
*/
#include "EXTERN.h"
#include "common.h"
#include "rcstuff.h"
#include "trn.h"
#include "cache.h"
#include "bits.h"
#include "head.h"
#include "rthread.h"
#include "rt-select.h"
#include "ng.h"
#include "intrp.h"
#include "kfile.h"
#include "final.h"
#include "rcln.h"
#include "term.h"
#include "util.h"
#include "nntp.h"
#include "ndir.h"
#include "INTERN.h"
#include "ngdata.h"
/* open the active file */
void
ngdata_init()
{
#ifdef USE_NNTP
switch (nntp_list("active", "control", 7)) {
case 1:
do {
nntp_gets(ser_line, sizeof ser_line);
} while (!NNTP_LIST_END(ser_line));
/* FALL THROUGH */
case 0:
/*actfp = NULL;*/
fuzzyGet = 0;
break;
case -1:
#endif
ngdatahash_init();
if (fseek(actfp,0L,0) == -1) { /* just get to the beginning */
printf("Error seeking in active file.\n") FLUSH;
finalize(1);
}
#ifdef USE_NNTP
break;
}
#endif
}
bool
access_ng()
{
#ifdef USE_NNTP
ART_NUM old_first = abs1st[ng];
if (!nntp_group(ngname,ng)) {
toread[ng] = TR_BOGUS;
return FALSE;
}
if ((lastart = getngsize(ng)) < 0) /* this cannot happen (laugh here) */
return FALSE;
absfirst = abs1st[ng];
lastart = ngmax[ng];
if (absfirst > old_first)
checkexpired(ng,absfirst);
#else /* !USE_NNTP */
if (eaccess(ngdir,5)) { /* directory read protected? */
if (eaccess(ngdir,0)) {
# ifdef VERBOSE
IF(verbose)
printf("\nNewsgroup %s does not have a spool directory!\n",
ngname) FLUSH;
ELSE
# endif
# ifdef TERSE
printf("\nNo spool for %s!\n",ngname) FLUSH;
# endif
} else {
# ifdef VERBOSE
IF(verbose)
printf("\nNewsgroup %s is not currently accessible.\n",
ngname) FLUSH;
ELSE
# endif
# ifdef TERSE
printf("\n%s not readable.\n",ngname) FLUSH;
# endif
}
toread[ng] = TR_NONE; /* make this newsgroup temporarily invisible */
return FALSE;
}
/* chdir to newsgroup subdirectory */
if (chdir(ngdir)) {
printf(nocd,ngdir) FLUSH;
return FALSE;
}
if ((lastart = getngsize(ng)) < 0) /* this cannot happen (laugh here) */
return FALSE;
absfirst = abs1st[ng];
setfoundbits(); /* might reset absfirst */
#endif /* !USE_NNTP */
dmcount = 0;
in_ng = TRUE; /* tell the world we are here */
build_cache();
return TRUE;
}
void
grow_ng(newlast)
ART_NUM newlast;
{
ART_NUM tmpfirst;
forcegrow = FALSE;
if (newlast > lastart) {
ART_NUM tmpart = art;
toread[ng] += (ART_UNREAD)(newlast-lastart);
grow_cache(newlast);
tmpfirst = lastart+1;
lastart = newlast;
thread_grow();
#ifdef KILLFILES
#ifdef VERBOSE
IF(verbose)
sprintf(buf,
"%ld more article%s arrived -- processing memorized commands...\n\n",
(long)(lastart - tmpfirst + 1),
(lastart > tmpfirst ? "s have" : " has" ) );
ELSE /* my, my, how clever we are */
#endif
#ifdef TERSE
strcpy(buf, "More news -- auto-processing...\n\n");
#endif
if (has_normal_kills) {
bool forcelast_save = forcelast;
ARTICLE *artp_save = artp;
kill_unwanted(tmpfirst,buf,TRUE);
artp = artp_save;
forcelast = forcelast_save;
}
#endif
art = tmpart;
}
}
void
ng_skip()
{
#ifndef USE_NNTP /* never read it & cannot find it? */
if (errno != ENOENT) { /* has it not been deleted? */
clear();
# ifdef VERBOSE
IF(verbose)
printf("\n(Article %ld exists but is unreadable.)\n",(long)art)
FLUSH;
ELSE
# endif
# ifdef TERSE
printf("\n(%ld unreadable.)\n",(long)art) FLUSH;
# endif
if (novice_delays) {
pad(just_a_sec);
sleep(2);
}
}
inc_art(selected_only,FALSE); /* try next article */
#else /* USE_NNTP */
ART_NUM artnum;
clear();
# ifdef VERBOSE
IF(verbose)
fputs("Skipping unavailable article\n",stdout);
ELSE
# endif /* VERBOSE */
# ifdef TERSE
fputs("Skipping\n",stdout);
# endif /* TERSE */
if (novice_delays) {
pad(just_a_sec/3);
sleep(1);
}
art++;
artp++;
do {
/* tries to grab PREFETCH_SIZE XHDRS, flagging missing articles */
(void) fetchsubj(art, FALSE);
artnum = art+PREFETCH_SIZE-1;
if (artnum > lastart)
artnum = lastart;
while (art <= artnum) {
if (!(artp->flags & AF_MISSING))
return;
art++;
artp++;
}
} while (art <= lastart);
#endif /* USE_NNTP */
}
/* find the maximum article number of a newsgroup */
ART_NUM
getngsize(num)
register NG_NUM num;
{
register int len;
register char *nam;
char tmpbuf[LBUFLEN];
ART_POS oldsoft;
long last, first;
char ch;
nam = rcline[num];
len = rcnums[num] - 1;
softtries++;
#ifdef DEBUG
if (debug & DEB_SOFT_POINTERS)
printf("Softptr = %ld\n",(long)softptr[num]) FLUSH;
#endif
oldsoft = softptr[num];
#ifndef USE_NNTP
fseek(actfp,100000L,1); /* hopefully this forces a reread */
#endif
if ((softptr[num] = findact(tmpbuf, nam, len, (long)oldsoft)) >= 0) {
if (softptr[num] != oldsoft) {
softmisses++;
writesoft = TRUE;
}
}
else {
softptr[num] = 0;
if (RCCHAR(rcchar[num]) == ':')
rcchar[num] = NEGCHAR;
return TR_BOGUS;
}
#ifdef DEBUG
if (debug & DEB_SOFT_POINTERS) {
printf("Should be %ld\n",(long)softptr[num]) FLUSH;
}
#endif
#ifdef ANCIENT_NEWS
sscanf(tmpbuf+len+1, "%ld %c", &last, &ch);
first = 1;
#else
sscanf(tmpbuf+len+1, "%ld %ld %c", &last, &first, &ch);
#endif
if (!abs1st[num])
abs1st[num] = (ART_NUM)first;
if (!in_ng) {
if (redirected) {
if (redirected != nullstr)
free(redirected);
redirected = Nullch;
}
switch (ch) {
case 'n':
moderated = getval("NOPOSTRING"," (no posting)");
break;
case 'm':
moderated = getval("MODSTRING", " (moderated)");
break;
case 'x':
redirected = nullstr;
moderated = " (DISABLED)";
break;
case '=':
len = strlen(tmpbuf);
if (tmpbuf[len-1] == '\n')
tmpbuf[len-1] = '\0';
redirected = savestr(rindex(tmpbuf, '=') + 1);
moderated = " (REDIRECTED)";
break;
default:
moderated = nullstr;
break;
}
}
if (last < ngmax[num])
return ngmax[num];
return ngmax[num] = (ART_NUM)last;
}
|