1 /*
2   database.h
3 
4   Article database.
5 
6   $Id: database.h,v 1.7 2002/11/10 11:32:16 bears Exp $
7 */
8 
9 #ifndef DB_H
10 #define DB_H
11 
12 #if HAVE_CONFIG_H
13 #include <config.h>
14 #endif
15 
16 #if TIME_WITH_SYS_TIME
17 #include <sys/time.h>
18 #include <time.h>
19 #else
20 #if HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #else
23 #include <time.h>
24 #endif
25 #endif
26 
27 #include "common.h"
28 #include "dynamicstring.h"
29 #include "over.h"
30 
31 /* Article status flags: */
32 #define DB_INTERESTING       0x01u  /* Was article ever tried to read? */
33 #define DB_NOT_DOWNLOADED    0x02u  /* Not fully downloaded */
34 #define DB_RETRIEVING_FAILED 0x04u  /* Retrieving of article failed */
35 
36 /* Open database for r/w. Locking must be done by the caller! */
37 Bool
38 Db_open( void );
39 
40 void
41 Db_close( void );
42 
43 /*
44   Creates an database entry for the article from the overview
45   information. Xref is replaced by grp:numb.
46 */
47 Bool
48 Db_prepareEntry( const Over *ov, const char *grp, int numb );
49 
50 /* Store full article. Can only be used after Db_prepareEntry. */
51 Bool
52 Db_storeArt( const char *msgId, const char *artTxt );
53 
54 void
55 Db_setStatus( const char *msgId, unsigned status );
56 
57 void
58 Db_updateLastAccess( const char *msgId );
59 
60 /* Xref header line without hostname */
61 void
62 Db_setXref( const char *msgId, const char *xref );
63 
64 const char *
65 Db_header( const char *msgId );
66 
67 const char *
68 Db_body( const char *msgId );
69 
70 unsigned
71 Db_status( const char *msgId );
72 
73 /* Get last modification time of entry. Returns -1, if msgId non-existing. */
74 time_t
75 Db_lastAccess( const char *msgId );
76 
77 /* Value of the References header line */
78 const char *
79 Db_ref( const char *msgId );
80 
81 /* Value of the From header line */
82 const char *
83 Db_from( const char *msgId );
84 
85 /* Value of the Date header line */
86 const char *
87 Db_date( const char *msgId );
88 
89 /* Xref header line without hostname */
90 const char *
91 Db_xref( const char *msgId );
92 
93 /* Overview - need to del_Over result when finished with */
94 Over *
95 Db_over( const char *msgId );
96 
97 Bool
98 Db_contains( const char *msgId );
99 
100 /* Delete entry from database */
101 void
102 Db_delete( const char *msgId );
103 
104 Bool
105 Db_first( const char** msgId );
106 
107 Bool
108 Db_next( const char** msgId );
109 
110 /* Compact database if appropriate - give deleted article space back to OS */
111 void
112 Db_compact( void );
113 
114 /* Rebuild the article database. */
115 Bool
116 Db_rebuild( void );
117 
118 #endif
119