service_table.h File Reference
`#include "LinkedList.h"`
`#include "config.h"`
`#include "ixml.h"`
`#include "upnp.h"`
`#include "upnpdebug.h"`
`#include "uri.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

## Macros

#define | SID_SIZE (size_t)41

## Typedefs

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

## Functions

void | freeSubscriptionQueuedEvents (subscription *sub)
int | copy_subscription (subscription *in, subscription *out)
| Makes a copy of the subscription.
void | RemoveSubscriptionSID (Upnp_SID sid, service_info *service)
subscription * | GetSubscriptionSID (const Upnp_SID sid, service_info *service)
| Return the subscription from the service table that matches const Upnp_SID sid value.
subscription * | GetFirstSubscription (service_info *service)
| Gets pointer to the first subscription node in the service table.
subscription * | GetNextSubscription (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_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.
service_info * | FindServiceEventURLPath (service_table *table, const char *eventURLPath)
| Traverses the service table and finds the node whose event URL Path matches a know value.
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.
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.

## Function Documentation

## addServiceTable()

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

Add Service to the table.

Parameters

  [in] | node | XML node information.
  [in] | in | Service table that will be initialized with services.
  [in] | DefaultURLBase | Default base URL on which the URL will be returned to the service list.

References ixmlCloneDOMString().

## copy_subscription()

int copy_subscription | ( | subscription * | in,
|  | subscription * | out
| ) |  |

Makes a copy of the subscription.

Returns
  HTTP_SUCCESS on success.

Parameters

  [in] | in | Source subscription.
  [in] | out | Destination subscription.

References copy_URL_list().

## FindServiceControlURLPath()

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] | table | Service table.
  [in] | controlURLPath | Control URL path used to find a service from the table.

References parse_uri(), and token_cmp().

## FindServiceEventURLPath()

service_info * FindServiceEventURLPath | ( | service_table * | table,
|  | const 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] | table | Service table.
  [in] | eventURLPath | Event URL path used to find a service from the table.

References parse_uri(), and token_cmp().

## FindServiceId()

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] | table | Service table.
  [in] | serviceId | String representing the service id to be found among those in the table.
  [in] | UDN | String representing the UDN to be found among those in the table.

## freeService()

void freeService | ( | service_info * | in | ) |

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

Parameters

  [in] | in | Service information that is to be freed.

References ixmlFreeDOMString().

## freeServiceList()

void freeServiceList | ( | service_info * | head | ) |

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

Parameters

  [in] | head | Head of the service list to be freed.

References ixmlFreeDOMString().

## freeServiceTable()

void freeServiceTable | ( | service_table * | table | ) |

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

Parameters

  [in] | table | Service table whose internal memory needs to be freed.

References ixmlFreeDOMString().

## freeSubscription()

void freeSubscription | ( | subscription * | sub | ) |

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

Parameters

  [in] | sub | Subscription object to be freed.

References free_URL_list().

## freeSubscriptionList()

void freeSubscriptionList | ( | subscription * | head | ) |

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

Parameters

  [in] | head | Head of the subscription list.

## getElementValue()

DOMString getElementValue | ( | IXML_Node * | node | ) |

Returns the clone of the element value.

Note
  Value must be freed with DOMString_free.

Returns
  DOMString

Parameters

  [in] | node | Input node which provides the list of child nodes.

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

## GetFirstSubscription()

subscription * GetFirstSubscription | ( | service_info * | service | ) |

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

Returns
  Pointer to the first subscription node.

Parameters

  [in] | service | Service object providing the list of subscriptions.

## GetNextSubscription()

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] | service | Service object providing the list of subscriptions.
  [in] | current | Current subscription object.

## getServiceTable()

int getServiceTable | ( | IXML_Node * | node,
|  | service_table * | out,
|  | const char * | DefaultURLBase
| ) |  |

Retrieve service from the table.

Returns
  An integer

Parameters

  [in] | node | XML node information.
  [in] | out | Output parameter which will contain the service list and URL.
  [in] | DefaultURLBase | Default base URL on which the URL will be returned.

References ixmlCloneDOMString().

## getSubElement()

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_name | Sub element name to be searched for.
  [in] | node | Input node which provides the list of child nodes.
  [out] | out | Ouput node to which the matched child node is returned.

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

## GetSubscriptionSID()

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] | sid | Subscription ID.
  [in] | service | Service object providing the list of subscriptions.

## printService()

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] | service | Service whose information is to be printed.
  [in] | level | Debug level specified to the print function.
  [in] | module | Debug module specified to the print function.

References UpnpPrintf().

## printServiceList()

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] | service | Service whose information is to be printed.
  [in] | level | Debug level specified to the print function.
  [in] | module | Debug module specified to the print function.

References UpnpPrintf().

## printServiceTable()

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] | table | Service table to be printed.
  [in] | level | Debug level specified to the print function.
  [in] | module | Debug module specified to the print function.

References UpnpPrintf().

## removeServiceTable()

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] | node | XML node information.
  [in] | in | Service table from which services will be removed.

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

## RemoveSubscriptionSID()

void RemoveSubscriptionSID | ( | Upnp_SID | sid,
|  | service_info * | service
| ) |  |

Parameters

  [in] | sid | Subscription ID.
  [in] | service | Service object providing the list of subscriptions.