The UpnpString Class

Implements string operations in the UPnP library. More...

## Files

file | UpnpString.h
| UpnpString object declaration.
file | UpnpString.c
| UpnpString object implementation.

## Data Structures

struct | SUpnpString
| Internal implementation of the class UpnpString. More...

## Typedefs

typedef struct s_UpnpString | UpnpString
| Type of the string objects inside libupnp.

## Functions

UpnpString * | UpnpString_new (void)
| Constructor.
void | UpnpString_delete (UpnpString *p)
| Destructor.
UpnpString * | UpnpString_dup (const UpnpString *p)
| Copy Constructor.
void | UpnpString_assign (UpnpString *p, const UpnpString *q)
| Assignment operator.
size_t | UpnpString_get_Length (const UpnpString *p)
| Returns the length of the string.
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 equal to the requested length.
const char * | UpnpString_get_String (const UpnpString *p)
| Returns the pointer to char.
int | UpnpString_set_String (UpnpString *p, const char *s)
| Sets the string from a pointer to char.
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.
void | UpnpString_clear (UpnpString *p)
| Clears the string, sets its size to zero.
int | UpnpString_cmp (UpnpString *p, UpnpString *q)
| Compares two strings for equality. Case matters.
int | UpnpString_casecmp (UpnpString *p, UpnpString *q)
| Compares two strings for equality. Case does not matter.
static size_t | strnlen (const char *s, size_t n)
static char * | strndup (const char *__string, size_t __n)

## Variables

size_t | SUpnpString::m_length
| Length of the string.
char * | SUpnpString::m_string
| Pointer to a dynamically allocated area that holds the NULL terminated string.

## Detailed Description

Implements string operations in the UPnP library.

Author
  Marcelo Roberto Jimenez

Version
  1.0

Due to its heavy use, this class is coded for efficiency, not for beauty. Do not use this as example to other classes. Please take a look at any other one.

Todo:
  Always alloc a minimum size like 64 bytes or so and when shrinking do not perform a new memory allocation.

## Typedef Documentation

## UpnpString

typedef struct s_UpnpString UpnpString

Type of the string objects inside libupnp.

## Function Documentation

## UpnpString_assign()

void UpnpString_assign | ( | UpnpString * | p,
|  | const UpnpString * | q
| ) |  |

Assignment operator.

Parameters

  [in] | p | The this pointer.
  [in] | q | The that pointer.

References UpnpString_get_String(), and UpnpString_set_String().

Referenced by genaSubscribe().

## UpnpString_casecmp()

int UpnpString_casecmp | ( | UpnpString * | p,
|  | UpnpString * | q
| ) |  |

Compares two strings for equality. Case does not matter.

Returns
  The result of strcasecmp().

Parameters

  [in] | p | The the first string.
  [in] | q | The the second string.

References UpnpString_get_String().

## UpnpString_clear()

void UpnpString_clear | ( | UpnpString * | p | ) |

Clears the string, sets its size to zero.

Parameters

  [in] | p | The this pointer.

Referenced by gena_subscribe(), genaSubscribe(), GenlibClientSubscription_clear_ActualSID(), GenlibClientSubscription_clear_EventURL(), GenlibClientSubscription_clear_SID(), TestClass_clear_TheString(), UpnpActionComplete_clear_CtrlUrl(), UpnpActionRequest_clear_ActionName(), UpnpActionRequest_clear_DevUDN(), UpnpActionRequest_clear_ErrStr(), UpnpActionRequest_clear_Os(), UpnpActionRequest_clear_ServiceID(), UpnpDiscovery_clear_Date(), UpnpDiscovery_clear_DeviceID(), UpnpDiscovery_clear_DeviceType(), UpnpDiscovery_clear_Ext(), UpnpDiscovery_clear_Location(), UpnpDiscovery_clear_Os(), UpnpDiscovery_clear_ServiceType(), UpnpDiscovery_clear_ServiceVer(), UpnpEvent_clear_SID(), UpnpEventSubscribe_clear_PublisherUrl(), UpnpEventSubscribe_clear_SID(), UpnpExtraHeaders_clear_name(), UpnpExtraHeaders_clear_value(), UpnpFileInfo_clear_Os(), UpnpStateVarComplete_clear_CtrlUrl(), UpnpStateVarComplete_clear_StateVarName(), UpnpStateVarRequest_clear_DevUDN(), UpnpStateVarRequest_clear_ErrStr(), UpnpStateVarRequest_clear_ServiceID(), UpnpStateVarRequest_clear_StateVarName(), UpnpSubscriptionRequest_clear_ServiceId(), UpnpSubscriptionRequest_clear_SID(), and UpnpSubscriptionRequest_clear_UDN().

