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

NAME

6       explain_closedir - explain closedir(3) errors
7

SYNOPSIS

9       #include <libexplain/closedir.h>
10       const char *explain_closedir(DIR *dir);
11       const char *explain_errno_closedir(int errnum, DIR *dir);
12       void  explain_message_closedir(char  *message,  int  message_size,  DIR
13       *dir);
14       void explain_message_errno_closedir(char  *message,  int  message_size,
15       int errnum, DIR *dir);
16

DESCRIPTION

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

SEE ALSO

162       closedir(3)
163               close a directory
164
165       explain_closedir_or_die(3)
166               close a directory and report errors
167
169       libexplain version 0.40
170       Copyright (C) 2008 Peter Miller
171
172
173
174                                                           explain_closedir(3)
Impressum