bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
|
Classes | |
struct | url |
Static Public Member Functions | |
static long | get_current_memory_usage () noexcept |
Get the Resident Set Size in KB. | |
static void | trim_if_surrounding_quotes (std::string &value) |
Remove double quotes around a string This function will remove a leading and/or trailing double quote surrounding a string. | |
static void | trim_if_trailing_slash (std::string &value) |
If the string ends in a slash, remove it This function works for empty strings (doing nothing). If the string ends in a '/' it will be removed. | |
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 | set_mime_text (std::ostream &strm) |
Generate an HTTP 1.0 response header for a text document. | |
static void | set_mime_html (std::ostream &strm) |
Generate an HTTP 1.0 response header for a html document. | |
static std::string | www2id (const std::string &in, const std::string &escape="%", const std::string &except="") |
static std::string | unhexstring (const std::string &s) |
static std::string | lowercase (const std::string &s) |
static std::string | unescape (const std::string &s) |
static void | check_path (const std::string &path, const std::string &root, bool follow_sym_links) |
Is the combination of root + path a pathname the BES can/should access? | |
static char * | fastpidconverter (char *buf, int base) |
static char * | fastpidconverter (long val, char *buf, int base) |
static void | removeLeadingAndTrailingBlanks (std::string &key) |
static std::string | id2xml (std::string in, const std::string ¬_allowed="><&'\"") |
static std::string | xml2id (std::string in) |
static void | explode (char delim, const std::string &str, std::list< std::string > &values) |
static std::string | implode (const std::list< std::string > &values, char delim) |
static void | url_explode (const std::string &url_str, BESUtil::url &url_parts) |
Given a url, break the url into its different parts. | |
static std::string | url_create (BESUtil::url &url_parts) |
static std::string | assemblePath (const std::string &firstPart, const std::string &secondPart, bool leadingSlash=false, bool trailingSlash=false) |
Assemble path fragments making sure that they are separated by a single '/' character. | |
static std::string | pathConcat (const std::string &firstPart, const std::string &secondPart, char separator='/') |
Concatenate path fragments making sure that they are separated by a single '/' character. | |
static bool | endsWith (std::string const &fullString, std::string const &ending) |
static void | conditional_timeout_cancel () |
Checks if the timeout alarm should be canceled based on the value of the BES key BES.CancelTimeoutOnSend. | |
static void | exit_on_request_timeout () |
Checks if the timeout alarm should be canceled based on the value of the BES key BES.CancelTimeoutOnSend. | |
static unsigned int | replace_all (std::string &s, std::string find_this, std::string replace_with_this) |
Operates on the string 's' to replaces every occurrence of the value of the string 'find_this' with the value of the string 'replace_with_this'. | |
static std::string | normalize_path (const std::string &path, bool leading_separator, bool trailing_separator, std::string separator="/") |
Removes duplicate separators and provides leading and trailing separators as directed. | |
static void | tokenize (const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters="/") |
static std::string | get_time (bool use_local_time=false) |
static std::string | get_time (time_t the_time, bool use_local_time=false) |
Returns the time represented by 'the_time' as an ISO8601 string. | |
static std::vector< std::string > | split (const std::string &s, char delim='/', bool skip_empty=true) |
Splits the string s into the return vector of tokens using the delimiter delim and skipping empty values as instructed by skip_empty. | |
static BESCatalog * | separateCatalogFromPath (std::string &path) |
static uint64_t | file_to_stream (const std::string &file_name, std::ostream &o_strm, uint64_t read_start_position=0) |
Copies the contents of the file identified by file_name to the stream o_strm. | |
static std::string | get_dir_name (const std::string &p) |
static bool | is_directory (const std::string &p) |
Is the given path a directory? | |
static int | mkdir_p (const std::string &path, mode_t mode) |
static std::string | file_to_string (const std::string &filename) |
static std::string | file_to_string (const std::string &filename, std::string &error_msg) |
static int | make_temp_file (const std::string &temp_file_dir, std::string &temp_file_name) |
Make and open a temporary file. The file is opened such that we know it is unique and not in use by another process. The name and file descriptor are set in the RemoteResource object. | |
static void | string_to_file (const std::string &filename, const std::string &content) |
Write a string to a file. | |
static std::string & | remove_crlf (std::string &str) |
"Sanitizes" the string by replacing any 0x0A (new line) or 0x0D (carriage return) characters with 0x20 (space) | |
static std::string | uuid () |
|
static |
Assemble path fragments making sure that they are separated by a single '/' character.
If the parameter ensureLeadingSlash is true then the returned string will begin with a single '/' character followed by the string firstPart, a single '/' character, and the string secondPart.
firstPart | The first string to concatenate. |
secondPart | The second string to concatenate. |
leadingSlash | If this bool value is true then the returned string will have a leading slash. If the value of leadingSlash is false then the first character of the returned string will be the first character of the passed firstPart, which may be a slash. Default False. |
trailingSlash | If this bool is true then the returned string will end it a slash. If trailingSlash is false, then the returned string will not end with a slash. If trailing slash(es) need to be removed to accomplish this, then they will be removed. Default False. |
Definition at line 804 of file BESUtil.cc.
|
static |
Is the combination of root + path a pathname the BES can/should access?
Check if the specified path is valid
path | The path relative to the BES catalog root directory |
root | The BES catalog root directory |
follow_sym_links | True if the bes conf allows symbolic links, false by default |
Definition at line 385 of file BESUtil.cc.
|
static |
Checks if the timeout alarm should be canceled based on the value of the BES key BES.CancelTimeoutOnSend.
If the value of the BES Key BES.CancelTimeoutOnSend is false || no, then do not cancel the timeout alarm. The intent of this is to stop the timeout counter once the BES starts sending data back since, the network link used by a remote client may be low-bandwidth and data providers might want to ensure those users get their data (and don't submit second, third, ..., requests when/if the first one fails). The timeout is initiated in the BES framework when it first processes the request.
Default: If the BES key BES.CancelTimeoutOnSend is not set, or if it is set to true || yes then the timeout alarm will be canceled.
Definition at line 898 of file BESUtil.cc.
|
static |
Returns true if (the value of) 'fullString' ends with (the value of) 'ending', false otherwise.
Definition at line 837 of file BESUtil.cc.
|
static |
Checks if the timeout alarm should be canceled based on the value of the BES key BES.CancelTimeoutOnSend.
If the value of the BES Key BES.CancelTimeoutOnSend is false || no, then do not cancel the timeout alarm. The intent of this is to stop the timeout counter once the BES starts sending data back since, the network link used by a remote client may be low-bandwidth and data providers might want to ensure those users get their data (and don't submit second, third, ..., requests when/if the first one fails). The timeout is initiated in the BES framework when it first processes the request.
Default: If the BES key BES.CancelTimeoutOnSend is not set, or if it is set to true || yes then the timeout alrm will be canceled.
Definition at line 868 of file BESUtil.cc.
|
static |
explode a string into an array given a delimiter
Given a string of values separated by a delimiter, break out the values and store in the list.
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 543 of file BESUtil.cc.
|
static |
convert pid and place in provided buffer
Definition at line 418 of file BESUtil.cc.
|
static |
Definition at line 424 of file BESUtil.cc.
|
static |
Copies the contents of the file identified by file_name to the stream o_strm.
Thanks to O'Reilly: https://www.oreilly.com/library/view/c-cookbook/0596007612/ch10s08.html
file_name | |
o_strm |
Definition at line 1136 of file BESUtil.cc.
|
static |
Definition at line 1280 of file BESUtil.cc.
|
staticnoexcept |
Get the Resident Set Size in KB.
Definition at line 89 of file BESUtil.cc.
|
static |
For the given path, return the directory name. If the path is a directory, return the path. If the path is a file, return the directory name. This does not check if the path exists, but instead just parses the path.
Definition at line 1235 of file BESUtil.cc.
Returns the current time as an ISO8601 string.
use_local_time | True to use the local time, false (default) to use GMT |
Definition at line 1017 of file BESUtil.cc.
Returns the time represented by 'the_time' as an ISO8601 string.
the_time | A time_t value |
use_local_time | True to use the local time, false (default) to use GMT |
Definition at line 1029 of file BESUtil.cc.
|
static |
convert characters not allowed in xml to escaped characters
Replace characters that are not allowed in XML
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 487 of file BESUtil.cc.
|
static |
implode a list of values into a single string delimited by delim
Given a list of string values create a single string of values 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 620 of file BESUtil.cc.
|
static |
Is the given path a directory?
Definition at line 1222 of file BESUtil.cc.
|
static |
Convert a string to all lower case
Definition at line 257 of file BESUtil.cc.
|
static |
Make and open a temporary file. The file is opened such that we know it is unique and not in use by another process. The name and file descriptor are set in the RemoteResource object.
temp_file_dir | The directory to hold the temporary file. |
temp_file_name | The name of the temporary file. A value-result parameter. |
Definition at line 1297 of file BESUtil.cc.
|
static |
Create a directory and any parent directories that do not exist.
path | |
mode |
Definition at line 1254 of file BESUtil.cc.
|
static |
Removes duplicate separators and provides leading and trailing separators as directed.
raw_path | The string to normalize |
leading_separator | if true then the result will begin with a single separator character. If false the result will not begin with a separator character. |
trailing_separator | If true the result will end with a single separator character. If false the result will not end with a separator character. |
separator | A string, of length one, containing the separator character for the path. This parameter is optional and its value defaults to the slash '/' character. |
Definition at line 949 of file BESUtil.cc.
|
static |
Concatenate path fragments making sure that they are separated by a single '/' character.
Returns a new string made from appending secondPart to firstPart while ensuring that a single separator appears between the two parts.
firstPart | The first string to concatenate. |
secondPart | The second string to concatenate. |
separator | The separator character to use between the two concatenated strings. Default: '/' |
Definition at line 754 of file BESUtil.cc.
|
static |
"Sanitizes" the string by replacing any 0x0A (new line) or 0x0D (carriage return) characters with 0x20 (space)
msg | The string to "sanitize" |
Definition at line 1334 of file BESUtil.cc.
|
static |
remove leading and trailing blanks from a string
Definition at line 448 of file BESUtil.cc.
|
static |
Operates on the string 's' to replaces every occurrence of the value of the string 'find_this' with the value of the string 'replace_with_this'.
Convert a string to all lower case
Definition at line 924 of file BESUtil.cc.
|
static |
Definition at line 1085 of file BESUtil.cc.
|
static |
Generate an HTTP 1.0 response header for a html document.
strm | Write the MIME header to this ostream. |
Definition at line 158 of file BESUtil.cc.
|
static |
Generate an HTTP 1.0 response header for a text document.
strm | Write the MIME header to this ostream. |
Definition at line 139 of file BESUtil.cc.
|
static |
Splits the string s into the return vector of tokens using the delimiter delim and skipping empty values as instructed by skip_empty.
s | The string to tokenize. |
delim | The character delimiter to utilize during tokenization. default: '/' |
skip_empty | A boolean flag which controls if empty tokens are returned. |
Definition at line 1068 of file BESUtil.cc.
|
static |
Write a string to a file.
filename | |
content |
Definition at line 1321 of file BESUtil.cc.
|
static |
A call out thanks to: http://www.oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html for the tokenizer.
Definition at line 995 of file BESUtil.cc.
|
static |
Remove double quotes around a string This function will remove a leading and/or trailing double quote surrounding a string.
value | The string, modified |
Definition at line 126 of file BESUtil.cc.
|
static |
If the string ends in a slash, remove it This function works for empty strings (doing nothing). If the string ends in a '/' it will be removed.
value | The string, modified in place |
Definition at line 113 of file BESUtil.cc.
|
static |
Unescape characters with backslash before them
Definition at line 267 of file BESUtil.cc.
|
static |
Definition at line 229 of file BESUtil.cc.
|
static |
Definition at line 728 of file BESUtil.cc.
|
static |
Given a url, break the url into its different parts.
The different parts are the protocol, the domain name, a username if specified, a password if specified, a port if specified, and a path if specified.
struct url { string protocol ; string domain ; string uname ; string psswd ; string port ; string path ; } ;
url | string representation of the URL |
Definition at line 660 of file BESUtil.cc.
|
static |
Definition at line 1344 of file BESUtil.cc.
|
static |
This functions are used to unescape hex characters from strings
Definition at line 242 of file BESUtil.cc.
|
static |
unescape xml escaped characters
Given a string that contains XML escape sequences (i.e., entities), translate those back into ASCII characters. Return the modified string.
in | The string to modify. |
Definition at line 504 of file BESUtil.cc.