UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
compa::anonymous_namespace{webserver.cpp} Namespace Reference

Classes

struct  CXmlAlias
 Alias directory structure on the webserver for an XML document. More...
 

Enumerations

enum  resp_type {
  RESP_UNSPEC , RESP_FILEDOC , RESP_XMLDOC , RESP_HEADERS ,
  RESP_WEBDOC , RESP_POST
}
 Response Types. More...
 

Functions

Scope restricted to file
char * web_server_asctime_r (const struct tm *tm, char *buf)
 Multiplatform wrapper to make win32 asctime_s compatible to posix asctime_r.
 
int search_extension (const char *a_extension, const char **a_con_type, const char **a_con_subtype)
 Based on the extension, returns the content type and content subtype.
 
int get_content_type (const char *filename, UpnpFileInfo *fileInfo)
 Based on the extension of the filename, clones an XML string based on type and content subtype.
 
int get_file_info (const char *filename, UpnpFileInfo *info)
 Get file information.
 
int get_alias (const char *request_file, CXmlAlias *alias, UpnpFileInfo *info)
 Compare file names.
 
int isFileInVirtualDir (char *filePath, const void **cookie)
 Compares filePath with paths from the list of virtual directory lists.
 
void ToUpperCase (char *s)
 Converts C string in place to upper case.
 
char * StrStr (char *s1, const char *s2)
 Finds a substring from a string in a case insensitive way.
 
char * StrTok (char **Src, const char *Del)
 Finds next token in a string.
 
int GetNextRange (char **SrcRangeStr, off_t *FirstByte, off_t *LastByte)
 Returns a range of integers from a string.
 
int CreateHTTPRangeResponseHeader (char *ByteRangeSpecifier, off_t FileLength, struct SendInstruction *Instr)
 Fills in the Offset, read size and contents to send out as an HTTP Range Response.
 
int CheckOtherHTTPHeaders (http_message_t *Req, struct SendInstruction *RespInstr, off_t FileSize)
 Get header id from the request parameter.
 
void FreeExtraHTTPHeaders (UpnpListHead *extraHeadersList)
 Free extra HTTP headers.
 
int ExtraHTTPHeaders (http_message_t *Req, UpnpListHead *extraHeadersList)
 Build an array of unrecognized headers.
 
int process_request_in (SOCKINFO *info, http_message_t *req, enum resp_type *rtype, membuffer *headers, membuffer *filename, CXmlAlias *a_alias, SendInstruction *RespInstr)
 Process a remote request and return the result.
 
int http_RecvPostMessage (http_parser_t *parser, SOCKINFO *info, char *filename, struct SendInstruction *Instr)
 Receives the HTTP post message.
 

Variables

const char * gMediaTypes []
 Media types.
 
constexpr size_t APPLICATION_INDEX {4}
 index to get media type of application from the media types table.
 
constexpr size_t ASCTIME_R_BUFFER_SIZE {26}
 Number of elements for asctime_s on win32, means buffer size.
 
CXmlAlias gAliasDoc
 Global XML document object.
 

Enumeration Type Documentation

◆ resp_type

enum compa::anonymous_namespace{webserver.cpp}::resp_type

Response Types.

Definition at line 74 of file webserver.cpp.

Function Documentation

◆ web_server_asctime_r()

char * compa::anonymous_namespace{webserver.cpp}::web_server_asctime_r ( const struct tm *  tm,
char *  buf 
)

Multiplatform wrapper to make win32 asctime_s compatible to posix asctime_r.

Only available on Microsoft Windows.

Definition at line 318 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search_extension()

int compa::anonymous_namespace{webserver.cpp}::search_extension ( const char *  a_extension,
const char **  a_con_type,
const char **  a_con_subtype 
)
inline

Based on the extension, returns the content type and content subtype.

For example:

Ext type subtype
txt text plain
htm text html
xml text xml
mp3 audio mpeg

The complete list you find at UPnPsdk::mediatype_list.

Returns
On Success: 0
On Error: -1 - not found
Parameters
[in]a_extension
[out]a_con_type
[out]a_con_subtype

