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

NAME

6       explain_tmpfile - explain tmpfile(3) errors
7

SYNOPSIS

9       #include <libexplain/tmpfile.h>
10       const char *explain_tmpfile(void);
11       const char *explain_errno_tmpfile(int errnum, void);
12       void explain_message_tmpfile(char *message, int message_size, void);
13       void explain_message_errno_tmpfile(char *message, int message_size, int
14       errnum, void);
15

DESCRIPTION

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

SEE ALSO

164       tmpfile(3)
165               create a temporary file
166
167       explain_tmpfile_or_die(3)
168               create a temporary file and report errors
169
171       libexplain version 1.4
172       Copyright (C) 2009 Peter Miller
173
174
175
176                                                            explain_tmpfile(3)
Impressum