File: TestClass.c

package info (click to toggle)
pupnp 1%3A1.14.20-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,440 kB
  • sloc: ansic: 34,488; xml: 1,173; cpp: 573; makefile: 341; sh: 130; python: 51; javascript: 7
file content (248 lines) | stat: -rw-r--r-- 5,256 bytes parent folder | download
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
/*!
 * \file
 *
 * \brief Source file for TestClass methods.
 *
 * Do not edit this file, it is automatically generated. Please look at
 * generator.c.
 *
 * \author Marcelo Roberto Jimenez
 */
#include "config.h"

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

#include "TestClass.h"

struct s_TestClass
{
	UpnpListHead m_TheList;
	int m_TheInteger;
	unsigned long m_TheUnsignedLong;
	char *m_TheCharPointer;
	struct TheStruct m_TheBuffer;
	UpnpActionComplete *m_TheActionComplete;
	UpnpString *m_TheString;
	DOMString m_TheDomString;
};

TestClass *TestClass_new()
{
	struct s_TestClass *p = calloc(1, sizeof(struct s_TestClass));

	if (!p)
		return 0;

	UpnpListInit(&p->m_TheList);
	/*p->m_TheInteger = 0;*/
	/*p->m_TheUnsignedLong = 0;*/
	/*p->m_TheCharPointer = 0;*/
	/* memset(&p->m_TheBuffer, 0, sizeof (struct TheStruct)); */
	p->m_TheActionComplete = UpnpActionComplete_new();
	p->m_TheString = UpnpString_new();
	/*p->m_TheDomString = 0;*/

	return (TestClass *)p;
}

void TestClass_delete(TestClass *q)
{
	struct s_TestClass *p = (struct s_TestClass *)q;

	if (!p)
		return;

	ixmlFreeDOMString(p->m_TheDomString);
	p->m_TheDomString = 0;
	UpnpString_delete(p->m_TheString);
	p->m_TheString = 0;
	UpnpActionComplete_delete(p->m_TheActionComplete);
	p->m_TheActionComplete = 0;
	memset(&p->m_TheBuffer, 0, sizeof(struct TheStruct));
	p->m_TheCharPointer = 0;
	p->m_TheUnsignedLong = 0;
	p->m_TheInteger = 0;
	UpnpListInit(&p->m_TheList);

	free(p);
}

int TestClass_assign(TestClass *p, const TestClass *q)
{
	int ok = 1;

	if (p != q) {
		ok = ok && TestClass_set_TheList(p, TestClass_get_TheList(q));
		ok = ok &&
		     TestClass_set_TheInteger(p, TestClass_get_TheInteger(q));
		ok = ok && TestClass_set_TheUnsignedLong(
				   p, TestClass_get_TheUnsignedLong(q));
		ok = ok && TestClass_set_TheCharPointer(
				   p, TestClass_get_TheCharPointer(q));
		ok = ok &&
		     TestClass_set_TheBuffer(p, TestClass_get_TheBuffer(q));
		ok = ok && TestClass_set_TheActionComplete(
				   p, TestClass_get_TheActionComplete(q));
		ok = ok &&
		     TestClass_set_TheString(p, TestClass_get_TheString(q));
		ok = ok && TestClass_set_TheDomString(
				   p, TestClass_get_TheDomString(q));
	}

	return ok;
}

TestClass *TestClass_dup(const TestClass *q)
{
	TestClass *p = TestClass_new();

	if (!p)
		return 0;

	TestClass_assign(p, q);

	return p;
}

const UpnpListHead *TestClass_get_TheList(const TestClass *p)
{
	return &p->m_TheList;
}

int TestClass_set_TheList(TestClass *p, const UpnpListHead *q)
{
	p->m_TheList = *q;

	return 1;
}

void TestClass_add_to_list_TheList(TestClass *p, struct UpnpListHead *head)
{
	UpnpListHead *list = &p->m_TheList;
	UpnpListInsert(list, UpnpListEnd(list), head);
}

int TestClass_get_TheInteger(const TestClass *p) { return p->m_TheInteger; }

int TestClass_set_TheInteger(TestClass *p, int n)
{
	p->m_TheInteger = n;

	return 1;
}

unsigned long TestClass_get_TheUnsignedLong(const TestClass *p)
{
	return p->m_TheUnsignedLong;
}

int TestClass_set_TheUnsignedLong(TestClass *p, unsigned long n)
{
	p->m_TheUnsignedLong = n;

	return 1;
}

char *TestClass_get_TheCharPointer(const TestClass *p)
{
	return p->m_TheCharPointer;
}

int TestClass_set_TheCharPointer(TestClass *p, char *n)
{
	p->m_TheCharPointer = n;

	return 1;
}

const struct TheStruct *TestClass_get_TheBuffer(const TestClass *p)
{
	return &p->m_TheBuffer;
}

int TestClass_set_TheBuffer(TestClass *p, const struct TheStruct *buf)
{
	p->m_TheBuffer = *buf;

	return 1;
}

void TestClass_clear_TheBuffer(TestClass *p)
{
	memset(&p->m_TheBuffer, 0, sizeof(struct TheStruct));
}

const UpnpActionComplete *TestClass_get_TheActionComplete(const TestClass *p)
{
	return p->m_TheActionComplete;
}

int TestClass_set_TheActionComplete(TestClass *p, const UpnpActionComplete *s)
{
	UpnpActionComplete *q = UpnpActionComplete_dup(s);
	if (!q)
		return 0;
	UpnpActionComplete_delete(p->m_TheActionComplete);
	p->m_TheActionComplete = q;

	return 1;
}

const UpnpString *TestClass_get_TheString(const TestClass *p)
{
	return p->m_TheString;
}

int TestClass_set_TheString(TestClass *p, const UpnpString *s)
{
	const char *q = UpnpString_get_String(s);

	return UpnpString_set_String(p->m_TheString, q);
}

size_t TestClass_get_TheString_Length(const TestClass *p)
{
	return UpnpString_get_Length(TestClass_get_TheString(p));
}

const char *TestClass_get_TheString_cstr(const TestClass *p)
{
	return UpnpString_get_String(TestClass_get_TheString(p));
}

int TestClass_strcpy_TheString(TestClass *p, const char *s)
{
	return UpnpString_set_String(p->m_TheString, s);
}

int TestClass_strncpy_TheString(TestClass *p, const char *s, size_t n)
{
	return UpnpString_set_StringN(p->m_TheString, s, n);
}

void TestClass_clear_TheString(TestClass *p)
{
	UpnpString_clear(p->m_TheString);
}

const DOMString TestClass_get_TheDomString(const TestClass *p)
{
	return p->m_TheDomString;
}

int TestClass_set_TheDomString(TestClass *p, const DOMString s)
{
	DOMString q = ixmlCloneDOMString(s);
	if (!q)
		return 0;
	ixmlFreeDOMString(p->m_TheDomString);
	p->m_TheDomString = q;

	return 1;
}

const char *TestClass_get_TheDomString_cstr(const TestClass *p)
{
	return (const char *)TestClass_get_TheDomString(p);
}