## UpnpString_cmp()

int UpnpString_cmp | ( | UpnpString * | p,
|  | UpnpString * | q
| ) |  |

Compares two strings for equality. Case matters.

Returns
  The result of strcmp().

Parameters

  [in] | p | The the first string.
  [in] | q | The the second string.

References UpnpString_get_String().

## UpnpString_delete()

void UpnpString_delete | ( | UpnpString * | p | ) |

Destructor.

Parameters

  [in] | p | The this pointer.

References SUpnpString::m_length, and SUpnpString::m_string.

Referenced by genaRenewSubscription(), genaSubscribe(), GenlibClientSubscription_delete(), TestClass_delete(), UpnpActionComplete_delete(), UpnpActionRequest_delete(), UpnpDiscovery_delete(), UpnpEvent_delete(), UpnpEventSubscribe_delete(), UpnpExtraHeaders_delete(), UpnpFileInfo_delete(), UpnpRenewSubscription(), UpnpStateVarComplete_delete(), UpnpStateVarRequest_delete(), UpnpSubscribe(), UpnpSubscriptionRequest_delete(), UpnpThreadDistribution(), and UpnpUnSubscribe().

## UpnpString_dup()

UpnpString * UpnpString_dup | ( | const UpnpString * | p | ) |

Copy Constructor.

Returns
  A pointer to a new allocated copy of the original object.

Parameters

  [in] | p | The this pointer.

References SUpnpString::m_length, and SUpnpString::m_string.

## UpnpString_get_Length()

size_t UpnpString_get_Length | ( | const UpnpString * | p | ) |

Returns the length of the string.

Returns
  The length of the string.

Parameters

  [in] | p | The this pointer.

Referenced by gena_subscribe(), gena_unsubscribe(), GenlibClientSubscription_get_ActualSID_Length(), GenlibClientSubscription_get_EventURL_Length(), GenlibClientSubscription_get_SID_Length(), handle_query_variable(), ssdp_handle_ctrlpt_msg(), TestClass_get_TheString_Length(), UpnpActionComplete_get_CtrlUrl_Length(), UpnpActionRequest_get_ActionName_Length(), UpnpActionRequest_get_DevUDN_Length(), UpnpActionRequest_get_ErrStr_Length(), UpnpActionRequest_get_Os_Length(), UpnpActionRequest_get_ServiceID_Length(), UpnpDiscovery_get_Date_Length(), UpnpDiscovery_get_DeviceID_Length(), UpnpDiscovery_get_DeviceType_Length(), UpnpDiscovery_get_Ext_Length(), UpnpDiscovery_get_Location_Length(), UpnpDiscovery_get_Os_Length(), UpnpDiscovery_get_ServiceType_Length(), UpnpDiscovery_get_ServiceVer_Length(), UpnpEvent_get_SID_Length(), UpnpEventSubscribe_get_PublisherUrl_Length(), UpnpEventSubscribe_get_SID_Length(), UpnpExtraHeaders_get_name_Length(), UpnpExtraHeaders_get_value_Length(), UpnpFileInfo_get_Os_Length(), UpnpStateVarComplete_get_CtrlUrl_Length(), UpnpStateVarComplete_get_StateVarName_Length(), UpnpStateVarRequest_get_DevUDN_Length(), UpnpStateVarRequest_get_ErrStr_Length(), UpnpStateVarRequest_get_ServiceID_Length(), UpnpStateVarRequest_get_StateVarName_Length(), UpnpSubscriptionRequest_get_ServiceId_Length(), UpnpSubscriptionRequest_get_SID_Length(), and UpnpSubscriptionRequest_get_UDN_Length().

