1 /* $Id: storage.h 5933 2002-12-07 09:47:17Z rra $
3 ** Here be declarations related to the storage subsystem.
9 /* We've probably already included this; only include it if we need it. */
15 #include <sys/types.h>
17 #define STORAGE_TOKEN_LENGTH 16
19 /* This is the type of an empty token. Tokens with this type will be
20 returned when errors occur */
21 #define TOKEN_EMPTY 255
23 typedef enum {RETR_ALL, RETR_HEAD, RETR_BODY, RETR_STAT} RETRTYPE;
24 typedef enum {SM_RDWR, SM_PREOPEN} SMSETUP;
26 #define NUM_STORAGE_CLASSES 256
27 typedef unsigned char STORAGECLASS;
28 typedef unsigned char STORAGETYPE;
30 typedef struct token {
33 char token[STORAGE_TOKEN_LENGTH];
37 unsigned char type; /* Method that retrieved the article */
38 const char *data; /* Where the requested data starts */
39 struct iovec *iov; /* writev() style vector */
40 int iovcnt; /* writev() style count */
41 size_t len; /* Length of the requested data */
42 unsigned char nextmethod; /* Next method to try when iterating over the
44 void *private; /* A pointer to method specific data */
45 time_t arrived; /* The time when the article arrived */
46 time_t expires; /* The time when the article will be expired */
47 char *groups; /* Where Newsgroups header starts */
48 int groupslen; /* Length of Newsgroups header */
49 TOKEN *token; /* A pointer to the article's TOKEN */
51 /* SMstore uses iov* but not data,len
52 * SMretrieve sets type data,len private data is in wire format
55 #define SMERR_NOERROR 0
56 #define SMERR_INTERNAL 1
57 #define SMERR_UNDEFINED 2
59 #define SMERR_TOKENSHORT 4
60 #define SMERR_NOBODY 5
61 #define SMERR_UNINIT 6
62 #define SMERR_CONFIG 7
63 #define SMERR_BADHANDLE 8
64 #define SMERR_BADTOKEN 9
65 #define SMERR_NOMATCH 10
68 extern char *SMerrorstr;
70 typedef enum {SELFEXPIRE, SMARTNGNUM, EXPENSIVESTAT} PROBETYPE;
71 typedef enum {SM_ALL, SM_HEAD, SM_CANCELEDART} FLUSHTYPE;
80 char * TokenToText(const TOKEN token);
81 TOKEN TextToToken(const char *text);
82 bool IsToken(const char *text);
83 char * ToWireFmt(const char *article, size_t len, size_t *newlen);
84 char * FromWireFmt(const char *article, size_t len, size_t *newlen);
86 bool SMsetup(SMSETUP type, void *value);
88 TOKEN SMstore(const ARTHANDLE article);
89 ARTHANDLE * SMretrieve(const TOKEN token, const RETRTYPE amount);
90 ARTHANDLE * SMnext(const ARTHANDLE *article, const RETRTYPE amount);
91 void SMfreearticle(ARTHANDLE *article);
92 bool SMcancel(TOKEN token);
93 bool SMprobe(PROBETYPE type, TOKEN *token, void *value);
94 bool SMflushcacheddata(FLUSHTYPE type);
95 void SMprintfiles(FILE *file, TOKEN token, char **xref, int ngroups);
96 void SMshutdown(void);