long int Timer :: m_span(long int start) const { long int span = m_time() - start; if ( span < 0 ) span += 0x100000 * 1000; return span; }
void Timer :: start() { if (!m_running) { m_start_time = m_time(); m_running = 1; } }
static int collect_article(register group_header * gh, article_number art_num) { FILE *art_file; news_header_buffer nhbuf, dgbuf; article_header art_hdr; int mode, count; cross_post_number *cp_ptr; long age; count = 0; db_hdr.dh_number = art_num; /* get article header */ art_hdr.a_number = art_num; art_hdr.hpos = 0; art_hdr.lpos = (off_t) 0; art_hdr.flag = 0; mode = FILL_NEWS_HEADER | FILL_OFFSETS | SKIP_HEADER; if ((gh->master_flag & (M_CONTROL | M_NEVER_DIGEST | M_ALWAYS_DIGEST)) == 0) mode |= DIGEST_CHECK; #ifdef NNTP if ((gh->master_flag & M_ALWAYS_DIGEST) == 0) mode |= LAZY_BODY; #endif if ((art_file = open_news_article(&art_hdr, mode, nhbuf, (char *) NULL)) == NULL) { #ifdef NNTP if (nntp_failed) { /* * connection to nntp_server is broken stop collection of * articles immediately */ return -1; } #endif /* * it is not really necessary to save anything in the data file we * simply use the index file to get the *first* available article */ return 0; } if (art_file == (FILE *) 1) { /* empty file */ if (!ignore_bad_articles) return 0; news.ng_groups = NULL; art_file = NULL; } else if (max_article_age && /* == 0 if use_nntp */ (gh->master_flag & M_INCLUDE_OLD) == 0 && (age = m_time(art_file)) < max_article_age) { if (remove_bad_articles) unlink(group_path_name); log_entry('O', "%sold article (%ld days): %s/%ld", remove_bad_articles ? "removed " : "", (cur_time() - age) / (24 * 60 * 60), current_group->group_name, (long) art_num); bad_count++; fclose(art_file); return 0; } if (ignore_bad_articles && news.ng_groups == NULL) { char *rem = ""; if (!use_nntp && remove_bad_articles) { unlink(group_path_name); rem = "removed "; } log_entry('B', "%sbad article: %s/%ld", rem, current_group->group_name, (long) art_num); if (art_file != NULL) fclose(art_file); bad_count++; return 0; } /* map cross-postings into a list of group numbers */ db_hdr.dh_cross_postings = 0; if (gh->master_flag & M_CONTROL) { /* we cannot trust the Newsgroups: line in the control group */ /* so we simply ignore it (i.e. use "Newsgroups: control") */ goto dont_digest; } if (news.ng_groups) { char *curg, *nextg; group_header *gh1; for (nextg = news.ng_groups, cp_ptr = db_data.dh_cross; *nextg;) { curg = nextg; if ((nextg = strchr(curg, ','))) *nextg++ = NUL; else nextg = ""; if (strcmp(gh->group_name, curg) == 0) gh1 = gh; else if ((gh1 = lookup(curg)) == NULL) continue; *cp_ptr++ = NETW_CROSS_EXT(gh1->group_num); if (++db_hdr.dh_cross_postings == DBUF_SIZE) break; } } if (db_hdr.dh_cross_postings == 1) db_hdr.dh_cross_postings = 0; /* only current group */ if (gh->master_flag & M_NEVER_DIGEST) goto dont_digest; /* split digest */ if ((gh->master_flag & M_ALWAYS_DIGEST) || (news.ng_flag & N_DIGEST)) { int any = 0, cont = 1; skip_digest_body(art_file); while (cont && (cont = get_digest_article(art_file, dgbuf)) >= 0) { if (any == 0) { build_hdr(DH_DIGEST_HEADER); /* write DIGEST_HEADER */ count++; db_hdr.dh_cross_postings = 0; /* no cross post in sub */ any++; } build_hdr(DH_SUB_DIGEST); /* write SUB_DIGEST */ count++; } if (any) goto finish; } /* not a digest */ dont_digest: build_hdr(DH_NORMAL); /* normal article */ count++; finish: if (gh->master_flag & M_AUTO_ARCHIVE) { #ifdef NNTP FILE *f; f = nntp_get_article(art_num, 0); do_auto_archive(gh, f, art_num); fclose(f); #else do_auto_archive(gh, art_file, art_num); #endif /* NNTP */ } fclose(art_file); return count; }