str: Dynamically allocated string library.

## Data Structures

struct | str
struct | str_sortentry

## Macros

#define | STR_BLOCKSIZE 16

## Typedefs

typedef struct str | str
typedef struct str_sortentry | str_sortentry

## Globals

const char str_lcase_digits[36] | __DEPRECATED__
const char | str_ucase_digits [36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

## Overhead Functions

int | str_init (str *s)
int | str_alloc (str *s, unsigned size, int copy)
void | str_free (str *s)
int | str_truncate (str *s, unsigned len)
#define | str_ready(S, SZ)
#define | str_realloc(S, SZ)

## Assignment Functions

int | str_copy (str *s, const str *in)
int | str_copys (str *s, const char *in)
int | str_copyb (str *s, const char *in, unsigned len)
int | str_copyf (str *s, const char *format,...)
int | str_copyfv (str *s, const char *format, va_list ap)
int | str_copyns (str *s, unsigned int count,...)
int | str_copy2s (str *s, const char *a, const char *b)
int | str_copy3s (str *s, const char *a, const char *b, const char *c)
int | str_copy4s (str *s, const char *a, const char *b, const char *c, const char *d)
int | str_copy5s (str *s, const char *a, const char *b, const char *c, const char *d, const char *e)
int | str_copy6s (str *s, const char *a, const char *b, const char *c, const char *d, const char *e, const char *f)

## Appending Functions

int | str_cat (str *s, const str *in)
int | str_cats (str *s, const char *in)
int | str_catc (str *s, char in)
int | str_catb (str *s, const char *in, unsigned len)
int | str_catf (str *s, const char *format,...)
int | str_catfv (str *s, const char *format, va_list ap)
int | str_cati (str *s, long in)
int | str_catiw (str *s, long in, unsigned width, char pad)
int | str_catu (str *s, unsigned long in)
int | str_catuw (str *s, unsigned long in, unsigned width, char pad)
int | str_catx (str *s, unsigned long in)
int | str_catxw (str *s, unsigned long in, unsigned width, char pad)
int | str_catill (str *s, long long in)
int | str_catiwll (str *s, long long in, unsigned width, char pad)
int | str_catull (str *s, unsigned long long in)
int | str_catuwll (str *s, unsigned long long in, unsigned width, char pad)
int | str_catxll (str *s, unsigned long long in)
int | str_catxwll (str *s, unsigned long long in, unsigned width, char pad)
int | str_catsnumw (str *s, long in, unsigned width, char pad, unsigned base, const char *digits)
int | str_catunumw (str *s, unsigned long in, unsigned width, char pad, unsigned base, const char *digits)
int | str_catsllnumw (str *s, long long in, unsigned width, char pad, unsigned base, const char *digits)
int | str_catullnumw (str *s, unsigned long long in, unsigned width, char pad, unsigned base, const char *digits)
int | str_catns (str *s, unsigned int count,...)
int | str_cat2s (str *s, const char *a, const char *b)
int | str_cat3s (str *s, const char *a, const char *b, const char *c)
int | str_cat4s (str *s, const char *a, const char *b, const char *c, const char *d)
int | str_cat5s (str *s, const char *a, const char *b, const char *c, const char *d, const char *e)
int | str_cat6s (str *s, const char *a, const char *b, const char *c, const char *d, const char *e, const char *f)
int | str_join (str *s, char sep, const str *t)
int | str_joins (str *s, char sep, const char *in)
int | str_joinb (str *s, char sep, const char *in, unsigned len)

## In-place Modification Functions

void | str_lower (str *s)
void | str_upper (str *s)
long | str_subst (str *s, char from, char to)
void | str_lstrip (str *s)
void | str_rstrip (str *s)
void | str_lcut (str *s, unsigned count)
void | str_rcut (str *s, unsigned count)
int | str_sort (str *s, char sep, long count, int(*fn)(const str_sortentry *a, const str_sortentry *b))
int | str_splice (str *s, unsigned start, unsigned len, const str *r)
int | str_splices (str *s, unsigned start, unsigned len, const char *r)
int | str_spliceb (str *s, unsigned start, unsigned len, const char *r, unsigned rlen)
long | str_xlate (str *s, const char *from, const char *to, unsigned nchars)
#define | str_strip(S)

## Comparison Functions

int | str_cmp (const str *a, unsigned aoffset, const str *b, unsigned boffset)
int | str_cmps (const str *a, unsigned offset, const char *b)
int | str_cmpb (const str *a, unsigned offset, const char *b, unsigned len)
int | str_diff (const str *a, const str *b)
int | str_diffs (const str *a, const char *b)
int | str_diffb (const str *a, const char *b, unsigned len)
int | str_start (const str *a, const str *b)
int | str_starts (const str *a, const char *b)
int | str_startb (const str *a, const char *b, unsigned len)
int | str_case_start (const str *a, const str *b)
int | str_case_starts (const str *a, const char *b)
int | str_case_startb (const str *a, const char *b, unsigned len)
int | str_end (const str *a, const str *b)
int | str_ends (const str *a, const char *b)
int | str_endb (const str *a, const char *b, unsigned len)
int | str_case_end (const str *a, const str *b)
int | str_case_ends (const str *a, const char *b)
int | str_case_endb (const str *a, const char *b, unsigned len)

## Searching Functions

void | str_buildmap (int map[256], const char *list)
unsigned | str_count (const str *s, char ch)
unsigned | str_countof (const str *s, const char *list)
int | str_findnext (const str *s, char ch, unsigned pos)
int | str_findnextof (const str *s, const char *list, unsigned pos)
int | str_findnextnot (const str *s, const char *list, unsigned pos)
int | str_findprev (const str *s, char ch, unsigned pos)
int | str_findprevof (const str *s, const char *list, unsigned pos)
int | str_findprevnot (const str *s, const char *list, unsigned pos)
#define | str_findfirst(S, C)
#define | str_findfirstof(S, L)
#define | str_findfirstnot(S, L)
#define | str_findlast(S, C)
#define | str_findlastof(S, L)
#define | str_findlastnot(S, L)

## Pattern Matching Functions

int | str_match (const str *s, const str *pattern)
int | str_matchb (const str *s, const char *pptr, unsigned plen)
int | str_matchs (const str *s, const char *pattern)
int | str_case_match (const str *s, const str *pattern)
int | str_case_matchb (const str *s, const char *pptr, unsigned plen)
int | str_case_matchs (const str *s, const char *pattern)
int | str_glob (const str *s, const str *pattern)
int | str_globb (const str *s, const char *pptr, unsigned plen)
int | str_globs (const str *s, const char *pattern)
int | str_case_glob (const str *s, const str *pattern)
int | str_case_globb (const str *s, const char *pptr, unsigned plen)
int | str_case_globs (const str *s, const char *pattern)

## Detailed Description

Calling Convention
  The standard calling convention to `str` functions is to pass the string being examined or modified as the first argument. For most functions, the return value will be `0` (false) if an error occurred (ie memory allocation failed) and non-zero (true) otherwise.

## Macro Definition Documentation

## STR_BLOCKSIZE

#define STR_BLOCKSIZE 16

The block size in which string memory is allocated.

`STR_BLOCKSIZE` should be set to at least the size at which the allocator (ie `malloc`) will align the data it returns. String data will be allocated in steps of this number. Values smaller than the alignment will only cause a small amount of space to be wasted, and will not trigger bugs.

Referenced by str_alloc(), and str_init().

## str_findfirst

#define str_findfirst | ( |  | S,
|  |  | C )

