1 /*****************************************************************************
3 ** GNAT SYSTEM UTILITIES **
5 ** G E N - S O C C O N **
7 ** Copyright (C) 2004-2005 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, 51 Franklin Street, Fifth Floor, **
18 ** Boston, MA 02110-1301, 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 */
35 #include <netinet/in.h>
36 #include <netinet/tcp.h>
37 #include <sys/ioctl.h>
48 struct line
*first
= NULL
, *last
= NULL
;
50 #define TXT(_text) add_line(_text, NULL, NULL);
56 #define itoad(n) f_itoa ("%d", n)
57 #define itoax(n) f_itoa ("16#%08x#", n)
59 #define CND(name,comment) add_line(#name, itoad (name), comment);
60 /* Constant (decimal) */
62 #define CNX(name,comment) add_line(#name, itoax (name), comment);
63 /* Constant (hexadecimal) */
65 #define CN_(name,comment) add_line(#name, name, comment);
66 /* Constant (generic) */
69 /* Generate output spec */
71 char *f_itoa (char *, int);
74 void add_line (char *, char*, char*);
79 TXT("------------------------------------------------------------------------------")
81 TXT("-- GNAT COMPILER COMPONENTS --")
83 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
87 TXT("-- Copyright (C) 2000-2005 Free Software Foundation, Inc. --")
89 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
90 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
91 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
92 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
93 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
94 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
95 TXT("-- for more details. You should have received a copy of the GNU General --")
96 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
97 TXT("-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --")
98 TXT("-- Boston, MA 02110-1301, USA. --")
100 TXT("-- As a special exception, if other files instantiate generics from this --")
101 TXT("-- unit, or you link this unit with other files to produce an executable, --")
102 TXT("-- this unit does not by itself cause the resulting executable to be --")
103 TXT("-- covered by the GNU General Public License. This exception does not --")
104 TXT("-- however invalidate any other reasons why the executable file might be --")
105 TXT("-- covered by the GNU Public License. --")
107 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
108 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
110 TXT("------------------------------------------------------------------------------")
112 TXT("-- This package provides target dependent definitions of constant for use")
113 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
114 TXT("-- directly with'ed by an applications program.")
116 TXT("-- This is the version for " TARGET
)
117 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
118 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
120 TXT("package GNAT.Sockets.Constants is")
122 TXT(" --------------")
123 TXT(" -- Families --")
124 TXT(" --------------")
130 CND(AF_INET
, "IPv4 address family")
135 CND(AF_INET6
, "IPv6 address family")
143 #define SOCK_STREAM -1
145 CND(SOCK_STREAM
, "Stream socket")
148 #define SOCK_DGRAM -1
150 CND(SOCK_DGRAM
, "Datagram socket")
152 TXT(" -------------------")
153 TXT(" -- Socket errors --")
154 TXT(" -------------------")
160 CND(EACCES
, "Permission denied")
163 #define EADDRINUSE -1
165 CND(EADDRINUSE
, "Address already in use")
167 #ifndef EADDRNOTAVAIL
168 #define EADDRNOTAVAIL -1
170 CND(EADDRNOTAVAIL
, "Cannot assign address")
173 #define EAFNOSUPPORT -1
175 CND(EAFNOSUPPORT
, "Addr family not supported")
180 CND(EALREADY
, "Operation in progress")
185 CND(EBADF
, "Bad file descriptor")
188 #define ECONNABORTED -1
190 CND(ECONNABORTED
, "Connection aborted")
193 #define ECONNREFUSED -1
195 CND(ECONNREFUSED
, "Connection refused")
198 #define ECONNRESET -1
200 CND(ECONNRESET
, "Connection reset by peer")
203 #define EDESTADDRREQ -1
205 CND(EDESTADDRREQ
, "Destination addr required")
210 CND(EFAULT
, "Bad address")
215 CND(EHOSTDOWN
, "Host is down")
218 #define EHOSTUNREACH -1
220 CND(EHOSTUNREACH
, "No route to host")
223 #define EINPROGRESS -1
225 CND(EINPROGRESS
, "Operation now in progress")
230 CND(EINTR
, "Interrupted system call")
235 CND(EINVAL
, "Invalid argument")
240 CND(EIO
, "Input output error")
245 CND(EISCONN
, "Socket already connected")
250 CND(ELOOP
, "Too many symbolic lynks")
255 CND(EMFILE
, "Too many open files")
260 CND(EMSGSIZE
, "Message too long")
263 #define ENAMETOOLONG -1
265 CND(ENAMETOOLONG
, "Name too long")
270 CND(ENETDOWN
, "Network is down")
275 CND(ENETRESET
, "Disconn. on network reset")
278 #define ENETUNREACH -1
280 CND(ENETUNREACH
, "Network is unreachable")
285 CND(ENOBUFS
, "No buffer space available")
288 #define ENOPROTOOPT -1
290 CND(ENOPROTOOPT
, "Protocol not available")
295 CND(ENOTCONN
, "Socket not connected")
300 CND(ENOTSOCK
, "Operation on non socket")
303 #define EOPNOTSUPP -1
305 CND(EOPNOTSUPP
, "Operation not supported")
308 #define EPFNOSUPPORT -1
310 CND(EPFNOSUPPORT
, "Unknown protocol family")
312 #ifndef EPROTONOSUPPORT
313 #define EPROTONOSUPPORT -1
315 CND(EPROTONOSUPPORT
, "Unknown protocol")
318 #define EPROTOTYPE -1
320 CND(EPROTOTYPE
, "Unknown protocol type")
325 CND(ESHUTDOWN
, "Cannot send once shutdown")
327 #ifndef ESOCKTNOSUPPORT
328 #define ESOCKTNOSUPPORT -1
330 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
335 CND(ETIMEDOUT
, "Connection timed out")
338 #define ETOOMANYREFS -1
340 CND(ETOOMANYREFS
, "Too many references")
343 #define EWOULDBLOCK -1
345 CND(EWOULDBLOCK
, "Operation would block")
347 TXT(" -----------------")
348 TXT(" -- Host errors --")
349 TXT(" -----------------")
352 #ifndef HOST_NOT_FOUND
353 #define HOST_NOT_FOUND -1
355 CND(HOST_NOT_FOUND
, "Unknown host")
360 CND(TRY_AGAIN
, "Host name lookup failure")
365 CND(NO_DATA
, "No data record for name")
368 #define NO_RECOVERY -1
370 CND(NO_RECOVERY
, "Non recoverable errors")
372 TXT(" -------------------")
373 TXT(" -- Control flags --")
374 TXT(" -------------------")
380 CNX(FIONBIO
, "Set/clear non-blocking io")
385 CNX(FIONREAD
, "How many bytes to read")
387 TXT(" --------------------")
388 TXT(" -- Shutdown modes --")
389 TXT(" --------------------")
395 CND(SHUT_RD
, "No more recv")
400 CND(SHUT_WR
, "No more send")
405 CND(SHUT_RDWR
, "No more recv/send")
407 TXT(" ---------------------")
408 TXT(" -- Protocol levels --")
409 TXT(" ---------------------")
413 #define SOL_SOCKET -1
415 CND(SOL_SOCKET
, "Options for socket level")
418 #define IPPROTO_IP -1
420 CND(IPPROTO_IP
, "Dummy protocol for IP")
423 #define IPPROTO_UDP -1
425 CND(IPPROTO_UDP
, "UDP")
428 #define IPPROTO_TCP -1
430 CND(IPPROTO_TCP
, "TCP")
432 TXT(" -------------------")
433 TXT(" -- Request flags --")
434 TXT(" -------------------")
440 CND(MSG_OOB
, "Process out-of-band data")
445 CND(MSG_PEEK
, "Peek at incoming data")
450 CND(MSG_EOR
, "Send end of record")
453 #define MSG_WAITALL -1
455 CND(MSG_WAITALL
, "Wait for full reception")
458 #define MSG_NOSIGNAL -1
460 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
463 # define MSG_Forced_Flags "MSG_NOSIGNAL"
465 # define MSG_Forced_Flags "0"
467 CN_(MSG_Forced_Flags
, "")
468 TXT(" -- Flags set on all send(2) calls")
471 TXT(" --------------------")
472 TXT(" -- Socket options --")
473 TXT(" --------------------")
477 #define TCP_NODELAY -1
479 CND(TCP_NODELAY
, "Do not coalesce packets")
484 CND(SO_SNDBUF
, "Set/get send buffer size")
489 CND(SO_RCVBUF
, "Set/get recv buffer size")
492 #define SO_REUSEADDR -1
494 CND(SO_REUSEADDR
, "Bind reuse local address")
497 #define SO_KEEPALIVE -1
499 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
504 CND(SO_LINGER
, "Defer close to flush data")
509 CND(SO_ERROR
, "Get/clear error status")
512 #define SO_BROADCAST -1
514 CND(SO_BROADCAST
, "Can send broadcast msgs")
516 #ifndef IP_MULTICAST_IF
517 #define IP_MULTICAST_IF -1
519 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
521 #ifndef IP_MULTICAST_TTL
522 #define IP_MULTICAST_TTL -1
524 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
526 #ifndef IP_MULTICAST_LOOP
527 #define IP_MULTICAST_LOOP -1
529 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
531 #ifndef IP_ADD_MEMBERSHIP
532 #define IP_ADD_MEMBERSHIP -1
534 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
536 #ifndef IP_DROP_MEMBERSHIP
537 #define IP_DROP_MEMBERSHIP -1
539 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
542 TXT("end GNAT.Sockets.Constants;")
550 int text_max
= 0, value_max
= 0, l
;
553 #define UPD_MAX(x) do { \
555 if (l > x ## _max) x ## _max = l; \
558 for (p
= first
; p
!= NULL
; p
= p
->next
) {
559 if (p
->value
!= NULL
) {
564 sprintf (fmt
, " %%-%ds : constant := %%%ds;%%s%%s\n",
565 text_max
, value_max
);
567 for (p
= first
; p
!= NULL
; p
= p
->next
) {
568 if (p
->value
== NULL
) {
569 printf ("%s\n", p
->text
);
571 char *comment_sep
= (strlen (p
->comment
) > 0)
573 printf (fmt
, p
->text
, p
->value
, comment_sep
, p
->comment
);
579 f_itoa (char *fmt
, int n
) {
581 sprintf (buf
, fmt
, n
);
586 add_line (char *_text
, char *_value
, char *_comment
) {
587 struct line
*l
= (struct line
*) malloc (sizeof (struct line
));
590 l
->comment
= _comment
;