about summary refs log tree commit diff stats
path: root/gemtext_decode.3
blob: 29fabf40f459d0440e3177f5e9d6277ad25f35d9 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
.Dd 2020-10-22
.Dt gemtext 3
.Os
.Sh NAME
.Nm gemtext_decode ,
.Nm gemtext_decode_fd ,
.Nm gemtext_decode_file ,
.Nm gemtext_list_decode ,
.Nm gemtext_list_decode_fd ,
.Nm gemtext_list_decode_file
.Nd Gemini text parsing functions
.Sh SYNOPSIS
.In gemtext.h
.Ft struct gemtext *
.Fn gemtext_decode "char *text"
.Ft struct gemtext *
.Fn gemtext_decode_fd "int fd"
.Ft struct gemtext *
.Fn gemtext_decode_file "const char *path"
.Ft struct gemtext **
.Fn gemtext_list_decode "char *text"
.Ft struct gemtext **
.Fn gemtext_list_decode_fd "int fd"
.Ft struct gemtext **
.Fn gemtext_list_decode_file "const char *path"
.Sh DESCRIPTION
.Fn gemtext_decode
takes string consisting of a single line specified in
.Em text
and converts it to
.Em struct gemtext*
returned.
.Pp
.Fn gemtext_decode_fd
and
.Fn gemtext_decode_file
are wrappers for
.Fn gemtext_decode
where the former takes input from file descriptor specified int
.Em fd ,
and the latter reads input from file specified in
.Em file .
.Pp
.Fn gemtext_list_decode ,
.Fn gemtext_list_decode_fd
and
.Fn gemtext_list_decode_file
behave similar to
.Fn gemtext_decode
family of functions except text specified in
.Em text
can consist of multiple lines and the returned value would be a list of
.Em struct gemtext*
terminated by a NULL pointer.
.Sh RETURN VALUES
.Fn gemtext_decode ,
.Fn gemtext_decode_fd
and
.Fn gemtext_decode_file
return a valid pointer to
.Em struct gemtext
consisting of the parsed text on success, or NULL on error.
.Pp
.Fn gemtext_list_decode ,
.Fn gemtext_list_decode_fd
and
.Fn gemtext_list_decode_file
return a list of
.Em struct gemtext*
terminated by NULL pointer, or NULL on error.
.Pp
Pointers returned by
.Fn gemtext_decode
and it's wrappers should be freed using
.Xr gemtext_free(3) .
.Pp
Pointers returned by
.Fn gemtext_list_decode
and it's wrappers should be freed using
.Xr gemtext_list_free(3) .
.Sh SEE ALSO
.Xr gemtext_encode 3 ,
.Xr gemtext_text_new 3 ,
.Xr gemtext_type 3 ,
.Xr gemtext_text_string 3 ,
.Xr gemtext_text_strlen 3 ,
.Xr gemtext_list_append 3 ,
.Xr gemtext_free 3
.Sh AUTHORS
.An Ali Fardan Aq Mt raiz@stellarbound.space