tools.cc File Reference

#include "tools.h"
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <limits.h>
#include <netdb.h>
#include <string.h>
#include "config_manager.h"
#include <net/if.h>
#include "md5/md5.h"
#include "file_io_handler.h"
#include "metadata_handler.h"

Go to the source code of this file.

Data Structures

struct  randomizer

Defines

#define WHITE_SPACE   " \t\r\n"
#define FCC_OFFSET   0xbc

Functions

Ref< Array< StringBase > > split_string (String str, char sep, bool empty)
 splits the given string into array of strings using a separator character.
Ref< Array< StringBase > > split_path (String str)
 splits the given file path into the path to the file and the filename.
String trim_string (String str)
 returns str with leading and trailing whitespace removed
bool check_path (String path, bool needDir)
 Checks existance of the specified file or path.
time_t check_path_ex (String path, bool needDir, bool existenceUnneeded, off_t *filesize)
 Checks existance of the specified file or path.
bool is_executable (String path, int *err)
 Checks if the given binary is executable by our process.
String find_in_path (String exec)
 Checks if the given executable exists in $PATH.
bool string_ok (String str)
 Checks if the string contains any data.
bool string_ok (Ref< StringBuffer > str)
void string_ok_ex (String str)
 Checks if the string contains any data.
String http_redirect_to (String ip, String port, String page)
 Render HTML that is doing a redirect to the given ip, port and html page.
String hex_encode (void *data, int len)
 Encodes arbitrary data to a hex string.
String hex_decode_string (String encoded)
 Decodes hex encoded string.
String hex_md5 (void *data, int length)
 Generates hex md5 sum of the given data.
String hex_string_md5 (String str)
 Generates hex md5 sum of the given string.
String generate_random_id ()
 Generates random id.
String url_escape (String str)
 Converts a string to a URL (meaning: 20 instead of space and so on).
String url_unescape (String str)
 Opposite of url_escape :).
String mime_types_to_CSV (Ref< Array< StringBase > > mimeTypes)
 Convert an array of strings to a CSV list, with additional protocol information.
String mt_strerror (int mt_errno)
 a wrapper for the reentrant strerror_r() function
String read_text_file (String path)
 Reads the entire contents of a text file and returns it as a string.
void write_text_file (String path, String contents)
 writes a string into a text file
void copy_file (String from, String to)
 copies a file
int StringBaseComparator (void *arg1, void *arg2)
static void quicksort_impl (COMPARABLE *a, int lo0, int hi0, COMPARATOR comparator)
void quicksort (COMPARABLE *arr, int size, COMPARATOR comparator)
String renderProtocolInfo (String mimetype, String protocol, String extend)
 Renders a string that can be used as the protocolInfo resource attribute: "http-get:*:mimetype:*".
String getMTFromProtocolInfo (String protocol)
 Extracts mimetype from the protocol info string.
String getProtocol (String protocolInfo)
 Parses a protocolInfo string (see renderProtocolInfo).
String secondsToHMS (int seconds)
 Converts a number of seconds to H+:MM:SS representation as required by the UPnP spec.
int HMSToSeconds (String time)
 converts a "H:MM:SS:" representation to seconds
void set_jpeg_resolution_resource (Ref< CdsItem > item, int res_num)
 Sets resolution for a given resource index, item must be a JPEG image.
bool check_resolution (String resolution, int *x, int *y)
 checks if the given string has the format xr x yr (i.e. 320x200 etc.)
String escape (String string, char escape_char, char to_escape)
String unescape (String string, char escape)
 Unescapes the given String.
String unescape_amp (String string)
String fallbackString (String first, String fallback)
 Returns the first string if it isn't "nil", otherwise the fallback string.
unsigned int stringHash (String str)
 computes an (unsigned int) hash for the given string
String intArrayToCSV (int *array, int size)
void getTimespecNow (struct timespec *ts)
long getDeltaMillis (struct timespec *first)
long getDeltaMillis (struct timespec *first, struct timespec *second)
void getTimespecAfterMillis (long delta, struct timespec *ret, struct timespec *start)
int compareTimespecs (struct timespec *a, struct timespec *b)
String normalizePath (String path)
 This function makes sure that there are no trailing slashes, no consecutive slashes. If /../ or /.. is encountered an exception is thrown.
String interfaceToIP (String interface)
 Finds the IP address of the specified network interface.
bool validateYesNo (String value)
 Returns true if the given string is eitehr "yes" or "no", otherwise returns false.
