libUPnP  1.6.17
Data Structures | Defines | Typedefs | Functions
service_table.h File Reference
#include "config.h"
#include "uri.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include <stdio.h>
#include <time.h>
Include dependency graph for service_table.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SUBSCRIPTION
struct  SERVICE_INFO
struct  SERVICE_TABLE

Defines

#define SID_SIZE   (size_t)41

Typedefs

typedef struct SUBSCRIPTION subscription
typedef struct SERVICE_INFO service_info
typedef struct SERVICE_TABLE service_table

Functions

int copy_subscription (subscription *in, subscription *out)
 Makes a copy of the subscription.
void RemoveSubscriptionSID (Upnp_SID sid, service_info *service)
subscriptionGetSubscriptionSID (const Upnp_SID sid, service_info *service)
 Return the subscription from the service table that matches const Upnp_SID sid value.
subscriptionGetFirstSubscription (service_info *service)
 Gets pointer to the first subscription node in the service table.
subscriptionGetNextSubscription (service_info *service, subscription *current)
 Get current and valid subscription from the service table.
void freeSubscription (subscription *sub)
 Free's the memory allocated for storing the URL of the subscription.
void freeSubscriptionList (subscription *head)
 Free's memory allocated for all the subscriptions in the service table.
service_infoFindServiceId (service_table *table, const char *serviceId, const char *UDN)
 Traverses through the service table and returns a pointer to the service node that matches a known service id and a known UDN.
service_infoFindServiceEventURLPath (service_table *table, char *eventURLPath)
 Traverses the service table and finds the node whose event URL Path matches a know value.
service_infoFindServiceControlURLPath (service_table *table, const char *controlURLPath)
 Traverses the service table and finds the node whose control URL Path matches a know value.
