24#ifndef COMPA_UPNPSTRING_HPP
25#error "Wrong UpnpString.hpp header file included."
29#include <umock/stdlib.hpp>
30#include <umock/stringh.hpp>
32#ifndef UPNP_USE_MSVCPP
34static size_t strnlen(
const char* s,
size_t n) {
return strnlen_s(s, n); }
38#if !HAVE_STRNLEN || defined(DOXYGEN_RUN)
40static size_t strnlen(
const char* s,
size_t n) {
41 const char* p = (
const char*)memchr(s, 0, n);
94 p->
m_string = (
char*)umock::stdlib_h.calloc((
size_t)1, (size_t)1);
103 umock::stdlib_h.free(p);
119 umock::stdlib_h.free(p);
138 umock::stdlib_h.free(q);
174 char* q = umock::string_h.strdup(s);
177 umock::stdlib_h.free(((
UpnpString*)p)->m_string);
188 char* q = umock::string_h.strndup(s, n);
191 umock::stdlib_h.free(((
UpnpString*)p)->m_string);
211 return strcmp(cp, cq);
218 return strcasecmp(cp, cq);
UpnpString object declaration.
char * m_string
Pointer to a dynamically allocated area that holds the NULL terminated string.
size_t m_length
Length of the string excluding terminating null byte ('\0').
Internal implementation of the class UpnpString.
PUPNP_Api UpnpString * UpnpString_dup(const UpnpString *p)
Copy Constructor.
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 int UpnpString_casecmp(UpnpString *p, UpnpString *q)
Compares two strings for equality. Case does not matter.
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.
static size_t strnlen(const char *s, size_t n)
strnlen() is a GNU extension and here provided for portability.
PUPNP_Api void UpnpString_delete(UpnpString *p)
Destructor.
PUPNP_Api int UpnpString_cmp(UpnpString *p, UpnpString *q)
Compares two strings for equality. Case matters.
PUPNP_Api void UpnpString_set_Length(UpnpString *p, size_t n)
Truncates the string to the specified lenght, or does nothing if the current lenght is less than or e...
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
PUPNP_Api void UpnpString_assign(UpnpString *p, const UpnpString *q)
Assignment operator.
PUPNP_Api void UpnpString_clear(UpnpString *p)
Clears the string, sets its size to zero.
Specifications to be portable between different platforms.