Value:
str_findnext(S,C,0)
str_findnext
int str_findnext(const str *s, char ch, unsigned pos)
Definition findnext.c:22

## str_findfirstnot

#define str_findfirstnot | ( |  | S,
|  |  | L )

Value:
str_findnextnot(S,L,0)

## str_findfirstof

#define str_findfirstof | ( |  | S,
|  |  | L )

Value:
str_findnextof(S,L,0)
str_findnextof
int str_findnextof(const str *s, const char *list, unsigned pos)
Definition findnextof.c:22

## str_findlast

#define str_findlast | ( |  | S,
|  |  | C )

Value:
str_findprev(S,C,-1)
str_findprev
int str_findprev(const str *s, char ch, unsigned pos)
Definition findprev.c:21

## str_findlastnot

#define str_findlastnot | ( |  | S,
|  |  | L )

Value:
str_findprevof(S,L,-1)
str_findprevof
int str_findprevof(const str *s, const char *list, unsigned pos)
Definition findprevof.c:22

## str_findlastof

#define str_findlastof | ( |  | S,
|  |  | L )

Value:
str_findprevof(S,L,-1)

## str_ready

#define str_ready | ( |  | S,
|  |  | SZ )

Value:
str_alloc(S,SZ,0)
str_alloc
int str_alloc(str *s, unsigned size, int copy)
Definition alloc.c:32

