1 // 2 // $Id: squid-tlv.hh,v 1.1 1999/06/15 21:10:16 voeckler Exp $ 3 // 4 // Author: Jens-S. V�ckler <voeckler@rvs.uni-hannover.de> 5 // 6 // File: squid-tlv.hh 7 // Tue Jun 15 1999 8 // 9 // (c) 1999 Lehrgebiet Rechnernetze und Verteilte Systeme 10 // Universit�t Hannover, Germany 11 // 12 // Permission to use, copy, modify, distribute, and sell this software 13 // and its documentation for any purpose is hereby granted without fee, 14 // provided that (i) the above copyright notices and this permission 15 // notice appear in all copies of the software and related documentation, 16 // and (ii) the names of the Lehrgebiet Rechnernetze und Verteilte 17 // Systeme and the University of Hannover may not be used in any 18 // advertising or publicity relating to the software without the 19 // specific, prior written permission of Lehrgebiet Rechnernetze und 20 // Verteilte Systeme and the University of Hannover. 21 // 22 // THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 23 // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 24 // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 25 // 26 // IN NO EVENT SHALL THE LEHRGEBIET RECHNERNETZE UND VERTEILTE SYSTEME OR 27 // THE UNIVERSITY OF HANNOVER BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 28 // INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES 29 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT 30 // ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, 31 // ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 32 // SOFTWARE. 33 // 34 // $Log: squid-tlv.hh,v $ 35 // Revision 1.1 1999/06/15 21:10:16 voeckler 36 // Initial revision 37 // 38 #ifndef _SQUID_TLV_HH 39 #define _SQUID_TLV_HH 40 41 #if defined(__GNUC__) || defined(__GNUG__) 42 #pragma interface 43 #else 44 #ifndef HAS_BOOL 45 #define HAS_BOOL 46 typedef int bool; 47 #define false 0 48 #define true 1 49 #endif 50 #endif 51 52 #include <sys/types.h> 53 #include <netinet/in.h> 54 #include <arpa/inet.h> 55 #include <time.h> 56 57 // taken from Squid-2.x 58 // NOTE! We must preserve the order of this list! 59 enum SquidMetaType { 60 STORE_META_VOID, // should not come up 61 STORE_META_KEY_URL, // key w/ keytype 62 STORE_META_KEY_SHA, 63 STORE_META_KEY_MD5, 64 STORE_META_URL, // the url , if not in the header 65 STORE_META_STD, // standard metadata 66 STORE_META_HITMETERING, // reserved for hit metering 67 STORE_META_VALID, 68 STORE_META_END 69 }; 70 71 // taken from Squid-2.x 72 struct StoreMetaStd { 73 time_t timestamp; 74 time_t lastref; 75 time_t expires; 76 time_t lastmod; 77 size_t swap_file_sz; 78 u_short refcount; 79 u_short flags; 80 }; 81 82 struct SquidTLV { 83 // create a shallow reference pointing into the "buffer" variable 84 // do not copy --> saves times, saves memory. 85 SquidTLV( SquidMetaType _type, size_t _size = 0, void* _data = 0 ); ~SquidTLVSquidTLV86 ~SquidTLV() {} 87 88 SquidTLV* next; 89 size_t size; 90 SquidMetaType type; 91 char* data; 92 }; 93 94 class SquidMetaList { 95 public: 96 SquidMetaList(); 97 ~SquidMetaList(); 98 99 void append( SquidMetaType type, size_t size, void* data ); 100 const SquidTLV* search( SquidMetaType type ) const; 101 102 private: 103 SquidTLV* head; 104 SquidTLV* tail; 105 }; 106 107 #endif // _SQUID_TLV_HH 108