This file is indexed.

/usr/include/mimetic/codec/codec_chain.h is in libmimetic-dev 0.9.8-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/***************************************************************************
    copyright            : (C) 2002-2008 by Stefano Barbato
    email                : stefano@codesink.org

    $Id: codec_chain.h,v 1.13 2008-10-07 11:06:26 tat Exp $
 ***************************************************************************/
#ifndef _MIMETIC_CODEC_CODEC_CHAIN_
#define _MIMETIC_CODEC_CODEC_CHAIN_
#include <iterator>
#include <string>
#include <mimetic/codec/codec_base.h>


namespace mimetic
{

struct null_node;

template<typename C, typename N = null_node>
struct codec_chain;


/*
 * push_back_node
 */
template<typename Node, typename LastNode>
struct push_back_node
{
    typedef    
     codec_chain<
         typename Node::content_type,
        typename
         push_back_node<
            typename Node::next_node_type, 
            LastNode
            >::node_type
        > node_type;
};

template<typename LastNode>
struct push_back_node<null_node, LastNode>
{
    typedef LastNode node_type;
};


/*
 * returns item[idx] of the Node passed to the ctor
 */
template<typename Node, unsigned int idx>
struct item
{
    typedef typename Node::next_node_type next_node_type;
    typedef typename item<next_node_type, idx-1>::node_type node_type;
    item(const Node& node)
    : m_node(node)
    {}
    const node_type& node() const
    {
        return item<next_node_type, idx-1>(m_node.m_next).node();
    }
    const typename node_type::content_type& content() const
    {
        return node().m_c;
    }

private:
    const Node& m_node;
};

template<typename Node>
struct item<Node, 0>
{
    typedef Node node_type;
    item(const Node& node)
    :m_node(node)
    {}
    const node_type& node() const
    {
        return m_node;
    }
    const typename node_type::content_type& content() const
    {
        return m_node.m_c;
    }
private:
    const Node& m_node;
};


/*
 * build push_back_node<Node,TailNode::node_type and
 * initialize it with values stored in Node
 */
template<typename Node, typename TailNode, unsigned int idx = Node::count-1>
struct build_push_back_node
{
    typedef typename item<Node,idx>::node_type nth_node_type;
    typedef typename nth_node_type::content_type nth_content_type;
    typedef codec_chain<nth_content_type,TailNode>     
        next_tail_node_type;
    typedef typename 
        build_push_back_node<Node,next_tail_node_type,idx-1>::result_node_type
        result_node_type;
    /* 
    result_node_type is equal to push_back_node<Node,TailNode>::node_type
    */
    build_push_back_node(const Node& initn, const TailNode& tailn)
    : m_initn(initn), m_tailn(tailn)
    {
    }
    operator const result_node_type() const
    {
        return get();
    }
    const result_node_type get() const
    {
        const nth_content_type& nth_c=item<Node,idx>(m_initn).content();
        next_tail_node_type next_tail(nth_c, m_tailn);
        return build_push_back_node<Node,next_tail_node_type,idx-1>(m_initn,next_tail).get();
    }
private:
    const Node& m_initn;
    const TailNode& m_tailn;
};


template<typename Node, typename TailNode>
struct build_push_back_node<Node,TailNode,0>
{
    typedef typename item<Node,0>::node_type nth_node_type;
    typedef typename nth_node_type::content_type nth_content_type;
    typedef codec_chain<nth_content_type, TailNode> next_tail_node_type;
    typedef next_tail_node_type result_node_type;

