This file is indexed.

/usr/include/upnp/TemplateSource.h is in libupnp1.8-dev 1:1.8.2-3.

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
/*
 * C Template objects.
 *
 * Copyright (C) 2010 Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
 */

#ifndef TEMPLATESOURCE_H
#define TEMPLATESOURCE_H

/*!
 * \file
 *
 * \brief Templates for source files of objects.
 *
 * Usage:
 *
 * - In the include file Token.h:
 *	#include "Token_def.h"
 *	#include "TemplateInclude.h"
 *
 * - In the source file Token.c:
 *	#include "Token.h"
 *	#include "TemplateSource.h"
 *
 * \author Marcelo Roberto Jimenez
 */


/******************************************************************************/
#define TEMPLATE_DEFINITION_INT(MEMBER, TYPE)		TYPE m_##MEMBER;
#define TEMPLATE_DEFINITION_BUFFER(MEMBER, TYPE)	TYPE m_##MEMBER;
#define TEMPLATE_DEFINITION_LIST(MEMBER)		struct list_head m_##MEMBER;
#define TEMPLATE_DEFINITION_OBJECT(MEMBER, TYPE)	TYPE *m_##MEMBER;
#define TEMPLATE_DEFINITION_STRING(MEMBER)		UpnpString *m_##MEMBER;
#define TEMPLATE_DEFINITION_DOMSTRING(MEMBER)		DOMString m_##MEMBER;

/******************************************************************************/
#define TEMPLATE_CONSTRUCTOR_INT(MEMBER, TYPE)		/* p->m_##MEMBER = 0; */
#define TEMPLATE_CONSTRUCTOR_BUFFER(MEMBER, TYPE)	\
	/* memset(&p->m_##MEMBER, 0, sizeof (TYPE)); */
#define TEMPLATE_CONSTRUCTOR_LIST(MEMBER, TYPE)		INIT_LIST_HEAD(&p->m_##MEMBER);
#define TEMPLATE_CONSTRUCTOR_OBJECT(MEMBER, TYPE)	p->m_##MEMBER = TYPE##_new();
#define TEMPLATE_CONSTRUCTOR_STRING(MEMBER)		p->m_##MEMBER = UpnpString_new();
#define TEMPLATE_CONSTRUCTOR_DOMSTRING(MEMBER)		 p->m_##MEMBER = NULL;

/******************************************************************************/
#define TEMPLATE_DESTRUCTOR_INT(MEMBER, TYPE)		p->m_##MEMBER = 0;
#define TEMPLATE_DESTRUCTOR_BUFFER(MEMBER, TYPE)	memset(&p->m_##MEMBER, 0, sizeof (TYPE));
#define TEMPLATE_DESTRUCTOR_LIST(MEMBER)		list_del(&p->m_##MEMBER);
#define TEMPLATE_DESTRUCTOR_OBJECT(MEMBER, TYPE)	TYPE##_delete(p->m_##MEMBER); p->m_##MEMBER = NULL;
#define TEMPLATE_DESTRUCTOR_STRING(MEMBER)		UpnpString_delete(p->m_##MEMBER); p->m_##MEMBER = NULL;
#define TEMPLATE_DESTRUCTOR_DOMSTRING(MEMBER)		ixmlFreeDOMString(p->m_##MEMBER); p->m_##MEMBER = NULL;

/******************************************************************************/
#define TEMPLATE_ASSIGNMENT(CLASS, MEMBER)	ok = ok && CLASS##_set_##MEMBER(p, CLASS##_get_##MEMBER(q));


/******************************************************************************/
#define TEMPLATE_METHODS_INT(CLASS, MEMBER, TYPE) \
	TEMPLATE_METHODS_INT_AUX(CLASS, MEMBER, TYPE)
