Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

strutils.h File Reference

#include "wvstring.h"
#include "wvstringlist.h"

Go to the source code of this file.

Functions

char * terminate_string (char *string, char c)
char * trim_string (char *string)
char * trim_string (char *string, char c)
void replace_char (void *string, char c1, char c2, int length)
char * strlwr (char *string)
char * strupr (char *string)
bool is_word (const char *string)
WvString hexdump_buffer (const void *buf, size_t len)
bool isnewline (char c)
void hexify (char *obuf, const void *ibuf, size_t len)
void unhexify (void *obuf, const char *ibuf)
WvString web_unescape (const char *str)
WvString rfc822_date (time_t _when=-1)
WvString passwd_crypt (const char *str)
WvString backslash_escape (const WvString &s1)
int strcount (const WvString &s, const char c)
WvString encode_hostname_as_DN (WvString &hostname)


Function Documentation

WvString backslash_escape const WvString   s1
 

Definition at line 277 of file strutils.cc.

References WvString::edit(), WvString::len(), and WvString::setsize().

WvString encode_hostname_as_DN WvString   hostname
 

Definition at line 311 of file strutils.cc.

References WvString::append(), WvString::edit(), WvStringList::split(), and WvString::unique().

WvString hexdump_buffer const void *    buf,
size_t    len
 

Produce a hexadecimal dump of the data buffer in 'buf' of length 'len'. It is formatted with 16 bytes per line; each line has an address offset, hex representation, and printable representation.

This is used mostly for debugging purposes. You can send the returned WvString object directly to a WvLog or any other WvStream for output.

Definition at line 132 of file strutils.cc.

References WvString::edit(), and WvString::setsize().

void hexify char *    obuf,
const void *    ibuf,
size_t    len
 

Write the contents of the binary string of length 'len' pointed to by 'ibuf' into the output buffer 'obuf' in hexadecimal format.

For example, if len==4, ibuf=="ABCDEF", then obuf will contain "41424344" with a terminating NUL character.

This is useful to turn arbitrary binary into a simple printable format, so that it can (for example) be written to a WvConf configuration file.

obuf must be a buffer with at least (len * 2) + 1 bytes available. (two digits for each byte of ibuf, plus a terminating NUL).

Definition at line 191 of file strutils.cc.

Referenced by WvX509Mgr::encodecert(), and WvRSAKey::WvRSAKey().

bool is_word const char *    string
 

Returns true if all characters in 'string' are isalnum() (alphanumeric).

Definition at line 117 of file strutils.cc.

bool isnewline char    c
 

Returns true if 'c' is a newline or carriage return character. Increases code readability a bit.

Definition at line 184 of file strutils.cc.

WvString passwd_crypt const char *    str
 

Definition at line 9 of file strcrypt.cc.

References WvString::unique().

void replace_char void *    string,
char    c1,
char    c2,
int    length
 

Replace all instances of c1 with c2 for the first 'length' characters in 'string'. Ignores terminating NUL, so make sure you set 'length' correctly.

Definition at line 79 of file strutils.cc.

WvString rfc822_date time_t    _when = -1
 

Definition at line 262 of file strutils.cc.

References WvString::edit(), and WvString::setsize().

int strcount const WvString   s,
const char    c
 

Definition at line 301 of file strutils.cc.

char* strlwr char *    string
 

In-place modify a character string so that all contained letters are in lower case. Returns 'string'.

Definition at line 90 of file strutils.cc.

Referenced by set_name_entry().

char* strupr char *    string
 

In-place modify a character string so that all contained letters are in upper case. Returns 'string'.

Definition at line 102 of file strutils.cc.

char* terminate_string char *    string,
char    c
 

Add character c to the end of a string after removing terminating carriage returns/linefeeds if any.

You need a buffer that's at least one character bigger than the current length of the string, including the terminating NULL.

Definition at line 15 of file strutils.cc.

char* trim_string char *    string,
char    c
 

Similar to above, but trims the string starting at the first occurrence of c.

Definition at line 59 of file strutils.cc.

Referenced by WvLogBuffer::_end_line(), WvStringTable::join(), WvStringList::join(), WvConf::load_file(), WvLockFile::lock(), WvConf::parse_section(), WvConf::parse_value(), set_name_entry(), WvProtoStream::token_remaining(), WvProtoStream::tokline(), WvHTTPStream::uread(), and web_unescape().

char* trim_string char *    string
 

Trims whitespace from the beginning and end of the character string, including carriage return / linefeed characters. Modifies the string in place. Returns the new first character of the string, which points either at 'string' itself or some character contained therein.

string is allowed to be NULL; returns NULL in that case.

void unhexify void *    obuf,
const char *    ibuf
 

Reverse the operation performed by hexify(). obuf must be a buffer large enough to contain the entire binary output string; you can calculate this size with (strlen(ibuf) / 2). obuf will NOT be automatically NUL-terminated.

Definition at line 205 of file strutils.cc.

Referenced by WvX509Mgr::decodecert(), and WvRSAKey::WvRSAKey().

WvString web_unescape const char *    str
 

Converts escaped characters (things like %20 etc.) from web URLS into their normal ASCII representations.

Definition at line 226 of file strutils.cc.

References WvString::edit(), WvString::setsize(), and trim_string().


Generated on Sat Aug 24 21:37:02 2002 for WvStreams by doxygen1.2.15