1 /*
2  *	(c) Copyright 1990, Kim Fabricius Storm.  All rights reserved.
3  *      Copyright (c) 1996-2005 Michael T Pins.  All rights reserved.
4  *
5  *	Internal representation of the master, group, and article
6  *	information read from the database.
7  *
8  *	For each article read from the database, an article_header
9  *	structure is initialized.
10  */
11 
12 #ifndef _NN_DATA_H
13 #define _NN_DATA_H 1
14 
15 /*
16  *	The magic number allows us to change the format of the database
17  *	and tell the users about it
18  */
19 
20 #define NNDB_MAGIC	0x4e4e2302	/* NN#2 */
21 
22 /*
23  *	global master data
24  */
25 
26 #define	DB_LOCK_MESSAGE		80
27 
28 typedef struct {
29     int32           db_magic;
30     char            db_lock[DB_LOCK_MESSAGE];
31     time_t          db_created;	/* when database was last built */
32     time_t          last_scan;	/* age of active file at last scan */
33     off_t           last_size;	/* size of active file at last scan */
34     group_number    number_of_groups;
35     int32           free_groups;
36 }               master_header;
37 
38 /*
39  *	group information
40  */
41 
42 typedef struct group_header {
43 
44     /* this part of the header is read from the MASTER file */
45 
46     flag_type       master_flag;/* master's flags */
47 
48 #define M_VALID		FLAG(1)	/* group present in active file */
49 #define M_CONTROL	FLAG(2)	/* group is control group */
50 #define M_NO_DIRECTORY	FLAG(3)	/* group directory not found */
51 #define M_ALWAYS_DIGEST	FLAG(4)	/* D in GROUPS */
52 #define M_NEVER_DIGEST	FLAG(5)	/* N in GROUPS */
53 #define M_EXPIRE		FLAG(6)	/* expire in progress or pending */
54 #define M_BLOCKED	FLAG(7)	/* don't trust this entry */
55 #define M_MUST_CLEAN	FLAG(8)	/* group should be cleaned */
56 #define M_MODERATED	FLAG(9)	/* group is moderated */
57 #define M_ALIASED	FLAG(10)/* =xxx in active file */
58 #define M_NOPOST		FLAG(11)	/* 'n' in active file */
59 #define M_AUTO_RECOLLECT	FLAG(12)	/* R in GROUPS */
60 #define M_AUTO_ARCHIVE	FLAG(13)/* >file in GROUPS */
61 #define M_INCLUDE_OLD	FLAG(14)/* O in GROUPS */
62 #define M_IGNORE_G	FLAG(15)/* ignore this group (GROUPS X) */
63 #define M_IGNORE_A	FLAG(16)/* ignore this group (ACTIVE x) */
64 #define M_IGNORE_GROUP	(M_IGNORE_G | M_IGNORE_A)
65 
66     article_number  first_db_article;	/* min article in db */
67     article_number  last_db_article;	/* max article in db */
68 
69     article_number  first_a_article;	/* min article in active */
70     article_number  last_a_article;	/* max article in active */
71 
72     long            index_write_offset;
73     long            data_write_offset;
74 
75     time_t          creation_time;	/* when group was created */
76 
77     int             group_name_length;
78 
79     /* this part is initialized during reading of the GROUPS file */
80 
81     /* DO NOT CHANGE THE POSITION OF group_flag AS THE FIRST FIELD */
82     /* AFTER THE PART WHICH IS SAVED IN THE MASTER FILE */
83 
84     flag_type       group_flag;	/* client's flags */
85 
86 #define G_UNSUBSCRIBED	FLAG(1)	/* ! in .newsrc */
87 #define G_READ		FLAG(2)	/* group has been visited */
88 #define G_FAKED		FLAG(3)	/* faked group - not in .newsrc */
89 #define G_NEW		FLAG(5)	/* new group */
90 #define G_FOLDER		FLAG(6)	/* "group" is a folder file */
91 #define G_DIRECTORY	FLAG(7)	/* "group" is directory */
92 #define G_SEQUENCE	FLAG(8)	/* in presentation sequence */
93 #define G_DONE		FLAG(9)	/* sequence is done with group */
94 #define G_MAILBOX	FLAG(10)/* user's mail box file */
95 #define G_MERGE_HEAD	FLAG(11)/* merged group head */
96 #define G_MERGE_SUB	FLAG(12)/* merged group sub element */
97 #define G_MERGED 	(G_MERGE_HEAD | G_MERGE_SUB)
98 #define G_COUNTED	FLAG(13)/* counted in unread_count */
99 
100     group_number    group_num;
101     group_number    preseq_index;
102 
103     char           *group_name;
104 
105     char           *archive_file;
106 
107     article_number  first_article;
108     article_number  last_article;
109 
110     article_number  current_first;	/* first article currently read in */
111 
112     struct group_header *next_group;	/* group sequence */
113     struct group_header *prev_group;
114 
115     struct group_header *merge_with;	/* merged groups */
116 
117     char           *kill_list;
118     char           *save_file;	/* default save file from init */
119     char           *enter_macro;
120 
121     struct group_header *newsrc_seq;	/* .newsrc sequence		 */
122     char           *newsrc_line;/* .newsrc line for this group */
123     char           *newsrc_orig;/* original newsrc_line if changed */
124     char           *select_line;/* .nn/select line for this group */
125     char           *select_orig;/* original select_line if changed */
126 
127     article_number  unread_count;	/* number of unread articles */
128 }               group_header;
129 
130 
131 /* size of the part of the group header placed on backing storage */
132 
133 
134 #define SAVED_GROUP_HEADER_SIZE(group) \
135     (((char *)(&((group).group_flag))) - ((char *)(&(group))))
136 
137 /*
138  *	Internal article header information.
139  */
140 
141 typedef struct {
142     union {
143 	article_number  au_number;	/* article number in the group	 */
144 	char           *au_string;
145     }               au_union;
146     group_header   *a_group;	/* if merged article menu	 */
147 
148     /* indexes to header line text	 */
149     long            hpos;	/* first byte of header		 */
150     long            fpos;	/* first byte in article text	 */
151     off_t           lpos;	/* last pos of article		 */
152 
153     time_stamp      t_stamp;	/* encoded time_stamp		 */
154     time_stamp      root_t_stamp;	/* subject's time_stamp		 */
155 
156     char           *sender;	/* sender's name		 */
157     char           *subject;	/* subject (w/o Re:)		 */
158 
159     int16           lines;	/* no of lines		 */
160     int8            replies;	/* no of Re:			 */
161 
162     int8            subj_length;/* length of subject		 */
163     int8            name_length;/* length of sender		 */
164 
165     int8            menu_line;	/* current line on menu		 */
166 
167     attr_type       attr;	/* attributes: 			 */
168     attr_type       disp_attr;	/* currently displayed attr.	 */
169     /* warning: notice relation between A_SELECT and A_AUTO_SELECT */
170 
171 #define A_READ		0x01	/* article has been read	 */
172 #define A_SEEN		0x02	/* article presented on menu	 */
173 #define A_LEAVE		0x03	/* marked for later activity	 */
174 #define A_LEAVE_NEXT	0x04	/* marked for next invokation	 */
175 #define A_CANCEL		0x05	/* folder entry cancelled	 */
176 #define A_KILL		0x06	/* eliminate article		 */
177 #define A_SELECT   	0x08	/* article has been selected	 */
178 #define A_AUTO_SELECT	0x09	/* will match & A_SELECT	 */
179 
180 #define A_NOT_DISPLAYED	0x7f	/* not currently on menu	 */
181 
182     flag_type       flag;	/* attributes and flags:	 */
183 
184 #define A_SAME	    	FLAG(1)	/* same subject as prev. article */
185 #define A_ALMOST_SAME	FLAG(2)	/* A_SAME (match-limit)		 */
186 #define A_ROOT_ART	FLAG(3)	/* root article in subject	 */
187 #define A_NEXT_SAME	FLAG(4)	/* next is same subject		 */
188 #define A_DIGEST   	FLAG(5)	/* digest sub article		 */
189 #define A_FULL_DIGEST	FLAG(6)	/* full digest			 */
190 #define A_FOLDER		FLAG(7)	/* article file = "folder_path"	 */
191 #define A_FAKED    	FLAG(8)	/* only 'number' is valid	 */
192 #define A_ST_FILED	FLAG(10)/* articles is saved		 */
193 #define A_ST_REPLY	FLAG(11)/* sent reply to article	 */
194 #define A_ST_FOLLOW	FLAG(12)/* sent followup to article	 */
195 #define A_CLOSED		FLAG(13)	/* subject closed on menu	 */
196 #define A_HIDE		FLAG(14)/* hide subject on menu	 */
197 
198 }               article_header;
199 
200 
201 #define	a_number	au_union.au_number
202 #define a_string	au_union.au_string
203 #endif				/* _NN_DATA_H */
204