Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@431 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
2
Doxyfile
2
Doxyfile
@@ -1029,7 +1029,7 @@ INCLUDE_FILE_PATTERNS =
|
|||||||
# undefined via #undef or recursively expanded use the := operator
|
# undefined via #undef or recursively expanded use the := operator
|
||||||
# instead of the = operator.
|
# instead of the = operator.
|
||||||
|
|
||||||
PREDEFINED = DEBUG INCLUDE_DEVICE_APIS INCLUDE_CLIENT_APIS EXCLUDE_GENA=0 EXCLUDE_DOM=0
|
PREDEFINED = DEBUG UPNP_HAVE_TOOLS INCLUDE_DEVICE_APIS INCLUDE_CLIENT_APIS EXCLUDE_GENA=0 EXCLUDE_DOM=0
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
|
||||||
# this tag can be used to specify a list of macro names that should be expanded.
|
# this tag can be used to specify a list of macro names that should be expanded.
|
||||||
|
|||||||
@@ -1,41 +1,51 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
|
|
||||||
|
|
||||||
#include "FreeList.h"
|
#include "FreeList.h"
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: DiffMillis
|
* Function: DiffMillis
|
||||||
*
|
*
|
||||||
@@ -1506,6 +1516,7 @@ int TPAttrSetMaxJobsTotal( ThreadPoolAttr *attr, int maxJobsTotal )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef STATS
|
#ifdef STATS
|
||||||
void ThreadPoolPrintStats(ThreadPoolStats *stats)
|
void ThreadPoolPrintStats(ThreadPoolStats *stats)
|
||||||
{
|
{
|
||||||
@@ -1535,6 +1546,7 @@ void ThreadPoolPrintStats(ThreadPoolStats *stats)
|
|||||||
}
|
}
|
||||||
#endif /* STATS */
|
#endif /* STATS */
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: ThreadPoolGetStats
|
* Function: ThreadPoolGetStats
|
||||||
*
|
*
|
||||||
@@ -1597,6 +1609,7 @@ int ThreadPoolGetStats( ThreadPool *tp, ThreadPoolStats *stats )
|
|||||||
|
|
||||||
#endif /* STATS */
|
#endif /* STATS */
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||||
@@ -1639,3 +1652,4 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file
|
* \file
|
||||||
*
|
*
|
||||||
* \brief The purpose of this file is to define constants that for some reason
|
* \brief Defines constants that for some reason are not defined on some systems.
|
||||||
* might not be defined on every system.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "upnp.h"
|
#include "ixml.h" /* for IXML_Document */
|
||||||
|
|
||||||
|
|
||||||
/* Function declarations only if tools compiled into the library */
|
/* Function declarations only if tools compiled into the library */
|
||||||
#if UPNP_HAVE_TOOLS
|
#if UPNP_HAVE_TOOLS
|
||||||
|
|||||||
@@ -39,15 +39,17 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "ithread.h"
|
#include "ithread.h"
|
||||||
#include "ixml.h"
|
#include "ixml.h" /* for IXML_Document, IXML_Element */
|
||||||
|
#include "upnp.h" /* for Upnp_EventType */
|
||||||
#include "upnptools.h"
|
#include "upnptools.h"
|
||||||
|
|
||||||
|
|
||||||
// mutex to control displaying of events
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* mutex to control displaying of events */
|
||||||
extern ithread_mutex_t display_mutex;
|
extern ithread_mutex_t display_mutex;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,10 @@
|
|||||||
#include "upnp_tv_ctrlpt.h"
|
#include "upnp_tv_ctrlpt.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
#include "upnp.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
Mutex for protecting the global device list
|
Mutex for protecting the global device list
|
||||||
in a multi-threaded, asynchronous environment.
|
in a multi-threaded, asynchronous environment.
|
||||||
All functions should lock this mutex before reading
|
All functions should lock this mutex before reading
|
||||||
@@ -50,7 +53,7 @@ char *TvServiceType[] = {
|
|||||||
};
|
};
|
||||||
char *TvServiceName[] = { "Control", "Picture" };
|
char *TvServiceName[] = { "Control", "Picture" };
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
Global arrays for storing variable names and counts for
|
Global arrays for storing variable names and counts for
|
||||||
TvControl and TvPicture services
|
TvControl and TvPicture services
|
||||||
*/
|
*/
|
||||||
@@ -61,12 +64,12 @@ char *TvVarName[TV_SERVICE_SERVCOUNT][TV_MAXVARS] = {
|
|||||||
char TvVarCount[TV_SERVICE_SERVCOUNT] =
|
char TvVarCount[TV_SERVICE_SERVCOUNT] =
|
||||||
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
|
{ TV_CONTROL_VARCOUNT, TV_PICTURE_VARCOUNT };
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
Timeout to request during subscriptions
|
Timeout to request during subscriptions
|
||||||
*/
|
*/
|
||||||
int default_timeout = 1801;
|
int default_timeout = 1801;
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
The first node in the global device list, or NULL if empty
|
The first node in the global device list, or NULL if empty
|
||||||
*/
|
*/
|
||||||
struct TvDeviceNode *GlobalDeviceList = NULL;
|
struct TvDeviceNode *GlobalDeviceList = NULL;
|
||||||
|
|||||||
@@ -41,14 +41,17 @@
|
|||||||
#if EXCLUDE_DOM == 0
|
#if EXCLUDE_DOM == 0
|
||||||
|
|
||||||
|
|
||||||
|
#include "upnp.h"
|
||||||
|
#include "upnptools.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "uri.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#include "upnptools.h"
|
|
||||||
#include "uri.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*! Maximum action header buffer length. */
|
/*! Maximum action header buffer length. */
|
||||||
#define HEADER_LENGTH 2000
|
#define HEADER_LENGTH 2000
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,11 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*!
|
||||||
* Purpose: This file contains functions for uri, url parsing utility.
|
* \file
|
||||||
******************************************************************************/
|
*
|
||||||
|
* \brief Contains functions for uri, url parsing utility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
@@ -44,179 +46,139 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
|
|
||||||
#include "upnpapi.h"
|
#include "upnpapi.h"
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : is_reserved
|
* \brief Returns a 1 if a char is a RESERVED char as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return 1 if char is a RESERVED char.
|
||||||
* char in ; char to be matched for RESERVED characters
|
*/
|
||||||
*
|
static int is_reserved(
|
||||||
* Description : Returns a 1 if a char is a RESERVED char as defined in
|
/*! [in] Char to be matched for RESERVED characters. */
|
||||||
* http://www.ietf.org/rfc/rfc2396.txt RFC explaining URIs)
|
char in)
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
is_reserved( char in )
|
|
||||||
{
|
{
|
||||||
if( strchr( RESERVED, in ) )
|
if (strchr(RESERVED, in)) {
|
||||||
return 1;
|
return 1;
|
||||||
else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : is_mark
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char in ; character to be matched for MARKED characters
|
|
||||||
*
|
|
||||||
* Description : Returns a 1 if a char is a MARK char as defined in
|
|
||||||
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
is_mark( char in )
|
|
||||||
{
|
|
||||||
if( strchr( MARK, in ) )
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : is_unreserved
|
/*!
|
||||||
|
* \brief Returns a 1 if a char is a MARK char as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return 1 if char is a MARKED char.
|
||||||
* char in ; character to be matched for UNRESERVED characters
|
*/
|
||||||
*
|
int is_mark(
|
||||||
* Description : Returns a 1 if a char is an unreserved char as defined in
|
/*! [in] Char to be matched for MARKED characters. */
|
||||||
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
char in)
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
is_unreserved( char in )
|
|
||||||
{
|
{
|
||||||
if( isalnum( in ) || ( is_mark( in ) ) )
|
if (strchr(MARK, in)) {
|
||||||
return 1;
|
return 1;
|
||||||
else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : is_escaped
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char * in ; character to be matched for ESCAPED characters
|
|
||||||
*
|
|
||||||
* Description : Returns a 1 if a char[3] sequence is escaped as defined
|
|
||||||
* in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
|
||||||
* size of array is NOT checked (MUST be checked by caller)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
is_escaped( const char *in )
|
|
||||||
{
|
|
||||||
|
|
||||||
if( ( in[0] == '%' ) && ( isxdigit( in[1] ) ) && isxdigit( in[2] ) ) {
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : replace_escaped
|
/*!
|
||||||
|
* \brief Returns a 1 if a char is an UNRESERVED char as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return 1 if char is a UNRESERVED char.
|
||||||
* char * in ; string of characters
|
*/
|
||||||
* int index ; index at which to start checking the characters
|
int is_unreserved(
|
||||||
* int *max ;
|
/*! [in] Char to be matched for UNRESERVED characters. */
|
||||||
|
char in)
|
||||||
|
{
|
||||||
|
if (isalnum(in) || is_mark(in)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns a 1 if a char[3] sequence is ESCAPED as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Description : Replaces an escaped sequence with its unescaped version
|
* Size of array is NOT checked (MUST be checked by caller).
|
||||||
* as in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
|
||||||
* Size of array is NOT checked (MUST be checked by caller)
|
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* \return 1 if char is a ESCAPED char.
|
||||||
*
|
*/
|
||||||
* Note : This function modifies the string. If the sequence is an
|
int is_escaped(
|
||||||
* escaped sequence it is replaced, the other characters in the
|
/*! [in] Char sequence to be matched for ESCAPED characters. */
|
||||||
* string are shifted over, and NULL characters are placed at the
|
const char *in)
|
||||||
* end of the string.
|
{
|
||||||
************************************************************************/
|
if (in[0] == '%' && isxdigit(in[1]) && isxdigit(in[2])) {
|
||||||
int
|
return 1;
|
||||||
replace_escaped( char *in,
|
} else {
|
||||||
int index,
|
return 0;
|
||||||
size_t *max )
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int replace_escaped(char *in, int index, size_t *max)
|
||||||
{
|
{
|
||||||
int tempInt = 0;
|
int tempInt = 0;
|
||||||
char tempChar = 0;
|
char tempChar = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
if( ( in[index] == '%' ) && ( isxdigit( in[index + 1] ) )
|
if (in[index] == '%' && isxdigit(in[index + 1]) && isxdigit(in[index + 2])) {
|
||||||
&& isxdigit( in[index + 2] ) ) {
|
/* Note the "%2x", makes sure that we convert a maximum of two
|
||||||
//Note the "%2x", makes sure that we convert a maximum of two
|
* characters. */
|
||||||
//characters.
|
if (sscanf(&in[index + 1], "%2x", &tempInt) != 1) {
|
||||||
if( sscanf( &in[index + 1], "%2x", &tempInt ) != 1 )
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
tempChar = ( char )tempInt;
|
tempChar = ( char )tempInt;
|
||||||
|
for (i = index + 3, j = index; j < *max; i++, j++) {
|
||||||
for( i = index + 3, j = index; j < ( *max ); i++, j++ ) {
|
|
||||||
in[j] = tempChar;
|
in[j] = tempChar;
|
||||||
if( i < ( *max ) )
|
if (i < *max) {
|
||||||
tempChar = in[i];
|
tempChar = in[i];
|
||||||
else
|
} else {
|
||||||
tempChar = 0;
|
tempChar = 0;
|
||||||
}
|
}
|
||||||
( *max ) -= 2;
|
}
|
||||||
|
*max -= 2;
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_uric
|
/*!
|
||||||
|
* \brief Parses a string of uric characters starting at in[0] as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* char *in ; string of characters
|
*/
|
||||||
* int max ; maximum limit
|
static int parse_uric(
|
||||||
* token *out ; token object where the string of characters is
|
/*! [in] String of characters. */
|
||||||
* copied
|
const char *in,
|
||||||
*
|
/*! [in] Maximum limit. */
|
||||||
* Description : Parses a string of uric characters starting at in[0]
|
|
||||||
* as defined in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining
|
|
||||||
* URIs)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
parse_uric( const char *in,
|
|
||||||
int max,
|
int max,
|
||||||
|
/*! [out] Token object where the string of characters is copied. */
|
||||||
token *out)
|
token *out)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while( ( i < max )
|
while (i < max &&
|
||||||
&& ( ( is_unreserved( in[i] ) ) || ( is_reserved( in[i] ) )
|
(is_unreserved(in[i]) ||
|
||||||
|| ( ( i + 2 < max ) && ( is_escaped( &in[i] ) ) ) ) ) {
|
is_reserved(in[i]) ||
|
||||||
|
((i + 2 < max) && is_escaped(&in[i])))) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,55 +188,27 @@ parse_uric( const char *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : copy_token
|
* \brief Tokens are generally pointers into other strings. This copies the
|
||||||
*
|
* offset and size from a token (in) relative to one string (in_base) into
|
||||||
* Parameters :
|
* a token (out) relative to another string (out_base).
|
||||||
* const token *in ; source token
|
*/
|
||||||
* const char * in_base ;
|
static void copy_token(
|
||||||
* token * out ; destination token
|
/*! [in] Source token. */
|
||||||
* char * out_base ;
|
const token *in,
|
||||||
*
|
/*! [in] . */
|
||||||
* Description : Tokens are generally pointers into other strings
|
|
||||||
* this copies the offset and size from a token (in) relative to
|
|
||||||
* one string (in_base) into a token (out) relative to another
|
|
||||||
* string (out_base)
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
static void
|
|
||||||
copy_token( const token * in,
|
|
||||||
const char *in_base,
|
const char *in_base,
|
||||||
|
/*! [out] Destination token. */
|
||||||
token *out,
|
token *out,
|
||||||
|
/*! [in] . */
|
||||||
char *out_base)
|
char *out_base)
|
||||||
{
|
{
|
||||||
out->size = in->size;
|
out->size = in->size;
|
||||||
out->buff = out_base + (in->buff - in_base);
|
out->buff = out_base + (in->buff - in_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : copy_URL_list
|
int copy_URL_list(URL_list *in, URL_list *out)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* URL_list *in ; Source URL list
|
|
||||||
* URL_list *out ; Destination URL list
|
|
||||||
*
|
|
||||||
* Description : Copies one URL_list into another. This includes
|
|
||||||
* dynamically allocating the out->URLs field (the full string),
|
|
||||||
* and the structures used to hold the parsedURLs. This memory MUST
|
|
||||||
* be freed by the caller through: free_URL_list(&out)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* HTTP_SUCCESS - On Success
|
|
||||||
* UPNP_E_OUTOF_MEMORY - On Failure to allocate memory
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
copy_URL_list( URL_list * in,
|
|
||||||
URL_list * out )
|
|
||||||
{
|
{
|
||||||
int len = strlen( in->URLs ) + 1;
|
int len = strlen( in->URLs ) + 1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -312,46 +246,23 @@ copy_URL_list( URL_list * in,
|
|||||||
sizeof(struct sockaddr_storage) );
|
sizeof(struct sockaddr_storage) );
|
||||||
}
|
}
|
||||||
out->size = in->size;
|
out->size = in->size;
|
||||||
return HTTP_SUCCESS;
|
|
||||||
|
|
||||||
|
return HTTP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : free_URL_list
|
void free_URL_list(URL_list *list)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* URL_list * list ; URL List object
|
|
||||||
*
|
|
||||||
* Description : Frees the memory associated with a URL_list. Frees the
|
|
||||||
* dynamically allocated members of of list. Does NOT free the
|
|
||||||
* pointer to the list itself ( i.e. does NOT free(list))
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void
|
|
||||||
free_URL_list( URL_list * list )
|
|
||||||
{
|
{
|
||||||
if( list->URLs )
|
if (list->URLs) {
|
||||||
free(list->URLs);
|
free(list->URLs);
|
||||||
if( list->parsedURLs )
|
}
|
||||||
|
if (list->parsedURLs) {
|
||||||
free(list->parsedURLs);
|
free(list->parsedURLs);
|
||||||
|
}
|
||||||
list->size = 0;
|
list->size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : print_uri
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* uri_type *in ; URI object
|
|
||||||
*
|
|
||||||
* Description : Function useful in debugging for printing a parsed uri.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void print_uri(uri_type *in)
|
void print_uri(uri_type *in)
|
||||||
{
|
{
|
||||||
@@ -360,20 +271,9 @@ void print_uri( uri_type *in )
|
|||||||
print_token(&in->pathquery);
|
print_token(&in->pathquery);
|
||||||
print_token(&in->fragment);
|
print_token(&in->fragment);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : print_token
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token * in ; token
|
|
||||||
*
|
|
||||||
* Description : Function useful in debugging for printing a token.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void print_token(token * in)
|
void print_token(token * in)
|
||||||
{
|
{
|
||||||
@@ -385,113 +285,45 @@ void print_token(token * in)
|
|||||||
putchar( '\'' );
|
putchar( '\'' );
|
||||||
putchar( '\n' );
|
putchar( '\n' );
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* DEBUG */
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : token_string_casecmp
|
int token_string_casecmp(token *in1, char *in2)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token * in1 ; Token object whose buffer is to be compared
|
|
||||||
* char * in2 ; string of characters to compare with
|
|
||||||
*
|
|
||||||
* Description : Compares buffer in the token object with the buffer
|
|
||||||
* in in2
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* < 0 string1 less than string2
|
|
||||||
* 0 string1 identical to string2
|
|
||||||
* > 0 string1 greater than string2
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int token_string_casecmp(
|
|
||||||
token * in1,
|
|
||||||
char *in2 )
|
|
||||||
{
|
{
|
||||||
int in2_length = strlen(in2);
|
int in2_length = strlen(in2);
|
||||||
|
|
||||||
if( in1->size != in2_length )
|
if (in1->size != in2_length) {
|
||||||
return 1;
|
return 1;
|
||||||
else
|
} else {
|
||||||
return strncasecmp(in1->buff, in2, in1->size);
|
return strncasecmp(in1->buff, in2, in1->size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : token_string_cmp
|
int token_string_cmp(token * in1, char *in2)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token * in1 ; Token object whose buffer is to be compared
|
|
||||||
* char * in2 ; string of characters to compare with
|
|
||||||
*
|
|
||||||
* Description : Compares a null terminated string to a token (exact)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* < 0 string1 less than string2
|
|
||||||
* 0 string1 identical to string2
|
|
||||||
* > 0 string1 greater than string2
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
token_string_cmp( token * in1,
|
|
||||||
char *in2 )
|
|
||||||
{
|
{
|
||||||
int in2_length = strlen(in2);
|
int in2_length = strlen(in2);
|
||||||
|
|
||||||
if( in1->size != in2_length )
|
if (in1->size != in2_length) {
|
||||||
return 1;
|
return 1;
|
||||||
else
|
} else {
|
||||||
return strncmp(in1->buff, in2, in1->size);
|
return strncmp(in1->buff, in2, in1->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : token_cmp
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token *in1 ; First token object whose buffer is to be compared
|
|
||||||
* token *in2 ; Second token object used for the comparison
|
|
||||||
*
|
|
||||||
* Description : Compares two tokens
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* < 0 string1 less than string2
|
|
||||||
* 0 string1 identical to string2
|
|
||||||
* > 0 string1 greater than string2
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
token_cmp( token * in1,
|
|
||||||
token * in2 )
|
|
||||||
{
|
|
||||||
if( in1->size != in2->size )
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return memcmp( in1->buff, in2->buff, in1->size );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
int token_cmp(token *in1, token *in2)
|
||||||
* Function : parse_hostport
|
{
|
||||||
*
|
if (in1->size != in2->size) {
|
||||||
* Parameters :
|
return 1;
|
||||||
* char *in ; string of characters representing host and port
|
} else {
|
||||||
* int max ; sets a maximum limit (not used).
|
return memcmp(in1->buff, in2->buff, in1->size);
|
||||||
* hostport_type *out ; out parameter where the host and port
|
}
|
||||||
* are represented as an internet address
|
}
|
||||||
*
|
|
||||||
* Description : Parses a string representing a host and port
|
|
||||||
* (e.g. "127.127.0.1:80" or "localhost") and fills out a
|
int parse_hostport(
|
||||||
* hostport_type struct with internet address and a token
|
const char *in,
|
||||||
* representing the full host and port. uses gethostbyname.
|
|
||||||
*
|
|
||||||
* Returns: The number of characters that form up the host and port.
|
|
||||||
* UPNP_E_INVALID_URL on error.
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
parse_hostport( const char *in,
|
|
||||||
int max,
|
int max,
|
||||||
hostport_type *out)
|
hostport_type *out)
|
||||||
{
|
{
|
||||||
@@ -636,27 +468,22 @@ parse_hostport( const char *in,
|
|||||||
return hostport_size;
|
return hostport_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : parse_scheme
|
* \brief parses a uri scheme starting at in[0] as defined in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
|
||||||
* char * in ; string of characters representing a scheme
|
|
||||||
* int max ; maximum number of characters
|
|
||||||
* token * out ; output parameter whose buffer is filled in with
|
|
||||||
* the scheme
|
|
||||||
*
|
|
||||||
* Description : parses a uri scheme starting at in[0] as defined in
|
|
||||||
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
|
||||||
* (e.g. "http:" -> scheme= "http").
|
* (e.g. "http:" -> scheme= "http").
|
||||||
* Note, string MUST include ':' within the max charcters
|
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* \note String MUST include ':' within the max charcters.
|
||||||
*
|
*
|
||||||
* Note :
|
* \return
|
||||||
************************************************************************/
|
*/
|
||||||
int
|
static int parse_scheme(
|
||||||
parse_scheme( const char *in,
|
/*! [in] String of characters representing a scheme. */
|
||||||
|
const char *in,
|
||||||
|
/*! [in] Maximum number of characters. */
|
||||||
int max,
|
int max,
|
||||||
|
/*! [out] Output parameter whose buffer is filled in with the scheme. */
|
||||||
token *out)
|
token *out)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -686,26 +513,8 @@ parse_scheme( const char *in,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : remove_escaped_chars
|
int remove_escaped_chars(INOUT char *in, INOUT size_t *size )
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* INOUT char *in ; string of characters to be modified
|
|
||||||
* INOUT int *size ; size limit for the number of characters
|
|
||||||
*
|
|
||||||
* Description : removes http escaped characters such as: "%20" and
|
|
||||||
* replaces them with their character representation. i.e.
|
|
||||||
* "hello%20foo" -> "hello foo". The input IS MODIFIED in place.
|
|
||||||
* (shortened). Extra characters are replaced with NULL.
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* UPNP_E_SUCCESS
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
remove_escaped_chars( INOUT char *in,
|
|
||||||
INOUT size_t *size )
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -715,37 +524,8 @@ remove_escaped_chars( INOUT char *in,
|
|||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : remove_dots
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char *in ; string of characters from which "dots" have to be
|
|
||||||
* removed
|
|
||||||
* int size ; size limit for the number of characters
|
|
||||||
*
|
|
||||||
* Description : Removes ".", and ".." from a path. If a ".." can not
|
|
||||||
* be resolved (i.e. the .. would go past the root of the path) an
|
|
||||||
* error is returned. The input IS modified in place.)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* UPNP_E_SUCCESS - On Success
|
|
||||||
* UPNP_E_OUTOF_MEMORY - On failure to allocate memory
|
|
||||||
* UPNP_E_INVALID_URL - Failure to resolve URL
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
* Examples
|
|
||||||
* char path[30]="/../hello";
|
|
||||||
* remove_dots(path, strlen(path)) -> UPNP_E_INVALID_URL
|
|
||||||
* char path[30]="/./hello";
|
|
||||||
* remove_dots(path, strlen(path)) -> UPNP_E_SUCCESS,
|
|
||||||
* in = "/hello"
|
|
||||||
* char path[30]="/./hello/foo/../goodbye" ->
|
|
||||||
* UPNP_E_SUCCESS, in = "/hello/goodbye"
|
|
||||||
|
|
||||||
************************************************************************/
|
int remove_dots(char *in, size_t size)
|
||||||
int
|
|
||||||
remove_dots( char *in,
|
|
||||||
int size )
|
|
||||||
{
|
{
|
||||||
char *copyTo = in;
|
char *copyTo = in;
|
||||||
char *copyFrom = in;
|
char *copyFrom = in;
|
||||||
@@ -810,30 +590,8 @@ remove_dots( char *in,
|
|||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : resolve_rel_url
|
char *resolve_rel_url(char *base_url, char *rel_url)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char * base_url ; Base URL
|
|
||||||
* char * rel_url ; Relative URL
|
|
||||||
*
|
|
||||||
* Description : resolves a relative url with a base url returning a NEW
|
|
||||||
* (dynamically allocated with malloc) full url. If the base_url is
|
|
||||||
* NULL, then a copy of the rel_url is passed back if the rel_url
|
|
||||||
* is absolute then a copy of the rel_url is passed back if neither
|
|
||||||
* the base nor the rel_url are Absolute then NULL is returned.
|
|
||||||
* otherwise it tries and resolves the relative url with the base
|
|
||||||
* as described in: http://www.ietf.org/rfc/rfc2396.txt (RFCs
|
|
||||||
* explaining URIs)
|
|
||||||
* : resolution of '..' is NOT implemented, but '.' is resolved
|
|
||||||
*
|
|
||||||
* Return : char * ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
char *
|
|
||||||
resolve_rel_url( char *base_url,
|
|
||||||
char *rel_url )
|
|
||||||
{
|
{
|
||||||
uri_type base;
|
uri_type base;
|
||||||
uri_type rel;
|
uri_type rel;
|
||||||
@@ -921,7 +679,7 @@ resolve_rel_url( char *base_url,
|
|||||||
strlen( out_finger ) ) !=
|
strlen( out_finger ) ) !=
|
||||||
UPNP_E_SUCCESS ) {
|
UPNP_E_SUCCESS ) {
|
||||||
free(out);
|
free(out);
|
||||||
//free(rel_url);
|
/* free(rel_url); */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -930,45 +688,22 @@ resolve_rel_url( char *base_url,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
free(out);
|
free(out);
|
||||||
//free(rel_url);
|
/* free(rel_url); */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
free(out);
|
free(out);
|
||||||
//free(rel_url);
|
/* free(rel_url); */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//free(rel_url);
|
/* free(rel_url); */
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_uri
|
int parse_uri(const char *in, int max, uri_type *out)
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char * in ; character string containing uri information to be
|
|
||||||
* parsed
|
|
||||||
* int max ; maximum limit on the number of characters
|
|
||||||
* uri_type * out ; out parameter which will have the parsed uri
|
|
||||||
* information
|
|
||||||
*
|
|
||||||
* Description : parses a uri as defined in http://www.ietf.org/rfc/
|
|
||||||
* rfc2396.txt (RFC explaining URIs)
|
|
||||||
* Handles absolute, relative, and opaque uris. Parses into the
|
|
||||||
* following pieces: scheme, hostport, pathquery, fragment (path and
|
|
||||||
* query are treated as one token)
|
|
||||||
* Caller should check for the pieces they require.
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
parse_uri( const char *in,
|
|
||||||
int max,
|
|
||||||
uri_type * out )
|
|
||||||
{
|
{
|
||||||
int begin_path = 0;
|
int begin_path = 0;
|
||||||
int begin_hostport = 0;
|
int begin_hostport = 0;
|
||||||
@@ -1018,34 +753,22 @@ parse_uri( const char *in,
|
|||||||
return HTTP_SUCCESS;
|
return HTTP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_uri_and_unescape
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char * in ;
|
|
||||||
* int max ;
|
|
||||||
* uri_type * out ;
|
|
||||||
*
|
|
||||||
* Description : Same as parse_uri, except that all strings are
|
|
||||||
* unescaped (%XX replaced by chars)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note: This modifies 'pathquery' and 'fragment' parts of the input
|
|
||||||
************************************************************************/
|
|
||||||
int
|
|
||||||
parse_uri_and_unescape( char *in,
|
|
||||||
int max,
|
|
||||||
uri_type *out )
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if( ( ret = parse_uri( in, max, out ) ) != HTTP_SUCCESS )
|
int parse_uri_and_unescape(char *in, int max, uri_type *out)
|
||||||
|
{
|
||||||
|
int ret = parse_uri(in, max, out);
|
||||||
|
|
||||||
|
if (ret != HTTP_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
if( out->pathquery.size > 0 )
|
}
|
||||||
|
|
||||||
|
if (out->pathquery.size > 0) {
|
||||||
remove_escaped_chars((char *)out->pathquery.buff, &out->pathquery.size);
|
remove_escaped_chars((char *)out->pathquery.buff, &out->pathquery.size);
|
||||||
if( out->fragment.size > 0 )
|
}
|
||||||
|
if (out->fragment.size > 0) {
|
||||||
remove_escaped_chars((char *)out->fragment.buff, &out->fragment.size);
|
remove_escaped_chars((char *)out->fragment.buff, &out->fragment.size);
|
||||||
|
}
|
||||||
|
|
||||||
return HTTP_SUCCESS;
|
return HTTP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,24 +34,29 @@
|
|||||||
#define CLIENT_TABLE_H
|
#define CLIENT_TABLE_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "service_table.h"
|
||||||
|
#include "upnp.h"
|
||||||
|
#include "UpnpString.h"
|
||||||
|
#include "upnp_timeout.h"
|
||||||
|
#include "uri.h"
|
||||||
|
#include "TimerThread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
#include "service_table.h"
|
|
||||||
#include "UpnpString.h"
|
|
||||||
#include "TimerThread.h"
|
|
||||||
#include "upnp.h"
|
|
||||||
#include "upnp_timeout.h"
|
|
||||||
#include "uri.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern TimerThread gTimerThread;
|
extern TimerThread gTimerThread;
|
||||||
|
|
||||||
|
|
||||||
@@ -61,114 +66,205 @@ extern TimerThread gTimerThread;
|
|||||||
typedef struct s_ClientSubscription ClientSubscription;
|
typedef struct s_ClientSubscription ClientSubscription;
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/*!
|
||||||
|
* \brief Constructor.
|
||||||
|
*/
|
||||||
ClientSubscription *UpnpClientSubscription_new();
|
ClientSubscription *UpnpClientSubscription_new();
|
||||||
|
|
||||||
/** Destructor */
|
|
||||||
void UpnpClientSubscription_delete(ClientSubscription *p);
|
|
||||||
|
|
||||||
/** Copy Constructor */
|
/*!
|
||||||
ClientSubscription *UpnpClientSubscription_dup(const ClientSubscription *p);
|
* \brief Destructor.
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_delete(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p);
|
||||||
|
|
||||||
/** Assignment operator */
|
|
||||||
void UpnpClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p);
|
|
||||||
|
|
||||||
/* */
|
/*!
|
||||||
int UpnpClientSubscription_get_RenewEventId(const ClientSubscription *p);
|
* \brief Copy Constructor.
|
||||||
void UpnpClientSubscription_set_RenewEventId(ClientSubscription *p, int n);
|
*/
|
||||||
|
ClientSubscription *UpnpClientSubscription_dup(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
/* */
|
|
||||||
const UpnpString *UpnpClientSubscription_get_SID(const ClientSubscription *p);
|
|
||||||
void UpnpClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s);
|
|
||||||
void UpnpClientSubscription_strcpy_SID(ClientSubscription *p, const char *s);
|
|
||||||
|
|
||||||
/* */
|
/*!
|
||||||
const UpnpString *UpnpClientSubscription_get_ActualSID(const ClientSubscription *p);
|
* \brief Assignment operator.
|
||||||
void UpnpClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s);
|
*/
|
||||||
void UpnpClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s);
|
void UpnpClientSubscription_assign(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *q,
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
/* */
|
|
||||||
const UpnpString *UpnpClientSubscription_get_EventURL(const ClientSubscription *p);
|
|
||||||
void UpnpClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s);
|
|
||||||
void UpnpClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s);
|
|
||||||
|
|
||||||
/* */
|
/*!
|
||||||
ClientSubscription *UpnpClientSubscription_get_Next(const ClientSubscription *p);
|
* \brief
|
||||||
void UpnpClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q);
|
*/
|
||||||
|
int UpnpClientSubscription_get_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
/*! [in] . */
|
||||||
|
int n);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
ClientSubscription *UpnpClientSubscription_get_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
ClientSubscription *q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: free_client_subscription
|
* \brief Free memory allocated for client subscription data.
|
||||||
*
|
*
|
||||||
* Parameters:
|
|
||||||
* ClientSubscription *sub; - Client subscription to be freed
|
|
||||||
*
|
|
||||||
* Description: Free memory allocated for client subscription data.
|
|
||||||
* Remove timer thread associated with this subscription event.
|
* Remove timer thread associated with this subscription event.
|
||||||
************************************************************************/
|
*/
|
||||||
void free_client_subscription(ClientSubscription * sub);
|
void free_client_subscription(
|
||||||
|
/*! [in] Client subscription to be freed. */
|
||||||
|
ClientSubscription *sub);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: freeClientSubList
|
* \brief Free the client subscription table.
|
||||||
*
|
*/
|
||||||
* Parameters:
|
void freeClientSubList(
|
||||||
* ClientSubscription *list; Client subscription
|
/*! [in] Client subscription list to be freed. */
|
||||||
*
|
ClientSubscription *list);
|
||||||
* Description: Free the client subscription table.
|
|
||||||
*
|
|
||||||
* Return: void
|
|
||||||
************************************************************************/
|
|
||||||
void freeClientSubList(ClientSubscription *list);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: RemoveClientSubClientSID
|
* \brief Remove the client subscription matching the subscritpion id
|
||||||
*
|
* represented by the const Upnp_SID sid parameter from the table and
|
||||||
* Parameters:
|
* update the table.
|
||||||
* ClientSubscription **head; Head of the subscription list
|
*/
|
||||||
* const UpnpString sid; Subscription ID to be mactched
|
void RemoveClientSubClientSID(
|
||||||
*
|
/*! [in] Head of the subscription list. */
|
||||||
* Description: Remove the client subscription matching the
|
ClientSubscription **head,
|
||||||
* subscritpion id represented by the const Upnp_SID sid parameter
|
/*! [in] Subscription ID to be mactched. */
|
||||||
* from the table and update the table.
|
|
||||||
*
|
|
||||||
* Return: void
|
|
||||||
************************************************************************/
|
|
||||||
void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function: GetClientSubClientSID
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* ClientSubscription *head; Head of the subscription list
|
|
||||||
* const UpnpString *sid; Subscription ID to be matched
|
|
||||||
*
|
|
||||||
* Description: Return the client subscription from the client table
|
|
||||||
* that matches const Upnp_SID sid subscrition id value.
|
|
||||||
*
|
|
||||||
* Return: ClientSubscription * The matching subscription
|
|
||||||
************************************************************************/
|
|
||||||
ClientSubscription *GetClientSubClientSID(
|
|
||||||
ClientSubscription *head,
|
|
||||||
const UpnpString *sid);
|
const UpnpString *sid);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function: GetClientSubActualSID
|
* \brief Return the client subscription from the client table that matches
|
||||||
|
* const Upnp_SID sid subscrition id value.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* \return The matching subscription.
|
||||||
* ClientSubscription *head; Head of the subscription list
|
*/
|
||||||
* token *sid; Subscription ID to be matched
|
ClientSubscription *GetClientSubClientSID(
|
||||||
|
/*! [in] Head of the subscription list. */
|
||||||
|
ClientSubscription *head,
|
||||||
|
/*! [in] Subscription ID to be mactched. */
|
||||||
|
const UpnpString *sid);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the client subscription from the client subscription table
|
||||||
|
* that has the matching token *sid buffer value.
|
||||||
*
|
*
|
||||||
* Description: Returns the client subscription from the client
|
* \return The matching subscription.
|
||||||
* subscription table that has the matching token *sid buffer value.
|
*/
|
||||||
*
|
ClientSubscription *GetClientSubActualSID(
|
||||||
* Return: ClientSubscription *; The matching subscription
|
/*! [in] Head of the subscription list. */
|
||||||
************************************************************************/
|
ClientSubscription *head,
|
||||||
ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid);
|
/*! [in] Subscription ID to be mactched. */
|
||||||
|
token *sid);
|
||||||
|
|
||||||
|
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|||||||
@@ -34,7 +34,12 @@
|
|||||||
#define GENLIB_NET_URI_H
|
#define GENLIB_NET_URI_H
|
||||||
|
|
||||||
|
|
||||||
#include "upnp.h"
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "UpnpGlobal.h" /* for */
|
||||||
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -72,38 +77,66 @@ extern "C" {
|
|||||||
#define RESERVED ";/?:@&=+$,{}" //added {} for compatibility
|
#define RESERVED ";/?:@&=+$,{}" //added {} for compatibility
|
||||||
#define HTTP_SUCCESS 1
|
#define HTTP_SUCCESS 1
|
||||||
|
|
||||||
|
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define TAB 9
|
#define TAB 9
|
||||||
#define CR 13
|
#define CR 13
|
||||||
#define LF 10
|
#define LF 10
|
||||||
#define SOCKET_BUFFER_SIZE 5000
|
#define SOCKET_BUFFER_SIZE 5000
|
||||||
|
|
||||||
enum hostType { HOSTNAME, IPv4address };
|
|
||||||
enum pathType { ABS_PATH, REL_PATH, OPAQUE_PART };
|
enum hostType {
|
||||||
|
HOSTNAME,
|
||||||
|
IPv4address
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum pathType {
|
||||||
|
ABS_PATH,
|
||||||
|
REL_PATH,
|
||||||
|
OPAQUE_PART
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// there is a conflict in windows with other symbols
|
/* there is a conflict in windows with other symbols */
|
||||||
enum uriType { absolute, relative };
|
enum uriType {
|
||||||
|
absolute,
|
||||||
|
relative
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
enum uriType { ABSOLUTE, RELATIVE };
|
enum uriType {
|
||||||
|
ABSOLUTE,
|
||||||
|
RELATIVE
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Buffer used in parsinghttp messages, urls, etc. generally this simply
|
/*!
|
||||||
* holds a pointer into a larger array */
|
* \brief Buffer used in parsinghttp messages, urls, etc. generally this simply
|
||||||
|
* holds a pointer into a larger array.
|
||||||
|
*/
|
||||||
typedef struct TOKEN {
|
typedef struct TOKEN {
|
||||||
const char *buff;
|
const char *buff;
|
||||||
size_t size;
|
size_t size;
|
||||||
} token;
|
} token;
|
||||||
|
|
||||||
|
|
||||||
/* Represents a host port:e.g. :"127.127.0.1:80"
|
/*!
|
||||||
* text is a token pointing to the full string representation */
|
* \brief Represents a host port: e.g. "127.127.0.1:80" text is a token
|
||||||
|
* pointing to the full string representation.
|
||||||
|
*/
|
||||||
typedef struct HOSTPORT {
|
typedef struct HOSTPORT {
|
||||||
token text; //full host port
|
/*! Full host port. */
|
||||||
struct sockaddr_storage IPaddress; //Network Byte Order
|
token text;
|
||||||
|
/* Network Byte Order */
|
||||||
|
struct sockaddr_storage IPaddress;
|
||||||
} hostport_type;
|
} hostport_type;
|
||||||
|
|
||||||
/* Represents a URI used in parse_uri and elsewhere */
|
|
||||||
|
/*!
|
||||||
|
* \brief Represents a URI used in parse_uri and elsewhere
|
||||||
|
*/
|
||||||
typedef struct URI{
|
typedef struct URI{
|
||||||
enum uriType type;
|
enum uriType type;
|
||||||
token scheme;
|
token scheme;
|
||||||
@@ -113,240 +146,197 @@ typedef struct URI{
|
|||||||
hostport_type hostport;
|
hostport_type hostport;
|
||||||
} uri_type;
|
} uri_type;
|
||||||
|
|
||||||
/* Represents a list of URLs as in the "callback" header of SUBSCRIBE
|
|
||||||
* message in GENA
|
/*!
|
||||||
* char * URLs holds dynamic memory */
|
* \brief Represents a list of URLs as in the "callback" header of SUBSCRIBE
|
||||||
|
* message in GENA. "char *" URLs holds dynamic memory.
|
||||||
|
*/
|
||||||
typedef struct URL_LIST {
|
typedef struct URL_LIST {
|
||||||
|
/*! */
|
||||||
int size;
|
int size;
|
||||||
char * URLs; //all the urls, delimited by <>
|
/*! All the urls, delimited by <> */
|
||||||
|
char *URLs;
|
||||||
|
/*! */
|
||||||
uri_type *parsedURLs;
|
uri_type *parsedURLs;
|
||||||
} URL_list;
|
} URL_list;
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : replace_escaped
|
* \brief Replaces an escaped sequence with its unescaped version as in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
||||||
*
|
*
|
||||||
* Parameters :
|
|
||||||
* char * in ; string of characters
|
|
||||||
* int index ; index at which to start checking the characters
|
|
||||||
* size_t *max ;
|
|
||||||
*
|
|
||||||
* Description : Replaces an escaped sequence with its unescaped version
|
|
||||||
* as in http://www.ietf.org/rfc/rfc2396.txt (RFC explaining URIs)
|
|
||||||
* Size of array is NOT checked (MUST be checked by caller)
|
* Size of array is NOT checked (MUST be checked by caller)
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* \note This function modifies the string. If the sequence is an escaped
|
||||||
|
* sequence it is replaced, the other characters in the string are shifted
|
||||||
|
* over, and NULL characters are placed at the end of the string.
|
||||||
*
|
*
|
||||||
* Note : This function modifies the string. If the sequence is an
|
* \return
|
||||||
* escaped sequence it is replaced, the other characters in the
|
*/
|
||||||
* string are shifted over, and NULL characters are placed at the
|
int replace_escaped(
|
||||||
* end of the string.
|
/*! [in] String of characters. */
|
||||||
************************************************************************/
|
char *in,
|
||||||
int replace_escaped(char * in, int index, size_t *max);
|
/*! [in] Index at which to start checking the characters. */
|
||||||
|
int index,
|
||||||
|
/*! [out] . */
|
||||||
|
size_t *max);
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : copy_URL_list
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* URL_list *in ; Source URL list
|
|
||||||
* URL_list *out ; Destination URL list
|
|
||||||
*
|
|
||||||
* Description : Copies one URL_list into another. This includes
|
|
||||||
* dynamically allocating the out->URLs field (the full string),
|
|
||||||
* and the structures used to hold the parsedURLs. This memory MUST
|
|
||||||
* be freed by the caller through: free_URL_list(&out)
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* HTTP_SUCCESS - On Success
|
|
||||||
* UPNP_E_OUTOF_MEMORY - On Failure to allocate memory
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int copy_URL_list( URL_list *in, URL_list *out);
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : free_URL_list
|
* \brief Copies one URL_list into another.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* This includes dynamically allocating the out->URLs field (the full string),
|
||||||
* URL_list * list ; URL List object
|
* and the structures used to hold the parsedURLs. This memory MUST be freed
|
||||||
|
* by the caller through: free_URL_list(&out).
|
||||||
*
|
*
|
||||||
* Description : Frees the memory associated with a URL_list. Frees the
|
* \return
|
||||||
* dynamically allocated members of of list. Does NOT free the
|
* \li HTTP_SUCCESS - On Success.
|
||||||
* pointer to the list itself ( i.e. does NOT free(list))
|
* \li UPNP_E_OUTOF_MEMORY - On Failure to allocate memory.
|
||||||
*
|
*/
|
||||||
* Return : void ;
|
int copy_URL_list(
|
||||||
*
|
/*! [in] Source URL list. */
|
||||||
* Note :
|
URL_list *in,
|
||||||
************************************************************************/
|
/*! [out] Destination URL list. */
|
||||||
void free_URL_list(URL_list * list);
|
URL_list *out);
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : print_uri
|
* \brief Frees the memory associated with a URL_list.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Frees the dynamically allocated members of of list. Does NOT free the
|
||||||
* uri_type *in ; URI object
|
* pointer to the list itself ( i.e. does NOT free(list)).
|
||||||
*
|
*/
|
||||||
* Description : Function useful in debugging for printing a parsed uri.
|
void free_URL_list(
|
||||||
*
|
/*! [in] URL list object. */
|
||||||
* Return : void ;
|
URL_list *list);
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
/*!
|
||||||
|
* \brief Function useful in debugging for printing a parsed uri.
|
||||||
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void print_uri(uri_type *in);
|
void print_uri(
|
||||||
|
/*! [in] URI object to print. */
|
||||||
|
uri_type *in);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void print_uri(uri_type *in) {}
|
static UPNP_INLINE void print_uri(uri_type *in) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : print_token
|
/*!
|
||||||
*
|
* \brief Function useful in debugging for printing a token.
|
||||||
* Parameters :
|
*/
|
||||||
* token * in ;
|
|
||||||
*
|
|
||||||
* Description : Function useful in debugging for printing a token.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void print_token(token *in);
|
void print_token(
|
||||||
|
/*! [in] Token object to print. */
|
||||||
|
token *in);
|
||||||
#else
|
#else
|
||||||
static UPNP_INLINE void print_token(token * in) {}
|
static UPNP_INLINE void print_token(token * in) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : token_string_casecmp
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token * in1 ; Token object whose buffer is to be compared
|
|
||||||
* char * in2 ; string of characters to compare with
|
|
||||||
*
|
|
||||||
* Description : Compares buffer in the token object with the buffer
|
|
||||||
* in in2
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* < 0 string1 less than string2
|
|
||||||
* 0 string1 identical to string2
|
|
||||||
* > 0 string1 greater than string2
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int token_string_casecmp( token * in1, char * in2);
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : token_string_cmp
|
* \brief Compares buffer in the token object with the buffer in in2.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* token * in1 ; Token object whose buffer is to be compared
|
* \li < 0, if string1 is less than string2.
|
||||||
* char * in2 ; string of characters to compare with
|
* \li == 0, if string1 is identical to string2 .
|
||||||
*
|
* \li > 0, if string1 is greater than string2.
|
||||||
* Description : Compares a null terminated string to a token (exact)
|
*/
|
||||||
*
|
int token_string_casecmp(
|
||||||
* Return : int ;
|
/*! [in] Token object whose buffer is to be compared. */
|
||||||
* < 0 string1 less than string2
|
token *in1,
|
||||||
* 0 string1 identical to string2
|
/*! [in] String of characters to compare with. */
|
||||||
* > 0 string1 greater than string2
|
char *in2);
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int token_string_cmp( token * in1, char * in2);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : token_cmp
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* token *in1 ; First token object whose buffer is to be compared
|
|
||||||
* token *in2 ; Second token object used for the comparison
|
|
||||||
*
|
|
||||||
* Description : Compares two tokens
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* < 0 string1 less than string2
|
|
||||||
* 0 string1 identical to string2
|
|
||||||
* > 0 string1 greater than string2
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int token_cmp( token *in1, token *in2);
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : parse_port
|
* \brief Compares a null terminated string to a token (exact).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* int max ; sets a maximum limit
|
* \li < 0, if string1 is less than string2.
|
||||||
* char * port ; port to be parsed.
|
* \li == 0, if string1 is identical to string2 .
|
||||||
* unsigned short * out ; out parameter where the port is parsed
|
* \li > 0, if string1 is greater than string2.
|
||||||
* and converted into network format
|
*/
|
||||||
*
|
int token_string_cmp(
|
||||||
* Description : parses a port (i.e. '4000') and converts it into a
|
/*! [in] Token object whose buffer is to be compared. */
|
||||||
* network ordered unsigned short int.
|
token *in1,
|
||||||
*
|
/*! [in] String of characters to compare with. */
|
||||||
* Return : int ;
|
char *in2);
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int parse_port(int max, const char *port, unsigned short int *out);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_hostport
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* char *in ; string of characters representing host and port
|
|
||||||
* int max ; sets a maximum limit
|
|
||||||
* hostport_type *out ; out parameter where the host and port
|
|
||||||
* are represented as an internet address
|
|
||||||
*
|
|
||||||
* Description : Parses a string representing a host and port
|
|
||||||
* (e.g. "127.127.0.1:80" or "localhost") and fills out a
|
|
||||||
* hostport_type struct with internet address and a token
|
|
||||||
* representing the full host and port. uses gethostbyname.
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int parse_hostport(const char *in, int max, hostport_type *out );
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : remove_escaped_chars
|
* \brief Compares two tokens.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* INOUT char *in ; string of characters to be modified
|
* \li < 0, if string1 is less than string2.
|
||||||
* INOUT size_t *size ; size limit for the number of characters
|
* \li == 0, if string1 is identical to string2 .
|
||||||
*
|
* \li > 0, if string1 is greater than string2.
|
||||||
* Description : removes http escaped characters such as: "%20" and
|
*/
|
||||||
* replaces them with their character representation. i.e.
|
int token_cmp(
|
||||||
* "hello%20foo" -> "hello foo". The input IS MODIFIED in place.
|
/*! [in] First token object whose buffer is to be compared. */
|
||||||
* (shortened). Extra characters are replaced with NULL.
|
token *in1,
|
||||||
*
|
/*! [in] Second token object used for the comparison. */
|
||||||
* Return : int ;
|
token *in2);
|
||||||
* UPNP_E_SUCCESS
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int remove_escaped_chars(char *in, size_t *size);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : remove_dots
|
/*!
|
||||||
|
* \brief Parses a port (i.e. '4000') and converts it into a network ordered
|
||||||
|
* unsigned short int.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* char *in ; string of characters from which "dots" have to be
|
*/
|
||||||
* removed
|
int parse_port(
|
||||||
* int size ; size limit for the number of characters
|
/*! [in] Sets a maximum limit. */
|
||||||
|
int max,
|
||||||
|
/*! [in] Port to be parsed. */
|
||||||
|
const char *port,
|
||||||
|
/*! [out] Output parameter where the port is parsed and converted into
|
||||||
|
* network format. */
|
||||||
|
unsigned short int *out);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Parses a string representing a host and port (e.g. "127.127.0.1:80"
|
||||||
|
* or "localhost") and fills out a hostport_type struct with internet address
|
||||||
|
* and a token representing the full host and port.
|
||||||
*
|
*
|
||||||
* Description : Removes ".", and ".." from a path. If a ".." can not
|
* Uses gethostbyname.
|
||||||
* be resolved (i.e. the .. would go past the root of the path) an
|
*/
|
||||||
* error is returned. The input IS modified in place.)
|
int parse_hostport(
|
||||||
|
/*! [in] String of characters representing host and port. */
|
||||||
|
const char *in,
|
||||||
|
/*! [in] Sets a maximum limit. */
|
||||||
|
int max,
|
||||||
|
/*! [out] Output parameter where the host and port are represented as
|
||||||
|
* an internet address. */
|
||||||
|
hostport_type *out);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Removes http escaped characters such as: "%20" and replaces them with
|
||||||
|
* their character representation. i.e. "hello%20foo" -> "hello foo".
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* The input IS MODIFIED in place (shortened). Extra characters are replaced
|
||||||
* UPNP_E_SUCCESS - On Success
|
* with \b NULL.
|
||||||
* UPNP_E_OUTOF_MEMORY - On failure to allocate memory
|
|
||||||
* UPNP_E_INVALID_URL - Failure to resolve URL
|
|
||||||
*
|
*
|
||||||
* Note :
|
* \return UPNP_E_SUCCESS.
|
||||||
* Examples
|
*/
|
||||||
|
int remove_escaped_chars(
|
||||||
|
/*! [in,out] String of characters to be modified. */
|
||||||
|
char *in,
|
||||||
|
/*! [in,out] Size limit for the number of characters. */
|
||||||
|
size_t *size);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Removes ".", and ".." from a path.
|
||||||
|
*
|
||||||
|
* If a ".." can not be resolved (i.e. the .. would go past the root of the
|
||||||
|
* path) an error is returned.
|
||||||
|
*
|
||||||
|
* The input IS modified in place.)
|
||||||
|
*
|
||||||
|
* \note Examples
|
||||||
* char path[30]="/../hello";
|
* char path[30]="/../hello";
|
||||||
* remove_dots(path, strlen(path)) -> UPNP_E_INVALID_URL
|
* remove_dots(path, strlen(path)) -> UPNP_E_INVALID_URL
|
||||||
* char path[30]="/./hello";
|
* char path[30]="/./hello";
|
||||||
@@ -354,173 +344,247 @@ int remove_escaped_chars(char *in, size_t *size);
|
|||||||
* in = "/hello"
|
* in = "/hello"
|
||||||
* char path[30]="/./hello/foo/../goodbye" ->
|
* char path[30]="/./hello/foo/../goodbye" ->
|
||||||
* UPNP_E_SUCCESS, in = "/hello/goodbye"
|
* UPNP_E_SUCCESS, in = "/hello/goodbye"
|
||||||
|
*
|
||||||
|
* \return
|
||||||
|
* \li UPNP_E_SUCCESS - On Success.
|
||||||
|
* \li UPNP_E_OUTOF_MEMORY - On failure to allocate memory.
|
||||||
|
* \li UPNP_E_INVALID_URL - Failure to resolve URL.
|
||||||
|
*/
|
||||||
|
int remove_dots(
|
||||||
|
/*! [in] String of characters from which "dots" have to be removed. */
|
||||||
|
char *in,
|
||||||
|
/*! [in] Size limit for the number of characters. */
|
||||||
|
size_t size);
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
int remove_dots(char * in, int size);
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : resolve_rel_url
|
* \brief resolves a relative url with a base url returning a NEW (dynamically
|
||||||
|
* allocated with malloc) full url.
|
||||||
*
|
*
|
||||||
* Parameters :
|
* If the base_url is \b NULL, then a copy of the rel_url is passed back if
|
||||||
* char * base_url ; Base URL
|
* the rel_url is absolute then a copy of the rel_url is passed back if neither
|
||||||
* char * rel_url ; Relative URL
|
* the base nor the rel_url are Absolute then NULL is returned. Otherwise it
|
||||||
|
* tries and resolves the relative url with the base as described in
|
||||||
|
* http://www.ietf.org/rfc/rfc2396.txt (RFCs explaining URIs).
|
||||||
*
|
*
|
||||||
* Description : resolves a relative url with a base url returning a NEW
|
* The resolution of '..' is NOT implemented, but '.' is resolved.
|
||||||
* (dynamically allocated with malloc) full url. If the base_url is
|
|
||||||
* NULL, then a copy of the rel_url is passed back if the rel_url
|
|
||||||
* is absolute then a copy of the rel_url is passed back if neither
|
|
||||||
* the base nor the rel_url are Absolute then NULL is returned.
|
|
||||||
* otherwise it tries and resolves the relative url with the base
|
|
||||||
* as described in: http://www.ietf.org/rfc/rfc2396.txt (RFCs
|
|
||||||
* explaining URIs)
|
|
||||||
* : resolution of '..' is NOT implemented, but '.' is resolved
|
|
||||||
*
|
*
|
||||||
* Return : char * ;
|
* \return
|
||||||
*
|
*/
|
||||||
* Note :
|
char *resolve_rel_url(
|
||||||
************************************************************************/
|
/*! [in] Base URL. */
|
||||||
char * resolve_rel_url( char * base_url, char * rel_url);
|
char *base_url,
|
||||||
|
/*! [in] Relative URL. */
|
||||||
|
char *rel_url);
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_uri
|
/*!
|
||||||
|
* \brief Parses a uri as defined in http://www.ietf.org/rfc/rfc2396.txt
|
||||||
|
* (RFC explaining URIs).
|
||||||
*
|
*
|
||||||
* Parameters :
|
* Handles absolute, relative, and opaque uris. Parses into the following
|
||||||
* char * in ; character string containing uri information to be
|
* pieces: scheme, hostport, pathquery, fragment (path and query are treated
|
||||||
* parsed
|
* as one token)
|
||||||
* int max ; maximum limit on the number of characters
|
|
||||||
* uri_type * out ; out parameter which will have the parsed uri
|
|
||||||
* information
|
|
||||||
*
|
*
|
||||||
* Description : parses a uri as defined in http://www.ietf.org/rfc/
|
|
||||||
* rfc2396.txt (RFC explaining URIs)
|
|
||||||
* Handles absolute, relative, and opaque uris. Parses into the
|
|
||||||
* following pieces: scheme, hostport, pathquery, fragment (path and
|
|
||||||
* query are treated as one token)
|
|
||||||
* Caller should check for the pieces they require.
|
* Caller should check for the pieces they require.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* \return
|
||||||
|
*/
|
||||||
|
int parse_uri(
|
||||||
|
/*! [in] Character string containing uri information to be parsed. */
|
||||||
|
const char *in,
|
||||||
|
/*! [in] Maximum limit on the number of characters. */
|
||||||
|
int max,
|
||||||
|
/*! [out] Output parameter which will have the parsed uri information. */
|
||||||
|
uri_type *out);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Same as parse_uri(), except that all strings are unescaped
|
||||||
|
* (%XX replaced by chars).
|
||||||
*
|
*
|
||||||
* Note :
|
* \note This modifies 'pathquery' and 'fragment' parts of the input.
|
||||||
************************************************************************/
|
|
||||||
int parse_uri(const char * in, int max, uri_type * out);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : parse_uri_and_unescape
|
|
||||||
*
|
*
|
||||||
* Parameters :
|
* \return
|
||||||
* char * in ;
|
*/
|
||||||
* int max ;
|
int parse_uri_and_unescape(
|
||||||
* uri_type * out ;
|
/*! [in] Character string containing uri information to be parsed. */
|
||||||
|
char *in,
|
||||||
|
/*! [in] Maximum limit on the number of characters. */
|
||||||
|
int max,
|
||||||
|
/*! [out] Output parameter which will have the parsed uri information. */
|
||||||
|
uri_type *out);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
*
|
*
|
||||||
* Description : Same as parse_uri, except that all strings are
|
* \return
|
||||||
* unescaped (%XX replaced by chars)
|
*/
|
||||||
*
|
int parse_token(
|
||||||
* Return : int ;
|
/*! [in] . */
|
||||||
*
|
char *in,
|
||||||
* Note: This modifies 'pathquery' and 'fragment' parts of the input
|
/*! [out] . */
|
||||||
************************************************************************/
|
token *out,
|
||||||
int parse_uri_and_unescape(char * in, int max, uri_type * out);
|
/*! [in] . */
|
||||||
|
int max_size);
|
||||||
int parse_token( char * in, token * out, int max_size);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* commented #defines, functions and typdefs *
|
|
||||||
************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Commented #defines *
|
|
||||||
************************************************************************/
|
|
||||||
//#define HTTP_E_BAD_URL UPNP_E_INVALID_URL
|
|
||||||
//#define HTTP_E_READ_SOCKET UPNP_E_SOCKET_READ
|
|
||||||
//#define HTTP_E_BIND_SOCKET UPNP_E_SOCKET_BIND
|
|
||||||
//#define HTTP_E_WRITE_SOCKET UPNP_E_SOCKET_WRITE
|
|
||||||
//#define HTTP_E_CONNECT_SOCKET UPNP_E_SOCKET_CONNECT
|
|
||||||
//#define HTTP_E_SOCKET UPNP_E_OUTOF_SOCKET
|
|
||||||
//#define HTTP_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
|
|
||||||
//#define HTTP_E_BAD_REQUEST UPNP_E_BAD_REQUEST
|
|
||||||
//#define HTTP_E_BAD_IP_ADDRESS UPNP_E_INVALID_URL
|
|
||||||
|
|
||||||
//#define RESPONSE_TIMEOUT 30
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Commented typedefs *
|
|
||||||
************************************************************************/
|
|
||||||
//Buffer used to store data read from a socket during an http transfer
|
|
||||||
//in function read_bytes.
|
|
||||||
//typedef struct SOCKET_BUFFER{
|
|
||||||
// char buff[SOCKET_BUFFER_SIZE];
|
|
||||||
// int size;
|
|
||||||
// struct SOCKET_BUFFER *next;
|
|
||||||
//} socket_buffer;
|
|
||||||
|
|
||||||
//typedef struct HTTP_HEADER {
|
|
||||||
// token header;
|
|
||||||
// token value;
|
|
||||||
// struct HTTP_HEADER * next;
|
|
||||||
//} http_header;
|
|
||||||
|
|
||||||
//typedef struct HTTP_STATUS_LINE{
|
|
||||||
// token http_version;
|
|
||||||
// token status_code;
|
|
||||||
// token reason_phrase;
|
|
||||||
//} http_status;
|
|
||||||
|
|
||||||
//typedef struct HTTP_REQUEST_LINE {
|
|
||||||
// token http_version;
|
|
||||||
// uri_type request_uri;
|
|
||||||
// token method;
|
|
||||||
//} http_request;
|
|
||||||
|
|
||||||
//Represents a parsed HTTP_MESSAGE head_list is dynamically allocated
|
|
||||||
//typedef struct HTTP_MESSAGE {
|
|
||||||
// http_status status;
|
|
||||||
// http_request request;
|
|
||||||
// http_header * header_list;
|
|
||||||
// token content;
|
|
||||||
//} http_message;
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Commented functions *
|
|
||||||
************************************************************************
|
|
||||||
|
|
||||||
EXTERN_C int transferHTTP( char * request, char * toSend,
|
|
||||||
int toSendSize, char **out, char * Url);
|
|
||||||
|
|
||||||
|
|
||||||
EXTERN_C int transferHTTPRaw( char * toSend, int toSendSize,
|
/* Commented #defines, functions and typdefs */
|
||||||
char **out, char *URL);
|
|
||||||
|
|
||||||
helper function
|
#if 0
|
||||||
EXTERN_C int transferHTTPparsedURL( char * request,
|
#define HTTP_E_BAD_URL UPNP_E_INVALID_URL
|
||||||
char * toSend, int toSendSize,
|
#define HTTP_E_READ_SOCKET UPNP_E_SOCKET_READ
|
||||||
char **out, uri_type *URL);
|
#define HTTP_E_BIND_SOCKET UPNP_E_SOCKET_BIND
|
||||||
|
#define HTTP_E_WRITE_SOCKET UPNP_E_SOCKET_WRITE
|
||||||
|
#define HTTP_E_CONNECT_SOCKET UPNP_E_SOCKET_CONNECT
|
||||||
|
#define HTTP_E_SOCKET UPNP_E_OUTOF_SOCKET
|
||||||
|
#define HTTP_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
|
||||||
|
#define HTTP_E_BAD_REQUEST UPNP_E_BAD_REQUEST
|
||||||
|
#define HTTP_E_BAD_IP_ADDRESS UPNP_E_INVALID_URL
|
||||||
|
|
||||||
assumes that char * out has enough space ( 38 characters)
|
#define RESPONSE_TIMEOUT 30
|
||||||
outputs the current time in the following null terminated string:
|
#endif
|
||||||
"DATE: Sun, Jul 06 2000 08:53:01 GMT\r\n"
|
|
||||||
EXTERN_C void currentTmToHttpDate(char *out);
|
|
||||||
|
|
||||||
EXTERN_C int parse_http_response( char * in, http_message * out,
|
#if 0
|
||||||
|
/*!
|
||||||
|
* Buffer used to store data read from a socket during an http transfer in
|
||||||
|
* function read_bytes.
|
||||||
|
*/
|
||||||
|
typedef struct SOCKET_BUFFER{
|
||||||
|
char buff[SOCKET_BUFFER_SIZE];
|
||||||
|
int size;
|
||||||
|
struct SOCKET_BUFFER *next;
|
||||||
|
} socket_buffer;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct HTTP_HEADER {
|
||||||
|
token header;
|
||||||
|
token value;
|
||||||
|
struct HTTP_HEADER * next;
|
||||||
|
} http_header;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct HTTP_STATUS_LINE{
|
||||||
|
token http_version;
|
||||||
|
token status_code;
|
||||||
|
token reason_phrase;
|
||||||
|
} http_status;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct HTTP_REQUEST_LINE {
|
||||||
|
token http_version;
|
||||||
|
uri_type request_uri;
|
||||||
|
token method;
|
||||||
|
} http_request;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Represents a parsed HTTP_MESSAGE head_list is dynamically allocated
|
||||||
|
*/
|
||||||
|
typedef struct HTTP_MESSAGE {
|
||||||
|
http_status status;
|
||||||
|
http_request request;
|
||||||
|
http_header * header_list;
|
||||||
|
token content;
|
||||||
|
} http_message;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
int transferHTTP(
|
||||||
|
char *request,
|
||||||
|
char *toSend,
|
||||||
|
int toSendSize,
|
||||||
|
char **out,
|
||||||
|
char *Url);
|
||||||
|
|
||||||
|
|
||||||
|
int transferHTTPRaw(
|
||||||
|
char *toSend,
|
||||||
|
int toSendSize,
|
||||||
|
char **out,
|
||||||
|
char *URL);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief helper function.
|
||||||
|
*/
|
||||||
|
int transferHTTPparsedURL(
|
||||||
|
char *request,
|
||||||
|
char *toSend,
|
||||||
|
int toSendSize,
|
||||||
|
char **out,
|
||||||
|
uri_type *URL);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief assumes that char * out has enough space ( 38 characters)
|
||||||
|
* outputs the current time in the following null terminated string:
|
||||||
|
* "DATE: Sun, Jul 06 2000 08:53:01 GMT\r\n"
|
||||||
|
*/
|
||||||
|
void currentTmToHttpDate(
|
||||||
|
char *out);
|
||||||
|
|
||||||
|
|
||||||
|
int parse_http_response(
|
||||||
|
char *in,
|
||||||
|
http_message *out,
|
||||||
int max_len);
|
int max_len);
|
||||||
|
|
||||||
EXTERN_C int parse_http_request( char * in, http_message *out,
|
|
||||||
|
int parse_http_request(
|
||||||
|
char *in,
|
||||||
|
http_message *out,
|
||||||
int max_len);
|
int max_len);
|
||||||
|
|
||||||
EXTERN_C void print_http_message( http_message * message);
|
|
||||||
EXTERN_C int search_for_header( http_message * in,
|
|
||||||
char * header, token *out_value);
|
|
||||||
|
|
||||||
EXTERN_C void print_status_line(http_status *in);
|
void print_http_message(
|
||||||
EXTERN_C void print_request_line(http_request *in);
|
http_message *message);
|
||||||
EXTERN_C int parse_http_line( char * in, int max_size);
|
|
||||||
EXTERN_C int parse_not_LWS( char *in, token *out, int max_size);
|
|
||||||
EXTERN_C int parse_LWS( char * in, int max_size);
|
|
||||||
|
|
||||||
EXTERN_C size_t write_bytes(int fd, char * bytes, size_t n,
|
|
||||||
|
int search_for_header(
|
||||||
|
http_message *in,
|
||||||
|
char *header,
|
||||||
|
token *out_value);
|
||||||
|
|
||||||
|
|
||||||
|
void print_status_line(
|
||||||
|
http_status *in);
|
||||||
|
|
||||||
|
|
||||||
|
void print_request_line(
|
||||||
|
http_request *in);
|
||||||
|
|
||||||
|
|
||||||
|
int parse_http_line(
|
||||||
|
char *in,
|
||||||
|
int max_size);
|
||||||
|
|
||||||
|
|
||||||
|
int parse_not_LWS(
|
||||||
|
char *in,
|
||||||
|
token *out,
|
||||||
|
int max_size);
|
||||||
|
|
||||||
|
|
||||||
|
int parse_LWS(
|
||||||
|
char *in,
|
||||||
|
int max_size);
|
||||||
|
|
||||||
|
|
||||||
|
size_t write_bytes(
|
||||||
|
int fd,
|
||||||
|
char *bytes,
|
||||||
|
size_t n,
|
||||||
int timeout);
|
int timeout);
|
||||||
EXTERN_C void free_http_message(http_message * message);
|
|
||||||
|
|
||||||
************************************************************************/
|
|
||||||
|
void free_http_message(
|
||||||
|
http_message *message);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user