#define TEMPLATE_METHODS_INT_AUX(CLASS, MEMBER, TYPE) \
TYPE CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, TYPE n) \
{ \
	((struct S##CLASS *)p)->m_##MEMBER = n; \
	return 1; \
} \


/******************************************************************************/
#define TEMPLATE_METHODS_BUFFER(CLASS, MEMBER, TYPE) \
	TEMPLATE_METHODS_BUFFER_AUX(CLASS, MEMBER, TYPE)
#define TEMPLATE_METHODS_BUFFER_AUX(CLASS, MEMBER, TYPE) \
const TYPE *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return (TYPE *)&((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const TYPE *buf) \
{ \
	((struct S##CLASS *)p)->m_##MEMBER = *(TYPE *)buf; \
	return 1; \
} \
\
void CLASS##_clear_##MEMBER(CLASS *p) \
{ \
	memset(&((struct S##CLASS *)p)->m_##MEMBER, 0, sizeof(TYPE)); \
} \


/******************************************************************************/
#define TEMPLATE_METHODS_LIST(CLASS, MEMBER) \
	TEMPLATE_METHODS_LIST_AUX(CLASS, MEMBER)
#define TEMPLATE_METHODS_LIST_AUX(CLASS, MEMBER) \
const struct list_head *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return (struct list_head *)&((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
void CLASS##_add_to_list_##MEMBER(CLASS *p, struct list_head *head) \
{ \
	list_add(&((struct S##CLASS *)p)->m_##MEMBER, head); \
} \
\
void CLASS##_remove_from_list_##MEMBER(CLASS *p) \
{ \
	list_del_init(&((struct S##CLASS *)p)->m_##MEMBER); \
} \
\
void CLASS##_replace_in_list_##MEMBER(CLASS *p, struct list_head *new) \
{ \
	list_replace_init(&((struct S##CLASS *)p)->m_##MEMBER, new); \
} \


/******************************************************************************/
#define TEMPLATE_METHODS_OBJECT(CLASS, MEMBER, TYPE) \
	TEMPLATE_METHODS_OBJECT_AUX(CLASS, MEMBER, TYPE)
#define TEMPLATE_METHODS_OBJECT_AUX(CLASS, MEMBER, TYPE) \
const TYPE *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const TYPE *s) \
{ \
	TYPE *q = TYPE##_dup(s); \
	if (!q) return 0; \
	TYPE##_delete(((struct S##CLASS *)p)->m_##MEMBER); \
	((struct S##CLASS *)p)->m_##MEMBER = q; \
	return 1; \
} \


/******************************************************************************/
#define TEMPLATE_METHODS_STRING(CLASS, MEMBER) \
	TEMPLATE_METHODS_STRING_AUX(CLASS, MEMBER)
#define TEMPLATE_METHODS_STRING_AUX(CLASS, MEMBER) \
const UpnpString *CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const UpnpString *s) \
{ \
	const char *q = UpnpString_get_String(s); \
	return UpnpString_set_String(((struct S##CLASS *)p)->m_##MEMBER, q); \
} \
\
size_t CLASS##_get_##MEMBER##_Length(const CLASS *p) \
{ \
	return UpnpString_get_Length(CLASS##_get_##MEMBER(p)); \
} \
const char *CLASS##_get_##MEMBER##_cstr(const CLASS *p) \
{ \
	return UpnpString_get_String(CLASS##_get_##MEMBER(p)); \
} \
\
int CLASS##_strcpy_##MEMBER(CLASS *p, const char *s) \
{ \
	return UpnpString_set_String(((struct S##CLASS *)p)->m_##MEMBER, s); \
} \
\
int CLASS##_strncpy_##MEMBER(CLASS *p, const char *s, size_t n) \
{ \
	return UpnpString_set_StringN(((struct S##CLASS *)p)->m_##MEMBER, s, n); \
} \
\
void CLASS##_clear_##MEMBER(CLASS *p) \
{ \
	UpnpString_clear(((struct S##CLASS *)p)->m_##MEMBER); \
} \


/******************************************************************************/
#define TEMPLATE_METHODS_DOMSTRING(CLASS, MEMBER) \
	TEMPLATE_METHODS_DOMSTRING_AUX(CLASS, MEMBER)
#define TEMPLATE_METHODS_DOMSTRING_AUX(CLASS, MEMBER) \
const DOMString CLASS##_get_##MEMBER(const CLASS *p) \
{ \
	return ((struct S##CLASS *)p)->m_##MEMBER; \
} \
\
int CLASS##_set_##MEMBER(CLASS *p, const DOMString s) \
{ \
	DOMString q = ixmlCloneDOMString(s); \
	if (!q) return 0; \
	ixmlFreeDOMString(((struct S##CLASS *)p)->m_##MEMBER); \
	((struct S##CLASS *)p)->m_##MEMBER = q; \
	return 1; \
} \
\
const char *CLASS##_get_##MEMBER##_cstr(const CLASS *p) \
{ \
	return (const char *)CLASS##_get_##MEMBER(p); \
} \


/******************************************************************************
 *
 * Actual source starts here.
 *
 ******************************************************************************/

#include "config.h"

#include <stdlib.h> /* for calloc(), free() */	
#include <string.h> /* for strlen(), strdup() */

/******************************************************************************/
#define EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE)	TEMPLATE_DEFINITION_INT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE)	TEMPLATE_DEFINITION_BUFFER(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER)		TEMPLATE_DEFINITION_LIST(MEMBER)
#define EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE)	TEMPLATE_DEFINITION_OBJECT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER)	TEMPLATE_DEFINITION_STRING(MEMBER)
#define EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER)	TEMPLATE_DEFINITION_DOMSTRING(MEMBER)

#define TEMPLATE_DECLARATION_STRUCT(CLASS) \
	TEMPLATE_DECLARATION_STRUCT_AUX(CLASS)
#define TEMPLATE_DECLARATION_STRUCT_AUX(CLASS) \
struct S##CLASS { \
	EXPAND_CLASS_MEMBERS(CLASS) \
};

TEMPLATE_DECLARATION_STRUCT(CLASS)

#include "TemplateUndef.h"

/******************************************************************************/
#define EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE)	TEMPLATE_CONSTRUCTOR_INT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE)	TEMPLATE_CONSTRUCTOR_BUFFER(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER)		TEMPLATE_CONSTRUCTOR_LIST(MEMBER, MEMBER)
#define EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE)	TEMPLATE_CONSTRUCTOR_OBJECT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER)	TEMPLATE_CONSTRUCTOR_STRING(MEMBER)
#define EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER)	TEMPLATE_CONSTRUCTOR_DOMSTRING(MEMBER)

#define TEMPLATE_DEFINITION_CONSTRUCTOR(CLASS) \
	TEMPLATE_DEFINITION_CONSTRUCTOR_AUX(CLASS)
#define TEMPLATE_DEFINITION_CONSTRUCTOR_AUX(CLASS) \
CLASS *CLASS##_new() \
{ \
	struct S##CLASS *p = calloc(1, sizeof (struct S##CLASS)); \
\
	if (!p) return NULL; \
\
	EXPAND_CLASS_MEMBERS(CLASS) \
\
	return (CLASS *)p; \
}

TEMPLATE_DEFINITION_CONSTRUCTOR(CLASS)

#include "TemplateUndef.h"

/******************************************************************************/
#define EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE)	TEMPLATE_DESTRUCTOR_INT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE)	TEMPLATE_DESTRUCTOR_BUFFER(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER)		TEMPLATE_DESTRUCTOR_LIST(MEMBER)
#define EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE)	TEMPLATE_DESTRUCTOR_OBJECT(MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER)	TEMPLATE_DESTRUCTOR_STRING(MEMBER)
#define EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER)	TEMPLATE_DESTRUCTOR_DOMSTRING(MEMBER)

#define TEMPLATE_DEFINITION_DESTRUCTOR(CLASS) \
	TEMPLATE_DEFINITION_DESTRUCTOR_AUX(CLASS)
#define TEMPLATE_DEFINITION_DESTRUCTOR_AUX(CLASS) \
void CLASS##_delete(CLASS *q) \
{ \
	struct S##CLASS *p = (struct S##CLASS *)q; \
\
	if (!p) return; \
\
	EXPAND_CLASS_MEMBERS(CLASS) \
\
	free(p); \
}

TEMPLATE_DEFINITION_DESTRUCTOR(CLASS)

#include "TemplateUndef.h"

/******************************************************************************/
#define TEMPLATE_DEFINITION_COPY_CONSTRUCTOR(CLASS) \
	TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX(CLASS)
#define TEMPLATE_DEFINITION_COPY_CONSTRUCTOR_AUX(CLASS) \
CLASS *CLASS##_dup(const CLASS *q) \
{ \
	CLASS *p = CLASS##_new(); \
\
	if (!p) return NULL; \
\
	CLASS##_assign(p, q); \
\
	return p; \
}

TEMPLATE_DEFINITION_COPY_CONSTRUCTOR(CLASS)

/******************************************************************************/
#define EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE)	TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE)	TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER)		/* Do not assing. */
#define EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE)	TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER)	TEMPLATE_ASSIGNMENT(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER)	TEMPLATE_ASSIGNMENT(CLASS, MEMBER)

#define TEMPLATE_DEFINITION_ASSIGNMENT(CLASS) \
	TEMPLATE_DEFINITION_ASSIGNMENT_AUX(CLASS)
#define TEMPLATE_DEFINITION_ASSIGNMENT_AUX(CLASS) \
int CLASS##_assign(CLASS *p, const CLASS *q) \
{ \
	int ok = 1; \
	if (p != q) { \
		EXPAND_CLASS_MEMBERS(CLASS) \
	} \
	return ok; \
}

TEMPLATE_DEFINITION_ASSIGNMENT(CLASS)

#include "TemplateUndef.h"

/******************************************************************************/
#define EXPAND_CLASS_MEMBER_INT(CLASS, MEMBER, TYPE)	TEMPLATE_METHODS_INT(CLASS, MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_BUFFER(CLASS, MEMBER, TYPE)	TEMPLATE_METHODS_BUFFER(CLASS, MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_LIST(CLASS, MEMBER)		TEMPLATE_METHODS_LIST(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_OBJECT(CLASS, MEMBER, TYPE)	TEMPLATE_METHODS_OBJECT(CLASS, MEMBER, TYPE)
#define EXPAND_CLASS_MEMBER_STRING(CLASS, MEMBER)	TEMPLATE_METHODS_STRING(CLASS, MEMBER)
#define EXPAND_CLASS_MEMBER_DOMSTRING(CLASS, MEMBER)	TEMPLATE_METHODS_DOMSTRING(CLASS, MEMBER)

EXPAND_CLASS_MEMBERS(CLASS)

#include "TemplateUndef.h"


#endif /* TEMPLATESOURCE_H */