This file is indexed.

/usr/include/dclib-0.3/dclib/core/cstringlist.h is in libdc-dev 0.3.24~svn3121-2.

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
/***************************************************************************
                           cstringlist.h  -  description
                             -------------------
    begin                : Sat Jun 1 2002
    copyright            : (C) 2002-2003 by Mathias Küster
    email                : mathen@users.berlios.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CSTRINGLIST_H
#define CSTRINGLIST_H

/**
  *@author Mathias Küster
  *
  * Turned into a template class by Edward Sheldrake,
  * which makes the downloadmanager code a hell of a lot clearer.
  *
  * However this class and CList should still be removed entirely and replaced
  * with more appropriate STL classes (map, set, unordered_map).
  *
  * CStringList is a mapping class, not a list of strings. It is implemented
  * by containing lists per first key character. To handle more characters
  * of the key, the maxdepth parameter can be used, then it will contain
  * as many levels of CStringLists as necessary, each level handling
  * one character.
  *
  * CStringList's performance varies depending on how well
  * the items distribute, there is no real hash function to make
  * sure the items distribute evenly.
  *
  * The remove without deleting the item function never used to work
  * for CStringLists created with maxdepth > 0, the item was always
  * deleted. dclib does not require this to work, even if it was fixed.
  */

#include <dclib/dcos.h>
#include <dclib/core/cstring.h>
#include <dclib/core/clist.h>

template<class type> class CStringListObject {
public:
	/** */
	CStringListObject() {
		m_pObject = 0;
	};
	/** */
	~CStringListObject() {};

	/** */
	CString m_s;
	/** */
	type * m_pObject;
};

template<class type> class CStringList {
public: 
	/** */
	CStringList( int maxdepth = 0, int depth = 0 );
	/** */
	~CStringList();

	/** */
	int Add( const CString & s, type * object = 0 );
	/** */
	int Get( const CString & s, type ** object );
	/** */
	int Del( const CString & s, bool bdelobj = true );
	/** */
	int Remove( const CString & s ) { return Del(s,false); };
	/** */
	void Clear();
	/** */
	long Count() const;
	/** */
	int Next( type ** object );
	/** */
	int Next( CString & s, type ** object );
private:
	/** */
	int m_nDepth;
	/** */
	int m_nMaxDepth;
	/** */
	long m_nSize;
	/** */
	long m_nCachePos;
	/** */
	CStringListObject<type> * m_nCacheObj;
	/** */
	CStringList<type> ** m_pStringList;
	/** */
	CList<CStringListObject<type> > ** m_pList;
};

/** */
template<class type> inline long CStringList<type>::Count() const
{ return m_nSize; }

#define HASH_TABLE_SIZE 0x100

#include <stdio.h>
#include <string.h>

template<class type> CStringList<type>::CStringList( int maxdepth, int depth )
{
	m_nDepth    = depth;
	m_nMaxDepth = maxdepth;
	m_nSize     = 0;
	m_nCachePos = 0;
	m_nCacheObj = 0;

	m_pList       = 0;
	m_pStringList = 0;

	if ( m_nDepth == m_nMaxDepth )
	{
		m_pList = new CList<CStringListObject<type> >*[HASH_TABLE_SIZE];
		memset(m_pList, 0, HASH_TABLE_SIZE*sizeof(CList<CStringListObject<type> >*));
	}
	else
	{
		m_pStringList = new CStringList<type>*[HASH_TABLE_SIZE];
		memset(m_pStringList, 0, HASH_TABLE_SIZE*sizeof(CStringList<type>*));
	}
}

template<class type> CStringList<type>::~CStringList()
{
	Clear();

	if ( m_nDepth == m_nMaxDepth )
		delete [] m_pList;
	else
		delete [] m_pStringList;
}

/** */
template<class type> int CStringList<type>::Add( const CString & s, type * object )
{
	int i = s.GetHash(m_nDepth);

	if ( m_nDepth == m_nMaxDepth )
	{
		CStringListObject<type> * o = new CStringListObject<type>();

		o->m_s = s;
		o->m_pObject = object;

		if ( m_pList[i] == 0 )
			m_pList[i] = new CList<CStringListObject<type> >();

		m_pList[i]->Add(o);
	}
	else
	{
		if ( m_pStringList[i] == 0 )
			m_pStringList[i] = new CStringList<type>(m_nMaxDepth,m_nDepth+1);
		m_pStringList[i]->Add(s,object);
	}

	m_nSize++;

	m_nCachePos = 0;
	m_nCacheObj = 0;

	return 0;
}

