about summary refs log tree commit diff
path: root/README
blob: 577622892f4e238f4df0f15bbf255cb316190857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
LIBSTE(3)                  Library Functions Manual                  LIBSTE(3)

NAME
     stecpy, stecpe, stechr, steprn – string library based on string ends

SYNOPSIS
     #include <ste.h>

     char *
     stecpy(char *dst, char *end, const char *src);

     char *
     steccpy(char *dst, char *end, const char *src, int c);

     char *
     stecpe(char *dst, char *end, const char *src, const char *srcend);

     char *
     stechr(const char *src, const char *end, int c);

     char *
     steprn(char *dst, char *end, const char *fmt, ...);

DESCRIPTION
     libste provides five useful functions for dealing with strings.

     stecpy copies the NUL-terminated string src to dst, but writes no
     characters beyond end.  If any characters are copied, dst will be NUL-
     terminated and the return value is a pointer to the NUL byte.  On
     truncation, end is returned.

     steccpy copies the NUL-terminated string src to dst, stopping when the
     character c is found.  It writes no characters beyond end.  If any
     characters are copied, dst will be NUL-terminated and the return value is
     a pointer to the NUL byte.  On truncation, end is returned.

     stecpe copies the string between src and srcend to dst, but writes no
     characters beyond end.  If any characters are copied, dst will be NUL-
     terminated and the return value is a pointer to the NUL byte.  On
     truncation, end is returned.

     stechr returns a pointer to the first occurence of c (converted to a
     char) in the NUL-terminated string pointed to by src, but reads no
     characters beyond end.  If c is not found, stechr returns a pointer to
     the first NUL byte in src, or end if none was found.

     steprn uses vsnprintf(3) to write formatted output to dst, but writes no
     characters beyond end.  If any characters are written, dst will be NUL-
     terminated and the return value is a pointer to the NUL byte.  On
     truncation, end is returned.

     Note that it is safe to pass the return value of all functions listed
     above as argument for dst when the same end is reused.  In this case, the
     function call does nothing but return dst again.  At any point,
     truncation can be checked by comparing the return value to end.

IMPLEMENTATION DETAILS
     libste is written in portable C99.

     Functions do not use vectorization to keep code size small and because
     the inputs are expected to be small enough to not benefit from it.

     The functions can be vendored or inlined into your codebase easily.

AUTHORS
     Leah Neukirchen <leah@vuxu.org>

LICENSE
     libste is in the public domain.

     To the extent possible under law, the creator of this work has waived all
     copyright and related or neighboring rights to this work.

     http://creativecommons.org/publicdomain/zero/1.0/

Void Linux                     November 5, 2021                     Void Linux