File: getln2.3

package info (click to toggle)
qmail 1.01-5
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 2,188 kB
  • ctags: 1,711
  • sloc: ansic: 13,993; makefile: 1,914; perl: 448; sh: 377
file content (64 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (24)
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
.TH getln2 3
.SH NAME
getln2 \- read one line of data
.SH SYNTAX
.B #include <getln.h>

int \fBgetln2\fP(&\fIss\fR,&\fIsa\fR,&\fIcont\fR,&\fIclen\fR,\fIsep\fR);

substdio \fIss\fR;
.br
stralloc \fIsa\fR;
.br
char *\fIcont\fR;
.br
unsigned int \fIclen\fR;
.br
int \fIsep\fR;
.SH DESCRIPTION
.B getln2
reads a line of characters, terminated by a 
.I sep
character,
from
.IR ss .

The line is returned in two pieces.
The first piece is stored in
.IR sa .
The second piece is
.IR cont ,
a pointer to
.I clen
characters inside the
.I ss
buffer.
The second piece must be copied somewhere else
before
.I ss
is used again.

If
.B getln2
sees end-of-input before it sees
.IR sep ,
it sets
.I clen
to 0 and does not set
.IR cont .
It puts the partial line into
.IR sa .

.B getln2
normally returns 0.
If it runs out of memory,
or encounters an error from
.IR ss ,
it returns -1,
setting
.B errno
appropriately.
.SH "SEE ALSO"
stralloc(3),
substdio(3),
getln(3)