1explain_mkstemp(3)         Library Functions Manual         explain_mkstemp(3)
2
3
4

NAME

6       explain_mkstemp - explain mkstemp(3) errors
7

SYNOPSIS

9       #include <libexplain/mkstemp.h>
10       const char *explain_mkstemp(char *template);
11       const char *explain_errno_mkstemp(int errnum, char *template);
12       void explain_message_mkstemp(char *message, int message_size, char
13       *template);
14       void explain_message_errno_mkstemp(char *message, int message_size, int
15       errnum, char *template);
16

DESCRIPTION

18       These  functions may be used to obtain explanations for errors returned
19       by the mkstemp(3) system call.
20
21   explain_mkstemp
22       const char *explain_mkstemp(char *template);
23
24       The explain_mkstemp function is used to obtain  an  explanation  of  an
25       error  returned  by  the  mkstemp(3) system call. The least the message
26       will contain is the value of strerror(errno), but usually  it  will  do
27       much better, and indicate the underlying cause in more detail.
28
29       The  errno global variable will be used to obtain the error value to be
30       decoded.
31
32       template
33               The original template, exactly as passed to the mkstemp(3) sys‐
34               tem call.
35
36       Returns:
37               The message explaining the error. This message buffer is shared
38               by all libexplain functions which do not  supply  a  buffer  in
39               their argument list.  This will be overwritten by the next call
40               to any libexplain function which shares this buffer,  including
41               other threads.
42
43       Note: This function is not thread safe, because it shares a return buf‐
44       fer across all threads, and many other functions in this library.
45
46       Example: This function is intended to be used in a fashion  similar  to
47       the following example:
48              int result = mkstemp(template);
49              if (result < 0)
50              {
51                  fprintf(stderr, "%s\n", explain_mkstemp(template));
52                  exit(EXIT_FAILURE);
53              }
54
55       The   above   code   example   is   available   pre‐packaged   as   the
56       explain_mkstemp_or_die(3) function.
57
58   explain_errno_mkstemp
59       const char *explain_errno_mkstemp(int errnum, char *template);
60
61       The explain_errno_mkstemp function is used to obtain an explanation  of
62       an  error returned by the mkstemp(3) system call. The least the message
63       will contain is the value of strerror(errno), but usually  it  will  do
64       much better, and indicate the underlying cause in more detail.
65
66       errnum  The  error value to be decoded, usually obtained from the errno
67               global variable just before this function is  called.  This  is
68               necessary  if you need to call any code between the system call
69               to be explained and this function, because many libc  functions
70               will alter the value of errno.
71
72       template
73               The original template, exactly as passed to the mkstemp(3) sys‐
74               tem call.
75
76       Returns:
77               The message explaining the error. This message buffer is shared
78               by  all  libexplain  functions  which do not supply a buffer in
79               their argument list.  This will be overwritten by the next call
80               to  any libexplain function which shares this buffer, including
81               other threads.
82
83       Note: This function is not thread safe, because it shares a return buf‐
84       fer across all threads, and many other functions in this library.
85
86       Example:  This  function is intended to be used in a fashion similar to
87       the following example:
88              int result = mkstemp(template);
89              if (result < 0)
90              {
91                  int err = errno;
92                  fprintf(stderr, "%s\n", explain_errno_mkstemp(err, tem‐
93                  plate));
94                  exit(EXIT_FAILURE);
95              }
96
97       The   above   code   example   is   available   pre‐packaged   as   the
98       explain_mkstemp_or_die(3) function.
99
100   explain_message_mkstemp
101       void explain_message_mkstemp(char *message, int message_size, char
102       *template);
103
104       The  explain_message_mkstemp  function is used to obtain an explanation
105       of an error returned by the mkstemp(3) system call. The least the  mes‐
106       sage  will contain is the value of strerror(errno), but usually it will
107       do much better, and indicate the underlying cause in more detail.
108
109       The errno global variable will be used to obtain the error value to  be
110       decoded.
111
112       message The location in which to store the returned message. If a suit‐
113               able message return buffer is supplied, this function is thread
114               safe.
115
116       message_size
117               The  size  in  bytes  of  the  location  in  which to store the
118               returned message.
119
120       template
121               The original template, exactly as passed to the mkstemp(3) sys‐
122               tem call.
123
124       Example:  This  function is intended to be used in a fashion similar to
125       the following example:
126              int result = mkstemp(template);
127              if (result < 0)
128              {
129                  char message[3000];
130                  explain_message_mkstemp(message, sizeof(message), template);
131                  fprintf(stderr, "%s\n", message);
132                  exit(EXIT_FAILURE);
133              }
134
135       The   above   code   example   is   available   pre‐packaged   as   the
136       explain_mkstemp_or_die(3) function.
137
138   explain_message_errno_mkstemp
139       void explain_message_errno_mkstemp(char *message, int message_size, int
140       errnum, char *template);
141
142       The explain_message_errno_mkstemp function is used to obtain an  expla‐
143       nation  of  an  error returned by the mkstemp(3) system call. The least
144       the message will contain is the value of strerror(errno),  but  usually
145       it  will  do  much  better,  and  indicate the underlying cause in more
146       detail.
147
148       message The location in which to store the returned message. If a suit‐
149               able message return buffer is supplied, this function is thread
150               safe.
151
152       message_size
153               The size in bytes  of  the  location  in  which  to  store  the
154               returned message.
155
156       errnum  The  error value to be decoded, usually obtained from the errno
157               global variable just before this function is  called.  This  is
158               necessary  if you need to call any code between the system call
159               to be explained and this function, because many libc  functions
160               will alter the value of errno.
161
162       template
163               The original template, exactly as passed to the mkstemp(3) sys‐
164               tem call.
165
166       Example: This function is intended to be used in a fashion  similar  to
167       the following example:
168              int result = mkstemp(template);
169              if (result < 0)
170              {
171                  int err = errno;
172                  char message[3000];
173                  explain_message_errno_mkstemp(message, sizeof(message), err,
174                  template);
175                  fprintf(stderr, "%s\n", message);
176                  exit(EXIT_FAILURE);
177              }
178
179       The   above   code   example   is   available   pre‐packaged   as   the
180       explain_mkstemp_or_die(3) function.
181

SEE ALSO

183       mkstemp(3)
184               create a unique temporary file
185
186       explain_mkstemp_or_die(3)
187               create a unique temporary file and report errors
188
190       libexplain version 0.40
191       Copyright (C) 2009 Peter Miller
192
193
194
195                                                            explain_mkstemp(3)
Impressum