## UpnpString_get_String()

const char * UpnpString_get_String | ( | const UpnpString * | p | ) |

Returns the pointer to char.

Returns
  The pointer to char.

Parameters

  [in] | p | The this pointer.

Referenced by gena_subscribe(), gena_unsubscribe(), GenlibClientSubscription_get_ActualSID_cstr(), GenlibClientSubscription_get_EventURL_cstr(), GenlibClientSubscription_get_SID_cstr(), GenlibClientSubscription_set_ActualSID(), GenlibClientSubscription_set_EventURL(), GenlibClientSubscription_set_SID(), GetClientSubClientSID(), RemoveClientSubClientSID(), SampleUtil_PrintEvent(), TestClass_get_TheString_cstr(), TestClass_set_TheString(), TvDeviceHandleActionRequest(), TvDeviceHandleGetVarRequest(), TvDeviceHandleSubscriptionRequest(), UpnpActionComplete_get_CtrlUrl_cstr(), UpnpActionComplete_set_CtrlUrl(), UpnpActionRequest_get_ActionName_cstr(), UpnpActionRequest_get_DevUDN_cstr(), UpnpActionRequest_get_ErrStr_cstr(), UpnpActionRequest_get_Os_cstr(), UpnpActionRequest_get_ServiceID_cstr(), UpnpActionRequest_set_ActionName(), UpnpActionRequest_set_DevUDN(), UpnpActionRequest_set_ErrStr(), UpnpActionRequest_set_Os(), UpnpActionRequest_set_ServiceID(), UpnpDiscovery_get_Date_cstr(), UpnpDiscovery_get_DeviceID_cstr(), UpnpDiscovery_get_DeviceType_cstr(), UpnpDiscovery_get_Ext_cstr(), UpnpDiscovery_get_Location_cstr(), UpnpDiscovery_get_Os_cstr(), UpnpDiscovery_get_ServiceType_cstr(), UpnpDiscovery_get_ServiceVer_cstr(), UpnpDiscovery_set_Date(), UpnpDiscovery_set_DeviceID(), UpnpDiscovery_set_DeviceType(), UpnpDiscovery_set_Ext(), UpnpDiscovery_set_Location(), UpnpDiscovery_set_Os(), UpnpDiscovery_set_ServiceType(), UpnpDiscovery_set_ServiceVer(), UpnpEvent_get_SID_cstr(), UpnpEvent_set_SID(), UpnpEventSubscribe_get_PublisherUrl_cstr(), UpnpEventSubscribe_get_SID_cstr(), UpnpEventSubscribe_set_PublisherUrl(), UpnpEventSubscribe_set_SID(), UpnpExtraHeaders_get_name_cstr(), UpnpExtraHeaders_get_value_cstr(), UpnpExtraHeaders_set_name(), UpnpExtraHeaders_set_value(), UpnpFileInfo_get_Os_cstr(), UpnpFileInfo_set_Os(), UpnpStateVarComplete_get_CtrlUrl_cstr(), UpnpStateVarComplete_get_StateVarName_cstr(), UpnpStateVarComplete_set_CtrlUrl(), UpnpStateVarComplete_set_StateVarName(), UpnpStateVarRequest_get_DevUDN_cstr(), UpnpStateVarRequest_get_ErrStr_cstr(), UpnpStateVarRequest_get_ServiceID_cstr(), UpnpStateVarRequest_get_StateVarName_cstr(), UpnpStateVarRequest_set_DevUDN(), UpnpStateVarRequest_set_ErrStr(), UpnpStateVarRequest_set_ServiceID(), UpnpStateVarRequest_set_StateVarName(), UpnpString_assign(), UpnpString_casecmp(), UpnpString_cmp(), UpnpSubscribe(), UpnpSubscriptionRequest_get_ServiceId_cstr(), UpnpSubscriptionRequest_get_SID_cstr(), UpnpSubscriptionRequest_get_UDN_cstr(), UpnpSubscriptionRequest_set_ServiceId(), UpnpSubscriptionRequest_set_SID(), and UpnpSubscriptionRequest_set_UDN().

