aboutsummaryrefslogtreecommitdiffstats
path: root/libcolour_marshal.3
blob: 9cbb0da407cdac5b59aa5adf005f0d2368b95daf (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
.TH LIBCOLOUR_MARSHAL 3 libcolour
.SH NAME
libcolour_marshal - Marshal a colour record
.SH SYNOPSIS
.nf
#include <libcolour.h>

size_t \fBlibcolour_marshal_f\fP(const libcolour_colour_f_t *\fIcolour\fP, void *\fIbuffer\fP);
size_t \fBlibcolour_marshal_lf\fP(const libcolour_colour_lf_t *\fIcolour\fP, void *\fIbuffer\fP);
size_t \fBlibcolour_marshal_llf\fP(const libcolour_colour_ll_ft *\fIcolour\fP, void *\fIbuffer\fP);

#define \fBlibcolour_marshal\fP(\fIcolour\fP, \fIbuffer\fP)\\
	(_Generic((\fIvalue\fP),\\
	          const libcolour_colour_f_t *:   \fBlibcolour_marshal_f\fP(\fIcolour\fP, \fIbuffer\fP),\\
	          const libcolour_colour_lf_t *:  \fBlibcolour_marshal_lf\fP(\fIcolour\fP, \fIbuffer\fP),\\
	          const libcolour_colour_llf_t *: \fBlibcolour_marshal_llf\fP(\fIcolour\fP, \fIbuffer\fP)))
	          /* list is incomplete */
.fi
.SH DESCRIPTION
.B libcolour_marshal
and its non-generic functions stores a
.I colour
into a
.IR buffer ,
and returns the number of bytes written. If
.B NULL
is given instead of a
.IR buffer ,
the number of bytes that would have been written
is returned.
.P
These function will always write an
.B int
that is used to identify the version of libcolour
so it can be decoded by future versions.
.P
In addition to this
.IR int ,
all the content of the structure is copied, so
uninitialised values can be copied. However, it
will never copy more than the size of the structure
used to represent colours with used colour model.
For example, is the
.I .model
member if the colour is set to
.BR LIBCOLOUR_SRGB ,
no more than
.BR sizeof(libcolour_srgb_f_t) ,
.BR sizeof(libcolour_srgb_lf_t) ,
or
.BR sizeof(libcolour_srgb_llf_t) ,
depending on which function is called,
is written in addition to the initial
.IR int .
If the value of
.I .model
is invalid, 0 is returned and
.I errno
is set to
.IR EINVAL .
.P
The written data is machine dependant.
.SH RETURN VALUES
Upon successful completion, the number of bytes
written to
.I buffer
is returned, or if
.I buffer
is
.BR NULL ,
the number of bytes needed to to store the
.IR colour .
On error, 0 is returned and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EINVAL
.I .model
is invalid.
.SH SEE ALSO
.BR libcolour (7),
.BR libcolour_unmarshal (3)
.SH AUTHORS
Mattias Andrée
.RI < maandree@kth.se >