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

📄 trn.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  trn -- threaded readnews program based on rn 4.4 * *  Author/Maintainer of trn: davison@borland.com (Wayne Davison) *  Organization: Borland International *  Author/Maintainer of rn: sob@bcm.tmc.edu (Stan Barber) *  Organization: Baylor College of Medicine, Houston,Tx *  Original Author: lwall@sdcrdcf.UUCP (Larry Wall) *  Organization: System Development Corporation, Santa Monica * *  History: *	01/14/83 - rn begun *	04/08/83 - rn 1.0 *	09/01/83 - rn 2.0 *	05/01/85 - rn 4.3 *	11/01/89 - rn/rrn integration *	11/25/89 - trn begun *	07/21/90 - trn 1.0 *	07/04/91 - rn 4.4 *	11/25/91 - trn 2.0 *	03/01/93 - trn 3.0 (or so... :-) ) *//* 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 author 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 "patchlevel.h"static char rnid[] = "@(#)$Id: trn.c,v 3.0 1991/11/22 00:14:59 davison Trn $";static char patchlevel[] = PATCHLEVEL;#include "INTERN.h"#include "common.h"#include "trn.h"#include "EXTERN.h"#include "rcstuff.h"#include "term.h"#include "final.h"#include "search.h"#include "ngdata.h"#include "ngstuff.h"#include "util.h"#include "only.h"#include "ngsrch.h"#include "help.h"#include "last.h"#include "init.h"#include "intrp.h"#include "rcln.h"#include "sw.h"#include "cache.h"#include "addng.h"#include "ng.h"#include "kfile.h"#include "nntp.h"voidrn_init(){    ;}voidmain(argc,argv)int argc;char *argv[];{    bool foundany;    register char *s;    bool oh_for_the_good_old_days = FALSE;    int direction = 1;#if !THREAD_INIT    /* Default to threaded operation if our name starts with a 't' */    if ((s = rindex(argv[0],'/')) == Nullch)	s = argv[0];    else	s++;    if (*s == 't')	use_threads = TRUE;    else	select_on = 0;#endif    foundany = initialize(argc,argv);    if (maxngtodo)	starthere = 0;    else if (!foundany) {		/* nothing to do? */#ifdef VERBOSE	if (verbose)	    fputs("\No unread news in subscribed-to newsgroups.  To subscribe to a new\n\newsgroup use the g<newsgroup> command.\n\",stdout) FLUSH;#endif	starthere = nextrcline;    }    /* loop through all unread news */    {	bool special = FALSE;		/* temporarily allow newsgroup */					/*   with no unread news? */	bool retry;			/* cycle back to top of list? */	NG_NUM recent_ng = 0;		current_ng = 0;	do {	    retry = FALSE;	    if (findlast) {		findlast = FALSE;		starthere = 0;		if (*lastngname) {		    if ((ng = find_ng(lastngname)) == nextrcline)			ng = 0;		    else {			set_ngname(lastngname);		    	set_toread(ng);			if (toread[ng] <= TR_NONE)			    ng = 0;		    }		}	    } else {		ng = starthere;		starthere = 0;	    }	    while (ng <= nextrcline) {	/* for each newsgroup */		if (ng == nextrcline) {	/* after the last newsgroup? */		    mode = 'f';#ifdef ONLY		    if (maxngtodo) {			if (retry)#ifdef VERBOSE			    IF(verbose)				printf("\nRestriction %s%s still in effect.\n",				    ngtodo[0],				    maxngtodo > 1 ? ", etc." : nullstr) FLUSH;			    ELSE#endif#ifdef TERSE				fputs("\n(\"Only\" mode.)\n",stdout) FLUSH;#endif			else {#ifdef VERBOSE			    IF(verbose)				fputs("\nNo articles under restriction.",				  stdout) FLUSH;			    ELSE#endif#ifdef TERSE				fputs("\nNo \"only\" articles.",stdout) FLUSH;#endif			    end_only();	/* release the restriction */			    retry = TRUE;			}		    }#endif		} else {		    bool shoe_fits;	/* newsgroup matches restriction? */		    mode = 'n';		    if (toread[ng] >= TR_NONE) {	/* recalc toread? */			set_ngname(rcline[ng]);			shoe_fits = inlist(ngname);			if (shoe_fits)			    set_toread(ng);			if (paranoid) {			    recent_ng = current_ng;			    current_ng = ng;			    cleanup_rc();					/* this may move newsgroups around */			    ng = current_ng;			    set_ngname(rcline[ng]);			}		    }		    if (toread[ng] < (maxngtodo||special ? TR_NONE : TR_ONE)		     || !shoe_fits) {		/* unwanted newsgroup? */			ng += direction;	/* then skip it */			if (ng < 0) {			   ng = 1;			   direction = 1;			}			continue;		    }		}		special = FALSE;	/* go back to normal mode */		if (ng != current_ng) {		    recent_ng = current_ng;					/* remember previous newsgroup */		    current_ng = ng;	/* remember current newsgroup */		}    reask_newsgroup:		unflush_output();	/* disable any ^O in effect */		if (ng >= nextrcline) {#ifdef USE_NNTP		    if (time(Null(time_t*)) - lastactfetch > MINFETCHTIME) {			fclose(actfp);			ngdata_init();	/* re-grab the active file */		    }#endif		    dfltcmd = (retry ? "npq" : "qnp");#ifdef VERBOSE		    IF(verbose)			printf("\n****** End of newsgroups -- what next? [%s] ",			    dfltcmd);		    ELSE#endif#ifdef TERSE			printf("\n**** End -- next? [%s] ", dfltcmd);#endif		} else {		    ThreadedGroup = (use_threads && rcchar[ng] != '0');		    dfltcmd = (select_on			&& (ART_NUM)toread[ng] >= select_on ? "+ynq" : "ynq");#ifdef VERBOSE		    IF(verbose)			printf("\n%s %3ld unread article%s in %s -- read now? [%s] ",			    ThreadedGroup? "======" : "******",			    (long)toread[ng], (toread[ng]==TR_ONE ? nullstr : "s"),			    ngname, dfltcmd);		    ELSE#endif#ifdef TERSE			printf("\n%s %3ld in %s -- read? [%s] ",			    ThreadedGroup? "====" : "****",			    (long)toread[ng],ngname,dfltcmd);#endif		}		fflush(stdout);    reinp_newsgroup:		eat_typeahead();		getcmd(buf);		if (errno || *buf == '\f') {		    putchar('\n') FLUSH; /* if return from stop signal */		    goto reask_newsgroup;	/* give them a prompt again */		}		setdef(buf,dfltcmd);#ifdef VERIFY		printcmd();#endif    do_command:		direction = 1;		/* default to forward motion */		addnewbydefault = 0;		switch (*buf) {		case 'P':		/* goto previous newsgroup */		    special = TRUE;	/* don't skip it if toread==0 */		    /* FALL THROUGH */		case 'p':		/* find previous unread newsgroup */		    if (ng > 0)			ng--;		    direction = -1;	/* go backward in the newsrc */		    break;		case '-':		    ng = recent_ng;	/* recall previous newsgroup */		    if (ng < nextrcline)			if (!get_ng(rcline[ng],0))			    ng = current_ng;		    special = TRUE;	/* don't skip it if toread==0 */		    break;		case 'q': case 'Q': case 'x':	/* quit? */		    oh_for_the_good_old_days = (*buf == 'x');		    putchar('\n') FLUSH;		    ng = nextrcline+1;	/* satisfy */		    retry = FALSE;	/*   loop conditions */		    break;		case '^':		    putchar('\n') FLUSH;		    ng = 0;		    break;		case 'n':		/* find next unread newsgroup */		    if (ng == nextrcline) {			putchar('\n') FLUSH;			retry = TRUE;		    } else if (toread[ng] > TR_NONE)			retry = TRUE;		    ng++;		    break;		case 'N':		/* goto next newsgroup */		    special = TRUE;	/* and don't skip it if toread==0 */		    ng++;		    break;		case '1':		/* goto 1st newsgroup */		    ng = 0;		    special = TRUE;	/* and don't skip it if toread==0 */		    break;		case '$':		    ng = nextrcline;	/* goto last newsgroup */		    retry = TRUE;		    break;		case 'L':		    list_newsgroups();		    goto reask_newsgroup;		case '/': case '?':	/* scan for newsgroup pattern */#ifdef NGSEARCH		    switch (ng_search(buf,TRUE)) {		    case NGS_ERROR:			goto reask_newsgroup;		    case NGS_ABORT:			goto reinp_newsgroup;		    case NGS_INTR:#ifdef VERBOSE			IF(verbose)			    fputs("\n(Interrupted)\n",stdout) FLUSH;			ELSE#endif#ifdef TERSE			    fputs("\n(Intr)\n",stdout) FLUSH;#endif			ng = current_ng;

⌨️ 快捷键说明

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