STRING(3)

NAME
strindex, strrindex, strzero, str2bts, long2str, str2long, btscpy, btscat, btscmp, btszero, bts2str - operations on and conversions between strings and row of bytes

SYNOPSIS
#include <ack_string.h>

char *strindex(char *s, int c)

char *strrindex(char *s, int c)

char *strzero(char *s)

char *str2bts(char *s, char *b, int *n)

char *long2str(long l, int b)

long str2long(char *s, int b)

char *btscpy(char *b1, char *b2, int n)

char *btscat(char *b1, int n1, char *b2, int n2)

int btscmp(char *b1, int n1, char *b2, int n2)

char *btszero(char *b, int n)

char *bts2str(char *b, int n, char *s)

DESCRIPTION
The str* functions operate on null-terminated strings. The bts* functions operate on variable-length rows of bytes, regardless of null bytes. Neither of these functions check for overflow of any receiving area.

strindex (strrindex) returns a pointer to the first (last) occurrence of character c in string s, or zero if c does not occur in s.

strzero turns s into a null string.

bts2str turns a row of n consecutive bytes, the first of which is pointed by b, into a null-terminated string, starting at s. Printable characters are copied and non-printable characters are transformed into sequences of printable characters, representing those characters. Also, back-slashes and double quotes are escaped with a back-slash. The transformation agrees with the representation of non-printable characters in C strings.
E.g., the row of 2 bytes
    '\0' '\n'
is turned into the string consisting of the following characters
    '\' '0' '0' '0' '\' 'n' '\0'
The latter string could be represented in C as "\\000\\n".

str2bts turns string s into a sequence of bytes pointed by b. It has the inverse effect to bts2str. The length of the resulting byte sequence is returned in *n.
Both the functions bts2str and str2bts return a pointer to the result.

long2str converts a long value l into a null-terminated string according to base, which indicates the base to use. This base may be any of 2..16. A negative base (in the range -16..-2) indicates that the long must be seen as unsigned. A pointer to the string is returned. str2long returns the value that is represented in s, according to base.

btscpy copies n bytes from the string of bytes b2 to b1 and returns b1.

btscat appends a copy of n2 bytes from b2 to the end of b1, consisting of n1 bytes. b1 is returned.

btscmp compares row of bytes b1 with length n1 and b2 with length n2 and returns an integer greater than, equal to, or less than 0, if b1 is lexicographically greater then, equal to, or less than b2, respectively.

btszero places n null bytes in the string b. b is returned.

FILES
~em/modules/lib/libstring.a

SEE ALSO
string(3), bstring(3), atof(3)

BUGS
No checks for overflow or illegal parameters.