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
|
.Dd 2020-10-22
.Dt gemtext 3
.Os
.Sh NAME
.Nm gemtext_encode ,
.Nm gemtext_encode_fd ,
.Nm gemtext_encode_file ,
.Nm gemtext_list_encode ,
.Nm gemtext_list_encode_fd ,
.Nm gemtext_list_encode_file
.Nd Gemini text encoding functions
.Sh SYNOPSIS
.In gemtext.h
.Ft int
.Fo gemtext_encode
.Fa "struct gemtext *line"
.Fa "char **textptr"
.Fa "int *lenptr"
.Fc
.Ft int
.Fo gemtext_encode_fd
.Fa "struct gemtext *line"
.Fa "int fd"
.Fc
.Ft int
.Fo gemtext_encode_file
.Fa "struct gemtext *line"
.Fa "consr char *path"
.Fc
.Ft int
.Fo gemtext_list_encode
.Fa "struct gemtext **list"
.Fa "char **textptr"
.Fa "int *lenptr"
.Fc
.Ft int
.Fo gemtext_list_encode_fd
.Fa "struct gemtext **list"
.Fa "int fd"
.Fc
.Ft int
.Fo gemtext_list_encode_file
.Fa "struct gemtext **list"
.Fa "const char *path"
.Fc
.Sh DESCRIPTION
.Fn gemtext_encode
encodes
.Em line
to
.Nm text/gemini
and sets pointer pointed to by
.Em textptr
to the encoded text and sets
.Em int
pointed to by
.Em lenptr
to the size of the encoded text excluding terminating NULL byte.
.Pp
Upon success, pointer set at
.Em *textptr
should be passed to
.Fn free 3
after use.
.Pp
.Fn gemtext_encode_fd
and
.Fn gemtext_encode_file
are wrappers for
.Fn gemtext_encode
where
.Fn gemtext_encode_fd
writes the output to file descriptor specified in
.Em fd
and
.Fn gemtext_encode_file
writes the output to a file within the file system, specified in
.Em path .
.Pp
.Fn gemtext_list_encode ,
.Fn gemtext_list_encode_fd
and
.Fn gemtext_list_encode_file
behave the same as the
.Fn gemtext_encode
family of functions, except they operate on a list of
.Em struct gemtext*
terminated by a NULL pointer.
.Sh RETURN VALUES
.Fn gemtext_encode ,
.Fn gemtext_encode_fd ,
.Fn gemtext_encode_file ,
.Fn gemtext_list_encode ,
.Fn gemtext_list_encode_fd
and
.Fn gemtext_list_encode_file
all return
.Em 0
on success or
.Em -1
on error.
.Sh SEE ALSO
.Xr gemtext_decode 3 ,
.Xr gemtext_text_new 3 ,
.Xr gemtext_type 3 ,
.Xr gemtext_text_string 3 ,
.Xr gemtext_free 3 .
.Sh AUTHORS
.An Ali Fardan Aq Mt raiz@stellarbound.space
|