#include <BESUtil.h>
Static Public Member Functions | |
MIME utility functions | |
These functions are used to create the MIME headers for a message from a server to a client. NB: These functions actually write both the response status line and the header.
| |
static void | check_path (const string &path, const string &root, bool follow_sym_links) |
Check if the specified path is valid. | |
static void | explode (char delim, const string &str, list< string > &values) |
explode a string into an array given a delimiter | |
static char * | fastpidconverter (long val, char *buf, int base) |
static char * | fastpidconverter (char *buf, int base) |
convert pid and place in provided buffer | |
static string | id2xml (string in, const string ¬_allowed="><&'\"") |
convert characters not allowed in xml to escaped characters | |
static string | implode (const list< string > &values, char delim) |
implode a list of values into a single string delimited by delim | |
static string | lowercase (const string &s) |
Convert a string to all lower case. | |
static void | removeLeadingAndTrailingBlanks (string &key) |
remove leading and trailing blanks from a string | |
static void | set_mime_html (ostream &strm) |
Generate an HTTP 1.0 response header for a html document. | |
static void | set_mime_text (ostream &strm) |
Generate an HTTP 1.0 response header for a text document. | |
static string | unescape (const string &s) |
Unescape characters with backslash before them. | |
static string | unhexstring (string s) |
static string | www2id (const string &in, const string &escape="%", const string &except="") |
This functions are used to unescape hex characters from strings. | |
static string | xml2id (string in) |
unescape xml escaped characters |
Definition at line 44 of file BESUtil.h.
void BESUtil::check_path | ( | const string & | path, | |
const string & | root, | |||
bool | follow_sym_links | |||
) | [static] |
Check if the specified path is valid.
Checks to see if the specified path is a valid path or not. The root directory specified is assumed to be valid, so we don't check that part of the path. The path parameter is relative to the root directory.
If follow_sym_links is false, then if any part of the specified path is a symbolic link, this function will return false, set the passed has_sym_link parameter. No error message is specified.
If there is a problem accessing the specified path then the error string will be filled with whatever system error message is provided.
param path path to check param root root directory path, assumed to be valid param follow_sym_links specifies whether allowed to follow symbolic links throws BESForbiddenError if the user is not allowed to traverse the path throws BESNotFoundError if there is a problem accessing the path or the path does not exist.
Definition at line 249 of file BESUtil.cc.
Referenced by BESContainerStorageVolatile::add_container(), and BESCatalogDirectory::show_catalog().
void BESUtil::explode | ( | char | delim, | |
const string & | str, | |||
list< string > & | values | |||
) | [static] |
explode a string into an array given a delimiter
Quoted values must be escaped.
If values contain the delimiter then the value must be wrapped in quotes.
delim | delimiter separating the values | |
str | the original string | |
values | list of the delimited values returned to caller |
BESInternalError | if missing ending quote or delimiter does not follow end quote |
Definition at line 513 of file BESUtil.cc.
Referenced by BESCatalogUtils::BESCatalogUtils().
char * BESUtil::fastpidconverter | ( | long | val, | |
char * | buf, | |||
int | base | |||
) | [static] |
Definition at line 389 of file BESUtil.cc.
References fastpidconverter().
Here is the call graph for this function:
char * BESUtil::fastpidconverter | ( | char * | buf, | |
int | base | |||
) | [static] |
convert pid and place in provided buffer
Definition at line 383 of file BESUtil.cc.
Referenced by BESProcIdResponseHandler::execute(), and fastpidconverter().
string BESUtil::id2xml | ( | string | in, | |
const string & | not_allowed = "><&'\"" | |||
) | [static] |
convert characters not allowed in xml to escaped characters
in | The string in which to replace characters. | |
not_allowed | The set of characters that are not allowed in XML. default: ><&'(single quote)"(double quote) |
Definition at line 454 of file BESUtil.cc.
string BESUtil::implode | ( | const list< string > & | values, | |
char | delim | |||
) | [static] |
implode a list of values into a single string delimited by delim
If the delimiter exists in a value in the list then that value must be enclosed in quotes
values | list of string values to implode | |
delim | the delimiter to use in creating the resulting string |
Definition at line 606 of file BESUtil.cc.
string BESUtil::lowercase | ( | const string & | s | ) | [static] |
Convert a string to all lower case.
Definition at line 190 of file BESUtil.cc.
Referenced by BESCatalogUtils::BESCatalogUtils(), BESContainerStorageVolatile::BESContainerStorageVolatile(), BESXMLGetCommand::parse_basic_get(), and BESXMLShowCommand::parse_request().
void BESUtil::removeLeadingAndTrailingBlanks | ( | string & | key | ) | [static] |
remove leading and trailing blanks from a string
Definition at line 417 of file BESUtil.cc.
Referenced by BESXMLUtils::GetChild(), BESXMLUtils::GetNodeInfo(), and BESXMLUtils::GetProps().
void BESUtil::set_mime_html | ( | ostream & | strm | ) | [static] |
Generate an HTTP 1.0 response header for a html document.
strm | Write the MIME header to this ostream. |
Definition at line 85 of file BESUtil.cc.
References CRLF, and PACKAGE_STRING.
Referenced by BESHTMLInfo::add_data(), BESBasicTransmitter::send_html(), and BESBasicHttpTransmitter::send_html().
void BESUtil::set_mime_text | ( | ostream & | strm | ) | [static] |
Generate an HTTP 1.0 response header for a text document.
strm | Write the MIME header to this ostream. |
Definition at line 65 of file BESUtil.cc.
References CRLF, and PACKAGE_STRING.
Referenced by BESTextInfo::add_data(), BESBasicTransmitter::send_text(), and BESBasicHttpTransmitter::send_text().
string BESUtil::unescape | ( | const string & | s | ) | [static] |
string BESUtil::unhexstring | ( | string | s | ) | [static] |
string BESUtil::www2id | ( | const string & | in, | |
const string & | escape = "%" , |
|||
const string & | except = "" | |||
) | [static] |
This functions are used to unescape hex characters from strings.
Definition at line 174 of file BESUtil.cc.
References unhexstring().
Here is the call graph for this function:
string BESUtil::xml2id | ( | string | in | ) | [static] |
unescape xml escaped characters
Return the modified string.
in | The string to modify. |
Definition at line 473 of file BESUtil.cc.
Referenced by BESXMLUtils::GetNodeInfo(), and BESXMLUtils::GetProps().