/** */
template<class type> int CStringList<type>::Del( const CString & s, bool bdelobj )
{
	CStringListObject<type> * o = 0;
	int i = s.GetHash(m_nDepth);

	if ( m_nDepth == m_nMaxDepth )
	{
		if ( m_pList[i] == 0 )
			return -1;

		while( (o=m_pList[i]->Next(o)) != 0 )
		{
			if ( s == o->m_s )
				break;
		}

		if (!o)
			return -1;

		m_pList[i]->Remove(o);

		if ( bdelobj )
			delete o->m_pObject;

		delete o;

		if (m_pList[i]->Count() == 0 )
		{
			delete m_pList[i];
			m_pList[i]=0;
		}
	}
	else
	{
		if ( m_pStringList[i] == 0 )
			return -1;
		m_pStringList[i]->Del(s,bdelobj);
	}

	m_nSize--;

	m_nCachePos = 0;
	m_nCacheObj = 0;

	return 0;
}

/** */
template<class type> int CStringList<type>::Get( const CString & s, type ** object )
{
	CStringListObject<type> * o = 0;
	int i = s.GetHash(m_nDepth);

	if ( m_nDepth == m_nMaxDepth )
	{
		if ( !m_pList[i] )
			return -1;

		while( (o=m_pList[i]->Next(o)) != 0 )
		{
			if ( s == o->m_s )
				break;
		}

		if (!o)
			return -1;

		*object = o->m_pObject;
	}
	else
	{
		if ( !m_pStringList[i] )
			return -1;

		return m_pStringList[i]->Get(s,object);
	}

	return 0;
}

/** */
template<class type> void CStringList<type>::Clear()
{
	CStringListObject<type> * o = 0;
	int i;

	for(i=0;i<HASH_TABLE_SIZE;i++)
	{
		if ( m_nDepth == m_nMaxDepth )
		{
			if(m_pList[i])
			{
				while( (o=m_pList[i]->Next(0)) != 0 )
				{

					delete o->m_pObject;
					o->m_pObject = 0;

					m_pList[i]->Del(o);
				}

				delete m_pList[i];
			}
			m_pList[i]=0;
		}
		else
		{
			if(m_pStringList[i])
				delete m_pStringList[i];
			m_pStringList[i]=0;
		}
	}

	m_nSize     = 0;
	m_nCachePos = 0;
	m_nCacheObj = 0;
}

/** */
template<class type> int CStringList<type>::Next( type ** object )
{
	CString s;

	return Next(s,object);
}

/** */
template<class type> int CStringList<type>::Next( CString & s, type ** object )
{
	int i;
	long l;
	CStringListObject<type> * obj=0;

	if ( *object == 0 )
	{
		m_nCachePos = 0;
		m_nCacheObj = 0;
	}

	for(i=0,l=0;(i<HASH_TABLE_SIZE)&&(m_nSize>0);i++)
	{
		if ( m_nDepth == m_nMaxDepth )
		{
			if(!m_pList[i])
				continue;

			// fix cache after del
			if ( (*object != 0) && (m_nCacheObj == 0) )
			{
				obj = 0;
				while ( (obj=m_pList[i]->Next(obj)) != 0 )
				{
					m_nCachePos++;
					if ( obj->m_pObject == *object )
					{
						m_nCacheObj = obj;
						break;
					}
				}
				obj = 0;
			}
			else if ( (l<=m_nCachePos) && ((l+m_pList[i]->Count())>m_nCachePos) )
			{
				if(l==m_nCachePos)
					m_nCacheObj=0;
				obj = m_pList[i]->Next(m_nCacheObj);
				if ( obj )
					s = obj->m_s;
				else
					printf("WARNING: CStringList::Next nullpointer !\n");
				m_nCachePos++;
				m_nCacheObj = obj;
				break;
			}

			l+=m_pList[i]->Count();
		}
		else
		{
			if(!m_pStringList[i])
				continue;

			if ( (l<=m_nCachePos) && ((l+m_pStringList[i]->Count())>m_nCachePos) )
			{
				if(l==m_nCachePos)
					*object=0;
				m_nCachePos++;
				return m_pStringList[i]->Next(object);
			}

			l+=m_pStringList[i]->Count();
		}
	}
	
	if ( obj )
		*object = obj->m_pObject;
	else
		*object = 0;

	return (obj!=0);
}

#endif