chiark / gitweb /
update debian version
[inn-innduct.git] / include / storage.h
1 /*  $Id: storage.h 5933 2002-12-07 09:47:17Z rra $
2 **
3 **  Here be declarations related to the storage subsystem.
4 */
5
6 #ifndef __STORAGE_H__
7 #define __STORAGE_H__
8
9 /* We've probably already included this; only include it if we need it. */
10 #ifndef __CONFIG_H__
11 # include "config.h"
12 #endif
13
14 #include <stdio.h>
15 #include <sys/types.h>
16
17 #define STORAGE_TOKEN_LENGTH 16
18
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
22
23 typedef enum {RETR_ALL, RETR_HEAD, RETR_BODY, RETR_STAT} RETRTYPE;
24 typedef enum {SM_RDWR, SM_PREOPEN} SMSETUP;
25
26 #define NUM_STORAGE_CLASSES 256
27 typedef unsigned char STORAGECLASS;
28 typedef unsigned char STORAGETYPE;
29
30 typedef struct token {
31     STORAGETYPE         type;
32     STORAGECLASS        class;
33     char                token[STORAGE_TOKEN_LENGTH];
34 } TOKEN;
35
36 typedef struct {
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
43                                 spool */
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 */
50 } ARTHANDLE;
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_CANCELEDART} 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 char *      ToWireFmt(const char *article, size_t len, size_t *newlen);
81 char *      FromWireFmt(const char *article, size_t len, size_t *newlen);
82             
83 bool        SMsetup(SMSETUP type, void *value);
84 bool        SMinit(void);
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);
94
95 END_DECLS
96     
97 #endif