]>
Commit | Line | Data |
---|---|---|
d3b3ab85 | 1 | |
2 | /* | |
d3b3ab85 | 3 | * |
4 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
5 | * ---------------------------------------------------------- | |
6 | * | |
7 | * Squid is the result of efforts by numerous individuals from | |
8 | * the Internet community; see the CONTRIBUTORS file for full | |
9 | * details. Many organizations have provided support for Squid's | |
10 | * development; see the SPONSORS file for full details. Squid is | |
11 | * Copyrighted (C) 2001 by the Regents of the University of | |
12 | * California; see the COPYRIGHT file for full details. Squid | |
13 | * incorporates software developed and/or copyrighted by other | |
14 | * sources; see the CREDITS file for full details. | |
15 | * | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 of the License, or | |
19 | * (at your option) any later version. | |
26ac0430 | 20 | * |
d3b3ab85 | 21 | * This program is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | * GNU General Public License for more details. | |
26ac0430 | 25 | * |
d3b3ab85 | 26 | * You should have received a copy of the GNU General Public License |
27 | * along with this program; if not, write to the Free Software | |
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
29 | * | |
30 | */ | |
31 | ||
32 | #ifndef SQUID_STOREIOSTATE_H | |
33 | #define SQUID_STOREIOSTATE_H | |
34 | ||
8bf217bd | 35 | #include "base/RefCount.h" |
aa839030 | 36 | #include "cbdata.h" |
62e76326 | 37 | |
e877aaac | 38 | class StoreIOState : public RefCountable |
62e76326 | 39 | { |
40 | ||
d3b3ab85 | 41 | public: |
e877aaac | 42 | typedef RefCount<StoreIOState> Pointer; |
d3b3ab85 | 43 | |
4fcc8876 | 44 | /* |
45 | * STRCB is the "store read callback". STRCB functions are | |
46 | * passed to storeRead(). Examples of STRCB callbacks are: | |
47 | * storeClientReadBody | |
48 | * storeClientReadHeader | |
49 | */ | |
e5de8b13 | 50 | typedef void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self); |
4fcc8876 | 51 | |
52 | /* | |
53 | * STFNCB is the "store file number callback." It is called | |
54 | * when an underlying storage module has allocated the swap | |
55 | * file number and also indicates that the swap file has been | |
56 | * opened for reading or writing. STFNCB functions are passed | |
57 | * to storeCreate() and storeOpen(). Examples of STFNCB callbacks | |
58 | * are: | |
59 | * storeSwapInFileNotify | |
60 | * storeSwapOutFileNotify | |
61 | */ | |
e5de8b13 | 62 | typedef void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self); |
4fcc8876 | 63 | |
64 | /* | |
65 | * STIOCB is the "store close callback" for store files. It | |
66 | * is called when the store file is closed. STIOCB functions | |
67 | * are passed to storeCreate() and storeOpen(). Examples of | |
68 | * STIOCB callbacks are: | |
69 | * storeSwapOutFileClosed | |
70 | * storeSwapInFileClosed | |
71 | */ | |
e5de8b13 | 72 | typedef void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self); |
4fcc8876 | 73 | |
e877aaac | 74 | /* StoreIOState does not get mempooled - it's children do */ |
d3b3ab85 | 75 | void *operator new (size_t amount); |
76 | void operator delete (void *address); | |
e877aaac | 77 | virtual ~StoreIOState(); |
d3b3ab85 | 78 | |
e877aaac | 79 | StoreIOState(); |
d3b3ab85 | 80 | |
81 | off_t offset() const; | |
82 | ||
83 | virtual void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) = 0; | |
528b2c61 | 84 | virtual void write(char const *buf, size_t size, off_t offset, FREE * free_func) = 0; |
aa1a691e AR |
85 | |
86 | typedef enum { | |
9199139f AR |
87 | wroteAll, ///< success: caller supplied all data it wanted to swap out |
88 | writerGone, ///< failure: caller left before swapping out everything | |
89 | readerDone ///< success or failure: either way, stop swapping in | |
aa1a691e AR |
90 | } CloseHow; |
91 | virtual void close(int how) = 0; ///< finish or abort swapping per CloseHow | |
62e76326 | 92 | |
d3b3ab85 | 93 | sdirno swap_dirn; |
94 | sfileno swap_filen; | |
95 | StoreEntry *e; /* Need this so the FS layers can play god */ | |
96 | mode_t mode; | |
aa1a691e | 97 | off_t offset_; ///< number of bytes written or read for this entry so far |
d3b3ab85 | 98 | STFNCB *file_callback; /* called on delayed sfileno assignments */ |
99 | STIOCB *callback; | |
100 | void *callback_data; | |
62e76326 | 101 | |
26ac0430 | 102 | struct { |
62e76326 | 103 | STRCB *callback; |
104 | void *callback_data; | |
2fadd50d | 105 | } read; |
62e76326 | 106 | |
26ac0430 | 107 | struct { |
3d0ac046 | 108 | unsigned int closing:1; /* debugging aid */ |
2fadd50d | 109 | } flags; |
d3b3ab85 | 110 | }; |
111 | ||
4fcc8876 | 112 | StoreIOState::Pointer storeCreate(StoreEntry *, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); |
113 | StoreIOState::Pointer storeOpen(StoreEntry *, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); | |
d9c252f2 FC |
114 | void storeClose(StoreIOState::Pointer, int how); |
115 | void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *); | |
116 | void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *); | |
d3b3ab85 | 117 | |
118 | #endif /* SQUID_STOREIOSTATE_H */ |