]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreIOState.h
4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
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.
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.
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.
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.
32 #ifndef SQUID_STOREIOSTATE_H
33 #define SQUID_STOREIOSTATE_H
38 class StoreIOState
: public RefCountable
42 typedef RefCount
<StoreIOState
> Pointer
;
45 * STRCB is the "store read callback". STRCB functions are
46 * passed to storeRead(). Examples of STRCB callbacks are:
48 * storeClientReadHeader
50 typedef void STRCB(void *their_data
, const char *buf
, ssize_t len
, StoreIOState::Pointer self
);
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
59 * storeSwapInFileNotify
60 * storeSwapOutFileNotify
62 typedef void STFNCB(void *their_data
, int errflag
, StoreIOState::Pointer self
);
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
72 typedef void STIOCB(void *their_data
, int errflag
, StoreIOState::Pointer self
);
74 /* StoreIOState does not get mempooled - it's children do */
75 void *operator new (size_t amount
);
76 void operator delete (void *address
);
77 virtual ~StoreIOState();
83 virtual void read_(char *buf
, size_t size
, off_t offset
, STRCB
* callback
, void *callback_data
) = 0;
84 virtual void write(char const *buf
, size_t size
, off_t offset
, FREE
* free_func
) = 0;
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
91 virtual void close(int how
) = 0; ///< finish or abort swapping per CloseHow
95 StoreEntry
*e
; /* Need this so the FS layers can play god */
97 off_t offset_
; ///< number of bytes written or read for this entry so far
98 STFNCB
*file_callback
; /* called on delayed sfileno assignments */
108 unsigned int closing
:1; /* debugging aid */
112 StoreIOState::Pointer
storeCreate(StoreEntry
*, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
113 StoreIOState::Pointer
storeOpen(StoreEntry
*, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
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
*);
118 #endif /* SQUID_STOREIOSTATE_H */