## UpnpString_new()

UpnpString * UpnpString_new | ( | void |  | ) |

Constructor.

Returns
  A pointer to a new allocated object.

References SUpnpString::m_length, and SUpnpString::m_string.

Referenced by genaRenewSubscription(), genaSubscribe(), GenlibClientSubscription_new(), TestClass_new(), UpnpActionComplete_new(), UpnpActionRequest_new(), UpnpDiscovery_new(), UpnpEvent_new(), UpnpEventSubscribe_new(), UpnpExtraHeaders_new(), UpnpFileInfo_new(), UpnpRenewSubscription(), UpnpStateVarComplete_new(), UpnpStateVarRequest_new(), UpnpSubscribe(), UpnpSubscriptionRequest_new(), UpnpThreadDistribution(), and UpnpUnSubscribe().

## UpnpString_set_Length()

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 equal to the requested length.

Parameters

  [in] | p | The this pointer.
  [in] | n | The requested length.

References SUpnpString::m_length.

## UpnpString_set_String()

int UpnpString_set_String | ( | UpnpString * | p,
|  | const char * | s
| ) |  |

Sets the string from a pointer to char.

Parameters

  [in] | p | The this pointer.
  [in] | s | (char *) to copy from.

References SUpnpString::m_string.

Referenced by genaSubscribe(), GenlibClientSubscription_set_ActualSID(), GenlibClientSubscription_set_EventURL(), GenlibClientSubscription_set_SID(), GenlibClientSubscription_strcpy_ActualSID(), GenlibClientSubscription_strcpy_EventURL(), GenlibClientSubscription_strcpy_SID(), TestClass_set_TheString(), TestClass_strcpy_TheString(), UpnpActionComplete_set_CtrlUrl(), UpnpActionComplete_strcpy_CtrlUrl(), UpnpActionRequest_set_ActionName(), UpnpActionRequest_set_DevUDN(), UpnpActionRequest_set_ErrStr(), UpnpActionRequest_set_Os(), UpnpActionRequest_set_ServiceID(), UpnpActionRequest_strcpy_ActionName(), UpnpActionRequest_strcpy_DevUDN(), UpnpActionRequest_strcpy_ErrStr(), UpnpActionRequest_strcpy_Os(), UpnpActionRequest_strcpy_ServiceID(), UpnpDiscovery_set_Date(), UpnpDiscovery_set_DeviceID(), UpnpDiscovery_set_DeviceType(), UpnpDiscovery_set_Ext(), UpnpDiscovery_set_Location(), UpnpDiscovery_set_Os(), UpnpDiscovery_set_ServiceType(), UpnpDiscovery_set_ServiceVer(), UpnpDiscovery_strcpy_Date(), UpnpDiscovery_strcpy_DeviceID(), UpnpDiscovery_strcpy_DeviceType(), UpnpDiscovery_strcpy_Ext(), UpnpDiscovery_strcpy_Location(), UpnpDiscovery_strcpy_Os(), UpnpDiscovery_strcpy_ServiceType(), UpnpDiscovery_strcpy_ServiceVer(), UpnpEvent_set_SID(), UpnpEvent_strcpy_SID(), UpnpEventSubscribe_set_PublisherUrl(), UpnpEventSubscribe_set_SID(), UpnpEventSubscribe_strcpy_PublisherUrl(), UpnpEventSubscribe_strcpy_SID(), UpnpExtraHeaders_set_name(), UpnpExtraHeaders_set_value(), UpnpExtraHeaders_strcpy_name(), UpnpExtraHeaders_strcpy_value(), UpnpFileInfo_set_Os(), UpnpFileInfo_strcpy_Os(), UpnpRenewSubscription(), UpnpStateVarComplete_set_CtrlUrl(), UpnpStateVarComplete_set_StateVarName(), UpnpStateVarComplete_strcpy_CtrlUrl(), UpnpStateVarComplete_strcpy_StateVarName(), UpnpStateVarRequest_set_DevUDN(), UpnpStateVarRequest_set_ErrStr(), UpnpStateVarRequest_set_ServiceID(), UpnpStateVarRequest_set_StateVarName(), UpnpStateVarRequest_strcpy_DevUDN(), UpnpStateVarRequest_strcpy_ErrStr(), UpnpStateVarRequest_strcpy_ServiceID(), UpnpStateVarRequest_strcpy_StateVarName(), UpnpString_assign(), UpnpSubscribe(), UpnpSubscriptionRequest_set_ServiceId(), UpnpSubscriptionRequest_set_SID(), UpnpSubscriptionRequest_set_UDN(), UpnpSubscriptionRequest_strcpy_ServiceId(), UpnpSubscriptionRequest_strcpy_SID(), UpnpSubscriptionRequest_strcpy_UDN(), and UpnpUnSubscribe().