Ref< Array< StringBase > > parseCommandLine (String line, String in, String out)
 Parses a command line, splitting the arguments into an array and substitutes in and out tokens with given strings.
String tempName (String leadPath, char *tmpl)
 this is the mkstemp routine from glibc, the only difference is that it does not return an fd but just the name that we could use.
bool isTheora (String ogg_filename)
 Determines if the particular ogg file contains a video (theora).
String get_last_path (String location)
 Gets an absolute filename as a parameter and returns the last parent.
ssize_t getValidUTF8CutPosition (zmm::String str, size_t cutpos)
 Calculates a position where it is safe to cut an UTF-8 string.
String getAVIFourCC (zmm::String avi_filename)
 Fallback code to retrieve the used fourcc from an AVI file.

Variables

static const char * HEX_CHARS = "0123456789abcdef"
static const char * hex = "0123456789ABCDEF"

Detailed Description

Definition in file tools.cc.


Define Documentation

#define FCC_OFFSET   0xbc

Referenced by getAVIFourCC().

#define WHITE_SPACE   " \t\r\n"

Definition at line 61 of file tools.cc.

Referenced by trim_string().


Function Documentation

bool check_path ( zmm::String  path,
bool  needDir = false 
)

Checks existance of the specified file or path.

Parameters:
path file or directory to be checked.
needDir true when checked item has to be a directory.
Returns:
true path or file exists
false path of file not found

Definition at line 157 of file tools.cc.

References zmm::String::c_str().

Referenced by ContentManager::_rescanDirectory(), ContentManager::addFile(), ConfigManager::ConfigManager(), ContentManager::ContentManager(), ConfigManager::createAutoscanListFromNodeset(), ConfigManager::createDefaultConfig(), find_in_path(), web::addObject::process(), ConfigManager::validate(), CdsActiveItem::validate(), and CdsItem::validate().

time_t check_path_ex ( zmm::String  path,
bool  needDir = false,
bool  existenceUnneeded = false,
off_t *  filesize = NULL 
)

Checks existance of the specified file or path.

Parameters:
path file or directory to be checked.
needDir true when checked item has to be a directory.
existenceUnneeded do not throw exception if file was not found
filesize returns the size of the file
Returns:
last modification time of the path or directory

More or less the same as check_path, the only difference is, that this function throws an exception if a path or directory was not found or was not the desired type. Additionally this function returns the last modification time of the file or directory and, if needed, also the filesize.

Definition at line 171 of file tools.cc.

References _, _Exception, zmm::String::c_str(), mt_strerror(), and NULL.

Referenced by ContentManager::addVirtualItem(), ConfigManager::prepare_path(), MetadataHandler::setMetadata(), and ContentManager::shutdown().

bool check_resolution ( String  resolution,
int *  x,
int *  y 
)

checks if the given string has the format xr x yr (i.e. 320x200 etc.)

Definition at line 757 of file tools.cc.

References _, NULL, split_string(), and string_ok().

Referenced by CdsResourceManager::addResources().

int compareTimespecs ( struct timespec *  a,
struct timespec *  b 
)

Definition at line 1041 of file tools.cc.

Referenced by Timer::getNextNotifyTime(), Timer::notify(), and Timer::triggerWait().

void copy_file ( zmm::String  from,
zmm::String  to 
)

copies a file

Parameters:
from the path to the file to copy from
to the path to the file to copy to

Definition at line 510 of file tools.cc.

References _, _Exception, zmm::String::c_str(), FREE, MALLOC, and mt_strerror().

String escape ( String  string,
char  escape_char,
char  to_escape 
)
String fallbackString ( zmm::String  first,
zmm::String  fallback 
)

Returns the first string if it isn't "nil", otherwise the fallback string.

Parameters:
first the string to return if it isn't nil
fallback fallback string to return if first is nil
Returns:
return first if it isn't nil, otherwise fallback

Definition at line 972 of file tools.cc.

References nil.

Referenced by SQLStorage::createObjectFromRow().

String find_in_path ( zmm::String  exec  ) 

Checks if the given executable exists in $PATH.

Parameters:
exec filename of the executable that needs to be checked
Returns:
aboslute path to the given executable or nil of it was not found

Definition at line 213 of file tools.cc.

References _, check_path(), nil, zmm::String::startsWith(), and string_ok().

String generate_random_id (  ) 

Generates random id.

Returns:
String representing the newly created id.

Definition at line 346 of file tools.cc.

