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

Defined functions

addng_init defined in line 27; used 2 times
birthof defined in line 104; used 3 times
newlist defined in line 36; used 4 times
scanactive defined in line 119; used 3 times

Defined variables

bool defined in line 36; never used
Last modified: 1985-06-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 725
Valid CSS Valid XHTML 1.0 Strict