DCMTK
Version 3.6.2
OFFIS DICOM Toolkit
|
A non-POD version of "struct hostent" for thread- and memory-safe data access. More...
Public Types | |
enum | E_MarkupMode { MM_HTML, MM_HTML32, MM_XHTML, MM_XML } |
Markup language mode. More... | |
Public Member Functions | |
OFHostent () | |
default constructor that creates an invalid object. | |
OFBool | operator! () const |
test if a OFHostent object is invalid. More... | |
operator OFBool () const | |
test if a OFHostent object is valid. More... | |
Static Public Member Functions | |
static size_t | strlcpy (char *dst, const char *src, size_t siz) |
This function copies up to size - 1 characters from the NUL- terminated string src to dst, NUL-terminating the result. More... | |
static size_t | strlcat (char *dst, const char *src, size_t siz) |
This function appends the NUL-terminated string src to the end of dst. More... | |
static const char * | strerror (const int errnum, char *buf, const size_t buflen) |
convert a given error code to a string. More... | |
static OFString & | toUpper (OFString &result, const OFString &value) |
returns the upper-case version of a given string More... | |
static OFString & | toUpper (OFString &value) |
returns the upper-case version of a given string. More... | |
static OFString & | toLower (OFString &result, const OFString &value) |
returns the lower-case version of a given string More... | |
static OFString & | toLower (OFString &value) |
returns the lower-case version of a given string. More... | |
static OFBool | pathExists (const OFFilename &pathName) |
check whether the given path exists. More... | |
static OFBool | fileExists (const OFFilename &fileName) |
check whether the given file exists. More... | |
static OFBool | dirExists (const OFFilename &dirName) |
check whether the given directory exists. More... | |
static OFBool | isReadable (const OFFilename &pathName) |
check whether the given path is readable. More... | |
static OFBool | isWriteable (const OFFilename &pathName) |
check whether the given path is writeable. More... | |
static OFString & | getDirNameFromPath (OFString &result, const OFString &pathName, const OFBool assumeDirName=OFTrue) |
get directory name component from given path name. More... | |
static OFFilename & | getDirNameFromPath (OFFilename &result, const OFFilename &pathName, const OFBool assumeDirName=OFTrue) |
get directory name component from given path name. More... | |
static OFString & | getFilenameFromPath (OFString &result, const OFString &pathName, const OFBool assumeFilename=OFTrue) |
get file name component from given path name. More... | |
static OFFilename & | getFilenameFromPath (OFFilename &result, const OFFilename &pathName, const OFBool assumeFilename=OFTrue) |
get file name component from given path name. More... | |
static OFString & | normalizeDirName (OFString &result, const OFString &dirName, const OFBool allowEmptyDirName=OFFalse) |
normalize the given directory name. More... | |
static OFFilename & | normalizeDirName (OFFilename &result, const OFFilename &dirName, const OFBool allowEmptyDirName=OFFalse) |
normalize the given directory name. More... | |
static OFString & | combineDirAndFilename (OFString &result, const OFString &dirName, const OFString &fileName, const OFBool allowEmptyDirName=OFFalse) |
combine the given directory and file name. More... | |
static OFFilename & | combineDirAndFilename (OFFilename &result, const OFFilename &dirName, const OFFilename &fileName, const OFBool allowEmptyDirName=OFFalse) |
combine the given directory and file name. More... | |
static OFCondition | removeRootDirFromPathname (OFFilename &result, const OFFilename &rootDir, const OFFilename &pathName, const OFBool allowLeadingPathSeparator=OFTrue) |
remove root directory prefix from given path name. More... | |
static OFFilename & | appendFilenameExtension (OFFilename &result, const OFFilename &fileName, const OFFilename &fileExtension) |
append a filename extension to the given filename More... | |
static size_t | searchDirectoryRecursively (const OFString &directory, OFList< OFString > &fileList, const OFString &pattern="", const OFString &dirPrefix="", const OFBool recurse=OFTrue) |
scan a given directory (recursively) and add all filenames found to a list More... | |
static size_t | searchDirectoryRecursively (const OFFilename &directory, OFList< OFFilename > &fileList, const OFFilename &pattern, const OFFilename &dirPrefix, const OFBool recurse=OFTrue) |
scan a given directory (recursively) and add all filenames found to a list More... | |
static OFCondition | createDirectory (const OFFilename &dirName, const OFFilename &rootDir) |
create a directory (including sub-directories) if it does not yet exist. More... | |
static OFBool | copyFile (const OFFilename &sourceFilename, const OFFilename &destFilename) |
copy an existing file to a new file More... | |
static OFBool | deleteFile (const OFFilename &filename) |
delete given file from filesystem More... | |
static OFBool | renameFile (const OFFilename &oldFilename, const OFFilename &newFilename) |
change name of a given file More... | |
static size_t | getFileSize (const OFFilename &filename) |
determine size of given file (in bytes) More... | |
static OFBool | checkForMarkupConversion (const OFString &sourceString, const OFBool convertNonASCII=OFFalse, const size_t maxLength=0) |
check whether conversion to a HTML/XML mnenonic string is required. More... | |
static OFCondition | convertToMarkupStream (STD_NAMESPACE ostream &out, const OFString &sourceString, const OFBool convertNonASCII=OFFalse, const E_MarkupMode markupMode=MM_XML, const OFBool newlineAllowed=OFFalse, const size_t maxLength=0) |
convert character string to a HTML/XHTML/XML mnenonic stream. More... | |
static const OFString & | convertToMarkupString (const OFString &sourceString, OFString &markupString, const OFBool convertNonASCII=OFFalse, const E_MarkupMode markupMode=MM_XML, const OFBool newlineAllowed=OFFalse, const size_t maxLength=0) |
convert character string to a HTML/XHTML/XML mnenonic string. More... | |
static OFBool | checkForOctalConversion (const OFString &sourceString, const size_t maxLength=0) |
check whether conversion to an octal format is required. More... | |
static OFCondition | convertToOctalStream (STD_NAMESPACE ostream &out, const OFString &sourceString, const size_t maxLength=0) |
convert character string to an octal format stream. More... | |
static const OFString & | convertToOctalString (const OFString &sourceString, OFString &octalString, const size_t maxLength=0) |
convert character string to an octal format string. More... | |
static OFCondition | encodeBase64 (STD_NAMESPACE ostream &out, const unsigned char *data, const size_t length, const size_t width=0) |
encode binary data according to "Base64" as described in RFC 2045 (MIME). More... | |
static const OFString & | encodeBase64 (const unsigned char *data, const size_t length, OFString &result, const size_t width=0) |
encode binary data according to "Base64" as described in RFC 2045 (MIME). More... | |
static size_t | decodeBase64 (const OFString &data, unsigned char *&result) |
decode "Base64" encoded string. More... | |
static double | atof (const char *s, OFBool *success=NULL) |
converts a floating-point number from an ASCII decimal representation to internal double-precision format. More... | |
static void | ftoa (char *target, size_t targetSize, double value, unsigned int flags=0, int width=0, int precision=-1) |
formats a floating-point number into an ASCII string. More... | |
static unsigned int | sleep (unsigned int seconds) |
makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored More... | |
static void | milliSleep (unsigned int millisecs) |
makes the current process sleep until the given number of milliseconds have elapsed or a signal which is not ignored arrives More... | |
static long | getProcessID () |
Determines the identification of the running process. More... | |
static OFBool | check32BitAddOverflow (const Uint32 summand1, const Uint32 summand2) |
check whether the addition of two 32-bit integers yields in an overflow More... | |
template<typename T > | |
static OFBool | safeSubtract (T minuend, T subtrahend, T &difference) |
check whether subtraction is safe (i.e. no underflow occurs) and if so, perform it (i.e. compute minuend-subtrahend=difference). More... | |
template<typename T > | |
static OFBool | safeAdd (T a, T b, T &sum) |
check whether addition is safe (i.e. no overflow occurs) and if so, perform it (i.e. compute a+b=sum). More... | |
template<size_t Count> | |
static OFBool | checkDigits (const char *string) |
checks if a string only contains valid decimal digits, i.e. 0-9. More... | |
template<typename T , size_t Count> | |
static T | extractDigits (const char *) |
extracts digits from a string and converts them to the given integer number type. More... | |
static void | trimString (const char *&pBegin, const char *&pEnd) |
An utility function that finds a substring within a string that does not contain leading and trailing spaces and null bytes, effectively trimming the string without unnecessary copies. More... | |
static OFHostent | getHostByName (const char *name) |
Thread-safe version of gethostbyname. More... | |
static OFHostent | getHostByAddr (const char *addr, int len, int type) |
Thread-safe version of gethostbyaddr. More... | |
static OFGroup | getGrNam (const char *name) |
Thread-safe version of getgrnam. More... | |
static OFPasswd | getPwNam (const char *name) |
Thread-safe version of getpwnam. More... | |
static OFCondition | dropPrivileges () |
On Posix-like platform, this method executes setuid(getuid()), which causes the application to revert from root privileges to those of the calling user when the program is installed as setuid root. More... | |
static OFString | getUserName () |
Retrieve the name of the user that started the current process. More... | |
static OFString | getHostName () |
Retrieve the local domain name, e. More... | |
static void | initializeNetwork () |
Initialize the network API (if necessary), e.g. Winsock. More... | |
static void | shutdownNetwork () |
Shutdown the network API (if necessary), e.g. Winsock. More... | |
static OFerror_code | getLastSystemErrorCode () |
Retrieve the last operating system error code that was emitted in the calling thread. More... | |
static OFerror_code | getLastNetworkErrorCode () |
Retrieve the last network specific error code that was emitted in the calling thread. More... | |
Public Attributes | |
OFString | h_name |
official name of host. | |
OFVector< OFString > | h_aliases |
a vector containing all known aliases. | |
OFVector< OFString > | h_addr_list |
vector containing the addresses. | |
int | h_addrtype |
host address type. | |
int | h_length |
the length of each address (all have the same length). | |
Static Public Attributes | |
ftoa() processing flags. | |
These flags can be combined by bit-wise or. | |
static const unsigned int | ftoa_format_e |
Use e or E conversion format instead of g or G. | |
static const unsigned int | ftoa_format_f |
Use f or F conversion format instead of g or G. | |
static const unsigned int | ftoa_uppercase |
Use E, F or G conversion format instead of e, f or g. | |
static const unsigned int | ftoa_alternate |
convert value to alternate form. More... | |
static const unsigned int | ftoa_leftadj |
left-justify number be within the field | |
static const unsigned int | ftoa_zeropad |
pad with zeroes instead of blanks | |
Private Member Functions | |
OFHostent (hostent *const h) | |
the constructor that "sucks out" a struct hostent instance. More... | |
Static Private Member Functions | |
static size_t | my_strlcpy (char *dst, const char *src, size_t siz) |
private implementation of strlcpy. More... | |
static size_t | my_strlcat (char *dst, const char *src, size_t siz) |
private implementation of strlcat. More... | |
static unsigned int | my_sleep (unsigned int seconds) |
makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored More... | |
Private Attributes | |
OFBool | ok |
internal state, OFTrue when valid. | |
Friends | |
class | OFStandard |
only OFStandard may instantiate a valid object. | |
A non-POD version of "struct hostent" for thread- and memory-safe data access.
A class for various helper functions.
Wraps the contents of a "struct hostent" instance to a non-POD object containing RAII-style data (e.g. OFString instead of const char*). To handle the old pointer behavior, OFHostent objects can have an invalid state in which case all members are undefined. You can test whether an OFHostent object is invalid or not with the overloaded operators "operator !" and "operator OFBool". Therefore, it behaves quite the same way as pointers in this regard.
This class is used to comprise a number of "global" helper functions.
|
static |
append a filename extension to the given filename
result | string variable in which the resulting filename is stored. This name may contain wide characters if support is enabled and 'fileName' contains wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
fileName | filename to which the extension should be appended. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
fileExtension | filename extension to be appended (e.g. ".bak"). It is converted to wide characters if 'fileName' contains wide characters. |
|
static |
converts a floating-point number from an ASCII decimal representation to internal double-precision format.
Unlike the atof() function defined in Posix, this implementation is not affected by a locale setting, the radix character is always assumed to be '.' This implementation does not set errno if the input cannot be parsed and it does not implement special handling for overflow/underflow. It does handle "NaN" and "Inf" (case insensitive; following characters are ignore). A return code indicates whether or not a successful conversion could be performed. The precision of this implementation is limited to approx. 9 decimal digits.
s | A decimal ASCII floating-point number, optionally preceded by white space. Must have form "-I.FE-X", where I is the integer part of the mantissa, F is the fractional part of the mantissa, and X is the exponent. Either of the signs may be "+", "-", or omitted. Either I or F may be omitted, or both. The decimal point isn't necessary unless F is present. The "E" may actually be an "e". E and X may both be omitted (but not just one). |
success | pointer to return status code, may be NULL. if present, a status code is stored in the variable pointed to by this parameter. The status is OFTrue if a conversion could be performed and OFFalse if the string does not have the expected format. |
|
inlinestatic |
check whether the addition of two 32-bit integers yields in an overflow
summand1 | first integer value to be added |
summand2 | second integer value to be added |
|
static |
checks if a string only contains valid decimal digits, i.e. 0-9.
Count | the number of characters (bytes) to check. |
string | a pointer to a character array to check. |
|
static |
check whether conversion to a HTML/XML mnenonic string is required.
This check can be performed before convertToMarkupStream() or convertToMarkupString() is called in order to speed up the process in case the conversion is not required.
sourceString | source string to be checked. May contain one or more NULL bytes. |
convertNonASCII | convert non-ASCII characters (< #32 and >= #127) to numeric value (&#nnn;) if OFTrue |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
check whether conversion to an octal format is required.
This check can be performed before convertToOctalStream() or convertToOctalString() is called in order to speed up the process in case the conversion is not required.
sourceString | source string to be checked. May contain one or more NULL bytes. |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
combine the given directory and file name.
Normalizes the directory name and appends the file name (with a path separator) if not empty. If both 'dirName' and 'fileName' are empty strings and the flag 'allowEmptyDirName' is OFFalse the resulting path name is set to "." (current directory). If 'dirName' is "." and the flag 'allowEmptyDirName' is OFTrue an empty directory name is used. NB: This function neither checks whether the given 'dirName' exists nor whether the resulting path name points to a valid or existing file name. Furthermore, the value of 'dirName' is ignored if 'fileName' starts with a path separator.
result | string variable in which the resulting path name is stored |
dirName | directory name to be combined with the file name |
fileName | file name to be combined with the directory name |
allowEmptyDirName | flag indicating whether an empty directory name is allowed |
|
static |
combine the given directory and file name.
Normalizes the directory name and appends the file name (with a path separator) if not empty. If both 'dirName' and 'fileName' are empty strings and the flag 'allowEmptyDirName' is OFFalse the resulting path name is set to "." (current directory). If 'dirName' is "." and the flag 'allowEmptyDirName' is OFTrue an empty directory name is used. NB: This function neither checks whether the given 'dirName' exists nor whether the resulting path name points to a valid or existing file name. Furthermore, the value of 'dirName' is ignored if 'fileName' starts with a path separator.
result | string variable in which the resulting path name is stored. This name may contain wide characters if support is enabled and 'dirName' as well as 'fileName' contain wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
dirName | directory name to be combined with the file name. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
fileName | file name to be combined with the directory name. Should contain wide characters if and only if 'dirName' contains wide characters. |
allowEmptyDirName | flag indicating whether an empty directory name is allowed |
|
static |
convert character string to a HTML/XHTML/XML mnenonic stream.
Characters with special meaning for HTML/XHTML/XML (e.g. '<' and '&') are replaced by the corresponding mnenonics (e.g. "<" and "&"). If flag 'convertNonASCII' is OFTrue, all characters < #32 and >= #127 are also converted (useful if only HTML 3.2 is supported which does not allow to specify the character set). In HTML 3.2 mode, the quotation mark (") is converted to """ instead of """ because the latter entity is not defined. In HTML mode, the apostrophe sign (') is converted to "'" instead of "'" for the same reason.
out | stream used for the HTML/XHTML/XML mnenonic output |
sourceString | source string to be converted. May contain one or more NULL bytes. |
convertNonASCII | convert non-ASCII characters (< # 32 and >= #127) to numeric value (&#nnn;) if OFTrue |
markupMode | convert to HTML, HTML 3.2, XHTML or XML markup. LF and CR are encoded as " " and " " in XML mode, the flag 'newlineAllowed' has no meaning in this case. |
newlineAllowed | optional flag indicating whether newlines are allowed or not. If they are allowed, the text "<br>" (HTML) or "<br />" (XHTML) is used, "¶" otherwise. The following combinations are accepted: LF, CR, LF CR, CF LF. |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
convert character string to a HTML/XHTML/XML mnenonic string.
Characters with special meaning for HTML/XHTML/XML (e.g. '<' and '&') are replaced by the corresponding mnenonics (e.g. "<" and "&"). If flag 'convertNonASCII' is OFTrue, all characters < #32 and >= #127 are also converted (useful if only HTML 3.2 is supported which does not allow to specify the character set). In HTML 3.2 mode, the quotation mark (") is converted to """ instead of """ because the latter entity is not defined. In HTML mode, the apostrophe sign (') is converted to "'" instead of "'" for the same reason.
sourceString | source string to be converted. May also contain one or more NULL bytes. |
markupString | reference to character string where the result should be stored |
convertNonASCII | convert non-ASCII characters (< # 32 and >= #127) to numeric value (&#nnn;) if OFTrue |
markupMode | convert to HTML, HTML 3.2, XHTML or XML markup string. LF and CR are encoded as "@&@#10;" and "@&@#13;" in XML mode, the flag 'newlineAllowed' has no meaning in this case. |
newlineAllowed | optional flag indicating whether newlines are allowed or not. If they are allowed, the text "<br>" (HTML) or "<br />" (XHTML) is used, "¶" otherwise. The following combinations are accepted: LF, CR, LF CR, CF LF. |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
convert character string to an octal format stream.
All non-ASCII and control characters (code < #32 and >= #127) are converted to their octal representation, i.e. to '\ooo' where 'ooo' are the three octal digits of the character. All other characters are output as is. See section 6.1.2.3 in DICOM PS 3.5.
out | stream used for the output |
sourceString | source string to be converted. May contain one or more NULL bytes. |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
convert character string to an octal format string.
All non-ASCII and control characters (code < #32 and >= #127) are converted to their octal representation, i.e. to '\ooo' where 'ooo' are the three octal digits of the character. All other characters are output as is. See section 6.1.2.3 in DICOM PS 3.5.
sourceString | source string to be converted. May contain one or more NULL bytes. |
octalString | reference to character string where the result should be stored |
maxLength | maximum number of characters from the source string to be converted. A value of 0 means all characters. |
|
static |
copy an existing file to a new file
sourceFilename | name of the existing file (including directory) to be copied. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
destFilename | name of the new file (including directory) to be created as a copy. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
create a directory (including sub-directories) if it does not yet exist.
In other words, this function creates directories recursively, i.e. with all sub-components.
dirName | name of the directory to be created. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
rootDir | optional name of a root directory (prefix of 'dirName') that already exists and that can, therefore, be skipped during the creation of sub-directories. Should contain wide characters if and only if 'dirName' contains wide characters. |
|
static |
decode "Base64" encoded string.
Any character that does not belong to the Base64 alphabet (0..9, A..Z, a..z, + and /) is ignored when decoding the input string. This is especially true for line breaks which are usually contained in MIME (RFC 2045) encoded streams (see above). The first occurrence of a '=' character is taken as evidence that the end of the data has been reached. NB: The memory buffer in which the binary output is stored is allocated inside this function and has to to be freed (using "delete[]") by the caller! Do not pass a pointer to an already allocated buffer to this function, the caller does not know the exact size anyway.
data | Base64 encoded input data (possibly padded with '=' at the end) |
result | receives pointer to resulting buffer with binary data (big endian encoded) |
|
static |
delete given file from filesystem
filename | name of the file (including directory) to delete. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
check whether the given directory exists.
This function also checks that the specified path points to directory and not to a file (or the like).
dirName | name of the directory to be checked. This directory name may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
On Posix-like platform, this method executes setuid(getuid()), which causes the application to revert from root privileges to those of the calling user when the program is installed as setuid root.
DCMTK command line tools that open a socket for incoming DICOM network connections will call this method immediately after opening the socket. Since DICOM by default operates on port 104, which on Posix platforms requires root privileges to open, this ensures that the socket can be opened, yet operation continues with the (hopefully) limited rights of the calling user. On non-Posix platforms, this method does nothing and returns success.
|
static |
encode binary data according to "Base64" as described in RFC 2045 (MIME).
Basic algorithm: groups of 3 bytes from the binary input are coded as groups of 4 bytes in the textual output. The input data is 'padded' with zeros to create a length that is an even multiple of 3. A special character ('=') is used to denote padding so that the output can be decoded back to its exact size. If the input data is NULL an error code (EC_IllegalParameter) is returned.
out | output stream used for the base64 encoded data |
data | buffer with binary data to be encoded (big endian required!) |
length | length of the input data buffer (in bytes) |
width | maximum number of characters per line in the output stream (default: 0 = no line breaks, typical for MIME = 72) |
|
static |
encode binary data according to "Base64" as described in RFC 2045 (MIME).
Basic algorithm: groups of 3 bytes from the binary input are coded as groups of 4 bytes in the textual output. The input data is 'padded' with zeros to create a length that is an even multiple of 3. A special character ('=') is used to denote padding so that the output can be decoded back to its exact size. If the input data is NULL an empty string is returned.
data | buffer with binary data to be encoded (big endian required!) |
length | length of the input data buffer (in bytes) |
result | reference to resulting string variable (Base64 encoded) |
width | maximum number of characters per line in the output string (default: 0 = no line breaks, typical for MIME = 72) |
|
static |
extracts digits from a string and converts them to the given integer number type.
The result is similar to calling atoi, but extractDigits does not verify all characters are digits and does not require zero terminated strings. It is meant to be used in conjunction with OFStandard::checkDigits(). extractDigits does not handle sign characters ('+' and '-').
T | the type of the resulting value, e.g. unsigned int. Must be a valid integer type, i.e. OFnumeric_limits<T>::is_integer must be OFTrue. |
Count | the number of digits to extract. Must be greater zero and less or equal to OFnumeric_limits<T>::digits10 |
string | a pointer to a character array to extract digits from. |
|
static |
check whether the given file exists.
This function also checks that the specified path points to file and not to a directory (or the like).
fileName | name of the file to be checked. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
formats a floating-point number into an ASCII string.
This function works similar to sprintf(), except that this implementation is not affected by a locale setting. The radix character is always '.'. This implementation guarantees that the given string size is always respected by using strlcpy to copy the formatted string into the target buffer.
target | pointer to target string buffer |
targetSize | size of target string buffer |
value | double value to be formatted |
flags | processing flags. Any of the flags defined below can be combined by bit-wise or. |
width | width from format (%8d), or 0 |
precision | precision from format (%.3d), or -1 |
|
static |
get directory name component from given path name.
Extracts the substring before the last path separator. If there is no path separator in the given path name, the value of 'pathName' is returned by default; if 'assumeDirName' is OFFalse, an empty string is returned. NB: This function neither checks whether the given 'pathName' exists nor whether the resulting name points to a valid or existing directory.
result | string variable in which the resulting directory name is stored |
pathName | path name from which the directory name should be extracted |
assumeDirName | assume that there always is a directory name in 'pathName' |
|
static |
get directory name component from given path name.
Extracts the substring before the last path separator. If there is no path separator in the given path name, the value of 'pathName' is returned by default; if 'assumeDirName' is OFFalse, an empty string is returned. NB: This function neither checks whether the given 'pathName' exists nor whether the resulting name points to a valid or existing directory.
result | string variable in which the resulting directory name is stored. This name may contain wide characters if support is enabled and 'pathName' contains wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
pathName | path name from which the directory name should be extracted. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
assumeDirName | assume that there always is a directory name in 'pathName' |
|
static |
get file name component from given path name.
Extracts the substring after the last path separator. If there is no path separator in the given path name, the value of 'pathName' is returned by default; if 'assumeFilename' is OFFalse, an empty string is returned. NB: This function neither checks whether the given 'pathName' exists nor whether the resulting name points to a valid or existing file.
result | string variable in which the resulting file name is stored |
pathName | path name from which the file name should be extracted |
assumeFilename | assume that there always is a file name in 'pathName' |
|
static |
get file name component from given path name.
Extracts the substring after the last path separator. If there is no path separator in the given path name, the value of 'pathName' is returned by default; if 'assumeFilename' is OFFalse, an empty string is returned. NB: This function neither checks whether the given 'pathName' exists nor whether the resulting name points to a valid or existing file.
result | string variable in which the resulting file name is stored. This name may contain wide characters if support is enabled and 'pathName' contains wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
pathName | path name from which the file name should be extracted. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
assumeFilename | assume that there always is a file name in 'pathName' |
|
static |
determine size of given file (in bytes)
filename | name of the file to be checked. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
Thread-safe version of getgrnam.
name | the group name. |
|
static |
Thread-safe version of gethostbyaddr.
addr | see manpage. |
len | see manpage. |
type | see manpage. |
|
static |
Thread-safe version of gethostbyname.
name | the host name. |
|
static |
|
static |
Retrieve the last network specific error code that was emitted in the calling thread.
The current implementation uses errno on POSIX-like platforms and WSAGetLastError() on Windows.
|
static |
Retrieve the last operating system error code that was emitted in the calling thread.
The current implementation uses errno on POSIX-like platforms and GetLastError() on Windows.
|
static |
Determines the identification of the running process.
|
static |
Thread-safe version of getpwnam.
name | the username. |
|
static |
Retrieve the name of the user that started the current process.
|
static |
Initialize the network API (if necessary), e.g. Winsock.
Calls the appropriate network initialization routines for the current platform, e.g. WSAStartup().
|
static |
check whether the given path is readable.
This function works for both files and directories.
pathName | name of the path to be checked. This path name may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
check whether the given path is writeable.
This function works for both files and directories.
pathName | name of the path to be checked. This path name may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
makes the current process sleep until the given number of milliseconds have elapsed or a signal which is not ignored arrives
millisecs | number of milliseconds to sleep |
|
staticprivate |
makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored
seconds | number of seconds to sleep |
|
staticprivate |
private implementation of strlcat.
Called when strlcat is not available in the standard library.
dst | destination buffer of size siz, must not be NULL |
src | source string, must not be NULL |
siz | size of destination buffer |
|
staticprivate |
private implementation of strlcpy.
Called when strlcpy is not available in the standard library.
dst | destination buffer of size siz, must not be NULL |
src | source string, must not be NULL |
siz | size of destination buffer |
|
static |
normalize the given directory name.
Removes trailing path separators from the directory name. If the resulting directory name is an empty string and the flag 'allowEmptyDirName' is OFFalse the directory name is set to "." (current directory). If the resulting directory name is "." and the flag 'allowEmptyDirName' is OFTrue the directory name is set to an empty string.
result | string variable in which the resulting directory name is stored |
dirName | directory name to be normalized |
allowEmptyDirName | flag indicating whether an empty directory name is allowed |
|
static |
normalize the given directory name.
Removes trailing path separators from the directory name. If the resulting directory name is an empty string and the flag 'allowEmptyDirName' is OFFalse the directory name is set to "." (current directory). If the resulting directory name is "." and the flag 'allowEmptyDirName' is OFTrue the directory name is set to an empty string.
result | string variable in which the resulting directory name is stored. This name may contain wide characters if support is enabled and 'dirName' contains wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
dirName | directory name to be normalized. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
allowEmptyDirName | flag indicating whether an empty directory name is allowed |
|
private |
the constructor that "sucks out" a struct hostent instance.
h | the struct hostent instance to clone into this object. |
OFStandard::operator OFBool | ( | ) | const |
test if a OFHostent object is valid.
OFBool OFStandard::operator! | ( | ) | const |
test if a OFHostent object is invalid.
|
static |
check whether the given path exists.
This function does not distinguish files from directories (use 'fileExists()' or 'directoryExists()' if required).
pathName | name of the path to be checked. This path name may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
|
static |
remove root directory prefix from given path name.
In case 'pathName' starts with 'rootDir', the common prefix is removed. Otherwise, an empty string is returned (or a cleared OFFilename in case of error).
result | string variable in which the resulting path name is stored. This name may contain wide characters if support is enabled and 'rootDir' as well as 'pathName' contain wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. |
rootDir | name of the root directory to be removed. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
pathName | path name from which the root directory (prefix) is removed. Should contain wide characters if and only if 'rootDir' contains wide characters. |
allowLeadingPathSeparator | flag indicating whether a leading path separator is allowed for the resulting path name (automatically removed otherwise) |
|
static |
change name of a given file
oldFilename | current name of the file (including directory) to be renamed. This filename may contain wide characters if support enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
newFilename | new name of the file (including directory), i.e. after renaming. Should contain wide characters if and only if 'oldFilename' contains wide characters. |
|
inlinestatic |
check whether addition is safe (i.e. no overflow occurs) and if so, perform it (i.e. compute a+b=sum).
Only works for unsigned types.
a | first number to add |
b | second number to add |
sum | resulting sum of both numbers, if addition is safe, otherwise parameter value is not touched by the function |
|
inlinestatic |
check whether subtraction is safe (i.e. no underflow occurs) and if so, perform it (i.e. compute minuend-subtrahend=difference).
Only works for unsigned types.
minuend | number to subtract from |
subtrahend | number to subtract from minuend |
difference | difference, if subtraction is safe, otherwise the parameter value is not touched by the function |
|
static |
scan a given directory (recursively) and add all filenames found to a list
directory | name of the directory to be scanned |
fileList | list to which the filenames are added. Please note that the list is not not cleared automatically before new entries are added. |
pattern | optional wildcard pattern used to match the filenames against. By default all files match. In order to work under Unix the system function fnmatch() is required. |
dirPrefix | optional prefix added to the directory name. This prefix will, however, not be part of the filenames added to the list. |
recurse | flag indicating whether to search recursively (default) or not |
|
static |
scan a given directory (recursively) and add all filenames found to a list
directory | name of the directory to be scanned. This name may contain wide characters if support is enabled. Since there are various constructors for the OFFilename class, a "char *", "OFString" or "wchar_t *" can also be passed directly to this parameter. |
fileList | list to which the filenames are added. These names may contain wide characters if support is enabled and 'directory' contains wide characters. In any case, the resulting string is stored with UTF-8 encoding (8-bit) as an alternative representation. Please note that the list is not not cleared automatically before new entries are added. |
pattern | wildcard pattern used to match the filenames against. Should contain wide characters if and only if 'directory' contains wide characters. An empty pattern matches all files. In order to work under Unix the system function fnmatch() is required. |
dirPrefix | prefix added to the directory name. Should contain wide characters if and only if 'directory' contains wide characters. This prefix will, however, not be part of the filenames added to the list. |
recurse | flag indicating whether to search recursively (default) or not |
|
static |
Shutdown the network API (if necessary), e.g. Winsock.
Calls the appropriate network shutdown routines to free used resources (e.g. WSACleanup()).
|
inlinestatic |
makes the current process sleep until seconds seconds have elapsed or a signal arrives which is not ignored
seconds | number of seconds to sleep |
|
static |
convert a given error code to a string.
This function wraps the various approaches found on different systems. Internally, the standard function strerror() or strerror_r() is used.
errnum | error code to be converted |
buf | buffer which is used to store the result string (if supported) |
buflen | size if the buffer in bytes |
Referenced by OFFile::getLastErrorString().
|
inlinestatic |
This function appends the NUL-terminated string src to the end of dst.
It will append at most size - strlen(dst) - 1 bytes, NUL- terminating the result. It is designed to be a safer, more consistent, and less error-prone replacement for strncat(3). strlcat takes the full size of the buffer (not just the length) and guarantees to NUL-terminate the result (as long as size is larger than 0). Note that you should include a byte for the NUL in size. Also note that strlcat only operates on true C strings, i. e. dst and src must be NUL-terminated.
dst | destination buffer of size siz, must not be NULL |
src | source string, must not be NULL |
siz | size of destination buffer |
|
inlinestatic |
This function copies up to size - 1 characters from the NUL- terminated string src to dst, NUL-terminating the result.
It is designed to be a safer, more consistent, and less error-prone replacement for strncpy(3). strlcpy takes the full size of the buffer (not just the length) and guarantees to NUL-terminate the result (as long as size is larger than 0). Note that you should include a byte for the NUL in size. Also note that strlcpy only operates on true C strings, i. e. src must be NUL-terminated.
dst | destination buffer of size siz, must not be NULL |
src | source string, must not be NULL |
siz | size of destination buffer |
returns the lower-case version of a given string
result | string variable in which the result is stored |
value | string value to be converted to lower case |
returns the lower-case version of a given string.
NB: This function changes the parameter 'value'.
value | string value to be converted to lower case |
returns the upper-case version of a given string
result | string variable in which the result is stored |
value | string value to be converted to upper case |
returns the upper-case version of a given string.
NB: This function changes the parameter 'value'.
value | string value to be converted to upper case |
|
static |
An utility function that finds a substring within a string that does not contain leading and trailing spaces and null bytes, effectively trimming the string without unnecessary copies.
pBegin | a reference to a pointer to the beginning of the string. |
pEnd | a reference to a pointer to the end of the string (the first byte behind the string). |
trimString() increments pBegin and decrements pEnd until either both point to a non-null and non-space character (the position after it in case of pEnd) or both become equal (in case the string only contains spaces and null bytes).
|
static |
convert value to alternate form.
The result will always contain a decimal point, even if no digits follow the point. For g and G conversions, trailing zeroes will not be removed from the result.