References hex_md5(), NULL, randomizer::salt, and randomizer::tv.

Referenced by SessionManager::createSession(), and generate_token().

String get_last_path ( zmm::String  location  ) 

Gets an absolute filename as a parameter and returns the last parent.

"/some/path/to/file.txt" -> "to"

Definition at line 1360 of file tools.cc.

References DIR_SEPARATOR, zmm::String::length(), zmm::String::rindex(), and zmm::String::substring().

Referenced by FallbackLayout::addImage(), and FallbackLayout::addVideo().

String getAVIFourCC ( zmm::String  avi_filename  ) 

Fallback code to retrieve the used fourcc from an AVI file.

This code is based on offsets, so we will use it only if ffmpeg is not available.

Definition at line 1441 of file tools.cc.

References _, _Exception, zmm::String::c_str(), FCC_OFFSET, MALLOC, mt_strerror(), nil, NULL, and string_ok().

Referenced by MetadataHandler::setMetadata().

long getDeltaMillis ( struct timespec *  first,
struct timespec *  second 
)

Definition at line 1017 of file tools.cc.

long getDeltaMillis ( struct timespec *  first  ) 
String getMTFromProtocolInfo ( zmm::String  protocol  ) 

Extracts mimetype from the protocol info string.

Parameters:
protocol info string as used in the protocolInfo attribute

Definition at line 636 of file tools.cc.

References nil, and split_string().

Referenced by CdsResourceManager::addResources(), FileRequestHandler::get_info(), and FileRequestHandler::open().

String getProtocol ( zmm::String  protocolInfo  ) 

Parses a protocolInfo string (see renderProtocolInfo).

Parameters:
protocolInfoStr the String from renderProtocolInfo.
Returns:
Protocol (i.e. http-get).

Definition at line 645 of file tools.cc.

References _, zmm::String::index(), and zmm::String::substring().

Referenced by web::edit_load::process().

void getTimespecAfterMillis ( long  delta,
struct timespec *  ret,
struct timespec *  start 
)

Definition at line 1022 of file tools.cc.

References getTimespecNow(), and NULL.

Referenced by Timer::TimerSubscriberElement< T >::notified(), and UpdateManager::threadProc().

void getTimespecNow ( struct timespec *  ts  ) 
ssize_t getValidUTF8CutPosition ( zmm::String  str,
size_t  cutpos 
)

Calculates a position where it is safe to cut an UTF-8 string.

Returns:
Caclulated position or -1 in case of an error.

Definition at line 1377 of file tools.cc.

References zmm::String::charAt(), and zmm::String::length().

Referenced by UpnpXML_DIDLRenderObject().

String hex_decode_string ( zmm::String  encoded  ) 

Decodes hex encoded string.

Parameters:
encoded hex-encoded string.
Returns:
decoded string

Definition at line 299 of file tools.cc.

References zmm::String::c_str(), HEX_CHARS, and zmm::String::length().

Referenced by web::autoscan::process(), web::files::process(), web::directories::process(), and web::add::process().

String hex_encode ( void *  data,
int  len 
)

Encodes arbitrary data to a hex string.

Parameters:
data Buffer that is holding the data
len Length of the buffer.
Returns:
string of the data in hex representation.

Definition at line 279 of file tools.cc.

References HEX_CHARS.

Referenced by hex_md5(), web::files::process(), and web::directories::process().

String hex_md5 ( void *  data,
int  length 
)

Generates hex md5 sum of the given data.

Definition at line 331 of file tools.cc.

References hex_encode(), md5_append(), md5_finish(), and md5_init().

Referenced by generate_random_id(), and hex_string_md5().

String hex_string_md5 ( String  str  ) 

Generates hex md5 sum of the given string.

Definition at line 342 of file tools.cc.

References zmm::String::c_str(), hex_md5(), and zmm::String::length().

Referenced by check_token().

int HMSToSeconds ( String  time  ) 

converts a "H:MM:SS:" representation to seconds

Definition at line 673 of file tools.cc.

References zmm::String::c_str(), log_warning, and string_ok().

String http_redirect_to ( zmm::String  ip,
zmm::String  port,
zmm::String  page = _("") 
)

Render HTML that is doing a redirect to the given ip, port and html page.

Parameters:
ip IP address as string.
port Port as string. page HTML document to redirect to.
Returns:
string representing the desired HTML document.

Definition at line 274 of file tools.cc.

References _.

Referenced by ConfigManager::writeBookmark().

