1 /* $Id: storage.h 9877 2015-05-24 13:59:15Z iulius $ 2 ** 3 ** Here be declarations related to the storage subsystem. 4 */ 5 6 #ifndef INN_STORAGE_H 7 #define INN_STORAGE_H 1 8 9 #include <inn/defines.h> 10 #include <inn/options.h> 11 #include <stdio.h> 12 #include <sys/types.h> 13 14 #define STORAGE_TOKEN_LENGTH 16 15 16 /* This is the type of an empty token. Tokens with this type will be 17 returned when errors occur */ 18 #define TOKEN_EMPTY 255 19 20 typedef enum {RETR_ALL, RETR_HEAD, RETR_BODY, RETR_STAT} RETRTYPE; 21 typedef enum {SM_RDWR, SM_PREOPEN} SMSETUP; 22 23 #define NUM_STORAGE_CLASSES 256 24 typedef unsigned char STORAGECLASS; 25 typedef unsigned char STORAGETYPE; 26 27 typedef struct token { 28 STORAGETYPE type; 29 STORAGECLASS class; 30 char token[STORAGE_TOKEN_LENGTH]; 31 } TOKEN; 32 33 typedef struct { 34 unsigned char type; /* Method that retrieved the article */ 35 const char *data; /* Where the requested data starts */ 36 struct iovec *iov; /* writev() style vector */ 37 int iovcnt; /* writev() style count */ 38 size_t len; /* Length of the requested data */ 39 unsigned char nextmethod; /* Next method to try when iterating over the 40 spool */ 41 void *private; /* A pointer to method specific data */ 42 time_t arrived; /* The time when the article arrived */ 43 time_t expires; /* The time when the article will be expired */ 44 char *groups; /* Where Newsgroups header starts */ 45 int groupslen; /* Length of Newsgroups header */ 46 TOKEN *token; /* A pointer to the article's TOKEN */ 47 } ARTHANDLE; 48 49 /* Initializer for the ARTHANDLE structure. */ 50 #define ARTHANDLE_INITIALIZER { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 51 52 #define SMERR_NOERROR 0 53 #define SMERR_INTERNAL 1 54 #define SMERR_UNDEFINED 2 55 #define SMERR_NOENT 3 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 63 64 extern int SMerrno; 65 extern char *SMerrorstr; 66 67 typedef enum {SELFEXPIRE, SMARTNGNUM, EXPENSIVESTAT} PROBETYPE; 68 typedef enum {SM_ALL, SM_HEAD, SM_CANCELLEDART} FLUSHTYPE; 69 70 struct artngnum { 71 char *groupname; 72 ARTNUM artnum; 73 }; 74 75 BEGIN_DECLS 76 77 char * TokenToText(const TOKEN token); 78 TOKEN TextToToken(const char *text); 79 bool IsToken(const char *text); 80 81 bool SMsetup(SMSETUP type, void *value); 82 bool SMinit(void); 83 TOKEN SMstore(const ARTHANDLE article); 84 ARTHANDLE * SMretrieve(const TOKEN token, const RETRTYPE amount); 85 ARTHANDLE * SMnext(ARTHANDLE *article, const RETRTYPE amount); 86 void SMfreearticle(ARTHANDLE *article); 87 bool SMcancel(TOKEN token); 88 bool SMprobe(PROBETYPE type, TOKEN *token, void *value); 89 bool SMflushcacheddata(FLUSHTYPE type); 90 void SMprintfiles(FILE *file, TOKEN token, char **xref, int ngroups); 91 char * SMexplaintoken(const TOKEN token); 92 void SMshutdown(void); 93 94 END_DECLS 95 96 #endif /* !INN_STORAGE_H */ 97