Make sure string S has at least SZ bytes ready (no copy)

Referenced by ibuf_getnetstring(), str_copy2s(), str_copy3s(), str_copy4s(), str_copy5s(), str_copy6s(), str_copyb(), and str_copyfv().

## str_realloc

#define str_realloc | ( |  | S,
|  |  | SZ )

Value:
str_alloc(S,SZ,1)

Reallocate string S to size SZ bytes, copying the existing string

Referenced by dns_domain_todot_cat(), str_cat2s(), str_cat3s(), str_cat4s(), str_cat5s(), str_cat6s(), str_catb(), str_catc(), str_catfv(), str_catsllnumw(), str_catsnumw(), str_catullnumw(), str_catunumw(), str_joinb(), and str_truncate().

## str_strip

#define str_strip | ( |  | S | ) |

Value:
(str_rstrip(S), str_lstrip(S))
str_rstrip
void str_rstrip(str *s)
Definition rstrip.c:22
str_lstrip
void str_lstrip(str *s)
Definition lstrip.c:23

## Typedef Documentation

## str

typedef struct str str

String structure typedef.

## str_sortentry

typedef struct str_sortentry str_sortentry

String sort entry typedef.

## Function Documentation

## str_alloc()

int str_alloc | ( | str * | s,
|  | unsigned | size,
|  | int | copy )

Allocate storage for a string.

Parameters

  s | String to modify.
  size | Minimum number of bytes for which to allocate.
  copy | If set, the existing string will be copied into the new string.

The size given is incremented to account for adding a trailing `NUL` byte (to ensure compatibility with C string functions) and is then rounded up to the nearest `STR_BLOCKSIZE` interval.

References STR_BLOCKSIZE.

## str_buildmap()

void str_buildmap | ( | int | map[256],
|  | const char * | list )

Build a map from the list of characters.

Each byte in the output map contains either `-1` if the corresponding character was not present in the input string, or the offset of the last instance of the character in the list.

Referenced by str_countof(), str_findnextof(), and str_findprevof().

## str_case_end()

int str_case_end | ( | const str * | a,
|  | const str * | b )

Match the suffix of the string to another string.

References str::len, str::s, and str_case_endb().

## str_case_endb()

int str_case_endb | ( | const str * | a,
|  | const char * | b,
|  | unsigned | len )

Match the suffix of the string to a binary chunk.

References str::len, and str::s.

Referenced by str_case_end(), and str_case_ends().

## str_case_ends()

int str_case_ends | ( | const str * | a,
|  | const char * | b )

Match the suffix of the string to a C string.

References str_case_endb().

## str_case_match()

int str_case_match | ( | const str * | s,
|  | const str * | pattern )

Simple pattern match on dynamic string pattern.

References str::len, str::s, and str_case_matchb().

## str_case_matchb()

int str_case_matchb | ( | const str * | s,
|  | const char * | pptr,
|  | unsigned | plen )

Simple but fast (linear time) pattern matching on binary pattern.

Referenced by str_case_match(), and str_case_matchs().

## str_case_matchs()

int str_case_matchs | ( | const str * | s,
|  | const char * | pattern )

Simple pattern match on C string pattern.

References str_case_matchb().

## str_case_start()

int str_case_start | ( | const str * | a,
|  | const str * | b )

Match the prefix of the string to another string.

References str::len, str::s, and str_case_startb().

## str_case_startb()

int str_case_startb | ( | const str * | a,
|  | const char * | b,
|  | unsigned | len )

Match the prefix of the string to a binary chunk.

References str::len, and str::s.

Referenced by str_case_start(), and str_case_starts().

## str_case_starts()

int str_case_starts | ( | const str * | a,
|  | const char * | b )

Match the prefix of the string to a C string.

References str_case_startb().

## str_cat()

int str_cat | ( | str * | s,
|  | const str * | in )

Append another string

References str::len, str::s, and str_catb().

## str_cat2s()

int str_cat2s | ( | str * | s,
|  | const char * | a,
|  | const char * | b )

Append 2 C strings

References str_realloc.

## str_cat3s()

int str_cat3s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c )

Append 3 C strings

References str_realloc.

## str_cat4s()

int str_cat4s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d )

Append 4 C strings

References str_realloc.

## str_cat5s()

int str_cat5s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d,
|  | const char * | e )

Append 5 C strings

References str_realloc.

## str_cat6s()

int str_cat6s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d,
|  | const char * | e,
|  | const char * | f )

Append 6 C strings

References str_realloc.

## str_catb()

int str_catb | ( | str * | s,
|  | const char * | in,
|  | unsigned | len )

Append a binary block

References str_realloc.

Referenced by ibuf_readall(), str_cat(), str_cats(), and str_sort().

## str_catc()

int str_catc | ( | str * | s,
|  | char | in )

Append a single character

References str_realloc.

Referenced by envstr_put(), envstr_set(), ibuf_getstr(), path_mktemp(), and str_sort().

## str_catf()

int str_catf | ( | str * | s,
|  | const char * | format,
|  |  | ... )

Append formatted data using `fmt_multi` from variable arguments

References str_catfv().

## str_catfv()

int str_catfv | ( | str * | s,
|  | const char * | format,
|  | va_list | ap )

Append formatted data using `fmt_multi` from a `va_list`

References fmt_multiv(), and str_realloc.

Referenced by str_catf().

## str_cati()

int str_cati | ( | str * | s,
|  | long | in )

Append a signed integer in decimal.

References fmt_lcase_digits, and str_catsnumw().

## str_catill()

int str_catill | ( | str * | s,
|  | long long | in )

Append a signed long long integer in decimal.

References fmt_lcase_digits, and str_catsllnumw().

## str_catiw()

int str_catiw | ( | str * | s,
|  | long | in,
|  | unsigned | width,
|  | char | pad )

Append a signed integer in decimal, padded to a minimum width.

References fmt_lcase_digits, and str_catsnumw().

## str_catiwll()

int str_catiwll | ( | str * | s,
|  | long long | in,
|  | unsigned | width,
|  | char | pad )

Append a signed long long integer in decimal, padded to a minimum width.

References fmt_lcase_digits, and str_catsllnumw().

## str_catns()

int str_catns | ( | str * | s,
|  | unsigned int | count,
|  |  | ... )

Append N C strings

References str_cats().

## str_cats()

int str_cats | ( | str * | s,
|  | const char * | in )

Append a C string

References str_catb().

Referenced by envstr_put(), envstr_set(), str_catns(), and str_copyns().

## str_catsllnumw()

int str_catsllnumw | ( | str * | s,
|  | long long | in,
|  | unsigned | width,
|  | char | pad,
|  | unsigned | base,
|  | const char * | digits )

Append a signed long long integer, optionally padded to a minimum width

References fmt_sllnumw(), and str_realloc.

Referenced by str_catill(), and str_catiwll().

## str_catsnumw()

int str_catsnumw | ( | str * | s,
|  | long | in,
|  | unsigned | width,
|  | char | pad,
|  | unsigned | base,
|  | const char * | digits )

Append a signed integer, optionally padded to a minimum width

References fmt_snumw(), and str_realloc.

Referenced by str_cati(), and str_catiw().

## str_catu()