Definition at line 346 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_content_type()

int compa::anonymous_namespace{webserver.cpp}::get_content_type ( const char *  filename,
UpnpFileInfo fileInfo 
)
inline

Based on the extension of the filename, clones an XML string based on type and content subtype.

If content type and sub type are not found, unknown types are used.

Returns
On Success: 0.
On Error:
  • UPNP_E_FILE_NOT_FOUND - on invalid filename.
  • UPNP_E_INVALID_ARGUMENT - on invalid fileInfo.
  • UPNP_E_OUTOF_MEMORY - on memory allocation failures.
Parameters
[in]filenamewith extension, extension will be used.
[out]fileInfo

Definition at line 379 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_file_info()

int compa::anonymous_namespace{webserver.cpp}::get_file_info ( const char *  filename,
UpnpFileInfo info 
)

Get file information.

Returns
Integer.
Parameters
[in]filenameFilename having the description document.
[out]infoFile information object having file attributes such as filelength, when was the file last modified, whether a file or a directory and whether the file or directory is readable.

Definition at line 430 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_alias()

int compa::anonymous_namespace{webserver.cpp}::get_alias ( const char *  request_file,
CXmlAlias alias,
UpnpFileInfo info 
)
inline

Compare file names.

Compare the file names between the one on the XML alias and the one passed in as the input parameter. If equal extract file information.

Returns
  • 1 - On Success
  • 0 if request is not an alias
Parameters
[in]request_filerequest file passed in to be compared with.
[out]aliasxml alias object which has a file name stored.
[out]infoFile information object which will be filled up if the file comparison succeeds.

Definition at line 505 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFileInVirtualDir()

int compa::anonymous_namespace{webserver.cpp}::isFileInVirtualDir ( char *  filePath,
const void **  cookie 
)

Compares filePath with paths from the list of virtual directory lists.

Returns
int.
Parameters
[in]filePathDirectory path to be tested for virtual directory.
[out]cookieThe cookie registered with this virtual directory, if matched.

Definition at line 531 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToUpperCase()

void compa::anonymous_namespace{webserver.cpp}::ToUpperCase ( char *  s)

Converts C string in place to upper case.

Parameters
[in,out]sstring to be converted.

Definition at line 572 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StrStr()

char * compa::anonymous_namespace{webserver.cpp}::StrStr ( char *  s1,
const char *  s2 
)

Finds a substring from a string in a case insensitive way.

Returns
A pointer to the first occurence of s2 in s1.
Parameters
[in]s1Input string.
[in]s2Input sub-string.

Definition at line 586 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StrTok()

char * compa::anonymous_namespace{webserver.cpp}::StrTok ( char **  Src,
const char *  Del 
)

Finds next token in a string.

Returns
Pointer to the next token.
Parameters
[in]SrcString containing the token.
[in]DelSet of delimiter characters.

Definition at line 622 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNextRange()

int compa::anonymous_namespace{webserver.cpp}::GetNextRange ( char **  SrcRangeStr,
off_t *  FirstByte,
off_t *  LastByte 
)

Returns a range of integers from a string.

Returns
Always returns 1.
Parameters
SrcRangeStrstring containing the token / range.
FirstBytegets the first byte of the token.
LastBytegets the last byte of the token.

Definition at line 650 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateHTTPRangeResponseHeader()

int compa::anonymous_namespace{webserver.cpp}::CreateHTTPRangeResponseHeader ( char *  ByteRangeSpecifier,
off_t  FileLength,
struct SendInstruction Instr 
)

Fills in the Offset, read size and contents to send out as an HTTP Range Response.

Returns
  • HTTP_BAD_REQUEST
  • HTTP_INTERNAL_SERVER_ERROR
  • HTTP_REQUEST_RANGE_NOT_SATISFIABLE
  • HTTP_OK
Parameters
ByteRangeSpecifierString containing the range.
FileLengthLength of the file.
[out]InstrSendInstruction object where the range operations will be stored.

Definition at line 707 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckOtherHTTPHeaders()

