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 */
52 #define SMERR_NOERROR 0
53 #define SMERR_INTERNAL 1
54 #define SMERR_UNDEFINED 2
56 #define SMERR_TOKENSHORT 4
57 #define SMERR_NOBODY 5
58 #define SMERR_UNINIT 6
59 #define SMERR_CONFIG 7
60 #define SMERR_BADHANDLE 8
61 #define SMERR_BADTOKEN 9
62 #define SMERR_NOMATCH 10
65 extern char *SMerrorstr;
67 typedef enum {SELFEXPIRE, SMARTNGNUM, EXPENSIVESTAT} PROBETYPE;
68 typedef enum {SM_ALL, SM_HEAD, SM_CANCELEDART} FLUSHTYPE;
77 char * TokenToText(const TOKEN token);
78 TOKEN TextToToken(const char *text);
79 bool IsToken(const char *text);
80 char * ToWireFmt(const char *article, size_t len, size_t *newlen);
81 char * FromWireFmt(const char *article, size_t len, size_t *newlen);
83 bool SMsetup(SMSETUP type, void *value);
85 TOKEN SMstore(const ARTHANDLE article);
86 ARTHANDLE * SMretrieve(const TOKEN token, const RETRTYPE amount);
87 ARTHANDLE * SMnext(const ARTHANDLE *article, const RETRTYPE amount);
88 void SMfreearticle(ARTHANDLE *article);
89 bool SMcancel(TOKEN token);
90 bool SMprobe(PROBETYPE type, TOKEN *token, void *value);
91 bool SMflushcacheddata(FLUSHTYPE type);
92 void SMprintfiles(FILE *file, TOKEN token, char **xref, int ngroups);
93 void SMshutdown(void);