aboutsummaryrefslogtreecommitdiffstats
path: root/man/libsimple_vputenvf.3
blob: 33c555923dd79bd856a5865c9dfea8615f09a74e (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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
.TH LIBSIMPLE_VPUTENVF 3 2018-10-20 libsimple
.SH NAME
libsimple_vputenvf \- change or add a string formatted value to the environment
.SH SYNOPSIS
.nf
#include <libsimple.h>

int libsimple_vputenvf(const char *\fIfmt\fP, va_list \fIap\fP);
static inline int libsimple_putenvf(const char *\fIfmt\fP, ...);
void libsimple_envputenvf(int \fIstatus\fP, const char *\fIfmt\fP, va_list \fIap\fP);
static inline void libsimple_enputenvf(int \fIstatus\fP, const char *\fIfmt\fP, ...);
static inline void libsimple_evputenvf(const char *\fIfmt\fP, va_list \fIap\fP);
static inline void libsimple_eputenvf(const char *\fIfmt\fP, ...);

#ifndef vputenvf
# define vputenvf libsimple_vputenvf
#endif
#ifndef putenvf
# define putenvf libsimple_putenvf
#endif
#ifndef envputenvf
# define envputenvf libsimple_envputenvf
#endif
#ifndef enputenvf
# define enputenvf libsimple_enputenvf
#endif
#ifndef evputenvf
# define evputenvf libsimple_evputenvf
#endif
#ifndef eputenvf
# define eputenvf libsimple_eputenvf
#endif
.fi
.PP
Link with
.IR \-lsimple .
.SH DESCRIPTION
The
.BR libsimple_vputenvf ()
function constructs a string using the
.BR vsprintf (3)
function, and adds it to the environment, overriding
its old value if it already exists. The string shall be on
the format \fB\(dq\fP\fIname\fP\fB=\fP\fIvalue\fP\fB\(dq\fP;
however this is not strictly enforced, see
.BR NOTES .
The parameter
.I fmt
is used as the format string for the
.BR vsprintf (3)
function, and the parameter
.I ap
is used as the formatting arguments.
.PP
The
.BR libsimple_putenvf ()
function is a version of the
.BR libsimple_vputenvf ()
function that uses variadic arguments instead of
.BR va_list .
.PP
The
.BR libsimple_envputenvf ()
and
.BR libsimple_evputenvf ()
functions are versions of the
.BR libsimple_vputenvf ()
function that call the
.BR libsimple_enprintf (3)
function on failure, causing the process to print
an error message and exit. See
.BR libsimple_enprintf (3)
for more information.
.PP
The
.BR libsimple_enputenvf ()
and
.BR libsimple_eputenvf ()
functions are versions of the
.BR libsimple_putenvf ()
function that call the
.BR libsimple_enprintf (3)
function on failure, causing the process to print
an error message and exit. See
.BR libsimple_enprintf ()
for more information.
.PP
Modifications made to the environment do not become
visible to other process until the process image is
changed.
.SH RETURN VALUE
Upon successful completion, the
.BR libsimple_vputenvf ()
and
.BR libsimple_putenvf ()
functions return 0; otherwise, they return \-1 and set
.I errno
to indicate the error.
.SH ERRORS
The
.BR libsimple_vputenvf ()
and
.BR libsimple_putenvf ()
functions will fail if:
.TP
.B EINVAL
The construct string is empty or starts with the
.B '='
character.
.TP
.B ENOMEM
Insufficient memory was available.
.PP
They may also fail for any reason specified for the
.BR vsnprintf (3)
function.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lb lb lb
l l l.
Interface	Attribute	Value
T{
.BR libsimple_vputenvf (),
.br
.BR libsimple_putenvf (),
.br
.BR libsimple_envputenvf (),
.br
.BR libsimple_enputenvf (),
.br
.BR libsimple_evputenvf (),
.br
.BR libsimple_eputenvf ()
T}	Thread safety	MT-Safe env
T{
.BR libsimple_vputenvf (),
.br
.BR libsimple_putenvf (),
.br
.BR libsimple_envputenvf (),
.br
.BR libsimple_enputenvf (),
.br
.BR libsimple_evputenvf (),
.br
.BR libsimple_eputenvf ()
T}	Async-signal safety	AS-Safe
T{
.BR libsimple_vputenvf (),
.br
.BR libsimple_putenvf (),
.br
.BR libsimple_envputenvf (),
.br
.BR libsimple_enputenvf (),
.br
.BR libsimple_evputenvf (),
.br
.BR libsimple_eputenvf ()
T}	Async-cancel safety	AC-Safe
.TE
.SH EXAMPLES
None.
.SH APPLICATION USAGE
None.
.SH RATIONALE
None.
.SH FUTURE DIRECTIONS
None.
.SH NOTES
If the construct does not contain the
.B '='
character, it may still be added to the environment,
however this can cause problem for some programs, and
the behaviour is unspecified when countered by the
.BR getenv (3),
.BR putenv (3),
.BR setenv (3),
and
.BR unsetenv (3)
functions.
.SH BUGS
There is no mechanism for detecting which entries in the
environment are statically allocated and which are
dynamically allocated, this can lead to memory leaks
with are detected by
.BR valgrind (1).
.SH SEE ALSO
.BR putenv (3),
.BR setenv (3),
.BR unsetenv (3),
.BR getenv (3),
.BR environ (3)