static char *sccsid
= "@(#)active.c 1.2 (Berkeley) 3/20/86";
* Routines to deal with the active file
* read_groups -- read the active file into memory, sort it,
* and return the number of newsgroups read in.
* If FASTFORK is true, this can be called by interrupt,
* and may have to free up the old storage. We decide
* this by the fact that "num_groups" will be non-zero if
* we're here on an interrupt.
* Returns: Number of newsgroups read into
* Side effects: Reads newsgroups into "group_array"
/* If we're here on an interrupt, free up all the */
for (i
= 0; i
< num_groups
; ++i
)
act_fp
= fopen(ACTIVE_FILE
, "r");
while (i
< MAX_GROUPS
&& fgets(line
, sizeof(line
), act_fp
) != NULL
) {
if ((group_array
[i
] = malloc(strlen(line
)+1)) == NULL
) {
(void) strcpy(group_array
[i
++], line
);
syslog(LOG_ERR
, "read_active: active file >= %d groups", i
);
syslog(LOG_ERR
, "warning: recompile with MAX_GROUPS larger");
qsort((char *) group_array
, i
, sizeof(char *), act_cmp
);
return(strcmp(*ptr1
, *ptr2
));
* find_group -- find a given newsgroup and return
* the low and high message numbers in the group
* (space provided by user).
* Parameters: "group" is the name of the group
* "num_groups" is the total number
* of groups in the group array.
* "low_msg" and "high_msg" are
* pointers to where we're supposed
* to put the low and high message numbers.
* Returns: 0 if all goes well,
* -1 if we can't find the group.
find_group(group
, num_groups
, low_msg
, high_msg
)
char kludgebuf
[MAX_STRLEN
];
(void) strcpy(kludgebuf
, group
);
(void) strcat(kludgebuf
, " ");
length
= strlen(kludgebuf
);
if ((cond
= strncmp(kludgebuf
, group_array
[mid
], length
)) < 0)
(void) sscanf(group_array
[mid
], "%s %d %d",
kludgebuf
, high_msg
, low_msg
);