⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bits.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
ARTICLE *ap;{    if (!(ap->flags & AF_READ)) {	ap->flags |= AF_READ;	/* Keep selected_count accurate */	if (ap->flags & sel_mask) {	    selected_count--;	    ap->flags &= ~sel_mask;	}	if (toread[ng] > TR_NONE)	    --toread[ng];    }}voidonemissing(ap)ARTICLE *ap;{    oneless(ap);    ap->flags = (ap->flags & ~(AF_HAS_RE|AF_YANKBACK|AF_FROMTRUNCED))	      | AF_MISSING|AF_CACHED|AF_THREADED;}/* mark an article as unread, with possible xref chasing */voidunmark_as_read(){    onemore(article_ptr(art));#ifdef MCHASE    chase_xrefs(art,FALSE);#endif}/* Mark an article as read in this newsgroup and possibly chase xrefs.** Don't call this on missing articles.*/voidset_read(ap)register ARTICLE *ap;{    register ART_NUM artnum = article_num(ap);    oneless(ap);    if (!olden_days && ap->xrefs != nullstr) {	if (output_chase_phrase) {#ifdef VERBOSE	    IF(verbose)		fputs("\nChasing xrefs", stdout);	    ELSE#endif#ifdef TERSE		fputs("\nXrefs", stdout);#endif	    output_chase_phrase = 0;	}	putchar('.'), fflush(stdout);	chase_xrefs(artnum, TRUE);    }}/* temporarily mark article as read.  When newsgroup is exited, articles *//* will be marked as unread.  Called via M command */voiddelay_unmark(ap)ARTICLE *ap;{    if (!(ap->flags & AF_YANKBACK)) {	ap->flags |= AF_YANKBACK;	dmcount++;    }}/* mark article as read.  If article is cross referenced to other *//* newsgroups, mark them read there also. */voidmark_as_read(){    oneless(article_ptr(art));    checkcount++;			/* get more worried about crashes */    chase_xrefs(art,TRUE);}/* keep firstart pointing at the first unread article */voidcheck_first(min)ART_NUM min;{    if (min < absfirst)	min = absfirst;    if (min < firstart)	firstart = min;}/* bring back articles marked with M */voidyankback(){    register ARTICLE *ap;    if (dmcount) {			/* delayed unmarks pending? */	if (mode == 't')	    sprintf(buf, "Returned %ld Marked article%s.",(long)dmcount,		dmcount == 1 ? nullstr : "s");	else#ifdef VERBOSE	    printf("\nReturning %ld Marked article%s...\n",(long)dmcount,		dmcount == 1 ? nullstr : "s") FLUSH;#endif	for (art=absfirst, ap=article_ptr(art); art <= lastart; art++, ap++) {	    if ((ap->flags & (AF_YANKBACK|AF_MISSING)) == AF_YANKBACK) {		unmark_as_read();		if (selected_only)		    select_article(ap, 0);		ap->flags &= ~AF_YANKBACK;	    }	}	dmcount = 0;    }}    /* run down xref list and mark as read or unread */#ifndef DBM_XREFSintchase_xrefs(artnum,markread)	/* The Xref-line-using version */ART_NUM artnum;int markread;{    bool valid_xref_site();    register char *xartnum;    register ART_NUM x;    char *xref_buf, *curxref;    char tmpbuf[128];    xref_buf = fetchcache(artnum, XREF_LINE);    if (!xref_buf || !*xref_buf)	return 0;    xref_buf = savestr(xref_buf);# ifdef DEBUG    if (debug & DEB_XREF_MARKER)	printf("Xref: %s\n",xref_buf) FLUSH;# endif    curxref = cpytill(tmpbuf,xref_buf,' ') + 1;    if (valid_xref_site(artnum,tmpbuf)) {	while (*curxref) {		/* for each newsgroup */	    curxref = cpytill(tmpbuf,curxref,' ');	    xartnum = index(tmpbuf,':');	    if (!xartnum)		break;	    *xartnum++ = '\0';	    if (!(x = atol(xartnum)))		continue;	    if (strEQ(tmpbuf,ngname)) {/* is this the current newsgroup? */		if (x < absfirst || x > lastart)		    continue;		if (markread)		    oneless(article_ptr(x)); /* take care of old C newses */#ifdef MCHASE		else		    onemore(article_ptr(x));#endif	    } else {		if (markread) {		    if (addartnum(x,tmpbuf))			break;		}# ifdef MCHASE		else		    subartnum(x,tmpbuf);# endif	    }	    while (*curxref && isspace(*curxref))		curxref++;	}    }    free(xref_buf);    return 0;}/* Make sure the site name on Xref matches what inews thinks the site * is.  Check first against last inews_site.  If it matches, fine. * If not, fetch inews_site from current Path or Relay-Version line and * check again.  This is so that if the new administrator decides * to change the system name as known to inews, rn will still do * Xrefs correctly--each article need only match itself to be valid. */ boolvalid_xref_site(artnum, site)ART_NUM artnum;char *site;{    static char *inews_site = Nullch;    char *sitebuf, *s;    if (inews_site && strEQ(site,inews_site))	return TRUE;    if (inews_site)	free(inews_site);#ifndef ANCIENT_NEWS    /* Grab the site from the first component of the Path line */    sitebuf = fetchlines(artnum,PATH_LINE);    if ((s = index(sitebuf, '!')) != Nullch) {	*s = '\0';	inews_site = savestr(sitebuf);    }#else /* ANCIENT_NEWS */    /* Grab the site from the Posting-Version line */    sitebuf = fetchlines(artnum,RVER_LINE);    if ((s = instr(sitebuf,"; site ",TRUE)) != Nullch) {	char *t = index(s+7, '.');	if (t)	    *t = '\0';	inews_site = savestr(s+7);    }#endif /* ANCIENT_NEWS */    else	inews_site = savestr(nullstr);    free(sitebuf);    if (strEQ(site,inews_site))	return TRUE;#ifdef DEBUG    if (debug)	printf("Xref not from %s--ignoring\n",inews_site) FLUSH;#endif    return FALSE;}#else /* DBM_XREFS */intchase_xrefs(artnum,markread)		/* The DBM version */ART_NUM artnum;int markread;{    datum lhs, rhs;    datum fetch();    register char *idp;    char *ident_buf;    static FILE *hist_file = Nullfp;    long pos;    register char *xartnum;    register ART_NUM x;    char *xref_buf, *curxref;    char tmpbuf[128];    xref_buf = fetchcache(artnum, NGS_LINE);    if (!xref_buf || !*xref_buf)	return 0;    xref_buf = safemalloc((MEM_SIZE)BUFSIZ);    if (hist_file == Nullfp) {	/* Init. file accesses */#ifdef DEBUG	if (debug)	    printf("chase_xref: opening files\n");#endif	dbminit(filexp(ARTFILE));	if ((hist_file = fopen(filexp(ARTFILE), "r")) == Nullfp)	    return 0;    }    ident_buf = fetchlines(artnum,MESSID_LINE);	/* get Message-ID */#ifdef DEBUG    if (debug)	printf ("chase_xref: Message-ID: %s\n", ident_buf);#endif        if ((idp = index(ident_buf, '@')) != Nullch) {	while (*++idp)			/* make message-id case insensitive */	    if (isupper(*idp))		*idp = tolower(*idp);    }    lhs.dptr = ident_buf;		/* look up article by id */    lhs.dsize = strlen(lhs.dptr) + 1;    rhs = fetch(lhs);			/* fetch the record */    if (rhs.dptr == NULL)		/* if null, nothing there */	goto wild_goose;    bcopy(rhs.dptr,(char*)&pos, 4);    fseek(hist_file, pos, 0);	/* datum returned is position in hist file */    fgets(xref_buf, BUFSIZ, hist_file);#ifdef DEBUG    if (debug)	printf ("Xref from history: %s\n", xref_buf);#endif    curxref = cpytill(tmpbuf, xref_buf, '\t') + 1;    curxref = cpytill(tmpbuf, curxref, '\t') + 1;#ifdef DEBUG    if (debug)	printf ("chase_xref: curxref: %s\n", curxref);#endif    while (*curxref) {			/* for each newsgroup */	curxref = cpytill(tmpbuf,curxref,' ');	xartnum = index(tmpbuf,'/');	if (!xartnum)			/* probably an old-style Xref */	    break;	*xartnum++ = '\0';	if (!(x = atol(xartnum)))	    continue;	if (strNE(tmpbuf,ngname)) {	/* not the current newsgroup? */	    if (markread) {		if (addartnum(x,tmpbuf))		    goto wild_goose;	    }#ifdef MCHASE	    else		subartnum(x,tmpbuf);#endif	}	while (*curxref && isspace(*curxref))	    curxref++;    }  wild_goose:    free(xref_buf);    free(ident_buf);    return 0;}#endif /* DBM_XREFS */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -