STRING(3ACK)

NAME
strcpy, strncpy, strcat, strncat, strcmp, strncmp, strlen, strindex, strrindex, strzero, str2bts, long2str, str2long, btscpy, btscat, btscmp, btszero, bts2str - operations on and conversions between strings and row of bytes

SYNOPSIS
char *strcpy(s1, s2)
char *s1, *s2;

char *strncpy(s1, s2, n)
char *s1, *s2;

char *strcat(s1, s2)
char *s1, *s2;

char *strncat(s1, s2, n)
char *s1, *s2;

int strcmp(s1, s2)
char *s1, *s2;

int strncmp(s1, s2, n)
char *s1, *s2;

int strlen(s)
char *s;

char *strindex(s, c)
char *s, c;

char *strrindex(s, c)
char *s, c;

char *strzero(s)
char *s;

char *str2bts(s, b, pn)
char *s, *b;
int *pn;

char *long2str(l, base)
long l;
int base;

long str2long(s, base)
char *s;
int base;

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

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

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

char *btszero(b, n)
char *b;
int n;

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

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.

Strcpy copies string s2 to s1, stopping after the null character has been moved. Strncpy copies exactly n characters, truncating or null-padding s2; the target may not be null-terminated if the length of s2 is n or more. Both return s1.

Strcat appends a copy of string s2 to the end of string s1. Strncat copies at most n characters. Both return a pointer to the null-terminated result s1.

Strcmp compares its arguments and returns an integer greater than, equal to, or less than 0, if s1 is lexicographically greater than, equal to, or less than s2, respectively. Strncmp makes the same comparison but checks at most n characters.

Strlen returns the number of characters before the null-character. s.

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 *pn.
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.

AUTHOR
Erik Baalbergen <erikb@vu44.UUCP>