sample_util.h File Reference
Sample Code
`#include "config_sample.h"`
`#include "ithread.h"`
`#include "ixml.h"`
`#include "upnp.h"`
`#include "upnptools.h"`
`#include <stdlib.h>`
`#include <string.h>`
Include dependency graph for sample_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Typedefs

typedef void(* | print_string) (const char *string,...)
| Prototype for displaying strings. All printing done by the device, control point, and sample util, ultimately use this to display strings to the user.
typedef void(* | state_update) (const char *varName, const char *varValue, const char *UDN, eventType type)
| Prototype for passing back state changes.

## Enumerations

enum | eventType { STATE_UPDATE = 0 , DEVICE_ADDED = 1 , DEVICE_REMOVED = 2 , GET_VAR_COMPLETE = 3 }

## Functions

char * | SampleUtil_GetElementValue ( IXML_Element *element)
| Given a DOM node such as <Channel>11</Channel>, this routine extracts the value (e.g., 11) from the node and returns it as a string. The string must be freed by the caller using free.
IXML_NodeList * | SampleUtil_GetFirstServiceList ( IXML_Document *doc)
| Given a DOM node representing a UPnP Device Description Document, this routine parses the document and finds the first service list (i.e., the service list for the root device). The service list is returned as a DOM node list. The NodeList must be freed using NodeList_free.
char * | SampleUtil_GetFirstDocumentItem ( IXML_Document *doc, const char *item)
| Given a document node, this routine searches for the first element named by the input string item, and returns its value as a string. String must be freed by caller using free.
char * | SampleUtil_GetFirstElementItem ( IXML_Element *element, const char *item)
| Given a DOM element, this routine searches for the first element named by the input string item, and returns its value as a string. The string must be freed using free.
void | SampleUtil_PrintEventType ( Upnp_EventType S)
| Prints a callback event type as a string.
int | SampleUtil_PrintEvent ( Upnp_EventType EventType, const void *Event)
| Prints callback event structure details.
int | SampleUtil_FindAndParseService ( IXML_Document *DescDoc, const char *location, const char *serviceType, char **serviceId, char **eventURL, char **controlURL)
| This routine finds the first occurance of a service in a DOM representation of a description document and parses it. Note that this function currently assumes that the eventURL and controlURL values in the service definitions are full URLs. Relative URLs are not handled here.
int | SampleUtil_Initialize ( print_string print_function)
| Initializes the sample util. Must be called before any sample util functions. May be called multiple times.
int | SampleUtil_Finish ()
| Releases Resources held by sample util.
int | SampleUtil_Print ( const char *fmt, ...)
| Function emulating printf that ultimately calls the registered print function with the formatted string.
int | SampleUtil_RegisterUpdateFunction ( state_update update_function)
void | SampleUtil_StateUpdate ( const char *varName, const char *varValue, const char *UDN, eventType type)
void | linux_print (const char *format,...)
| Prints a string to standard out.

## Variables

const char * | TvServiceType []
ithread_mutex_t | display_mutex
print_string | gPrintFun
state_update | gStateUpdateFun