String intArrayToCSV ( int *  array,
int  size 
)

Definition at line 989 of file tools.cc.

References nil.

Referenced by Session::getUIUpdateIDs().

String interfaceToIP ( zmm::String  interface  ) 

Finds the IP address of the specified network interface.

Parameters:
interface i.e. eth0, lo, etc.
Returns:
IP address or nil if interface was not found.

Definition at line 1128 of file tools.cc.

References log_error, MALLOC, mt_strerror(), nil, NULL, and string_ok().

Referenced by Server::upnp_init().

bool is_executable ( zmm::String  path,
int *  err = NULL 
)

Checks if the given binary is executable by our process.

Parameters:
path absolute path of the binary
err if not NULL err will contain the errno result of the check
Returns:
true if the given binary is executable by our process, otherwise false

Definition at line 201 of file tools.cc.

References zmm::String::c_str(), and NULL.

bool isTheora ( String  ogg_filename  ) 

Determines if the particular ogg file contains a video (theora).

Definition at line 1314 of file tools.cc.

References _, _Exception, zmm::String::c_str(), and mt_strerror().

Referenced by ContentManager::createObjectFromFile(), and MetadataHandler::setMetadata().

String mime_types_to_CSV ( zmm::Ref< zmm::Array< zmm::StringBase > >  mimeTypes  ) 

Convert an array of strings to a CSV list, with additional protocol information.

Parameters:
array that needs to be converted
Returns:
string containing the CSV list

Definition at line 430 of file tools.cc.

Referenced by ConnectionManagerService::process_subscription_request(), and ConnectionManagerService::upnp_action_GetProtocolInfo().

String mt_strerror ( int  mt_errno  ) 

a wrapper for the reentrant strerror_r() function

Parameters:
mt_errno the errno to get the error string from
Returns:
the error string

Definition at line 444 of file tools.cc.

References _, FREE, MALLOC, and NULL.

Referenced by ContentManager::_rescanDirectory(), CachedURL::CachedURL(), check_path_ex(), copy_file(), ContentManager::createObjectFromFile(), getAVIFourCC(), getTimespecNow(), CachedURL::getURL(), interfaceToIP(), isTheora(), read_text_file(), and write_text_file().

String normalizePath ( String  path  ) 

This function makes sure that there are no trailing slashes, no consecutive slashes. If /../ or /.. is encountered an exception is thrown.

Definition at line 1054 of file tools.cc.

References _, _Exception, zmm::String::c_str(), zmm::String::charAt(), zmm::String::charPtrAt(), DIR_SEPARATOR, zmm::String::index(), zmm::String::length(), log_debug, and print_backtrace.

Referenced by ConfigManager::ConfigManager(), and ConfigManager::createAutoscanListFromNodeset().

Ref<Array<StringBase> > parseCommandLine ( zmm::String  line,
zmm::String  in,
zmm::String  out 
)

Parses a command line, splitting the arguments into an array and substitutes in and out tokens with given strings.

This function splits a string into array parts, where space is used as the separator. In addition special in and out tokens are replaced by given strings.

Todo:
add escaping

Definition at line 1212 of file tools.cc.

References _, nil, zmm::String::replace(), and split_string().

void quicksort ( COMPARABLE arr,
int  size,
COMPARATOR  comparator 
)

Definition at line 618 of file tools.cc.

References quicksort_impl().

Referenced by web::autoscan::process(), and Filesystem::readDirectory().

static void quicksort_impl ( COMPARABLE a,
int  lo0,
int  hi0,
COMPARATOR  comparator 
) [static]

Definition at line 553 of file tools.cc.

Referenced by quicksort().

String read_text_file ( String  path  ) 

Reads the entire contents of a text file and returns it as a string.

Definition at line 467 of file tools.cc.

References _, _Exception, zmm::String::c_str(), FREE, MALLOC, and mt_strerror().

String renderProtocolInfo ( zmm::String  mimetype,
zmm::String  protocol = _(PROTOCOL),
zmm::String  extend = nil 
)

Renders a string that can be used as the protocolInfo resource attribute: "http-get:*:mimetype:*".

Parameters:
mimetype the mimetype that should be inserted
protocol the protocol which should be inserted (default: "http-get")
Returns:
The rendered protocolInfo String

Definition at line 623 of file tools.cc.

References _, and string_ok().

Referenced by CdsResourceManager::addResources(), web::addObject::addUrl(), MetadataHandler::setMetadata(), and ContentManager::updateObject().

