GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-errno.in.cc
Go to the documentation of this file.
1 // DO NOT EDIT! Generated automatically from oct-errno.in.cc by configure
2 /*
3 
4 Copyright (C) 2005-2015 John W. Eaton
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <cerrno>
29 
30 #include "singleton-cleanup.h"
31 
32 #include "oct-errno.h"
33 #include "oct-map.h"
34 #include "error.h"
35 
37 
39 {
40  struct errno_struct
41  {
42  const char *name;
43  int value;
44  };
45 
46  static errno_struct errno_codes[] =
47  {
48  // POSIX.
49 
50 #if defined (E2BIG)
51  { "E2BIG", E2BIG, },
52 #endif
53 #if defined (EACCES)
54  { "EACCES", EACCES, },
55 #endif
56 #if defined (EADDRINUSE)
57  { "EADDRINUSE", EADDRINUSE, },
58 #endif
59 #if defined (EADDRNOTAVAIL)
60  { "EADDRNOTAVAIL", EADDRNOTAVAIL, },
61 #endif
62 #if defined (EAFNOSUPPORT)
63  { "EAFNOSUPPORT", EAFNOSUPPORT, },
64 #endif
65 #if defined (EAGAIN)
66  { "EAGAIN", EAGAIN, },
67 #endif
68 #if defined (EALREADY)
69  { "EALREADY", EALREADY, },
70 #endif
71 #if defined (EBADF)
72  { "EBADF", EBADF, },
73 #endif
74 #if defined (EBUSY)
75  { "EBUSY", EBUSY, },
76 #endif
77 #if defined (ECHILD)
78  { "ECHILD", ECHILD, },
79 #endif
80 #if defined (ECONNABORTED)
81  { "ECONNABORTED", ECONNABORTED, },
82 #endif
83 #if defined (ECONNREFUSED)
84  { "ECONNREFUSED", ECONNREFUSED, },
85 #endif
86 #if defined (ECONNRESET)
87  { "ECONNRESET", ECONNRESET, },
88 #endif
89 #if defined (EDEADLK)
90  { "EDEADLK", EDEADLK, },
91 #endif
92 #if defined (EDESTADDRREQ)
93  { "EDESTADDRREQ", EDESTADDRREQ, },
94 #endif
95 #if defined (EDOM)
96  { "EDOM", EDOM, },
97 #endif
98 #if defined (EDQUOT)
99  { "EDQUOT", EDQUOT, },
100 #endif
101 #if defined (EEXIST)
102  { "EEXIST", EEXIST, },
103 #endif
104 #if defined (EFAULT)
105  { "EFAULT", EFAULT, },
106 #endif
107 #if defined (EFBIG)
108  { "EFBIG", EFBIG, },
109 #endif
110 #if defined (EHOSTDOWN)
111  { "EHOSTDOWN", EHOSTDOWN, },
112 #endif
113 #if defined (EHOSTUNREACH)
114  { "EHOSTUNREACH", EHOSTUNREACH, },
115 #endif
116 #if defined (EINPROGRESS)
117  { "EINPROGRESS", EINPROGRESS, },
118 #endif
119 #if defined (EINTR)
120  { "EINTR", EINTR, },
121 #endif
122 #if defined (EINVAL)
123  { "EINVAL", EINVAL, },
124 #endif
125 #if defined (EIO)
126  { "EIO", EIO, },
127 #endif
128 #if defined (EISCONN)
129  { "EISCONN", EISCONN, },
130 #endif
131 #if defined (EISDIR)
132  { "EISDIR", EISDIR, },
133 #endif
134 #if defined (ELOOP)
135  { "ELOOP", ELOOP, },
136 #endif
137 #if defined (EMFILE)
138  { "EMFILE", EMFILE, },
139 #endif
140 #if defined (EMLINK)
141  { "EMLINK", EMLINK, },
142 #endif
143 #if defined (EMSGSIZE)
144  { "EMSGSIZE", EMSGSIZE, },
145 #endif
146 #if defined (ENAMETOOLONG)
147  { "ENAMETOOLONG", ENAMETOOLONG, },
148 #endif
149 #if defined (ENETDOWN)
150  { "ENETDOWN", ENETDOWN, },
151 #endif
152 #if defined (ENETRESET)
153  { "ENETRESET", ENETRESET, },
154 #endif
155 #if defined (ENETUNREACH)
156  { "ENETUNREACH", ENETUNREACH, },
157 #endif
158 #if defined (ENFILE)
159  { "ENFILE", ENFILE, },
160 #endif
161 #if defined (ENOBUFS)
162  { "ENOBUFS", ENOBUFS, },
163 #endif
164 #if defined (ENODEV)
165  { "ENODEV", ENODEV, },
166 #endif
167 #if defined (ENOENT)
168  { "ENOENT", ENOENT, },
169 #endif
170 #if defined (ENOEXEC)
171  { "ENOEXEC", ENOEXEC, },
172 #endif
173 #if defined (ENOLCK)
174  { "ENOLCK", ENOLCK, },
175 #endif
176 #if defined (ENOMEM)
177  { "ENOMEM", ENOMEM, },
178 #endif
179 #if defined (ENOPROTOOPT)
180  { "ENOPROTOOPT", ENOPROTOOPT, },
181 #endif
182 #if defined (ENOSPC)
183  { "ENOSPC", ENOSPC, },
184 #endif
185 #if defined (ENOSYS)
186  { "ENOSYS", ENOSYS, },
187 #endif
188 #if defined (ENOTBLK)
189  { "ENOTBLK", ENOTBLK, },
190 #endif
191 #if defined (ENOTCONN)
192  { "ENOTCONN", ENOTCONN, },
193 #endif
194 #if defined (ENOTDIR)
195  { "ENOTDIR", ENOTDIR, },
196 #endif
197 #if defined (ENOTEMPTY)
198  { "ENOTEMPTY", ENOTEMPTY, },
199 #endif
200 #if defined (ENOTSOCK)
201  { "ENOTSOCK", ENOTSOCK, },
202 #endif
203 #if defined (ENOTTY)
204  { "ENOTTY", ENOTTY, },
205 #endif
206 #if defined (ENXIO)
207  { "ENXIO", ENXIO, },
208 #endif
209 #if defined (EOPNOTSUPP)
210  { "EOPNOTSUPP", EOPNOTSUPP, },
211 #endif
212 #if defined (EPERM)
213  { "EPERM", EPERM, },
214 #endif
215 #if defined (EPFNOSUPPORT)
216  { "EPFNOSUPPORT", EPFNOSUPPORT, },
217 #endif
218 #if defined (EPIPE)
219  { "EPIPE", EPIPE, },
220 #endif
221 #if defined (EPROTONOSUPPORT)
222  { "EPROTONOSUPPORT", EPROTONOSUPPORT, },
223 #endif
224 #if defined (EPROTOTYPE)
225  { "EPROTOTYPE", EPROTOTYPE, },
226 #endif
227 #if defined (ERANGE)
228  { "ERANGE", ERANGE, },
229 #endif
230 #if defined (EREMOTE)
231  { "EREMOTE", EREMOTE, },
232 #endif
233 #if defined (ERESTART)
234  { "ERESTART", ERESTART, },
235 #endif
236 #if defined (EROFS)
237  { "EROFS", EROFS, },
238 #endif
239 #if defined (ESHUTDOWN)
240  { "ESHUTDOWN", ESHUTDOWN, },
241 #endif
242 #if defined (ESOCKTNOSUPPORT)
243  { "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, },
244 #endif
245 #if defined (ESPIPE)
246  { "ESPIPE", ESPIPE, },
247 #endif
248 #if defined (ESRCH)
249  { "ESRCH", ESRCH, },
250 #endif
251 #if defined (ESTALE)
252  { "ESTALE", ESTALE, },
253 #endif
254 #if defined (ETIMEDOUT)
255  { "ETIMEDOUT", ETIMEDOUT, },
256 #endif
257 #if defined (ETOOMANYREFS)
258  { "ETOOMANYREFS", ETOOMANYREFS, },
259 #endif
260 #if defined (ETXTBSY)
261  { "ETXTBSY", ETXTBSY, },
262 #endif
263 #if defined (EUSERS)
264  { "EUSERS", EUSERS, },
265 #endif
266 #if defined (EWOULDBLOCK)
267  { "EWOULDBLOCK", EWOULDBLOCK, },
268 #endif
269 #if defined (EXDEV)
270  { "EXDEV", EXDEV, },
271 #endif
272 
273  // Others (duplicates are OK).
274 
275 @SYSDEP_ERRNO_LIST@
276 
277  { 0, 0, },
278  };
279 
280  // Stuff them all in a map for fast access.
281 
282  errno_struct *ptr = errno_codes;
283 
284  while (ptr->name)
285  {
286  errno_tbl[ptr->name] = ptr->value;
287  ptr++;
288  }
289 }
290 
291 bool
293 {
294  bool retval = true;
295 
296  if (! instance)
297  {
298  instance = new octave_errno ();
299 
300  if (instance)
302  }
303 
304  if (! instance)
305  {
306  ::error ("unable to create errno object!");
307 
308  retval = false;
309  }
310 
311  return retval;
312 }
313 
314 int
315 octave_errno::lookup (const std::string& name)
316 {
317  return (instance_ok ()) ? instance->do_lookup (name) : -1;
318 }
319 
321 octave_errno::list (void)
322 {
323  return (instance_ok ()) ? instance->do_list () : octave_scalar_map ();
324 }
325 
326 int
327 octave_errno::do_lookup (const std::string& name)
328 {
329  return (errno_tbl.find (name) != errno_tbl.end ()) ? errno_tbl[name] : -1;
330 }
331 
334 {
335  octave_scalar_map retval;
336 
337  for (std::map<std::string, int>::const_iterator p = errno_tbl.begin ();
338  p != errno_tbl.end ();
339  p++)
340  {
341  retval.assign (p->first, p->second);
342  }
343 
344  return retval;
345 }
static void cleanup_instance(void)
Definition: oct-errno.h:46
static octave_errno * instance
Definition: oct-errno.h:65
void error(const char *fmt,...)
Definition: error.cc:476
static bool instance_ok(void)
Definition: oct-errno.cc:694
static void add(fptr f)
int do_lookup(const std::string &name)
Definition: oct-errno.cc:729
octave_scalar_map do_list(void)
Definition: oct-errno.cc:735
void assign(const std::string &k, const octave_value &val)
Definition: oct-map.h:225
static int lookup(const std::string &name)
Definition: oct-errno.cc:717
static octave_scalar_map list(void)
Definition: oct-errno.cc:723
std::map< std::string, int > errno_tbl
Definition: oct-errno.h:63
octave_errno(void)
Definition: oct-errno.cc:38