    build_push_back_node(const Node& initn, const TailNode& tailn)
    : m_initn(initn), m_tailn(tailn)
    {
    }
    operator const result_node_type() const
    {
        return get();
    }
    const result_node_type get() const
    {
        const nth_content_type& nth_c=item<Node,0>(m_initn).content();
        next_tail_node_type next_tail(nth_c, m_tailn);
        return next_tail;    
    }
private:
    const Node& m_initn;
    const TailNode& m_tailn;
};

/// Defines a chain of codecs
/*!
 Chain of codecs. <b>Don't use it directly use | operator instead</b>.

 \code
     // converts test string to upper case, replaces LF chars with
    // CRLF and encodes it using quoted-printable codec
    ToUpperCase tuc;
    Lf2CrLf l2c;
    QP::Encoder qp; 
    char buf[MAXLEN]; 

    string test("....some text here....");
    code(test.begin(), test.end(), tuc | l2c | qp, buf);
 \endcode

 \warning Chainable codecs must derive from chainable_codec<>
 \sa encode decode
 */


template<typename C, typename N>
struct codec_chain
{
    typedef codec_chain<C, N> self_type;
    typedef C content_type;
    typedef N next_node_type;
    enum { count = 1 + next_node_type::count };
    codec_chain()
    {
        setName();
    }
    codec_chain(const content_type& c)
    : m_c(c)
    {
        setName();
    }
    codec_chain(const content_type& c, const next_node_type& node)
    : m_c(c), m_next(node)
    {
        setName();
    }
    codec_chain(const codec_chain& node)
    : m_c(node.m_c), m_next(node.m_next)
    {
        setName();
    }
    codec_chain(const null_node&) 
    {
        setName();
    }
    const char* name() const
    {
        return m_name.c_str();
    }
    void process(char c)
    {
        m_c.process(c, m_next);
    }
    void flush()
    {
        m_c.flush(m_next);
        m_next.flush();
    }
    template<typename Cn>
    const Cn& get_c(int idx) const
    {
        return get_c(--idx);
    }
    const content_type& get_c(int idx) const
    {
        if(idx == 0)
            return m_c;
        else
            return get_c(--idx);
    }
    template<typename C1>
    const C1& operator[](int idx) const
    {
        if(idx == 0)
            return m_c;
        else
            return m_next[--idx];
    }
    self_type& operator*()
    {    return *this;    }
    self_type& operator=(char c)
    {
        m_c.process(c, m_next);
        return *this;
    }
    self_type& operator++()
    {    return *this;    }
    self_type& operator++(int)
    {    return *this;    }
    template<typename TailC>
    typename 
    push_back_node<self_type, codec_chain<TailC> >::node_type 
    operator|(const TailC& l)
    {
        typedef codec_chain<TailC> tail_node;
        tail_node tail = l;
        build_push_back_node<self_type, tail_node> bpbn(*this,tail);
        return bpbn.get();
    }
 //protected:
    content_type m_c;
    next_node_type m_next;
    std::string m_name;
private:
    void setName()
    {
        m_name = std::string() + m_c.name() + "|" + m_next.name();
    }
};


struct null_node
{
    enum { idx = 1 };
    enum { count = 0 };
    struct null_content
    {};
    typedef null_node self_type;
    typedef null_content content_type;
    null_node()
    {
    }
    template<typename C1, typename N1>
    null_node(const codec_chain<C1, N1>& node)
    {
    }
    const char* name() const
    {    return "null_node";    }
    self_type& operator*()
    {    return *this;    }
    self_type& operator=(char c)
    {    return *this;    }
    self_type& operator++()
    {    return *this;    }
    self_type& operator++(int)
    {    return *this;    }
    void flush()
    {
    }
    null_content m_c;
};


/*
 * helper classes useful to build codec chains
 * i.e.  node_traits<Base64,QP>::node_type
 * i.e.  node_traits<Base64,QP,Lf2CrLf>::node_type
 */
template<typename A, typename B=null_node, typename C=null_node, typename D=null_node, typename E=null_node, typename F=null_node, typename G=null_node>
struct node_traits
{
};

// class specializations...

template<typename A, typename B, typename C, typename D, typename E,typename F>
struct node_traits<A,B,C,D,E,F>
{
    typedef codec_chain<A,
        codec_chain<B,
        codec_chain<C,
        codec_chain<D,
        codec_chain<E,
        codec_chain<F> > > > > > node_type;
};

template<typename A, typename B, typename C, typename D, typename E>
struct node_traits<A,B,C,D,E>
{
    typedef codec_chain<A,
        codec_chain<B,
        codec_chain<C,
        codec_chain<D,
        codec_chain<E> > > > > node_type;
};

template<typename A, typename B, typename C, typename D>
struct node_traits<A,B,C,D>
{
    typedef codec_chain<A,
        codec_chain<B,
        codec_chain<C,
        codec_chain<D> > > > node_type;
};

template<typename A, typename B, typename C>
struct node_traits<A,B,C>
{
    typedef codec_chain<A,
        codec_chain<B,
        codec_chain<C> > > node_type;
};


template<typename A, typename B>
struct node_traits<A,B>
{
    typedef codec_chain<A,
        codec_chain<B> > node_type;
};

template<typename A>
struct node_traits<A>
{
    typedef codec_chain<A> node_type;
};


/*
 * must be the base of all chainable codecs
 */
template<typename A>
struct chainable_codec
{
    template<typename B>
    typename node_traits<A,B>::node_type
    operator|(const B& b)
    {
        typedef codec_chain<B> node_b;
        const A& a = static_cast<A&>(*this);
        return typename node_traits<A,B>::node_type(a, node_b(b));
    }
};


/*
 * operator|-creates temporary nodes to initialize chain contents
 */


#if 0
template<class A, class B>
typename node_traits<A,B>::node_type 
operator|(const A& a, const B& b)
{

    typedef codec_chain<B> node_b;
    return typename node_traits<A,B>::node_type(a, node_b(b));
}

template<typename C, typename Node, typename Last>
typename 
push_back_node<codec_chain<C, Node>, codec_chain<Last> >::node_type 
operator|(const codec_chain<C, Node>& node, const Last& l)
{
    typedef codec_chain<C,Node> InitNode;
    typedef codec_chain<Last> TailNode;
    TailNode tailnode = l;
    build_push_back_node<InitNode,TailNode> bpbn(node,tailnode);

    return bpbn.get();
}

#endif
} // namespace mimetic

#endif