## UpnpString_set_StringN()

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.

Parameters

  [in] | p | The this pointer.
  [in] | s | (char *) to copy from.
  | n | Maximum number of chars to copy.

References SUpnpString::m_string.

Referenced by gena_subscribe(), GenlibClientSubscription_strncpy_ActualSID(), GenlibClientSubscription_strncpy_EventURL(), GenlibClientSubscription_strncpy_SID(), TestClass_strncpy_TheString(), UpnpActionComplete_strncpy_CtrlUrl(), UpnpActionRequest_strncpy_ActionName(), UpnpActionRequest_strncpy_DevUDN(), UpnpActionRequest_strncpy_ErrStr(), UpnpActionRequest_strncpy_Os(), UpnpActionRequest_strncpy_ServiceID(), UpnpDiscovery_strncpy_Date(), UpnpDiscovery_strncpy_DeviceID(), UpnpDiscovery_strncpy_DeviceType(), UpnpDiscovery_strncpy_Ext(), UpnpDiscovery_strncpy_Location(), UpnpDiscovery_strncpy_Os(), UpnpDiscovery_strncpy_ServiceType(), UpnpDiscovery_strncpy_ServiceVer(), UpnpEvent_strncpy_SID(), UpnpEventSubscribe_strncpy_PublisherUrl(), UpnpEventSubscribe_strncpy_SID(), UpnpExtraHeaders_strncpy_name(), UpnpExtraHeaders_strncpy_value(), UpnpFileInfo_strncpy_Os(), UpnpStateVarComplete_strncpy_CtrlUrl(), UpnpStateVarComplete_strncpy_StateVarName(), UpnpStateVarRequest_strncpy_DevUDN(), UpnpStateVarRequest_strncpy_ErrStr(), UpnpStateVarRequest_strncpy_ServiceID(), UpnpStateVarRequest_strncpy_StateVarName(), UpnpSubscriptionRequest_strncpy_ServiceId(), UpnpSubscriptionRequest_strncpy_SID(), and UpnpSubscriptionRequest_strncpy_UDN().

## Variable Documentation

## m_length

size_t SUpnpString::m_length

Length of the string.

Referenced by UpnpString_delete(), UpnpString_dup(), UpnpString_new(), and UpnpString_set_Length().

## m_string

char* SUpnpString::m_string

Pointer to a dynamically allocated area that holds the NULL terminated string.

Referenced by UpnpString_delete(), UpnpString_dup(), UpnpString_new(), UpnpString_set_String(), and UpnpString_set_StringN().