1 /* cache.h
2  */
3 /* This software is copyrighted as detailed in the LICENSE file. */
4 
5 
6 /* Subjects get their own structure */
7 
8 struct subject {
9     SUBJECT* next;
10     SUBJECT* prev;
11     ARTICLE* articles;
12     ARTICLE* thread;
13     SUBJECT* thread_link;
14     char* str;
15     time_t date;
16     short flags;
17     short misc;		/* used for temporary totals and subject numbers */
18 };
19 
20 /* subject flags */
21 
22 #define SF_SEL		0x0001
23 #define SF_DEL		0x0002
24 #define SF_DELSEL	0x0004
25 #define SF_OLDVISIT	0x0008
26 #define SF_INCLUDED	0x0010
27 
28 #define SF_VISIT	0x0200
29 #define SF_WASSELECTED  0x0400
30 #define SF_SUBJTRUNCED	0x1000
31 #define SF_ISOSUBJ	0x2000
32 
33 /* This is our article-caching structure */
34 
35 struct article {
36     ART_NUM num;
37     time_t date;
38     SUBJECT* subj;
39     char* from;
40     char* msgid;
41     char* xrefs;
42 #ifdef USE_FILTER
43     char* refs;
44 #endif
45     ARTICLE* parent;		/* parent article */
46     ARTICLE* child1;		/* first child of a chain */
47     ARTICLE* sibling;		/* our next sibling */
48     ARTICLE* subj_next;		/* next article in subject order */
49     long bytes;
50     long lines;
51 #ifdef SCORE
52     int score;
53     unsigned short scoreflags;
54 #endif
55     unsigned short flags;	/* article state flags */
56     unsigned short flags2;	/* more state flags */
57     unsigned short autofl;	/* auto-processing flags */
58 };
59 
60 /* article flags */
61 
62 #define AF_SEL		0x0001
63 #define AF_DEL		0x0002
64 #define AF_DELSEL	0x0004
65 #define AF_OLDSEL	0x0008
66 #define AF_INCLUDED	0x0010
67 
68 #define AF_UNREAD	0x0020
69 #define AF_CACHED	0x0040
70 #define AF_THREADED	0x0080
71 #define AF_EXISTS	0x0100
72 #define AF_HAS_RE	0x0200
73 #define AF_KCHASE	0x0400
74 #define AF_MCHASE	0x0800
75 #define AF_YANKBACK	0x1000
76 #define AF_FROMTRUNCED	0x2000
77 #define AF_TMPMEM	0x4000
78 #define AF_FAKE 	0x8000
79 
80 #define AF2_WASUNREAD   0x0001
81 #define AF2_NODEDRAWN   0x0002
82 #define AF2_CHANGED     0x0004
83 #define AF2_BOGUS	0x0008
84 
85 /* See kfile.h for the AUTO_* flags */
86 
87 #define article_ptr(an)      ((ARTICLE*)listnum2listitem(article_list,(long)(an)))
88 #define article_num(ap)      ((ap)->num)
89 #define article_find(an)     ((an) <= lastart && article_hasdata(an)? \
90 			      article_ptr(an) : NULL)
91 #define article_walk(cb,ag)  walk_list(article_list,cb,ag)
92 #define article_hasdata(an)  existing_listnum(article_list,(long)(an),0)
93 #define article_first(an)    existing_listnum(article_list,(long)(an),1)
94 #define article_next(an)     existing_listnum(article_list,(long)(an)+1,1)
95 #define article_last(an)     existing_listnum(article_list,(long)(an),-1)
96 #define article_prev(an)     existing_listnum(article_list,(long)(an)-1,-1)
97 #define article_nextp(ap)    ((ARTICLE*)next_listitem(article_list,(char*)(ap)))
98 
99 #define article_exists(an)   (article_ptr(an)->flags & AF_EXISTS)
100 #define article_unread(an)   (article_ptr(an)->flags & AF_UNREAD)
101 
102 #define was_read(an)	    (!article_hasdata(an) || !article_unread(an))
103 #define is_available(an)    ((an) <= lastart && article_hasdata(an) \
104 			  && article_exists(an))
105 #define is_unavailable(an)  (!is_available(an))
106 
107 EXT LIST* article_list INIT(0);		/* a list of ARTICLEs */
108 EXT ARTICLE** artptr_list INIT(0);	/* the article-selector creates this */
109 EXT ARTICLE** artptr;			/* ditto -- used for article order */
110 EXT ART_NUM artptr_list_size INIT(0);
111 
112 #ifdef ARTSEARCH
113 EXT ART_NUM srchahead INIT(0); 	/* are we in subject scan mode? */
114 				/* (if so, contains art # found or -1) */
115 #endif
116 
117 EXT ART_NUM first_cached;
118 EXT ART_NUM last_cached;
119 EXT bool cached_all_in_range;
120 EXT ARTICLE* sentinel_artp;
121 
122 #define DONT_FILL_CACHE	0
123 #define FILL_CACHE	1
124 
125 EXT SUBJECT* first_subject INIT(0);
126 EXT SUBJECT* last_subject INIT(0);
127 
128 EXT bool untrim_cache INIT(FALSE);
129 
130 #ifdef PENDING
131 EXT ART_NUM subj_to_get;
132 EXT ART_NUM xref_to_get;
133 #endif
134 
135 /* DON'T EDIT BELOW THIS LINE OR YOUR CHANGES WILL BE LOST! */
136 
137 void cache_init _((void));
138 void build_cache _((void));
139 void close_cache _((void));
140 void cache_article _((ARTICLE*));
141 void check_for_near_subj _((ARTICLE*));
142 void change_join_subject_len _((int));
143 void check_poster _((ARTICLE*));
144 void uncache_article _((ARTICLE*,bool_int));
145 char* fetchcache _((ART_NUM,int,bool_int));
146 char* get_cached_line _((ARTICLE*,int,bool_int));
147 void set_subj_line _((ARTICLE*,char*,int));
148 int decode_header _((char*,char*,int));
149 void dectrl _((char*));
150 void set_cached_line _((ARTICLE*,int,char*));
151 int subject_cmp _((char*,int,HASHDATUM));
152 #ifdef PENDING
153 void look_ahead _((void));
154 #endif
155 void cache_until_key _((void));
156 #ifdef PENDING
157 bool cache_subjects _((void));
158 #endif
159 bool cache_xrefs _((void));
160 bool cache_all_arts _((void));
161 bool cache_unread_arts _((void));
162 bool art_data _((ART_NUM,ART_NUM,bool_int,bool_int));
163 bool cache_range _((ART_NUM,ART_NUM));
164 void clear_article _((ARTICLE*));
165