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

NAME

6       explain_fputc - explain fputc(3) errors
7

SYNOPSIS

9       #include <libexplain/fputc.h>
10       const char *explain_fputc(int c, FILE *fp);
11       const char *explain_errno_fputc(int errnum, int c, FILE *fp);
12       void explain_message_fputc(char *message, int message_size, int c, FILE
13       *fp);
14       void explain_message_errno_fputc(char *message, int  message_size,  int
15       errnum, int c, FILE *fp);
16

DESCRIPTION

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

SEE ALSO

165       fputc(3)
166               output of characters
167
168       explain_fputc_or_die(3)
169               output of characters and report errors
170
172       libexplain version 1.4
173       Copyright (C) 2008 Peter Miller
174
175
176
177                                                              explain_fputc(3)
Impressum