📄 httputil.h
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 THE AUTHORS OR ITS 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.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/Pi3API/HTTPUtil.h,v $
* $Date: 2004/07/04 19:42:42 $
*
Description:
HTTP utilities which require no context other than thier parameters.
\*____________________________________________________________________________*/
/* $SourceTop:$ */
#ifndef HTTPUTIL_H_
#define HTTPUTIL_H_
#include <time.h>
#include "Pi3API.h"
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_contractPath
Synopsis:
int HTTPUtil_contractPath( char *pPath )
Description:
Contract the directory path <B>pPath</B> in place by removing directories
with the name '..'.
Notes:
Return Values:
Returns the number of directories above the root pPath which should be
discarded. Typically a value of 0 is the desired result.
Errors:
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPUtil_contractPath( char *pPath );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_rFC822Time
Synopsis:
int HTTPUtil_rFC822Time( struct tm *pT, Pi3String *pResult )
Description:
This function converts a given time value into a valid RFC822 time string.
Notes:
Return Values:
PIAPI_TRUE on success, PIAPI_ERROR otherwise. The converted time string is
returned in pResult.
Errors:
PIAPI_ERROR
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPUtil_rFC822Time( struct tm *pT, Pi3String *pResult );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_rcNumberToName
Synopsis:
const char *HTTPUtil_rcNumberToName( int iRC )
Description:
This function does convert a given PiAPI return code to the corresponding string.
Notes:
Return Values:
The name corresponding to the given PiAPI return code
<TABLE>
<TR><TH>API return code<TH>Name string
<TR><TD>PIAPI_COMPLETED<TD>COMPLETED
<TR><TD>PIAPI_CONTINUE<TD>CONTINUE
<TR><TD>PIAPI_ERROR<TD>ERROR
<TR><TD>PIAPI_ABORT<TD>ABORT
<TR><TD>INT_REDIRECT<TD>REDIRECT
<TR><TD><TD>UNKNOWN
</TABLE>
Errors:
See Also:
HTTPUtil_rcNameToNumber
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *HTTPUtil_rcNumberToName( int iRC );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_rcNameToNumber
Synopsis:
int HTTPUtil_rcNameToNumber( const char *pName )
Description:
This function returns the corresponding code to the name of a PiAPI return value.
Notes:
Return Values:
Refer to the table of return values of HTTPUtil_rcNumberToName.
Errors:
PIAPI_ABORT is also returned on a wrong name in pName.
See Also:
HTTPUtil_rcNumberToName
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPUtil_rcNameToNumber( const char *pName );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_phaseNumberToName
Synopsis:
const char *HTTPUtil_phaseNumberToName( int iPhaseNumber )
Description:
This function does convert a given process phase number to the corresponding string.
Notes:
Return Values:
The name corresponding to the given process phase number
<TABLE>
<TR><TH>Phase No.<TH>Name string
<TR><TD>PH_INVALID<TD>INVALID
<TR><TD>PH_INIT<TD>INIT
<TR><TD>PH_HEADERS<TD>HEADERS
<TR><TD>PH_HOSTMAP<TD>HOSTMAP
<TR><TD>PH_MAPPING<TD>MAPPING
<TR><TD>PH_CHECKPATH<TD>CHECKPATH
<TR><TD>PH_CHECKAUTH<TD>CHECKAUTH
<TR><TD>PH_CHECKACCESS<TD>CHECKACCESS
<TR><TD>PH_CHECKTYPE<TD>CHECKTYPE
<TR><TD>PH_HANDLE<TD>HANDLE
<TR><TD>PH_LOG<TD>LOG
<TR><TD>PH_DESTROY<TD>DESTROY
</TABLE>
Errors:
See Also:
HTTPUtil_phaseNameToNumber
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *HTTPUtil_phaseNumberToName( int iPhaseNumber );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_phaseNameToNumber
Synopsis:
int HTTPUtil_phaseNameToNumber( const char *pPhaseName )
Description:
This function returns the corresponding code to the given process phase name.
Notes:
Return Values:
Refer to the table of return values of HTTPUtil_phaseNumberToName.
Errors:
PH_INVALID
See Also:
HTTPUtil_phaseNumberToName
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPUtil_phaseNameToNumber( const char *pPhaseName );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_getHostName
Synopsis:
const char *HTTPUtil_getHostName( PIHTTP *pPIHTTP )
Description:
This function returns the name of the virtual host associated with the
HTTP object in pPIHTTP.
Notes:
Return Values:
The name of the virtual host or NULL.
Errors:
See Also:
HTTPUtil_getHostPort
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *HTTPUtil_getHostName( PIHTTP *pPIHTTP );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_getHostPort
Synopsis:
const char *HTTPUtil_getHostPort( PIHTTP *pPIHTTP )
Description:
This function returns the port of the virtual host associated with the
HTTP object in pPIHTTP.
Notes:
Return Values:
The port number of the virtual host as decimal string or NULL.
Errors:
See Also:
HTTPUtil_getHostName
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *HTTPUtil_getHostPort( PIHTTP *pPIHTTP );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_protocolNumberToName
Synopsis:
const char *HTTPUtil_protocolNumberToName( int iProtocol )
Description:
This function does convert a given HTTP protocol version number to the
corresponding string.
Notes:
Return Values:
The name corresponding to the given process phase number
<TABLE>
<TR><TH>Protocol version<TH>Name string
<TR><TD>PR_HTTP09<TD>HTTP/0.9
<TR><TD>PR_HTTP10<TD>HTTP/1.0
<TR><TD>PR_HTTP11<TD>HTTP/1.1
</TABLE>
Errors:
The string "Unknown" is returned in case of unknown value in iProtocol.
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI const char *HTTPUtil_protocolNumberToName( int iProtocol );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_readTime
Synopsis:
int HTTPUtil_readTime( const char *pLine, struct tm *pT )
Description:
This function does scan pLine for a valid ANSI-C, RFC1123 or RFC850
timestamp and parse it into a time structure.
Notes:
The pLine may contain more characters than only the time string.
Return Values:
PIAPI_COMPLETED on success, PIAPI_ERROR otherwise. The time structure
in pT will be filled in case of success.
Errors:
PIAPI_ERROR
See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPUtil_readTime( const char *pLine, struct tm *pT );
/*____________________________________________________________________________*\
*
Name:
HTTPUtil_regexMatch
Synopsis:
int HTTPUtil_regexMatch( const char *pRegex, int iRegex, const char *pString,
int iStringLen )
Description:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -