1: /*
   2:  * Hacked for rrn
   3:  */
   4: 
   5: /* $Header: addng.c,v 4.3.1.2 85/05/29 09:06:24 lwall Exp $
   6:  *
   7:  * $Log:	addng.c,v $
   8:  * Revision 4.3.1.2  85/05/29  09:06:24  lwall
   9:  * New newsgroups without spool directories incorrectly classified as "ancient".
  10:  *
  11:  * Revision 4.3.1.1  85/05/10  11:30:50  lwall
  12:  * Branch for patches.
  13:  *
  14:  * Revision 4.3  85/05/01  11:34:41  lwall
  15:  * Baseline for release with 4.3bsd.
  16:  *
  17:  */
  18: 
  19: #include "EXTERN.h"
  20: #include "common.h"
  21: #include "rn.h"
  22: #include "ngdata.h"
  23: #include "last.h"
  24: #include "util.h"
  25: #include "intrp.h"
  26: #include "only.h"
  27: #include "rcstuff.h"
  28: #include "INTERN.h"
  29: #include "addng.h"
  30: 
  31: void
  32: addng_init()
  33: {
  34:     ;
  35: }
  36: 
  37: #ifdef FINDNEWNG
  38: /* generate a list of new newsgroups from active file */
  39: 
  40: bool
  41: newlist(munged,checkinlist)
  42: bool munged;            /* are we scanning the whole file? */
  43: bool checkinlist;
  44: {
  45:     char *tmpname;
  46:     register char *s, *status;
  47:     register NG_NUM ngnum;
  48: #ifndef ACTIVE_TIMES
  49:     long birthof();
  50: #endif
  51:     extern char int_count;
  52: 
  53:     tmpname = filexp("/tmp/rnew.%$");
  54:     tmpfp = fopen(tmpname,"w+");
  55:     if (tmpfp == Nullfp) {
  56:     printf(cantcreate,tmpname) FLUSH;
  57:     return FALSE;
  58:     }
  59:     UNLINK(tmpname);            /* be nice to the world */
  60: 
  61:     while (fgets(buf,LBUFLEN,actfp) != Nullch) {
  62:     /* Check if they want to break out of the new newsgroups search */
  63:     if (int_count) {
  64:         int_count = 0;
  65:         fclose(tmpfp);
  66:         return FALSE;
  67:     }
  68:     if (s = index(buf,' ')) {
  69:         status=s;
  70:         while (isdigit(*status) || isspace(*status)) status++;
  71:         *s++ = '\0';
  72:         if (strnEQ(buf,"to.",3) || *status == 'x' || *status == '=')
  73:             /* since = groups are refiling to another group, just
  74: 		   ignore their existence */
  75:         continue;
  76: #ifdef ACTIVE_TIMES
  77:         if (inlist(buf) && ((ngnum = find_ng(buf)) == nextrcline
  78:                 || toread[ngnum] == TR_UNSUB)
  79: #else
  80:         if (checkinlist ?
  81:         (inlist(buf) && ((ngnum = find_ng(buf)) == nextrcline
  82:                  || toread[ngnum] == TR_UNSUB))
  83:           : (find_ng(buf) == nextrcline
  84:          && birthof(buf,(ART_NUM)atol(s)) > lasttime)
  85: #endif
  86:         ) {
  87:                     /* if not in .newsrc and younger */
  88:                     /* than the last time we checked */
  89:         fprintf(tmpfp,"%s\n",buf);
  90:                     /* then remember said newsgroup */
  91:         }
  92: #ifdef FASTNEW
  93:         else {          /* not really a new group */
  94:         if (!munged) {      /* did we assume not munged? */
  95:             fclose(tmpfp);  /* then go back, knowing that */
  96:             return TRUE;    /* active file was indeed munged */
  97:         }
  98:         }
  99: #endif
 100:     }
 101: #ifdef DEBUGGING
 102:     else
 103:         printf("Bad active record: %s\n",buf) FLUSH;
 104: #endif
 105:     }
 106: 
 107:     /* we have successfully generated the list */
 108: 
 109:     fseek(tmpfp,0L,0);          /* rewind back to the beginning */
 110:     while (fgets(buf,LBUFLEN,tmpfp) != Nullch) {
 111:     buf[strlen(buf)-1] = '\0';
 112:     get_ng(buf,TRUE);       /* add newsgroup, maybe */
 113:     }
 114:     fclose(tmpfp);          /* be nice to ourselves */
 115:     return FALSE;           /* do not call us again */
 116: }
 117: 
 118: /* return creation time of newsgroup */
 119: 
 120: long
 121: birthof(ngnam,ngsize)
 122: char *ngnam;
 123: ART_NUM ngsize;
 124: {
 125:     char tst[128];
 126:     long time();
 127: 
 128: #ifdef SERVER
 129: 
 130:     return (ngsize < 2 ? time(0) : 0);
 131: 
 132: #else not SERVER
 133: 
 134:     sprintf(tst, ngsize ? "%s/%s/1" : "%s/%s" ,spool,getngdir(ngnam));
 135:     if (stat(tst,&filestat) < 0)
 136:     return (ngsize ? 0L : time(Null(long *)));
 137:     /* not there, assume something good */
 138:     else
 139:     return filestat.st_mtime;
 140: 
 141: #endif
 142: }
 143: 
 144: bool
 145: scanactive()
 146: {
 147:     NG_NUM oldnext = nextrcline;    /* remember # lines in newsrc */
 148: 
 149:     fseek(actfp,0L,0);
 150:     newlist(TRUE,TRUE);
 151:     if (nextrcline != oldnext) {    /* did we add any new groups? */
 152:     return TRUE;
 153:     }
 154:     return FALSE;
 155: }
 156: 
 157: #endif

Defined functions

addng_init defined in line 31; used 2 times
birthof defined in line 120; used 3 times
newlist defined in line 40; used 4 times
scanactive defined in line 144; used 3 times

Defined variables

bool defined in line 40; never used
Last modified: 1992-08-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 827
Valid CSS Valid XHTML 1.0 Strict