1 /* datasrc.h
2  */
3 /* This software is copyrighted as detailed in the LICENSE file. */
4 
5 
6 struct srcfile {
7     FILE*	fp;		/* the file pointer to read the data */
8     HASHTABLE*	hp;		/* the hash table for the data */
9     LIST*	lp;		/* the list used to store the data */
10     long	recent_cnt;	/* # lines/bytes this file might be */
11 #ifdef SUPPORT_NNTP
12     time_t	lastfetch;	/* when the data was last fetched */
13     time_t	refetch_secs;	/* how long before we refetch this file */
14 #endif
15 };
16 
17 struct datasrc {
18     char*	name;		/* our user-friendly name */
19     char*	newsid;		/* the active file name or host name */
20     SRCFILE	act_sf;		/* the active file's hashed contents */
21     char*	grpdesc;	/* the newsgroup description file or tmp */
22     SRCFILE	desc_sf;	/* the group description's hashed contents */
23     char*	extra_name;	/* local active.times or server's actfile */
24 #ifdef SUPPORT_NNTP
25     NNTPLINK	nntplink;
26 #endif
27     char*	spool_dir;
28     char*	over_dir;
29     char*	over_fmt;
30     char*	thread_dir;
31     char*	auth_user;
32     char*	auth_pass;
33 #ifdef USE_GENAUTH
34     char*	auth_command;
35 #endif
36     long	lastnewgrp;	/* time of last newgroup check */
37     FILE*	ov_in;		/* the overview's file handle */
38     time_t	ov_opened;	/* time overview file was opened */
39     Uchar	fieldnum[OV_MAX_FIELDS];
40     Uchar	fieldflags[OV_MAX_FIELDS];
41     int		flags;
42 };
43 
44 #define DF_TRY_OVERVIEW	0x0001
45 #define DF_TRY_THREAD	0x0002
46 #define DF_ADD_OK	0x0004
47 #define DF_DEFAULT	0x0008
48 
49 #define DF_OPEN 	0x0010
50 #define DF_ACTIVE 	0x0020
51 #define DF_UNAVAILABLE 	0x0040
52 #ifdef SUPPORT_NNTP
53 #define DF_REMOTE	0x0080
54 #define DF_TMPACTFILE	0x0100
55 #define DF_TMPGRPDESC	0x0200
56 #define DF_USELISTACT	0x0400
57 #define DF_XHDR_BROKEN	0x0800
58 #define DF_NOXGTITLE	0x1000
59 #define DF_NOLISTGROUP	0x2000
60 #define DF_NOXREFS	0x4000
61 #endif
62 
63 #define FF_HAS_FIELD	0x01
64 #define FF_CHECK4FIELD	0x02
65 #define FF_HAS_HDR	0x04
66 #define FF_CHECK4HDR	0x08
67 #define FF_FILTERSEND	0x10
68 
69 #define DATASRC_NNTP_FLAGS(dp) (((dp) == datasrc? nntplink.flags : (dp)->nntplink.flags))
70 
71 EXT LIST* datasrc_list;		/* a list of all DATASRCs */
72 EXT DATASRC* datasrc;		/* the current datasrc */
73 EXT int datasrc_cnt INIT(0);
74 
75 #define datasrc_ptr(n)  ((DATASRC*)listnum2listitem(datasrc_list,(long)(n)))
76 #define datasrc_first() ((DATASRC*)listnum2listitem(datasrc_list,0L))
77 #define datasrc_next(p) ((DATASRC*)next_listitem(datasrc_list,(char*)(p)))
78 
79 #define LENGTH_HACK 5	/* Don't bother comparing strings with lengths
80 			 * that differ by more than this. */
81 #define MAX_NG 9	/* Maximum number of groups to offer. */
82 
83 #define DATASRC_ALARM_SECS   (5 * 60)
84 
85 EXT char* trnaccess_mem INIT(NULL);
86 
87 #ifdef SUPPORT_NNTP
88 EXT char* nntp_auth_file;
89 #endif
90 
91 /* DON'T EDIT BELOW THIS LINE OR YOUR CHANGES WILL BE LOST! */
92 
93 void datasrc_init _((void));
94 char* read_datasrcs _((char*));
95 DATASRC* get_datasrc _((char*));
96 DATASRC* new_datasrc _((char*,char**));
97 bool open_datasrc _((DATASRC*));
98 void set_datasrc _((DATASRC*));
99 void check_datasrcs _((void));
100 void close_datasrc _((DATASRC*));
101 bool actfile_hash _((DATASRC*));
102 bool find_actgrp _((DATASRC*,char*,char*,int,ART_NUM));
103 char* find_grpdesc _((DATASRC*,char*));
104 int srcfile_open _((SRCFILE*,char*,char*,char*));
105 #ifdef SUPPORT_NNTP
106 char* srcfile_append _((SRCFILE*,char*,int));
107 void srcfile_end_append _((SRCFILE*,char*));
108 #endif
109 void srcfile_close _((SRCFILE*));
110 int find_close_match _((void));
111