summaryrefslogtreecommitdiff
path: root/static/v10/man9/muxstring.9
blob: 738a4daaa09be772ef92508c6eb1c7cd6be0f5fa (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
.TH MUXSTRING 9.3
.CT 2 comm_term
.SH NAME
strinsure, strinsert, strdelete, strzero, setmuxbuf, getmuxbuf, movstring \- dynamic strings in mux
.SH SYNOPSIS
.B #include <jerq.h>
.PP
.B strinsure(s, n);  String *s;
.PP
.B "strinsert(d, i, s); String *d, *s;
.PP
.B "strdelete(d, i, j); String *d;
.PP
.B strzero(d); String *d;
.PP
.B setmuxbuf(s); String *s;
.PP
.B getmuxbuf(d); String *d;
.PP
.B movstring(n, sp, dp); char *sp, *dp;
.SH DESCRIPTION
These functions manipulate strings represented
in the following form.
.IP
.EX
.ta \w'struct 'u
struct	String {
	char *s;
	short n;
	short size;
};
.EE
.LP
The string proper occupies the first 
.B n
characters of a data block of
.L size
characters pointed to by
.BR s .
Initially both
.B size
and
.B s
should be 0.
Strings are always counted, not terminated by
.BR \e0 .
The functions obtain space as needed from
.IR gcalloc  ;
see
.IR alloc (9.3).
Thus a
.B String
structure should never be copied.
.PP
.I Strinsure
arranges that 
.IB s ->size\(>= n.
It must be called before any operation that could
overflow the current size.
.PP
.I Strinsert
inserts a copy of source
.I s
into destination
.I d
beginning at character 
.I i
(counted from 0),
adding
.IB s ->n
to
.IB d ->n .
.PP
.I Strdelete
removes characters
.I i
through
.IR j \-1
from string
.I d,
subtracting
.IR j \- i,
which must be nonnegative, from
.IB d ->n .
.PP
.IB Strzero
frees the memory associated with
.I d
and sets both
.IB d ->n
and
.IB d ->size
to zero.
.PP
.I Setmuxbuf
copies string 
.I s
into the snarf buffer maintained by
.IR mux (9.1);
.I getmuxbuf
copies from the snarf buffer into
.I d.
.PP
.I Movstr
copies a block of
.I n
characters beginning at
.I sp
to a block beginning at
.I dp.
If
.I n
is negative it copies
.RI \- n
characters ending at
.IR sp \- 1
to a block ending at
.IR dp \-1.
Notice that
.I movstring 
does not operate on
.BR String s.
.SH SEE ALSO
.IR libc (9.3)