int str_catu | ( | str * | s,
|  | unsigned long | in )

Append an unsigned integer in decimal, padded to a minimum width.

References fmt_lcase_digits, and str_catunumw().

Referenced by path_mktemp().

## str_catull()

int str_catull | ( | str * | s,
|  | unsigned long long | in )

Append an unsigned long long integer in decimal.

References fmt_lcase_digits, and str_catullnumw().

## str_catullnumw()

int str_catullnumw | ( | str * | s,
|  | unsigned long long | in,
|  | unsigned | width,
|  | char | pad,
|  | unsigned | base,
|  | const char * | digits )

Append an unsigned long long integer, optionally padded to a minimum width

References fmt_ullnumw(), and str_realloc.

Referenced by str_catull(), str_catuwll(), str_catxll(), and str_catxwll().

## str_catunumw()

int str_catunumw | ( | str * | s,
|  | unsigned long | in,
|  | unsigned | width,
|  | char | pad,
|  | unsigned | base,
|  | const char * | digits )

Append an unsigned integer, optionally padded to a minimum width

References fmt_unumw(), and str_realloc.

Referenced by str_catu(), str_catuw(), str_catx(), and str_catxw().

## str_catuw()

int str_catuw | ( | str * | s,
|  | unsigned long | in,
|  | unsigned | width,
|  | char | pad )

Append an unsigned integer in decimal.

References fmt_lcase_digits, and str_catunumw().

Referenced by path_mktemp().

## str_catuwll()

int str_catuwll | ( | str * | s,
|  | unsigned long long | in,
|  | unsigned | width,
|  | char | pad )

Append an unsigned long long integer in decimal, padded to a minimum width.

References fmt_lcase_digits, and str_catullnumw().

## str_catx()

int str_catx | ( | str * | s,
|  | unsigned long | in )

Append an unsigned integer in hexadecimal, padded to a minimum width.

References fmt_lcase_digits, and str_catunumw().

## str_catxll()

int str_catxll | ( | str * | s,
|  | unsigned long long | in )

Append an unsigned long long integer in hexadecimal.

References fmt_lcase_digits, and str_catullnumw().

## str_catxw()

int str_catxw | ( | str * | s,
|  | unsigned long | in,
|  | unsigned | width,
|  | char | pad )

Append an unsigned integer in hexadecimal.

References fmt_lcase_digits, and str_catunumw().

## str_catxwll()

int str_catxwll | ( | str * | s,
|  | unsigned long long | in,
|  | unsigned | width,
|  | char | pad )

Append an unsigned long long integer in hexadecimal, padded to a minimum width.

References fmt_lcase_digits, and str_catullnumw().

## str_cmp()

int str_cmp | ( | const str * | a,
|  | unsigned | aoffset,
|  | const str * | b,
|  | unsigned | boffset )

Compare part of two strings.

This function compares two strings, starting at `aoffset` bytes into `a` and `boffset` bytes into `b`. The first non-zero difference is returned. If the portion of `b` is longer than the portion of `a`, the result is positive.

References str::len, str::s, and str_cmpb().

## str_cmpb()

int str_cmpb | ( | const str * | a,
|  | unsigned | offset,
|  | const char * | b,
|  | unsigned | len )

Compare a string against a binary block.

References str::len, and str::s.

Referenced by str_cmp(), and str_cmps().

## str_cmps()

int str_cmps | ( | const str * | a,
|  | unsigned | offset,
|  | const char * | b )

Compare a string against a C string.

References str_cmpb().

## str_copy()

int str_copy | ( | str * | s,
|  | const str * | in )

Copy in a string

References str::len, str::s, and str_copyb().

Referenced by dns_resolvconfrewrite(), and str_sort().

## str_copy2s()

int str_copy2s | ( | str * | s,
|  | const char * | a,
|  | const char * | b )

Copy in the concatenation of 2 C strings

References str_ready.

## str_copy3s()

int str_copy3s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c )

Copy in the concatenation of 3 C strings

References str_ready.

## str_copy4s()

int str_copy4s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d )

Copy in the concatenation of 4 C strings

