chiark / gitweb /
Turn SMstore thing into notes in manpage
[inn-innduct.git] / doc / man / libstorage.3
1 .\" $Revision: 6124 $
2 .TH LIBSTORAGE 3
3 .SH NAME
4 libstorage \- InterNetNews Storage API library routines
5 .SH SYNOPSIS
6 .nf
7 .ta \w'    unsigned long    'u
8
9 #include "storage.h"
10
11 .B "bool IsToken(const char *text);"
12
13 .B "char *TokenToText(const TOKEN token);"
14
15 .B "TOKEN TextToToken(const char *text);"
16
17 .B "bool SMsetup(SMSETUP type, void *value);"
18
19 .B "bool SMinit(void);"
20
21 .B "TOKEN SMstore(const ARTHANDLE article);"
22
23 .B "ARTHANDLE *SMretrieve(const TOKEN token, const RETRTYPE amount);"
24
25 .B "ARTHANDLE *SMnext(const ARTHANDLE *article, const RETRTYPE amount);"
26
27 .B "void SMfreearticle(ARTHANDLE *article);"
28
29 .B "bool SMcancel(TOKEN token);"
30
31 .B "bool SMprobe(PROBETYPE type, TOKEN *token, void *value);"
32
33 .B "void SMprintfiles(FILE *file, TOKEN token, char **xref, int ngroups)"
34
35 .B "bool SMflushcacheddata(FLUSHTYPE type);"
36
37 .B "void SMshutdown(void);"
38
39 .B "int SMerrno;"
40 .B "char *SMerrorstr;"
41
42 #include "ov.h"
43
44 .B "bool OVopen(int mode);"
45
46 .B "bool OVctl(OVCTLTYPE type, void *val);"
47
48 .B "bool OVgroupstats(char *group, int *lo, int *hi, int *count, int *flag);"
49
50 .B "bool OVgroupadd(char *group, ARTNUM lo, ARTNUM hi, char *flag);"
51
52 .B "bool OVgroupdel(char *group);"
53
54 .B "OVADDRESULT OVadd(TOKEN token, char *data, int len, time_t arrived);"
55
56 .B "bool OVcancel(TOKEN token);"
57
58 .B "void *OVopensearch(char *group, int low, int high);"
59
60 .B "bool OVsearch(void *handle, ARTNUM *artnum, char **data, int *len, TOKEN *token, time_t *arrived);"
61
62 .B "void OVclosesearch(void *handle);"
63
64 .B "bool OVgetartinfo(char *group, ARTNUM artnum, char **data, int *len, TOKEN *token);"
65
66 .B "bool OVexpiregroup(char *group, int *lo);"
67
68 .B "typedef struct _OVGE {"
69 .B "    bool        delayrm;"
70 .B "    bool        usepost;"
71 .B "    bool        quiet;"
72 .B "    bool        keep;"
73 .B "    bool        earliest;"
74 .B "    bool        ignoreselfexpire;"
75 .B "    char        *filename;"
76 .B "    time_t      now;"
77 .B "    float       timewarp;"
78 .B "} OVGE;"
79
80 .B "void OVclose(void);"
81
82 .fi
83 .SH DESCRIPTION
84 .I Libstorage
85 is a library of common utility (the storage manager) routines for accessing
86 Usenet articles and related data independent of particular storage method;
87 this is known as the storage API.
88 The storage manager's function is to isolate the applications from the
89 individual methods and make the policy decisions as to which storage method
90 should be called to store an article.
91 .PP
92 One of the core concepts in the storage API is that articles are not
93 manipulated using the message-id or article number, but rather a token that
94 uniquely identifies the article to the method that stored it.  This may seem
95 to be redundant since the message-id already is a unique identifier for the
96 article, however, since the storage method generates the token, it can
97 encode all the information it needs to locate the article in the token.
98 .PP
99 \&``OV'' is a common utility routines for accessing newsgroups and overview
100 data independent of particular overview method.
101 The ``OV'' function is to isolate the applications from the
102 individual methods.
103 .PP
104 All articles passed through the storage API are assumed to be in wire
105 format.  Wire format means ``\\CR\\LF'' at the end of lines, ``.'' at the
106 beginning of lines, and ``.\\CR\\LF'' at the end of article on NNTP stream
107 are not stripped.  This has a performance win when transferring articles.
108 For the ``tradspool'' method, wire format can be disabled.  This is just
109 for compatibility which is needed by some old tools written for
110 traditional spool.
111 .PP
112 .I IsToken
113 checks to see if the text is formatted as a text token string.
114 It returns true if formatted correctly or returns false if not.
115 .PP
116 .I TokenToText
117 converts token into text string for output.
118 .PP
119 .I TextToToken
120 converts text into token.
121 .PP
122 .I SMsetup
123 configures some parameters for use by storage manager.
124 .I Type
125 is one of following.
126 .sp 1
127 .in +0.5i
128 .nf
129 SM_RDWR allow read/write open for storage
130         files (default is false)
131 SM_PREOPEN      open all storage files at startup
132         time and keep them (default is false)
133 .fi
134 .in -0.5i
135 .sp 1
136 The
137 .I value
138 is the pointer which tells each type's value.
139 It returns true if setup is successful, or false if not.
140 .PP
141 .I SMinit
142 calls the setup function for all of the configured methods based on
143 .IR SMsetup .
144 This function should be called prior to all other storage API functions which
145 begin with ``SM'' except
146 .IR SMsetup .
147 It returns true if initialization is successful or returns false if not.
148 .I SMinit
149 returns true, unless all storage methods fail initialization.
150 .PP
151 .I SMstore
152 stores an article specified with
153 .IR article .
154 The headers and body of the article are supplied to
155 .I SMstore
156 using
157 .I iov
158 and
159 .IR iovcnt ;
160 .I data
161 and
162 .I private
163 are ignored by
164 .IR SMstore .
165 If
166 .I arrived
167 is specified,
168 .I SMstore
169 uses its value as article's arrival time; otherwise
170 .I SMstore
171 uses the current time for it.
172 .I SMstore
173 returns token type as
174 .IR type ,
175 or returns
176 .I TOKEN_EMPTY
177 if article is not stored because some error occurs or simply does not
178 match any
179 .IR uwildmat (3)
180 in
181 .IR storage.conf .
182 .I SMstore
183 fails if
184 .I SM_RDWR
185 has not been set to true with
186 .IR SMsetup .
187 .PP
188 .I SMretrieve
189 retrieves an article specified with
190 .IR token .
191 .I Amount
192 is the one of following which specifies retrieving type.
193 .sp 1
194 .in +0.5i
195 .nf
196 RETR_ALL        retrieve whole article
197 RETR_HEAD       retrieve headers of article
198 RETR_BODY       retrieve body of article
199 RETR_STAT       just check to see if article exists
200 .fi
201 .in -0.5i
202 .sp 1
203 .I SMretrieve
204 provides the article data via the
205 .I data
206 and
207 .I len
208 members of
209 .IR ARTHANDLE .
210 .I iov
211 is not set by
212 .IR SMretrieve .
213 The data area indicated by
214 .I ARTHANDLE
215 should not be modified.
216 .PP
217 .I SMnext
218 is similar in function to
219 .I SMretrieve
220 except that it is intended for traversing the method's article store
221 sequentially.
222 To start a query,
223 .I SMnext
224 should be called with a NULL pointer
225 .IR ARTHANDLE .
226 Then
227 .I SMnext
228 returns
229 .I ARTHANDLE
230 which should be used for the next query.
231 If a NULL pointer
232 .I ARTHANDLE
233 is returned, no articles are left to be queried.
234 If
235 .I data
236 of
237 .I ARTHANDLE
238 is NULL pointer or
239 .I len
240 of
241 .I ARTHANDLE
242 is 0, it indicates the article may be corrupted and should be cancelled by
243 .IR SMcancel .
244 The data area indicated by
245 .I ARTHANDLE
246 should not be modified.
247 .PP
248 .I SMfreearticle
249 frees all allocated memory used by
250 .I SMretrieve
251 and
252 .IR SMnext .
253 If
254 .I SMnext
255 will be called with previously returned
256 .IR ARTHANDLE ,
257 .I SMfreearticle
258 should not be called as
259 .I SMnext
260 frees allocated memory internally.
261 .PP
262 .I SMcancel
263 removes the article specified with
264 .IR token .
265 It returns true if cancellation is successful or returns false if not.
266 .I SMcancel
267 fails if
268 .I SM_RDWR
269 has not been set to true with
270 .IR SMsetup .
271 .PP
272 .I SMprobe
273 checks the token on
274 .IR PROBETYPE .
275 .I Type
276 is one of following.
277 .sp 1
278 .in +0.5i
279 .nf
280 SELFEXPIRE      checks to see if the method of the token
281         has self expire functionality
282 SMARTNGNUM      gets newsgroup name and article number
283         of the token.
284 .fi
285 .in -0.5i
286 .sp 1
287 .PP
288 .I SMprintfiles
289 shows file name or token usable by
290 .IR fastrm (8).
291 .PP
292 .I SMflushcacheddata
293 flushes cached data on each storage method.
294 .I Type
295 is one of following.
296 .sp 1
297 .in +0.5i
298 .nf
299 SM_HEAD flushes cached header
300 SM_CANCELEDART  flushes articles which should be canceled
301 SM_ALL  flushes all cached data
302 .fi
303 .in -0.5i
304 .sp 1
305 .PP
306 .I SMshutdown
307 calls the shutdown for each configured storage method and
308 then frees any resources it has allocated for itself.
309 .PP
310 .I SMerrno
311 and
312 .I SMerrorstr
313 indicate the reason of the last error concerning storage manager.
314 .PP
315 .I OVopen
316 calls the setup function for configured method which is specified as
317 \&``ovmethod'' in
318 .IR inn.conf .
319 .I Mode
320 is constructed from following.
321 .sp 1
322 .in +0.5i
323 .nf
324 OV_READ allow read open for overview
325         method
326 OV_WRITE        allow write open for overview
327         method
328 .fi
329 .in -0.5i
330 .sp 1
331 This function should be called prior to all other OV functions which
332 begin with ``OV''.
333 .PP
334 .I OVctl
335 probes or sets some parameters for overview method.
336 .I Type
337 is one of following.
338 .sp 1
339 .in +0.5i
340 .nf
341 OVGROUPBASEDEXPIRE      setup how group-based expiry is
342         done
343 OVCUTOFFLOW     do not add overview data, if the
344         data is under lowest article
345 OVSORT  probe which key is suitable for
346         overview method
347 OVSPACE probe overview space usage
348 OVSTATALL       stat all articles when
349         OVexpiregroup is called
350 .fi
351 .in -0.5i
352 .sp 1
353 .PP
354 .I OVgroupstats
355 retrieves specified newsgroup information from overview method.
356 .PP
357 .I OVgroupadd
358 informs overview method that specified newsgroup is being added.
359 .PP
360 .I OVgroupdel
361 informs overview method that specified newsgroup is being removed.
362 .PP
363 .I OVadd
364 stores an overview data.
365 .PP
366 .I OVcancel
367 requests the overview method delete overview data specified with token.
368 .PP
369 .I OVopensearch
370 requests the overview method prepare overview data retrieval.
371 The request range is determined by
372 .I low
373 and
374 .IR high .
375 .PP
376 .I OVsearch
377 retrieves information; article number, overview data, or arrival time.
378 .I OVsearch
379 should be called with NULL handle when it is the first time;
380 subsequent
381 .I OVsearch
382 calls should use the handle returned by the previous call to
383 .IR OVsearch .
384 .I OVsearch
385 returns true, unless it reaches high which is specified by
386 .IR OVopensearch .
387 Retrieved overview data are sorted by article number, and
388 .I len
389 is ``0'' if there is no overview data for article.  Note that the
390 retrieved data is not neccessarily null-terminated; you should only rely
391 on
392 .I len
393 octets of overview data being present.
394 .PP
395 .I OVclosesearch
396 frees all resources which have been allocated by
397 .IR OVopensearch .
398 .PP
399 .I OVgetartinfo
400 retrieves overview data and token specified with
401 .IR artnum .
402 .PP
403 .I OVexpiregroup
404 expires overview data for the newsgroup.
405 .I OVexpiregroup
406 checks the existense of the article and purges overview data if the
407 article no longer exists.
408 If ``groupbaseexpiry'' in
409 .I inn.conf
410 is true,
411 .I OVexpiregroup
412 also expires articles.
413 .PP
414 .I OVclose
415 frees all resources which are used by the overview method.
416 .SH HISTORY
417 Written by Katsuhiro Kondou <kondou@nec.co.jp> for InterNetNews.
418 .de R$
419 This is revision \\$3, dated \\$4.
420 ..
421 .R$ $Id: libstorage.3 6124 2003-01-14 06:03:29Z rra $
422 .SH "SEE ALSO"
423 expire(8),
424 inn.conf(5),
425 storage.conf(5).