~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/ufsdump.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-05-04 11:15:49 UTC
  • mfrom: (1.3.1 upstream)
  • mto: (20.3.1 squeeze) (21.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100504111549-1apjh2g5sndki4te
Tags: upstream-3.1.3
ImportĀ upstreamĀ versionĀ 3.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: ufsdump.cc,v 1.11 2007/11/15 16:47:35 wessels Exp $
 
3
 * $Id$
4
4
 *
5
5
 * DEBUG: section 0     UFS Store Dump
6
6
 * AUTHOR: Robert Collins
21
21
 *  it under the terms of the GNU General Public License as published by
22
22
 *  the Free Software Foundation; either version 2 of the License, or
23
23
 *  (at your option) any later version.
24
 
 *  
 
24
 *
25
25
 *  This program is distributed in the hope that it will be useful,
26
26
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27
27
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
28
 *  GNU General Public License for more details.
29
 
 *  
 
29
 *
30
30
 *  You should have received a copy of the GNU General Public License
31
31
 *  along with this program; if not, write to the Free Software
32
32
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33
33
 *
34
34
 */
35
35
 
36
 
#include "squid.h"
 
36
#include "config.h"
37
37
#include "StoreMeta.h"
38
38
#include "StoreMetaUnpacker.h"
39
39
#include "Store.h"
40
40
#include "Generic.h"
41
41
#undef malloc
42
42
#undef free
 
43
 
 
44
#if HAVE_STDEXCEPT
43
45
#include <stdexcept>
 
46
#endif
 
47
#if HAVE_IOSTREAM
44
48
#include <iostream>
 
49
#endif
 
50
#if HAVE_CASSERT
45
51
#include <cassert>
 
52
#endif
46
53
 
47
54
/* stub functions for parts of squid not factored to be dynamic yet */
48
 
void shut_down(int)
49
 
{}
50
 
 
51
 
void
52
 
reconfigure(int)
53
 
{}
54
 
 
55
 
#if WHENITMINIMAL
56
55
void
57
56
eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata)
58
57
{}
59
58
 
60
 
#endif
 
59
// required by storeKeyPublicByRequest*
 
60
// XXX: what pulls in storeKeyPublicByRequest?
 
61
const char *urlCanonical(HttpRequest *) { assert(false); return NULL; }
 
62
 
 
63
void
 
64
storeAppendPrintf(StoreEntry * e, const char *fmt,...)
 
65
{
 
66
    va_list args;
 
67
    va_start(args, fmt);
 
68
 
 
69
    assert(false);
 
70
 
 
71
    va_end(args);
 
72
}
 
73
 
 
74
#include "CacheManager.h"
 
75
CacheManager*
 
76
CacheManager::GetInstance()
 
77
{
 
78
    assert(false);
 
79
    return NULL;
 
80
}
 
81
 
 
82
void
 
83
CacheManager::registerAction(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic) {}
 
84
 
 
85
/* MinGW needs also a stub of death() */
 
86
void
 
87
death(int sig)
 
88
{
 
89
    std::cout << "Fatal: Signal " <<  sig;
 
90
    exit(1);
 
91
}
 
92
 
 
93
void
 
94
fatal(const char *message)
 
95
{
 
96
    fprintf(stderr, "FATAL: %s\n", message);
 
97
    exit(1);
 
98
}
 
99
 
61
100
/* end stub functions */
62
101
 
63
 
struct MetaStd{
64
 
    time_t timestamp;
65
 
     time_t lastref;
66
 
     time_t expires;
67
 
     time_t lastmod;
68
 
     size_t swap_file_sz;
69
 
     u_short refcount;
70
 
     u_short flags;
71
 
};
72
 
 
73
 
struct MetaStdLfs{
74
 
     time_t timestamp;
75
 
     time_t lastref;
76
 
     time_t expires;
77
 
     time_t lastmod;
78
 
     uint64_t swap_file_sz;
79
 
