service_table.h
Go to the documentation of this file.
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef SERVICE_TABLE_H
#define SERVICE_TABLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include "uri.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include <stdio.h>
#include <time.h>
#define SID_SIZE 41
#ifdef INCLUDE_DEVICE_APIS
typedef struct SUBSCRIPTION {
Upnp_SID sid;
int eventKey;
int ToSendEventKey;
time_t expireTime;
int active;
URL_list DeliveryURLs;
struct SUBSCRIPTION *next;
} subscription;
typedef struct SERVICE_INFO {
DOMString serviceType;
DOMString serviceId;
char *SCPDURL ;
char *controlURL;
char *eventURL;
DOMString UDN;
int active;
int TotalSubscriptions;
subscription *subscriptionList;
struct SERVICE_INFO *next;
} service_info;
typedef struct SERVICE_TABLE {
DOMString URLBase;
service_info *serviceList;
service_info *endServiceList;
} service_table;
/* Functions for Subscriptions */
int copy_subscription(
subscription *in,
subscription *out);
/*
* \brief Remove the subscription represented by the const Upnp_SID sid parameter
* from the service table and update the service table.
*/
void RemoveSubscriptionSID(
Upnp_SID sid,
service_info *service);
subscription *GetSubscriptionSID(
const Upnp_SID sid,
service_info *service);
subscription *GetFirstSubscription(
service_info *service);
subscription *GetNextSubscription(
service_info *service,
subscription *current);
void freeSubscription(
subscription *sub);
void freeSubscriptionList(
subscription * head);
service_info *FindServiceId(
service_table *table,
const char *serviceId,
const char *UDN);
service_info *FindServiceEventURLPath(
service_table *table,
char *eventURLPath);
service_info * FindServiceControlURLPath(
service_table *table,
const char *controlURLPath);
#ifdef DEBUG
void printService(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module);
#else
static UPNP_INLINE void printService(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module) {}
#endif
#ifdef DEBUG
void printServiceList(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module);
#else
static UPNP_INLINE void printServiceList(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module) {}
#endif
#ifdef DEBUG
void printServiceTable(
service_table *table,
Upnp_LogLevel level,
Dbg_Module module);
#else
static UPNP_INLINE void printServiceTable(
service_table *table,
Upnp_LogLevel level,
Dbg_Module module) {}
#endif
void freeService(
service_info *in);
void freeServiceList(
service_info *head);
void freeServiceTable(
service_table *table);
int removeServiceTable(
IXML_Node *node,
service_table *in);
int addServiceTable(
IXML_Node *node,
service_table *in,
const char *DefaultURLBase);
int getServiceTable(
IXML_Node *node,
service_table *out,
const char *DefaultURLBase);
/* Misc helper functions */
DOMString getElementValue(
IXML_Node *node);
int getSubElement(
const char *element_name,
IXML_Node *node,
IXML_Node **out);
#endif /* INCLUDE_DEVICE_APIS */
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_TABLE */