int compa::anonymous_namespace{webserver.cpp}::CheckOtherHTTPHeaders ( http_message_t Req,
struct SendInstruction RespInstr,
off_t  FileSize 
)

Get header id from the request parameter.

Get header id from the request parameter and take appropriate action based on the ids as an HTTP Range Response.

Returns
  • HTTP_BAD_REQUEST
  • HTTP_INTERNAL_SERVER_ERROR
  • HTTP_REQUEST_RANGE_NOT_SATISFIABLE
  • HTTP_OK
Parameters
[in]ReqHTTP Request message.
[out]RespInstrSend Instruction object to data for the response.
FileSizeSize of the file containing the request document.

Definition at line 822 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FreeExtraHTTPHeaders()

void compa::anonymous_namespace{webserver.cpp}::FreeExtraHTTPHeaders ( UpnpListHead extraHeadersList)

Free extra HTTP headers.

Parameters
[in]extraHeadersListextra HTTP headers to free.

Definition at line 945 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExtraHTTPHeaders()

int compa::anonymous_namespace{webserver.cpp}::ExtraHTTPHeaders ( http_message_t Req,
UpnpListHead extraHeadersList 
)

Build an array of unrecognized headers.

Returns
On success: HTTP_OK
On error: HTTP_INTERNAL_SERVER_ERROR
Parameters
[in]ReqHTTP Request message.
[in]extraHeadersListExtra header list.

Definition at line 966 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_request_in()

int compa::anonymous_namespace{webserver.cpp}::process_request_in ( SOCKINFO info,
http_message_t req,
enum resp_type rtype,
membuffer headers,
membuffer filename,
CXmlAlias a_alias,
SendInstruction RespInstr 
)

Process a remote request and return the result.

Creates the different kind of header depending on the type of request.

Returns
On success: HTTP_OK
On error:
  • HTTP_BAD_REQUEST
  • HTTP_INTERNAL_SERVER_ERROR
  • HTTP_REQUEST_RANGE_NOT_SATISFIABLE
  • HTTP_FORBIDDEN
  • HTTP_NOT_FOUND
  • HTTP_NOT_ACCEPTABLE
Parameters
[in]infoSocket info.
[in]reqHTTP Request message.
[out]rtypeTpye of response.
[out]headersHeaders.
[out]filenameGet filename from request document.
[out]a_aliasXml alias document from the request document.
[out]RespInstrSend Instruction object where the response is set up.

Definition at line 1025 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_RecvPostMessage()

int compa::anonymous_namespace{webserver.cpp}::http_RecvPostMessage ( http_parser_t parser,
SOCKINFO info,
char *  filename,
struct SendInstruction Instr 
)

Receives the HTTP post message.

Returns
On success: HTTP_OK
On error:
  • HTTP_INTERNAL_SERVER_ERROR
  • HTTP_UNAUTHORIZED
  • HTTP_BAD_REQUEST
  • HTTP_SERVICE_UNAVAILABLE
Parameters
parserHTTP Parser object.
[in]infoSocket Information object.
filenameFile where received data is copied to.
InstrSend Instruction object which gives information whether the file is a virtual file or not.

Definition at line 1390 of file webserver.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ gMediaTypes

const char* compa::anonymous_namespace{webserver.cpp}::gMediaTypes[]
Initial value:
= {
NULL,
"audio",
"video",
"image",
"application",
"text"
}

Media types.

Definition at line 84 of file webserver.cpp.

◆ APPLICATION_INDEX

constexpr size_t compa::anonymous_namespace{webserver.cpp}::APPLICATION_INDEX {4}
constexpr

index to get media type of application from the media types table.

Definition at line 94 of file webserver.cpp.

◆ ASCTIME_R_BUFFER_SIZE

constexpr size_t compa::anonymous_namespace{webserver.cpp}::ASCTIME_R_BUFFER_SIZE {26}
constexpr

Number of elements for asctime_s on win32, means buffer size.

Definition at line 97 of file webserver.cpp.

◆ gAliasDoc

CXmlAlias compa::anonymous_namespace{webserver.cpp}::gAliasDoc

Global XML document object.

Definition at line 307 of file webserver.cpp.