     u_short refcount;
80
 
     u_short flags;
81
 
};
82
 
 
83
 
struct DumpStoreMeta : public unary_function<StoreMeta, void>
84
 
{
85
 
    DumpStoreMeta(){}
86
 
 
87
 
    void operator()(StoreMeta const &x)
88
 
    {
 
102
struct MetaStd {
 
103
    time_t timestamp;
 
104
    time_t lastref;
 
105
    time_t expires;
 
106
    time_t lastmod;
 
107
    size_t swap_file_sz;
 
108
    u_short refcount;
 
109
    u_short flags;
 
110
};
 
111
 
 
112
struct MetaStdLfs {
 
113
    time_t timestamp;
 
114
    time_t lastref;
 
115
    time_t expires;
 
116
    time_t lastmod;
 
117
    uint64_t swap_file_sz;
 
118
    u_short refcount;
 
119
    u_short flags;
 
120
};
 
121
 
 
122
struct DumpStoreMeta : public unary_function<StoreMeta, void> {
 
123
    DumpStoreMeta() {}
 
124
 
 
125
    void operator()(StoreMeta const &x) {
89
126
        switch (x.getType()) {
90
127
 
91
128
        case STORE_META_KEY:
93
130
            break;
94
131
 
95
132
        case STORE_META_STD:
96
 
            std::cout << "STD, Size:" << ((struct MetaStd*)x.value)->swap_file_sz << 
97
 
                 " Flags: 0x" << std::hex << ((struct MetaStd*)x.value)->flags << std::dec <<
98
 
                 " Refcount: " << ((struct MetaStd*)x.value)->refcount <<
99
 
                 std::endl;
 
133
            std::cout << "STD, Size:" << ((struct MetaStd*)x.value)->swap_file_sz <<
 
134
                      " Flags: 0x" << std::hex << ((struct MetaStd*)x.value)->flags << std::dec <<
 
135
                      " Refcount: " << ((struct MetaStd*)x.value)->refcount <<
 
136
                      std::endl;
100
137
            break;
101
138
 
102
139
        case STORE_META_STD_LFS:
103
 
             std::cout << "STD_LFS, Size: " << ((struct MetaStdLfs*)x.value)->swap_file_sz <<
104
 
                  " Flags: 0x" << std::hex << ((struct MetaStdLfs*)x.value)->flags << std::dec <<
105
 
                  " Refcount: " << ((struct MetaStdLfs*)x.value)->refcount <<
106
 
                  std::endl;
 
140
            std::cout << "STD_LFS, Size: " << ((struct MetaStdLfs*)x.value)->swap_file_sz <<
 
141
                      " Flags: 0x" << std::hex << ((struct MetaStdLfs*)x.value)->flags << std::dec <<
 
142
                      " Refcount: " << ((struct MetaStdLfs*)x.value)->refcount <<
 
143
                      std::endl;
107
144
            break;
108
145
 
109
146
        case STORE_META_URL:
112
149
            break;
113
150
 
114
151
        default:
115
 
             std::cout << "Unknown store meta type: " << (int)x.getType() <<
116
 
                  " of length " << x.length << std::endl;
 
152
            std::cout << "Unknown store meta type: " << (int)x.getType() <<
 
153
                      " of length " << x.length << std::endl;
117
154
            break;
118
155
        }
119
156
    }
125
162
    int fd = -1;
126
163
    StoreMeta *metadata = NULL;
127
164
 
128
 
    try
129
 
    {
 
165
    try {
130
166
        if (argc != 2)
131
167
            throw std::runtime_error("No filename provided");
132
168
 
162
198
 
163
199
 
164
200
        return 0;
165
 
    } catch (std::runtime_error error)
166
 
    {
 
201
    } catch (std::runtime_error error) {
167
202
        std::cout << "Failed : " << error.what() << std::endl;
168
203
 
169
204
        if (fd >= 0)