uri.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 149 行
H
149 行
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: Eric Knudstrup
* Created: Thu Jun 16 11:28:55 2005
*
*******************************************************************/
#ifndef URI_H
#define URI_H
/** @file uri.h Provided by netutil.lib. */
/** @defgroup uri_functions RFC3986 URI processing functions
* @brief URI parsing functions. Provided by netutil.lib.
* @ingroup Network
* @{
*/
/* uri_scheme_strings and uri_scheme_def_port in uri.c
must be changed at the same time */
/** uri_parse() sets the scheme_type in the uri based on the scheme string */
typedef enum {
URI_SCHEME_HTTP, /**< HTTP Scheme */
URI_SCHEME_RTSP, /**< RTSP Scheme */
URI_SCHEME_HTTPS, /**< HTTPS Scheme */
URI_SCHEME_UNKNOWN /**< Everything else */
} URIScheme_t;
typedef struct {
int ref_count; /**< Reference count Internal use only */
URIScheme_t scheme_type; /**< URIScheme_t for this URI */
char *scheme_string; /**< Scheme as a string */
char *host; /**< Host as a string */
#ifdef AVOS
struct ip_addr host_addr; /**< Host as an address (network byte order) */
#else
struct in_addr host_addr; /**< Host as an address (network byte order) */
#endif
uint16_t port; /**< Port in network byte order. */
char *path; /**< URI Path */
char *string; /**< Internal use only */
char *original; /**< Original URI text */
} URI_t;
#define DEFAULT_URI_LENGTH 256
/*;emacs generated header for file uri.c. Global function declarations only. */
/**
* <A HREF="http://www.ietf.org/rfc/rfc3986.txt">RFC3986</A>
* Percent encode a URI path string
* @param [in] dest Destination buffer
* @param [in] src Source buffer (unencoded path string)
*
* @returns The encoded string.
*/
extern char *pct_encode_path(char *dest, char *src);
/**
* <A HREF="http://www.ietf.org/rfc/rfc3986.txt">RFC3986</A>
* Percent encode a URI host string
* @param [in] dest Destination buffer
* @param [in] src Source buffer (unencoded host string)
*
* @returns The encoded string.
*/
extern char *pct_encode_host(char *dest, char *src);
/**
* Given a URI path string, calculate how much space would be required to store it
* in RFC3946 percent encoded format
*/
extern int
get_path_encoded_len(char *path);
/**
* Given a URI host string, calculate how much space would be required to store it
* in RFC3946 percent encoded format
*/
extern int
get_host_encoded_len(char *host);
/**
* Given a null terminated string, remove all
* <A HREF="http://www.ietf.org/rfc/rfc3986.txt">RFC3986</A>
* escapes and replace them with their normal characters within the
* original string.
*
* @param[in] string String to pct_unencode.
* @returns string.
*/
extern char *
pct_unencode_string(char *string);
/**
* Free a parsed URI
*/
extern void
uri_free(URI_t *uri);
/**
* Increment the reference count of the URI_t.
*
* @param uri URI to increase reference counter of
*
*/
extern void
uri_ref(URI_t *uri);
/**
* Given the components of a URI, turn them into a URI structure. If the path doesn't
* start with a '/' one will be prepended.
*
* @param [in] scheme Scheme, such as "http"
* @param [in] host Host name or dotted decimal
* @param [in] port TCP/UDP port number. If 0, it will be considered default port.
* @param [in] path Path to locate object.
*
* @returns A URI structure if allocation and parsing completed successfully.
*/
extern URI_t *
uri_assemble(char *scheme, char *host, uint16_t port, char *path);
/**
* Parse a URI into its components. Does NOT try to guess if the scheme
* is not present. This function will attempt to turn the host parameter into
* a struct ip_addr. If host_addr is non zero upon return it was successful.
* Otherwise, gethostbyname() or gethostbyname_a() must be used to resolve the name.
* If the URI did not contain a port number, the parser will also attempt
* to find the default port for the service (for example, 80 for http).
*
* @param [in] uri_string String to parse (rtsp://media.test.com/BlazingSaddles)
*
* @returns A URI split into its components, if successful.
* @returns NULL on parsing or memory error.
*/
extern URI_t *
uri_parse(char *uri_string);
/*;end emacs generated header for file uri.c. Global function declarations only. */
#endif
/** @} */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?