References str_ready.

## str_copy5s()

int str_copy5s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d,
|  | const char * | e )

Copy in the concatenation of 5 C strings

References str_ready.

## str_copy6s()

int str_copy6s | ( | str * | s,
|  | const char * | a,
|  | const char * | b,
|  | const char * | c,
|  | const char * | d,
|  | const char * | e,
|  | const char * | f )

Copy in the concatenation of 6 C strings

References str_ready.

## str_copyb()

int str_copyb | ( | str * | s,
|  | const char * | in,
|  | unsigned | len )

Copy in a binary block

References str_ready.

Referenced by path_match(), str_copy(), and str_copys().

## str_copyf()

int str_copyf | ( | str * | s,
|  | const char * | format,
|  |  | ... )

Copy formatted data using `fmt_multi` from variable arguments

References str_copyfv().

## str_copyfv()

int str_copyfv | ( | str * | s,
|  | const char * | format,
|  | va_list | ap )

Copy formatted data using `fmt_multi` from a `va_list`

References fmt_multiv(), and str_ready.

Referenced by str_copyf().

## str_copyns()

int str_copyns | ( | str * | s,
|  | unsigned int | count,
|  |  | ... )

Copy in the concatenation of N C strings

References str_cats().

## str_copys()

int str_copys | ( | str * | s,
|  | const char * | in )

Copy in a C string

References str_copyb().

Referenced by dns_qualify_rules(), path_match(), path_merge(), and path_mktemp().

## str_count()

unsigned str_count | ( | const str * | s,
|  | char | ch )

Count the number of instances of a character

References str_findnext().

## str_countof()

unsigned str_countof | ( | const str * | s,
|  | const char * | list )

Count the number of instances of a list of characters

References str_buildmap().

## str_diff()

int str_diff | ( | const str * | a,
|  | const str * | b )

Differentiate two strings.

The first non-zero difference between `a` and `b` is returned. If `a` is longer than `b` and no differences are found up to the length of `b`, then the return value is positive. If `b` is longer than `a` and no differences are found up to the length of `a`, then the return value is negative.

References str::len, str::s, and str_diffb().

## str_diffb()

int str_diffb | ( | const str * | a,
|  | const char * | b,
|  | unsigned | len )

Differentiate a string and a binary block.

References str::len, and str::s.

Referenced by str_diff(), and str_diffs().

## str_diffs()

int str_diffs | ( | const str * | a,
|  | const char * | b )

Differentiate a string and a C string.

References str_diffb().

## str_end()

int str_end | ( | const str * | a,
|  | const str * | b )

Match the suffix of the string to another string.

References str::len, str::s, and str_endb().

## str_endb()

int str_endb | ( | const str * | a,
|  | const char * | b,
|  | unsigned | len )

Match the suffix of the string to a binary chunk.

References str::len, and str::s.

Referenced by str_end(), and str_ends().

## str_ends()

int str_ends | ( | const str * | a,
|  | const char * | b )

Match the suffix of the string to a C string.

References str_endb().

## str_findnext()

int str_findnext | ( | const str * | s,
|  | char | ch,
|  | unsigned | pos )

Find the next instance of the given character, on or after `pos`

Referenced by str_count(), and striter_advance().

## str_findnextof()

int str_findnextof | ( | const str * | s,
|  | const char * | list,
|  | unsigned | pos )

Find the next instance of the given list of characters, on or after `pos`

References str_buildmap().

## str_findprev()

int str_findprev | ( | const str * | s,
|  | char | ch,
|  | unsigned | pos )

Find the previous instance of the given character on or before `pos`

## str_findprevof()

int str_findprevof | ( | const str * | s,
|  | const char * | list,
|  | unsigned | pos )

Find the previous instance of the given list of characters, on or before `pos`

References str_buildmap().

## str_free()

void str_free | ( | str * | s | ) |

Free a string's storage. This function also sets all the members of the structure to zero.

Referenced by path_match(), resolve_qualdns(), and str_sort().

## str_init()

int str_init | ( | str * | s | ) |

Initialize a string, giving it a small empty allocation.

