166 lines
3.1 KiB
Groff
166 lines
3.1 KiB
Groff
.TH STRING 3 "$Revision$"
|
|
.ad
|
|
.SH NAME
|
|
strindex, strrindex, strzero, str2bts,
|
|
long2str, str2long,
|
|
btscpy, btscat, btscmp, btszero, bts2str \- operations on and
|
|
conversions between strings and row of bytes
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.B #include <ack_string.h>
|
|
.PP
|
|
.B char *strindex(char *s, int c)
|
|
.PP
|
|
.B char *strrindex(char *s, int c)
|
|
.PP
|
|
.B char *strzero(char *s)
|
|
.PP
|
|
.B char *str2bts(char *s, char *b, int *n)
|
|
.PP
|
|
.B char *long2str(long l, int b)
|
|
.PP
|
|
.B long str2long(char *s, int b)
|
|
.PP
|
|
.B char *btscpy(char *b1, char *b2, int n)
|
|
.PP
|
|
.B char *btscat(char *b1, int n1, char *b2, int n2)
|
|
.PP
|
|
.B int btscmp(char *b1, int n1, char *b2, int n2)
|
|
.PP
|
|
.B char *btszero(char *b, int n)
|
|
.PP
|
|
.B char *bts2str(char *b, int n, char *s)
|
|
.fi
|
|
.SH DESCRIPTION
|
|
The
|
|
.IR str *
|
|
functions operate on null-terminated strings.
|
|
The
|
|
.IR bts *
|
|
functions operate on variable-length rows of bytes,
|
|
regardless of null bytes.
|
|
Neither of these functions check for overflow of any receiving area.
|
|
.PP
|
|
.I strindex
|
|
.RI ( strrindex )
|
|
returns a pointer to the first (last)
|
|
occurrence of character
|
|
.I c
|
|
in string
|
|
.I s,
|
|
or zero if
|
|
.I c
|
|
does not occur in
|
|
.IR s .
|
|
.PP
|
|
.I strzero
|
|
turns
|
|
.I s
|
|
into a null string.
|
|
.PP
|
|
.I bts2str
|
|
turns a row of
|
|
.I n
|
|
consecutive bytes, the first of which is pointed by
|
|
.IR b ,
|
|
into a null-terminated string, starting at
|
|
.IR 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.
|
|
.br
|
|
E.g., the row of 2 bytes
|
|
.RS
|
|
\&'\e0' '\en'
|
|
.RE
|
|
is turned into the string consisting of the following characters
|
|
.RS
|
|
\&'\e' '0' '0' '0' '\e' 'n' '\e0'
|
|
.RE
|
|
The latter string could be represented in C as "\e\e000\e\en".
|
|
.PP
|
|
.I str2bts
|
|
turns string
|
|
.I s
|
|
into a sequence of bytes pointed by
|
|
.IR b .
|
|
It has the inverse effect to
|
|
.IR bts2str .
|
|
The length of the resulting byte sequence is returned in
|
|
.RI *n .
|
|
.br
|
|
Both the functions
|
|
.I bts2str
|
|
and
|
|
.I str2bts
|
|
return a pointer to the result.
|
|
.PP
|
|
.I long2str
|
|
converts a long value
|
|
.I l
|
|
into a null-terminated string according to
|
|
.IR 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.
|
|
.I str2long
|
|
returns the value that is represented in
|
|
.IR s ,
|
|
according to
|
|
.IR base .
|
|
.PP
|
|
.I btscpy
|
|
copies
|
|
.I n
|
|
bytes from the string of bytes
|
|
.I b2
|
|
to
|
|
.I b1
|
|
and returns
|
|
.IR b1 .
|
|
.PP
|
|
.I btscat
|
|
appends a copy of
|
|
.I n2
|
|
bytes from
|
|
.I b2
|
|
to the end of
|
|
.IR b1 ,
|
|
consisting of
|
|
.I n1
|
|
bytes.
|
|
.I b1
|
|
is returned.
|
|
.PP
|
|
.I btscmp
|
|
compares row of bytes
|
|
.I b1
|
|
with length
|
|
.I n1
|
|
and
|
|
.I b2
|
|
with length
|
|
.I n2
|
|
and returns an integer greater than, equal to, or less than 0, if
|
|
.I b1
|
|
is lexicographically greater then, equal to, or less than
|
|
.IR b2 ,
|
|
respectively.
|
|
.PP
|
|
.I btszero
|
|
places
|
|
.I n
|
|
null bytes in the string
|
|
.IR b .
|
|
.I b
|
|
is returned.
|
|
.SH FILES
|
|
~em/modules/lib/libstring.a
|
|
.SH "SEE ALSO"
|
|
string(3), bstring(3), atof(3)
|
|
.SH BUGS
|
|
No checks for overflow or illegal parameters.
|