home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume22 / nn6.4 / part20 / active.c next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.5 KB  |  112 lines

  1. /*
  2.  *    (c) Copyright 1990, Kim Fabricius Storm.  All rights reserved.
  3.  *
  4.  *    read/update incore copy of active file
  5.  */
  6.  
  7. #include "config.h"
  8.  
  9. read_active_file(act, copy)
  10. FILE *act, *copy;
  11. {
  12.     char line[512];
  13.     register char *cp, *name;
  14.     register group_header *gh, *gh1;
  15.     group_header *add_new_group(), *lookup_no_alias();
  16.     int must_update;
  17.     register flag_type old_flag;
  18.     
  19.     Loop_Groups_Header(gh)
  20.     gh->master_flag &= ~M_VALID;
  21.  
  22.     while (fgets(line, 512, act)) {
  23.     if (copy != NULL) fputs(line, copy);
  24.     must_update = 0;
  25.  
  26.     cp = line;
  27.     while (*cp && isspace(*cp)) cp++; /* eat blank lines */
  28.     if (*cp == NUL || *cp == '#') continue;
  29.  
  30.     /* cp -> NAME space 00888 ... nl */
  31.     name = cp;
  32.     while (*cp != ' ') cp++;
  33.     *cp++ = NUL;
  34.  
  35.     gh = lookup_no_alias(name);
  36.     if (gh == NULL) {
  37.         /* new group */
  38.         gh = add_new_group(name);
  39.         if (gh == NULL) continue;
  40.         must_update = 1;
  41.     }
  42.     
  43.     while (*cp && isspace(*cp)) cp++;
  44.     gh->last_a_article = atol(cp);
  45.  
  46.     while (*cp && isdigit(*cp)) cp++;
  47.     while (*cp && isspace(*cp)) cp++;
  48.  
  49.     if (*cp == NUL) {
  50.         log_entry('E', "Error in active file for entry %s", name);
  51.         continue;
  52.     }
  53.  
  54.     gh->first_a_article = atol(cp);
  55.     if (gh->first_a_article == 0) gh->first_a_article = 1;
  56.     while (*cp && isdigit(*cp)) cp++;
  57.     while (*cp && isspace(*cp)) cp++;
  58.  
  59.     gh->master_flag |= M_VALID;
  60.     if (gh->master_flag & M_IGNORE_G) continue;
  61.  
  62.     old_flag = gh->master_flag & 
  63.         (M_IGNORE_A | M_MODERATED | M_NOPOST | M_ALIASED);
  64.     gh->master_flag &= 
  65.         ~(M_IGNORE_A | M_MODERATED | M_NOPOST | M_ALIASED);
  66.     
  67.     switch (*cp) {
  68.      default:
  69.         break;
  70.  
  71.      case 'x':
  72.         gh->master_flag |= M_IGNORE_A;
  73.         if ((old_flag & (M_IGNORE_A|M_ALIASED)) == M_IGNORE_A) continue;
  74.         must_update++;
  75.         break;
  76.  
  77.      case 'm':
  78.         gh->master_flag |= M_MODERATED;
  79.         if (old_flag & M_MODERATED) continue;
  80.         must_update++;
  81.         break;
  82.  
  83.      case 'n':
  84.         gh->master_flag |= M_NOPOST;
  85.         if (old_flag & M_NOPOST) continue;
  86.         must_update++;
  87.         break;
  88.  
  89.      case '=':
  90.         gh->master_flag |= M_ALIASED | M_IGNORE_A;
  91.         if (old_flag & M_ALIASED) continue;
  92.         while (*++cp && isspace(*cp)) cp++;
  93.         name = cp;
  94.         while (*cp && !isspace(*cp)) cp++;
  95.         *cp = NUL;
  96.         gh1 = lookup(name);
  97.         gh->data_write_offset = (off_t)gh1->group_num;
  98.         must_update = 1;
  99.         break;
  100.     }
  101.  
  102.     if ((old_flag & M_ALIASED) && (gh->master_flag & M_ALIASED) == 0) {
  103.         gh->data_write_offset = 0;
  104.         gh->master_flag |= M_MUST_CLEAN;
  105.         continue;
  106.     }
  107.         
  108.     if (must_update && who_am_i == I_AM_MASTER)
  109.         db_write_group(gh);
  110.     }
  111. }
  112.