String secondsToHMS ( int  seconds  ) 

Converts a number of seconds to H+:MM:SS representation as required by the UPnP spec.

Definition at line 657 of file tools.cc.

References malloc.

void set_jpeg_resolution_resource ( Ref< CdsItem item,
int  res_num 
)

Sets resolution for a given resource index, item must be a JPEG image.

Definition at line 738 of file tools.cc.

References _, _Exception, get_jpeg_resolution(), MetadataHandler::getResAttrName(), zmm::Exception::printStackTrace(), R_RESOLUTION, and UPNP_READ.

Referenced by MetadataHandler::setMetadata().

Ref<Array<StringBase> > split_path ( zmm::String  str  ) 

splits the given file path into the path to the file and the filename.

Parameters:
str the path to split
Returns:
an array with the path at position 0 and the filename at position 1.

Definition at line 97 of file tools.cc.

References _, _DIR_SEPARATOR, _Exception, zmm::String::c_str(), DIR_SEPARATOR, zmm::String::rindex(), and string_ok().

Referenced by SQLStorage::_addUpdateObject(), SQLStorage::_ensurePathExistence(), and SQLStorage::_findObjectByPath().

Ref<Array<StringBase> > split_string ( zmm::String  str,
char  sep,
bool  empty = false 
)

splits the given string into array of strings using a separator character.

Parameters:
str String to split
sep separator character
treat subsequent separators as empty array elements
Returns:
array of strings

Definition at line 67 of file tools.cc.

References _, zmm::String::c_str(), zmm::String::length(), and NULL.

Referenced by check_resolution(), check_token(), SQLStorage::createObjectFromRow(), CdsResource::decode(), XPath::elementAtPath(), getMTFromProtocolInfo(), ConfigManager::getOption(), ContentManager::mimetype2upnpclass(), parseCommandLine(), and ContentManager::updateObject().

bool string_ok ( Ref< StringBuffer str  ) 

Definition at line 259 of file tools.cc.

References nil.

bool string_ok ( zmm::String  str  ) 

Checks if the string contains any data.

Parameters:
str String to be checked.
Returns:
true if ok
false if string was either nil or empty

Checks if str is nil or ""

Definition at line 252 of file tools.cc.

References nil.

Referenced by ContentManager::_addFile(), SQLStorage::_addUpdateObject(), SQLStorage::_fillAutoscanDirectory(), SQLStorage::_findObjectByPath(), SQLStorage::_getAutoscanObjectID(), SQLStorage::_purgeEmptyContainers(), SQLStorage::_recursiveRemove(), ContentManager::_rescanDirectory(), web::addObject::addActiveItem(), FallbackLayout::addAudio(), ContentManager::addContainerChain(), FallbackLayout::addImage(), web::addObject::addItem(), CdsResourceManager::addResources(), WebRequestHandler::addUpdateIDs(), web::addObject::addUrl(), FallbackLayout::addVideo(), WebRequestHandler::boolParam(), check_resolution(), ConfigManager::checkOptionString(), SQLStorage::checkRefID(), ConfigManager::ConfigManager(), ContentManager::ContentManager(), StringConverter::convert(), create_request_handler(), ConfigManager::createArrayFromNodeset(), ConfigManager::createAutoscanListFromNodeset(), SQLStorage::createContainer(), ConfigManager::createDefaultConfig(), ConfigManager::createDictionaryFromNodeset(), ContentManager::createObjectFromFile(), SQLStorage::createObjectFromRow(), FallbackLayout::FallbackLayout(), find_in_path(), WebRequestHandler::get_info(), ServeRequestHandler::get_info(), FileRequestHandler::get_info(), getAVIFourCC(), SQLStorage::getFsRootName(), ConfigManager::getOption(), mxml::XML2JSON::getValue(), CdsItem::getVirtualPath(), CdsContainer::getVirtualPath(), mxml::XML2JSON::handleElement(), WebRequestHandler::handleUpdateIDs(), HMSToSeconds(), interfaceToIP(), WebRequestHandler::intParam(), main(), ConfigManager::migrate(), WebRequestHandler::open(), ServeRequestHandler::open(), FileRequestHandler::open(), FDIOHandler::open(), web::autoscan::process(), web::tasks::process(), web::items::process(), web::files::process(), web::edit_save::process(), web::directories::process(), web::containers::process(), web::auth::process(), web::addObject::process(), web::add::process(), web::action::process(), SQLStorage::remapBool(), SQLStorage::removeObject(), ContentManager::removeObject(), mxml::Element::removeWhitespace(), CdsResourceManager::renderExtension(), renderProtocolInfo(), ContentManager::rescanDirectory(), ContentManager::setAutoscanDirectory(), SQLStorage::setFsRootName(), MetadataHandler::setMetadata(), split_path(), UpdateManager::threadProc(), SQLStorage::updateAutoscanPersistentList(), ContentManager::updateObject(), Server::upnp_init(), UpnpXML_RenderDeviceDescription(), ConfigManager::validate(), CdsItemExternalURL::validate(), CdsActiveItem::validate(), CdsItem::validate(), and CdsObject::validate().

