1 /*****************************************************************************
3 ** GNAT SYSTEM UTILITIES **
5 ** G E N - S O C C O N **
7 ** Copyright (C) 2004 Free Software Foundation, Inc. **
9 ** GNAT is free software; you can redistribute it and/or modify it under **
10 ** terms of the GNU General Public License as published by the Free Soft- **
11 ** ware Foundation; either version 2, or (at your option) any later ver- **
12 ** sion. GNAT is distributed in the hope that it will be useful, but WITH- **
13 ** OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY **
14 ** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License **
15 ** for more details. You should have received a copy of the GNU General **
16 ** Public License distributed with GNAT; see file COPYING. If not, write **
17 ** to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, **
18 ** MA 02111-1307, USA. **
20 ** GNAT was originally developed by the GNAT team at New York University. **
21 ** Extensive contributions were provided by Ada Core Technologies Inc. **
23 ******************************************************************************/
25 /* This program generates g-soccon.ads */
31 #include <netinet/in.h>
32 #include <netinet/tcp.h>
33 #include <sys/filio.h>
43 struct line *first = NULL, *last = NULL;
45 #define TXT(_text) add_line(_text, NULL, NULL);
51 #define itoad(n) itoa ("%d", n)
52 #define itoax(n) itoa ("16#%08x#", n)
54 #define CND(name,comment) add_line(#name, itoad (name), comment);
55 /* Constant (decimal) */
57 #define CNX(name,comment) add_line(#name, itoax (name), comment);
58 /* Constant (hexadecimal) */
60 #define CN_(name,comment) add_line(#name, name, comment);
61 /* Constant (generic) */
64 /* Generate output spec */
66 char *itoa (char *, int);
69 void add_line (char *, char*, char*);
73 TXT("------------------------------------------------------------------------------")
75 TXT("-- GNAT COMPILER COMPONENTS --")
77 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
81 TXT("-- Copyright (C) 2000-2004 Free Software Foundation, Inc. --")
83 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
84 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
85 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
86 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
87 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
88 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
89 TXT("-- for more details. You should have received a copy of the GNU General --")
90 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
91 TXT("-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --")
92 TXT("-- MA 02111-1307, USA. --")
94 TXT("-- As a special exception, if other files instantiate generics from this --")
95 TXT("-- unit, or you link this unit with other files to produce an executable, --")
96 TXT("-- this unit does not by itself cause the resulting executable to be --")
97 TXT("-- covered by the GNU General Public License. This exception does not --")
98 TXT("-- however invalidate any other reasons why the executable file might be --")
99 TXT("-- covered by the GNU Public License. --")
101 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
102 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
104 TXT("------------------------------------------------------------------------------")
106 TXT("-- This package provides target dependent definitions of constant for use")
107 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
108 TXT("-- directly with'ed by an applications program.")
110 TXT("-- This is the version for " TARGET)
111 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
112 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
114 TXT("package GNAT.Sockets.Constants is")
116 TXT(" --------------")
117 TXT(" -- Families --")
118 TXT(" --------------")
124 CND(AF_INET, "IPv4 address family")
129 CND(AF_INET6, "IPv6 address family")
137 #define SOCK_STREAM -1
139 CND(SOCK_STREAM, "Stream socket")
142 #define SOCK_DGRAM -1
144 CND(SOCK_DGRAM, "Datagram socket")
146 TXT(" -------------------")
147 TXT(" -- Socket errors --")
148 TXT(" -------------------")
154 CND(EACCES, "Permission denied")
157 #define EADDRINUSE -1
159 CND(EADDRINUSE, "Address already in use")
161 #ifndef EADDRNOTAVAIL
162 #define EADDRNOTAVAIL -1
164 CND(EADDRNOTAVAIL, "Cannot assign address")
167 #define EAFNOSUPPORT -1
169 CND(EAFNOSUPPORT, "Addr family not supported")
174 CND(EALREADY, "Operation in progress")
179 CND(EBADF, "Bad file descriptor")
182 #define ECONNABORTED -1
184 CND(ECONNABORTED, "Connection aborted")
187 #define ECONNREFUSED -1
189 CND(ECONNREFUSED, "Connection refused")
192 #define ECONNRESET -1
194 CND(ECONNRESET, "Connection reset by peer")
197 #define EDESTADDRREQ -1
199 CND(EDESTADDRREQ, "Destination addr required")
204 CND(EFAULT, "Bad address")
209 CND(EHOSTDOWN, "Host is down")
212 #define EHOSTUNREACH -1
214 CND(EHOSTUNREACH, "No route to host")
217 #define EINPROGRESS -1
219 CND(EINPROGRESS, "Operation now in progress")
224 CND(EINTR, "Interrupted system call")
229 CND(EINVAL, "Invalid argument")
234 CND(EIO, "Input output error")
239 CND(EISCONN, "Socket already connected")
244 CND(ELOOP, "Too many symbolic lynks")
249 CND(EMFILE, "Too many open files")
254 CND(EMSGSIZE, "Message too long")
257 #define ENAMETOOLONG -1
259 CND(ENAMETOOLONG, "Name too long")
264 CND(ENETDOWN, "Network is down")
269 CND(ENETRESET, "Disconn. on network reset")
272 #define ENETUNREACH -1
274 CND(ENETUNREACH, "Network is unreachable")
279 CND(ENOBUFS, "No buffer space available")
282 #define ENOPROTOOPT -1
284 CND(ENOPROTOOPT, "Protocol not available")
289 CND(ENOTCONN, "Socket not connected")
294 CND(ENOTSOCK, "Operation on non socket")
297 #define EOPNOTSUPP -1
299 CND(EOPNOTSUPP, "Operation not supported")
302 #define EPFNOSUPPORT -1
304 CND(EPFNOSUPPORT, "Unknown protocol family")
306 #ifndef EPROTONOSUPPORT
307 #define EPROTONOSUPPORT -1
309 CND(EPROTONOSUPPORT, "Unknown protocol")
312 #define EPROTOTYPE -1
314 CND(EPROTOTYPE, "Unknown protocol type")
319 CND(ESHUTDOWN, "Cannot send once shutdown")
321 #ifndef ESOCKTNOSUPPORT
322 #define ESOCKTNOSUPPORT -1
324 CND(ESOCKTNOSUPPORT, "Socket type not supported")
329 CND(ETIMEDOUT, "Connection timed out")
332 #define ETOOMANYREFS -1
334 CND(ETOOMANYREFS, "Too many references")
337 #define EWOULDBLOCK -1
339 CND(EWOULDBLOCK, "Operation would block")
341 TXT(" -----------------")
342 TXT(" -- Host errors --")
343 TXT(" -----------------")
346 #ifndef HOST_NOT_FOUND
347 #define HOST_NOT_FOUND -1
349 CND(HOST_NOT_FOUND, "Unknown host")
354 CND(TRY_AGAIN, "Host name lookup failure")
359 CND(NO_DATA, "No data record for name")
362 #define NO_RECOVERY -1
364 CND(NO_RECOVERY, "Non recoverable errors")
366 TXT(" -------------------")
367 TXT(" -- Control flags --")
368 TXT(" -------------------")
374 CNX(FIONBIO, "Set/clear non-blocking io")
379 CNX(FIONREAD, "How many bytes to read")
381 TXT(" --------------------")
382 TXT(" -- Shutdown modes --")
383 TXT(" --------------------")
389 CND(SHUT_RD, "No more recv")
394 CND(SHUT_WR, "No more send")
399 CND(SHUT_RDWR, "No more recv/send")
401 TXT(" ---------------------")
402 TXT(" -- Protocol levels --")
403 TXT(" ---------------------")
407 #define SOL_SOCKET -1
409 CND(SOL_SOCKET, "Options for socket level")
412 #define IPPROTO_IP -1
414 CND(IPPROTO_IP, "Dummy protocol for IP")
417 #define IPPROTO_UDP -1
419 CND(IPPROTO_UDP, "UDP")
422 #define IPPROTO_TCP -1
424 CND(IPPROTO_TCP, "TCP")
426 TXT(" -------------------")
427 TXT(" -- Request flags --")
428 TXT(" -------------------")
434 CND(MSG_OOB, "Process out-of-band data")
439 CND(MSG_PEEK, "Peek at incoming data")
444 CND(MSG_EOR, "Send end of record")
447 #define MSG_WAITALL -1
449 CND(MSG_WAITALL, "Wait for full reception")
452 #define MSG_NOSIGNAL -1
454 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
457 # define MSG_Forced_Flags "MSG_NOSIGNAL"
459 # define MSG_Forced_Flags "0"
461 CN_(MSG_Forced_Flags, "")
462 TXT(" -- Flags set on all send(2) calls")
465 TXT(" --------------------")
466 TXT(" -- Socket options --")
467 TXT(" --------------------")
471 #define TCP_NODELAY -1
473 CND(TCP_NODELAY, "Do not coalesce packets")
478 CND(SO_SNDBUF, "Set/get send buffer size")
483 CND(SO_RCVBUF, "Set/get recv buffer size")
486 #define SO_REUSEADDR -1
488 CND(SO_REUSEADDR, "Bind reuse local address")
491 #define SO_KEEPALIVE -1
493 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
498 CND(SO_LINGER, "Defer close to flush data")
503 CND(SO_ERROR, "Get/clear error status")
506 #define SO_BROADCAST -1
508 CND(SO_BROADCAST, "Can send broadcast msgs")
510 #ifndef IP_ADD_MEMBERSHIP
511 #define IP_ADD_MEMBERSHIP -1
513 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
515 #ifndef IP_DROP_MEMBERSHIP
516 #define IP_DROP_MEMBERSHIP -1
518 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
520 #ifndef IP_MULTICAST_TTL
521 #define IP_MULTICAST_TTL -1
523 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
525 #ifndef IP_MULTICAST_LOOP
526 #define IP_MULTICAST_LOOP -1
528 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
530 TXT("end GNAT.Sockets.Constants;")
537 int text_max = 0, value_max = 0, l;
540 #define UPD_MAX(x) do { \
542 if (l > x ## _max) x ## _max = l; \
545 for (p = first; p != NULL; p = p->next) {
546 if (p->value != NULL) {
551 sprintf (fmt, " %%-%ds : constant := %%%ds;%%s%%s\n",
552 text_max, value_max);
554 for (p = first; p != NULL; p = p->next) {
555 if (p->value == NULL) {
556 printf ("%s\n", p->text);
558 char *comment_sep = (strlen (p->comment) > 0)
560 printf (fmt, p->text, p->value, comment_sep, p->comment);
566 itoa (char *fmt, int n) {
568 sprintf (buf, fmt, n);
572 void add_line (char *_text, char *_value, char *_comment) {
573 struct line *l = (struct line *) malloc (sizeof (struct line));
576 l->comment = _comment;