Annotation of 43BSD/contrib/rn/inews.c.2.pat, revision 1.1.1.1

1.1       root        1: *** inews.old.c        Tue Apr 30 14:34:19 1985
                      2: --- inews.c    Tue Apr 30 14:34:33 1985
                      3: ***************
                      4: *** 416,421
                      5:   /*
                      6:    *   Link ARTICLE into dir for ngname and update active file.
                      7:    */
                      8:   localize(ngname)
                      9:   char *ngname;
                     10:   {
                     11: 
                     12: --- 416,424 -----
                     13:   /*
                     14:    *   Link ARTICLE into dir for ngname and update active file.
                     15:    */
                     16: + #ifdef DOXREFS
                     17: + long
                     18: + #endif
                     19:   localize(ngname)
                     20:   char *ngname;
                     21:   {
                     22: ***************
                     23: *** 453,458
                     24:                        mknewsg(cp, ngname);
                     25:   
                     26:                sprintf(bfr, "%s/%ld", cp, ngsize+1);
                     27:   #ifdef VMS
                     28:                if ((f2 = creat(bfr, 0666)) >=0 ) {
                     29:                        f1 = open(article, 0);
                     30: 
                     31: --- 456,466 -----
                     32:                        mknewsg(cp, ngname);
                     33:   
                     34:                sprintf(bfr, "%s/%ld", cp, ngsize+1);
                     35: + #ifdef LINKART
                     36: +              if (mylink(ARTICLE, bfr) == 0) break;
                     37: +                              /* on first file inits ARTICLE, on subsequent */
                     38: +                              /* files "links" to first article */
                     39: + #else !LINKART
                     40:   #ifdef VMS
                     41:                if ((f2 = creat(bfr, 0666)) >=0 ) {
                     42:                        f1 = open(article, 0);
                     43: ***************
                     44: *** 468,473
                     45:                if (link(ARTICLE, bfr) == 0)
                     46:                        break;
                     47:   #endif !VMS
                     48:                e = errno;      /* keep log from clobbering it */
                     49:                logerr("Cannot install article as %s", bfr);
                     50:                if (e != EEXIST) {
                     51: 
                     52: --- 476,482 -----
                     53:                if (link(ARTICLE, bfr) == 0)
                     54:                        break;
                     55:   #endif !VMS
                     56: + #endif !LINKART
                     57:                e = errno;      /* keep log from clobbering it */
                     58:                logerr("Cannot install article as %s", bfr);
                     59:                if (e != EEXIST) {
                     60: ***************
                     61: *** 494,499
                     62:                strcpy(firstbufname, bfr);
                     63:        sprintf(bfr, "%s/%ld ", ngname, ngsize+1);
                     64:        addhist(bfr);
                     65:        return TRUE;
                     66:   }
                     67:   
                     68: 
                     69: --- 503,509 -----
                     70:                strcpy(firstbufname, bfr);
                     71:        sprintf(bfr, "%s/%ld ", ngname, ngsize+1);
                     72:        addhist(bfr);
                     73: + #ifndef DOXREFS
                     74:        return TRUE;
                     75:   #else DOXREFS
                     76:        return ngsize+1;
                     77: ***************
                     78: *** 495,500
                     79:        sprintf(bfr, "%s/%ld ", ngname, ngsize+1);
                     80:        addhist(bfr);
                     81:        return TRUE;
                     82:   }
                     83:   
                     84:   /*
                     85: 
                     86: --- 505,513 -----
                     87:        addhist(bfr);
                     88:   #ifndef DOXREFS
                     89:        return TRUE;
                     90: + #else DOXREFS
                     91: +      return ngsize+1;
                     92: + #endif DOXREFS
                     93:   }
                     94:   
                     95:   /*
                     96: ***************
                     97: *** 507,512
                     98:        char c;
                     99:        struct srec srec;       /* struct for sys file lookup   */
                    100:        int is_invalid = FALSE;
                    101:   
                    102:        /* Fill up the rest of header. */
                    103:        if (mode != PROC) {
                    104: 
                    105: --- 520,529 -----
                    106:        char c;
                    107:        struct srec srec;       /* struct for sys file lookup   */
                    108:        int is_invalid = FALSE;
                    109: + #ifdef DOXREFS
                    110: +      register char *nextxref = header.xref; 
                    111: +      int numxrefs = 0;
                    112: + #endif DOXREFS
                    113:   
                    114:        /* Fill up the rest of header. */
                    115:        if (mode != PROC) {
                    116: ***************
                    117: *** 527,532
                    118:        if (!is_ctl && mode != CREATENG)
                    119:                is_invalid = ngfcheck(mode == PROC);
                    120:   
                    121:        /* Write article to temp file. */
                    122:        tfp = xfopen(mktemp(ARTICLE), "w");
                    123:        if ( (c=getc(infp)) == ' ' || c == '\t' ) {
                    124: 
                    125: --- 544,556 -----
                    126:        if (!is_ctl && mode != CREATENG)
                    127:                is_invalid = ngfcheck(mode == PROC);
                    128:   
                    129: + #ifdef LINKART
                    130: +      *ARTICLE = '\0';        /* tell mylink() to snarf the name */
                    131: + #else !LINKART
                    132: + #ifdef DOXREFS
                    133: +      /* Open temp file for article, but link before writing */
                    134: +      tfp = xfopen(mktemp(ARTICLE), "w");
                    135: + #else DOXREFS
                    136:        /* Write article to temp file. */
                    137:        tfp = xfopen(mktemp(ARTICLE), "w");
                    138:        if ( (c=getc(infp)) == ' ' || c == '\t' ) {
                    139: ***************
                    140: *** 545,550
                    141:                putc('\n',tfp);
                    142:        fclose(tfp);
                    143:        fclose(infp);
                    144:   
                    145:        if (is_invalid) {
                    146:                logerr("No valid newsgroups found, moved to junk");
                    147: 
                    148: --- 569,576 -----
                    149:                putc('\n',tfp);
                    150:        fclose(tfp);
                    151:        fclose(infp);
                    152: + #endif DOXREFS
                    153: + #endif LINKART
                    154:   
                    155:        if (is_invalid) {
                    156:                logerr("No valid newsgroups found, moved to junk");
                    157: ***************
                    158: *** 550,555
                    159:                logerr("No valid newsgroups found, moved to junk");
                    160:                if (localize("junk"))
                    161:                        savehist(histline);
                    162:                xxit(1);
                    163:        }
                    164:   
                    165: 
                    166: --- 576,582 -----
                    167:                logerr("No valid newsgroups found, moved to junk");
                    168:                if (localize("junk"))
                    169:                        savehist(histline);
                    170: + #ifndef DOXREFS
                    171:                xxit(1);
                    172:   #endif
                    173:        }
                    174: ***************
                    175: *** 551,556
                    176:                if (localize("junk"))
                    177:                        savehist(histline);
                    178:                xxit(1);
                    179:        }
                    180:   
                    181:        if (time((time_t)0) > (cgtdate(header.subdate) + DFLTEXP) ){
                    182: 
                    183: --- 578,584 -----
                    184:                        savehist(histline);
                    185:   #ifndef DOXREFS
                    186:                xxit(1);
                    187: + #endif
                    188:        }
                    189:   #ifdef DOXREFS
                    190:        else
                    191: ***************
                    192: *** 552,558
                    193:                        savehist(histline);
                    194:                xxit(1);
                    195:        }
                    196: ! 
                    197:        if (time((time_t)0) > (cgtdate(header.subdate) + DFLTEXP) ){
                    198:                logerr("Article too old, moved to junk");
                    199:                if (localize("junk"))
                    200: 
                    201: --- 580,588 -----
                    202:                xxit(1);
                    203:   #endif
                    204:        }
                    205: ! #ifdef DOXREFS
                    206: !      else
                    207: ! #endif
                    208:        if (time((time_t)0) > (cgtdate(header.subdate) + DFLTEXP) ){
                    209:                logerr("Article too old, moved to junk");
                    210:                if (localize("junk"))
                    211: ***************
                    212: *** 557,562
                    213:                logerr("Article too old, moved to junk");
                    214:                if (localize("junk"))
                    215:                        savehist(histline);
                    216:                xxit(1);
                    217:        }
                    218:   
                    219: 
                    220: --- 587,593 -----
                    221:                logerr("Article too old, moved to junk");
                    222:                if (localize("junk"))
                    223:                        savehist(histline);
                    224: + #ifndef DOXREFS
                    225:                xxit(1);
                    226:   #endif
                    227:        }
                    228: ***************
                    229: *** 558,563
                    230:                if (localize("junk"))
                    231:                        savehist(histline);
                    232:                xxit(1);
                    233:        }
                    234:   
                    235:        if (is_ctl) {
                    236: 
                    237: --- 589,595 -----
                    238:                        savehist(histline);
                    239:   #ifndef DOXREFS
                    240:                xxit(1);
                    241: + #endif
                    242:        }
                    243:   #ifdef DOXREFS
                    244:        else
                    245: ***************
                    246: *** 559,565
                    247:                        savehist(histline);
                    248:                xxit(1);
                    249:        }
                    250: ! 
                    251:        if (is_ctl) {
                    252:                control(&header);
                    253:                localize("control");
                    254: 
                    255: --- 591,599 -----
                    256:                xxit(1);
                    257:   #endif
                    258:        }
                    259: ! #ifdef DOXREFS
                    260: !      else
                    261: ! #endif
                    262:        if (is_ctl) {
                    263:   #ifndef DOXREFS
                    264:                control(&header);
                    265: ***************
                    266: *** 561,566
                    267:        }
                    268:   
                    269:        if (is_ctl) {
                    270:                control(&header);
                    271:                localize("control");
                    272:        } else {
                    273: 
                    274: --- 595,601 -----
                    275:        else
                    276:   #endif
                    277:        if (is_ctl) {
                    278: + #ifndef DOXREFS
                    279:                control(&header);
                    280:   #endif
                    281:                localize("control");
                    282: ***************
                    283: *** 562,567
                    284:   
                    285:        if (is_ctl) {
                    286:                control(&header);
                    287:                localize("control");
                    288:        } else {
                    289:                if (s_find(&srec, FULLSYSNAME) == FALSE)
                    290: 
                    291: --- 597,603 -----
                    292:        if (is_ctl) {
                    293:   #ifndef DOXREFS
                    294:                control(&header);
                    295: + #endif
                    296:                localize("control");
                    297:        } else {
                    298:                if (s_find(&srec, FULLSYSNAME) == FALSE)
                    299: ***************
                    300: *** 566,571
                    301:        } else {
                    302:                if (s_find(&srec, FULLSYSNAME) == FALSE)
                    303:                        xerror("Cannot find my name '%s' in %s", FULLSYSNAME, SUBFILE);
                    304:                for (ptr = nbuf; *ptr;) {
                    305:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    306:                                localize(ptr);
                    307: 
                    308: --- 602,611 -----
                    309:        } else {
                    310:                if (s_find(&srec, FULLSYSNAME) == FALSE)
                    311:                        xerror("Cannot find my name '%s' in %s", FULLSYSNAME, SUBFILE);
                    312: + #ifdef DOXREFS
                    313: +              sprintf(nextxref,"%s ",FULLSYSNAME);
                    314: +              nextxref += strlen(nextxref);
                    315: + #endif
                    316:                for (ptr = nbuf; *ptr;) {
                    317:   #ifndef DOXREFS
                    318:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    319: ***************
                    320: *** 567,572
                    321:                if (s_find(&srec, FULLSYSNAME) == FALSE)
                    322:                        xerror("Cannot find my name '%s' in %s", FULLSYSNAME, SUBFILE);
                    323:                for (ptr = nbuf; *ptr;) {
                    324:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    325:                                localize(ptr);
                    326:                        while (*ptr++)
                    327: 
                    328: --- 607,613 -----
                    329:                nextxref += strlen(nextxref);
                    330:   #endif
                    331:                for (ptr = nbuf; *ptr;) {
                    332: + #ifndef DOXREFS
                    333:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    334:                                localize(ptr);
                    335:   #else DOXREFS
                    336: ***************
                    337: *** 569,574
                    338:                for (ptr = nbuf; *ptr;) {
                    339:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    340:                                localize(ptr);
                    341:                        while (*ptr++)
                    342:                                ;
                    343:                }
                    344: 
                    345: --- 610,624 -----
                    346:   #ifndef DOXREFS
                    347:                        if (ngmatch(ptr, srec.s_nbuf) || index(ptr,'.') == NULL)
                    348:                                localize(ptr);
                    349: + #else DOXREFS
                    350: +                      if (ngmatch(ptr, srec.s_nbuf) ||
                    351: +                          index(ptr,'.') == NULL) {
                    352: +                              sprintf(nextxref,"%s:%ld ",ptr,localize(ptr));
                    353: +                              numxrefs++;
                    354: +                              while (*nextxref)
                    355: +                                     nextxref++;
                    356: +                      }
                    357: + #endif DOXREFS
                    358:                        while (*ptr++)
                    359:                                ;
                    360:                }
                    361: ***************
                    362: *** 577,582
                    363:                        localize("junk");
                    364:                }
                    365:        }
                    366:   
                    367:        broadcast();
                    368:        savehist(histline);
                    369: 
                    370: --- 627,638 -----
                    371:                        localize("junk");
                    372:                }
                    373:        }
                    374: + #ifdef DOXREFS
                    375: +      if (numxrefs >= 2)
                    376: +          *(nextxref-1) = '\0';       /* wipe out the last space */
                    377: +      else
                    378: +          header.xref[0] = '\0';      /* wipe out the whole thing */
                    379: + #endif
                    380:   
                    381:   #ifdef LINKART
                    382:        tfp = xfopen(ARTICLE,"w");      /* open 1st article localized */
                    383: ***************
                    384: *** 578,583
                    385:                }
                    386:        }
                    387:   
                    388:        broadcast();
                    389:        savehist(histline);
                    390:        xxit(0);
                    391: 
                    392: --- 634,669 -----
                    393:            header.xref[0] = '\0';      /* wipe out the whole thing */
                    394:   #endif
                    395:   
                    396: + #ifdef LINKART
                    397: +      tfp = xfopen(ARTICLE,"w");      /* open 1st article localized */
                    398: + #endif
                    399: + 
                    400: + #if defined(LINKART) || defined(DOXREFS)
                    401: +      /* Now that xref is constructed, write article to temp file. */
                    402: +      /* (We ought to detect no room at this point and clean up.) */ 
                    403: +      if ( (c=getc(infp)) == ' ' || c == '\t' ) {
                    404: +              header.intnumlines++;
                    405: +              sprintf(header.numlines,"%d",header.intnumlines);
                    406: +      }
                    407: +      lhwrite(&header, tfp);
                    408: +      /* Kludge to get around article truncation problem */
                    409: +      if (c == ' ' || c == '\t' )
                    410: +              putc('\n', tfp);
                    411: +      putc(c,tfp);
                    412: +      while (fgets(bfr, BUFLEN, infp) != NULL)
                    413: +              fputs(bfr, tfp);
                    414: + 
                    415: +      if (bfr[strlen(bfr)-1] != '\n')
                    416: +              putc('\n',tfp);
                    417: +      fclose(tfp);
                    418: +      fclose(infp);
                    419: + #endif LINKART || DOXREFS
                    420: + 
                    421: + #ifdef DOXREFS
                    422: +      if (is_ctl)     /* moved here cuz checkgroups uses ARTICLE! */
                    423: +              control(&header);
                    424: + #endif
                    425: + 
                    426:        broadcast();
                    427:        savehist(histline);
                    428:        xxit(0);
                    429: ***************
                    430: *** 853,855
                    431:        }
                    432:        return(NULL);
                    433:   }
                    434: 
                    435: --- 939,963 -----
                    436:        }
                    437:        return(NULL);
                    438:   }
                    439: + 
                    440: + #ifdef LINKART
                    441: + mylink(tmpart,linkfrom)
                    442: + char *tmpart, *linkfrom;
                    443: + {
                    444: +     struct stat statbuf;
                    445: + 
                    446: +     if (stat(linkfrom,&statbuf)==0)
                    447: +      return -1;
                    448: +     if (!*tmpart)                       /* first article? */
                    449: +      strcpy(tmpart,linkfrom);        /* just remember name */
                    450: +     else {
                    451: +      FILE *linkfp = fopen(linkfrom,"w");
                    452: + 
                    453: +      if (!linkfp)
                    454: +          return -1;
                    455: +      fprintf(linkfp,"%s\n",tmpart);  /* do "symbolic link" */
                    456: +      fclose(linkfp);
                    457: +     }
                    458: +     return 0;
                    459: + }
                    460: + #endif LINKART

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.