void string_ok_ex ( zmm::String  str  ) 

Checks if the string contains any data.

Parameters:
str String to be checked.

Checks if str is nil or "" and throws an exception if that is the case.

Definition at line 268 of file tools.cc.

References _, _Exception, and nil.

Referenced by MetadataHandler::setMetadata().

int StringBaseComparator ( void *  arg1,
void *  arg2 
)

Definition at line 548 of file tools.cc.

unsigned int stringHash ( zmm::String  str  ) 

computes an (unsigned int) hash for the given string

Parameters:
str the string to compute the hash for
Returns:
return the (unsigned int) hash value

Definition at line 979 of file tools.cc.

References zmm::String::c_str().

Referenced by SQLStorage::_addUpdateObject(), SQLStorage::_findObjectByPath(), SQLStorage::addContainerChain(), SQLStorage::createContainer(), DSOHash< zmm::Array< CacheObject > >::hashCode(), and DSBHash< VT >::hashCode().

String tempName ( zmm::String  leadPath,
char *  tmpl 
)

this is the mkstemp routine from glibc, the only difference is that it does not return an fd but just the name that we could use.

The reason behind this is, that we need to open a pipe, while mkstemp will open a regular file.

Definition at line 1256 of file tools.cc.

References zmm::String::c_str(), nil, and NULL.

Referenced by run_simple_process().

String trim_string ( String  str  ) 

returns str with leading and trailing whitespace removed

Definition at line 125 of file tools.cc.

References _, zmm::String::c_str(), zmm::String::length(), nil, zmm::String::substring(), and WHITE_SPACE.

Referenced by ConfigManager::getOption(), and mxml::Element::removeWhitespace().

String unescape ( zmm::String  string,
char  escape 
)

Unescapes the given String.

Parameters:
string the string to unescape
escape the escape character (e.g. "\")
Returns:
the unescaped string

Definition at line 847 of file tools.cc.

Referenced by Storage::stripAndUnescapeVirtualContainerFromPath().

String unescape_amp ( zmm::String  string  ) 

brief Unescape all & occurances in a given string.

This function will look for & in a string and convert it to '&', all other tokens are not touched.

Parameters:
string that should be unescaped
Returns:
the unescaped string

Definition at line 931 of file tools.cc.

References nil.

String url_escape ( zmm::String  str  ) 

Converts a string to a URL (meaning: 20 instead of space and so on).

Parameters:
str String to be converted.
Returns:
string that contains the url-escaped representation of the original string.

Definition at line 357 of file tools.cc.

References zmm::String::c_str(), hex, and zmm::String::length().

Referenced by Dictionary::_encode().

String url_unescape ( String  str  ) 

Opposite of url_escape :).

Definition at line 383 of file tools.cc.

References zmm::String::c_str(), hex, and zmm::String::length().

Referenced by create_request_handler(), Dictionary::decode(), and Dictionary::decodeSimple().

bool validateYesNo ( String  value  ) 

Returns true if the given string is eitehr "yes" or "no", otherwise returns false.

Definition at line 1204 of file tools.cc.

Referenced by ConfigManager::validate().

void write_text_file ( String  path,
String  contents 
)

writes a string into a text file

Definition at line 486 of file tools.cc.

References _, _Exception, zmm::String::c_str(), zmm::String::length(), and mt_strerror().


Variable Documentation

const char* hex = "0123456789ABCDEF" [static]

Definition at line 355 of file tools.cc.

Referenced by url_escape(), and url_unescape().

const char* HEX_CHARS = "0123456789abcdef" [static]

Definition at line 65 of file tools.cc.

Referenced by hex_decode_string(), and hex_encode().


Generated on Fri Mar 26 20:16:55 2010 for MediaTomb by  doxygen 1.6.1