void printService (service_info *service, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints information from the service passed into the function.
void printServiceList (service_info *service, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints information of each service from the service table passed into the function.
void printServiceTable (service_table *table, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints the URL base of the table and information of each service from the service table passed into the function.
void freeService (service_info *in)
 Free's memory allocated for the various components of the service entry in the service table.
void freeServiceList (service_info *head)
 Free's memory allocated for the various components of each service entry in the service table.
void freeServiceTable (service_table *table)
 Free's dynamic memory in table (does not free table, only memory within the structure).
int removeServiceTable (IXML_Node *node, service_table *in)
 This function assumes that services for a particular root device are placed linearly in the service table, and in the order in which they are found in the description document all services for this root device are removed from the list.
int addServiceTable (IXML_Node *node, service_table *in, const char *DefaultURLBase)
 Add Service to the table.
int getServiceTable (IXML_Node *node, service_table *out, const char *DefaultURLBase)
 Retrieve service from the table.
DOMString getElementValue (IXML_Node *node)
 Returns the clone of the element value.
int getSubElement (const char *element_name, IXML_Node *node, IXML_Node **out)
 Traverses through a list of XML nodes to find the node with the known element name.

Detailed Description


Function Documentation

int addServiceTable ( IXML_Node node,
service_table in,
const char *  DefaultURLBase 
)

Add Service to the table.

Parameters:
[in]nodeXML node information.
[in]inService table that will be initialized with services.
[in]DefaultURLBaseDefault base URL on which the URL will be returned to the service list.

References ixmlCloneDOMString().

int copy_subscription ( subscription in,
subscription out 
)

Makes a copy of the subscription.

Returns:
HTTP_SUCCESS on success.
Parameters:
[in]inSource subscription.
[in]outDestination subscription.

References copy_URL_list().

service_info* FindServiceControlURLPath ( service_table table,
const char *  controlURLPath 
)

Traverses the service table and finds the node whose control URL Path matches a know value.

Returns:
Pointer to the service list node from the service table whose control URL Path matches a known value.
Parameters:
[in]tableService table.
[in]controlURLPathControl URL path used to find a service from the table.

References parse_uri(), and token_cmp().

service_info* FindServiceEventURLPath ( service_table table,
char *  eventURLPath 
)

Traverses the service table and finds the node whose event URL Path matches a know value.

Returns:
Pointer to the service list node from the service table whose event URL matches a known event URL.
Parameters:
[in]tableService table.
[in]eventURLPathEvent URL path used to find a service from the table.

References parse_uri(), and token_cmp().

service_info* FindServiceId ( service_table table,
const char *  serviceId,
const char *  UDN 
)

Traverses through the service table and returns a pointer to the service node that matches a known service id and a known UDN.

Returns:
Pointer to the matching service_info node.
Parameters:
[in]tableService table.
[in]serviceIdString representing the service id to be found among those in the table.
[in]UDNString representing the UDN to be found among those in the table.
void freeService ( service_info in)

Free's memory allocated for the various components of the service entry in the service table.

Parameters:
[in]inService information that is to be freed.

References ixmlFreeDOMString().

void freeServiceList ( service_info head)

Free's memory allocated for the various components of each service entry in the service table.

Parameters:
[in]headHead of the service list to be freed.

References ixmlFreeDOMString().

void freeServiceTable ( service_table table)

Free's dynamic memory in table (does not free table, only memory within the structure).

Parameters:
[in]tableService table whose internal memory needs to be freed.

References ixmlFreeDOMString().

void freeSubscription ( subscription sub)

Free's the memory allocated for storing the URL of the subscription.

Parameters:
[in]subSubscription object to be freed.

References free_URL_list().

Free's memory allocated for all the subscriptions in the service table.

Parameters:
[in]headHead of the subscription list.

Returns the clone of the element value.

Note:
Value must be freed with DOMString_free.
Returns:
DOMString
Parameters:
[in]nodeInput node which provides the list of child nodes.

References DOMString, ixmlCloneDOMString(), ixmlNode_getFirstChild(), ixmlNode_getNodeType(), and ixmlNode_getNodeValue().

Gets pointer to the first subscription node in the service table.

Returns:
Pointer to the first subscription node.
Parameters:
[in]serviceService object providing the list of subscriptions.
subscription* GetNextSubscription ( service_info service,
subscription current 
)

Get current and valid subscription from the service table.

Returns:
Pointer to the next subscription node.
Parameters:
[in]serviceService object providing the list of subscriptions.
[in]currentCurrent subscription object.
int getServiceTable ( IXML_Node node,
service_table out,
const char *  DefaultURLBase 
)

Retrieve service from the table.

Returns:
An integer
Parameters:
[in]nodeXML node information.
[in]outOutput parameter which will contain the service list and URL.
[in]DefaultURLBaseDefault base URL on which the URL will be returned.

References ixmlCloneDOMString().

int getSubElement ( const char *  element_name,
IXML_Node node,
IXML_Node **  out 
)

Traverses through a list of XML nodes to find the node with the known element name.

Returns:
  • 1 - On Success
  • 0 - On Failure
Parameters:
[in]element_nameSub element name to be searched for.
[in]nodeInput node which provides the list of child nodes.
[out]outOuput node to which the matched child node is returned.

References DOMString, ixmlNode_getFirstChild(), ixmlNode_getNextSibling(), ixmlNode_getNodeName(), and ixmlNode_getNodeType().

subscription* GetSubscriptionSID ( const Upnp_SID  sid,
service_info service 
)

Return the subscription from the service table that matches const Upnp_SID sid value.

Returns:
Pointer to the matching subscription node.
Parameters:
[in]sidSubscription ID.
[in]serviceService object providing the list of subscriptions.
void printService ( service_info service,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints information from the service passed into the function.

Parameters:
[in]serviceService whose information is to be printed.
[in]levelDebug level specified to the print function.
[in]moduleDebug module specified to the print function.

References UpnpPrintf().

void printServiceList ( service_info service,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints information of each service from the service table passed into the function.

Parameters:
[in]serviceService whose information is to be printed.
[in]levelDebug level specified to the print function.
[in]moduleDebug module specified to the print function.

References UpnpPrintf().

void printServiceTable ( service_table table,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints the URL base of the table and information of each service from the service table passed into the function.

Parameters:
[in]tableService table to be printed.
[in]levelDebug level specified to the print function.
[in]moduleDebug module specified to the print function.

References UpnpPrintf().

int removeServiceTable ( IXML_Node node,
service_table in 
)

This function assumes that services for a particular root device are placed linearly in the service table, and in the order in which they are found in the description document all services for this root device are removed from the list.

Returns:
An integer.
Parameters:
[in]nodeXML node information.
[in]inService table from which services will be removed.

References DOMString, ixmlElement_getElementsByTagName(), ixmlFreeDOMString(), ixmlNodeList_free(), and ixmlNodeList_length().

void RemoveSubscriptionSID ( Upnp_SID  sid,
service_info service 
)
Parameters:
[in]sidSubscription ID.
[in]serviceService object providing the list of subscriptions.