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

NAME

6       explain_settimeofday - explain settimeofday(2) errors
7

SYNOPSIS

9       #include <libexplain/settimeofday.h>
10       const char *explain_settimeofday(const struct timeval *tv, const struct
11       timezone *tz);
12       const char *explain_errno_settimeofday(int errnum, const struct timeval
13       *tv, const struct timezone *tz);
14       void explain_message_settimeofday(char *message, int message_size,
15       const struct timeval *tv, const struct timezone *tz);
16       void explain_message_errno_settimeofday(char *message, int mes‐
17       sage_size, int errnum, const struct timeval *tv, const struct timezone
18       *tz);
19

DESCRIPTION

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

SEE ALSO

196       settimeofday(2)
197               sets system time
198
199       explain_settimeofday_or_die(3)
200               sets system time and report errors
201
203       libexplain version 1.4
204       Copyright (C) 2013 Peter Miller
205
206
207
208                                                       explain_settimeofday(3)
Impressum