UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
UpnpFileInfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
2// Redistribution only with this Copyright remark. Last modified: 2025-06-08
3// Also Copyright by other contributor as noted below.
4// Last compare with pupnp original source file on 2023-04-25, ver 1.14.15
11#include <UpnpFileInfo.hpp>
12#ifndef COMPA_UPNPFILEINFO_HPP
13#error "Wrong UpnpFileInfo.hpp header file included."
14#endif
15
16#include <cstring> // for memset
17#include <cstdlib>
18
19// This structure is addressed with 'UpnpFileInfo' by
20// 'typedef struct s_UpnpFileInfo UpnpFileInfo;' in the header file. The typedef
21// must be the same as in pupnp otherwise we cannot switch between pupnp gtest
22// and compa gtest.
37
39 UpnpFileInfo* p = (UpnpFileInfo*)calloc(1, sizeof(UpnpFileInfo));
40
41 if (!p)
42 return 0;
43
44 /*p->m_FileLength = 0;*/
45 /*p->m_LastModified = 0;*/
46 /*p->m_IsDirectory = 0;*/
47 /*p->m_IsReadable = 0;*/
48 /*p->m_ContentType = 0;*/
50 /* memset(&p->m_CtrlPtIPAddr, 0, sizeof (struct sockaddr_storage)); */
51 p->m_Os = UpnpString_new();
52
53 return (UpnpFileInfo*)p;
54}
55
58
59
60 if (!p)
61 return;
62
64 p->m_Os = 0;
65 memset(&p->m_CtrlPtIPAddr, 0, sizeof(struct sockaddr_storage));
68 p->m_ContentType = 0;
69 p->m_IsReadable = 0;
70 p->m_IsDirectory = 0;
71 p->m_LastModified = 0;
72 p->m_FileLength = 0;
73
74 free(p);
75}
76
100
103
104 if (!p)
105 return 0;
106
108
109 return p;
110}
111
113 if (!p)
114 return 0;
115 return p->m_FileLength;
116}
117
119 if (!p)
120 return 0;
121
122 p->m_FileLength = n;
123
124 return 1;
125}
126
128 if (!p)
129 return 0;
130
131 return p->m_LastModified;
132}
133
135 if (!p)
136 return 0;
137
138 p->m_LastModified = n;
139
140 return 1;
141}
142
144 if (!p)
145 return 0;
146
147 return p->m_IsDirectory;
148}
149
151 if (!p)
152 return 0;
153
154 p->m_IsDirectory = n;
155
156 return 1;
157}
158
160 if (!p)
161 return 0;
162
163 return p->m_IsReadable;
164}
165
167 if (!p)
168 return 0;
169
170 p->m_IsReadable = n;
171
172 return 1;
173}
174
176 if (!p)
177 return nullptr;
178 return p->m_ContentType;
179}
180
183 if (!p || !q)
184 return 0;
186 p->m_ContentType = q;
187
188 return 1;
189}
190
192 return (const char*)UpnpFileInfo_get_ContentType(p);
193}
194
198
200 if (!p || !q)
201 return 0;
202
203 p->m_ExtraHeadersList = *q;
204
205 return 1;
206}
207
209 struct UpnpListHead* head) {
210 if (!p || !head)
211 return;
213 UpnpListInsert(list, UpnpListEnd(list), head);
214}
215
216const sockaddr_storage* UpnpFileInfo_get_CtrlPtIPAddr(const UpnpFileInfo* p) {
217 if (!p)
218 return nullptr;
219
220 return &p->m_CtrlPtIPAddr;
221}
222
224 const struct sockaddr_storage* buf) {
225 if (!p || !buf)
226 return 0;
227
228 p->m_CtrlPtIPAddr = *buf;
229
230 return 1;
231}
232
234 if (!p)
235 return;
236
237 memset(&p->m_CtrlPtIPAddr, 0, sizeof(sockaddr_storage));
238}
239
241 if (!p)
242 return nullptr;
243
244 return p->m_Os;
245}
246
248 if (!p || !s)
249 return 0;
250
251 const char* q = UpnpString_get_String(s);
252
253 return UpnpString_set_String(p->m_Os, q);
254}
255
259
263
264int UpnpFileInfo_strcpy_Os(UpnpFileInfo* p, const char* s) {
265 if (!p)
266 return 0;
267
268 return UpnpString_set_String(p->m_Os, s);
269}
270
271int UpnpFileInfo_strncpy_Os(UpnpFileInfo* p, const char* s, size_t n) {
272 if (!p)
273 return 0;
274
275 return UpnpString_set_StringN(p->m_Os, s, n);
276}
277
279 if (!p)
280 return;
281
283}
UpnpFileInfo * UpnpFileInfo_dup(const UpnpFileInfo *q)
struct sockaddr_storage m_CtrlPtIPAddr
int UpnpFileInfo_set_IsDirectory(UpnpFileInfo *p, int n)
int UpnpFileInfo_set_LastModified(UpnpFileInfo *p, time_t n)
int UpnpFileInfo_set_CtrlPtIPAddr(UpnpFileInfo *p, const struct sockaddr_storage *buf)
int UpnpFileInfo_get_IsReadable(const UpnpFileInfo *p)
int UpnpFileInfo_strcpy_Os(UpnpFileInfo *p, const char *s)
off_t UpnpFileInfo_get_FileLength(const UpnpFileInfo *p)
time_t UpnpFileInfo_get_LastModified(const UpnpFileInfo *p)
const DOMString UpnpFileInfo_get_ContentType(const UpnpFileInfo *p)
const UpnpListHead * UpnpFileInfo_get_ExtraHeadersList(const UpnpFileInfo *p)
int UpnpFileInfo_get_IsDirectory(const UpnpFileInfo *p)
int UpnpFileInfo_set_FileLength(UpnpFileInfo *p, off_t n)
void UpnpFileInfo_clear_CtrlPtIPAddr(UpnpFileInfo *p)
int UpnpFileInfo_set_ContentType(UpnpFileInfo *p, const DOMString s)
int UpnpFileInfo_assign(UpnpFileInfo *p, const UpnpFileInfo *q)
void UpnpFileInfo_clear_Os(UpnpFileInfo *p)
UpnpFileInfo * UpnpFileInfo_new()
const UpnpString * UpnpFileInfo_get_Os(const UpnpFileInfo *p)
int UpnpFileInfo_set_ExtraHeadersList(UpnpFileInfo *p, const UpnpListHead *q)
const char * UpnpFileInfo_get_Os_cstr(const UpnpFileInfo *p)
int UpnpFileInfo_set_Os(UpnpFileInfo *p, const UpnpString *s)
DOMString m_ContentType
UpnpListHead m_ExtraHeadersList
const sockaddr_storage * UpnpFileInfo_get_CtrlPtIPAddr(const UpnpFileInfo *p)
void UpnpFileInfo_add_to_list_ExtraHeadersList(UpnpFileInfo *p, struct UpnpListHead *head)
int UpnpFileInfo_strncpy_Os(UpnpFileInfo *p, const char *s, size_t n)
const char * UpnpFileInfo_get_ContentType_cstr(const UpnpFileInfo *p)
void UpnpFileInfo_delete(UpnpFileInfo *q)
UpnpString * m_Os
size_t UpnpFileInfo_get_Os_Length(const UpnpFileInfo *p)
int UpnpFileInfo_set_IsReadable(UpnpFileInfo *p, int n)
s_UpnpFileInfo
Header file for UpnpFileInfo methods.
Internal implementation of the class UpnpString.
PUPNP_Api int UpnpString_set_StringN(UpnpString *p, const char *s, size_t n)
Sets the string from a pointer to char using a maximum of N chars.
PUPNP_Api int UpnpString_set_String(UpnpString *p, const char *s)
Sets the string from a pointer to char.
PUPNP_Api size_t UpnpString_get_Length(const UpnpString *p)
Returns the length of the string.
PUPNP_Api UpnpString * UpnpString_new(void)
Constructor.
PUPNP_Api const char * UpnpString_get_String(const UpnpString *p)
Returns the pointer to char.
PUPNP_Api void UpnpString_delete(UpnpString *p)
Destructor.
PUPNP_Api void UpnpString_clear(UpnpString *p)
Clears the string, sets its size to zero.
#define DOMString
The type of DOM strings.
Definition ixml.hpp:47
PUPNP_Api void ixmlFreeDOMString(DOMString buf)
Frees a DOMString.
Definition ixml.cpp:418
PUPNP_Api DOMString ixmlCloneDOMString(const DOMString src)
Clones an existing DOMString.
Definition ixml.cpp:410
PUPNP_Api UpnpListIter UpnpListInsert(UpnpListHead *list, UpnpListIter pos, UpnpListHead *elt)
Insert element before pos, returns iterator pointing to inserted element.
Definition list.cpp:68
PUPNP_Api UpnpListIter UpnpListEnd(UpnpListHead *list)
Return end of list sentinel iterator (not an element)
Definition list.cpp:58
PUPNP_Api void UpnpListInit(UpnpListHead *list)
Initialize empty list.
Definition list.cpp:44
List anchor structure.
Definition list.hpp:56