References STR_BLOCKSIZE.

## str_join()

int str_join | ( | str * | s,
|  | char | sep,
|  | const str * | in )

Join two strings together with exactly one instance of the seperator.

References str::len, str::s, and str_joinb().

## str_joinb()

int str_joinb | ( | str * | s,
|  | char | sep,
|  | const char * | in,
|  | unsigned | len )

Join a binary block to this string

References str_realloc.

Referenced by str_join(), and str_joins().

## str_joins()

int str_joins | ( | str * | s,
|  | char | sep,
|  | const char * | in )

Join a C string to this string

References str_joinb().

## str_lcut()

void str_lcut | ( | str * | s,
|  | unsigned | count )

Cut `count` bytes from the left (front) of the string

References str_truncate().

## str_lower()

void str_lower | ( | str * | s | ) |

Translate all upper-case characters to lower-case

## str_lstrip()

void str_lstrip | ( | str * | s | ) |

Strip all white space from the left (front) of the string

## str_match()

int str_match | ( | const str * | s,
|  | const str * | pattern )

Simple pattern match on dynamic string pattern.

References str::len, str::s, and str_matchb().

## str_matchb()

int str_matchb | ( | const str * | s,
|  | const char * | pptr,
|  | unsigned | plen )

Simple but fast (linear time) pattern matching on binary pattern.

Referenced by str_match(), and str_matchs().

## str_matchs()

int str_matchs | ( | const str * | s,
|  | const char * | pattern )

Simple pattern match on C string pattern.

References str_matchb().

## str_rcut()

void str_rcut | ( | str * | s,
|  | unsigned | count )

Cut `count` bytes from the right (end) of the string

References str_truncate().

## str_rstrip()

void str_rstrip | ( | str * | s | ) |

Strip all white space from the right (end) of the string

## str_sort()

int str_sort | ( | str * | s,
|  | char | sep,
|  | long | count,
|  | int(* | fn )(const str_sortentry *a, const str_sortentry *b) )

Sort a string.

Parameters

  s | The string to sort.
  sep | The character which delimits the substrings.
  count | The number of substrings within `s` (set to `-1` if not known).
  fn | The comparison function. Defaults to a function that works like `memcmp`.

Note
  This function allocates a temporary array of substring pointers, and so may return `0` if memory allocation fails. The string itself is not reallocated.

References str::len, str_sortentry::len, str::s, str_sortentry::str, str_catb(), str_catc(), str_copy(), str_free(), and str_truncate().

Referenced by path_match().

## str_start()

int str_start | ( | const str * | a,
|  | const str * | b )

Match the prefix of the string to another string.

References str::len, str::s, and str_startb().

## str_startb()

int str_startb | ( | const str * | a,
|  | const char * | b,
|  | unsigned | len )

Match the prefix of the string to a binary chunk.

References str::len, and str::s.

Referenced by str_start(), and str_starts().

## str_starts()

int str_starts | ( | const str * | a,
|  | const char * | b )

Match the prefix of the string to a C string.

References str_startb().

## str_subst()

long str_subst | ( | str * | s,
|  | char | from,
|  | char | to )

Substitute one character for another throughout the string.

Returns
  the number of substitutions made.

## str_truncate()

int str_truncate | ( | str * | s,
|  | unsigned | len )

Truncate a string.

If `len` is larger than the current size, the string is reallocated. If `len` is less than the existing length (not size), the length of the string is reduced to `len`. A `NUL` marker is placed at `len`.

References str_realloc.

Referenced by dns_qualify_rules(), ibuf_getstr(), ibuf_getstr_crlf(), str_lcut(), str_rcut(), and str_sort().

## str_upper()

void str_upper | ( | str * | s | ) |

Translate all lower-case characters to upper-case

## str_xlate()

long str_xlate | ( | str * | s,
|  | const char * | from,
|  | const char * | to,
|  | unsigned | nchars )

Substitute one character for another throughout the string.

Returns
  the number of substitutions made.

## Variable Documentation

## str_ucase_digits

const char str_ucase_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

Upper-case digits.