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 */
27 /* To build using DEC C:
28 CC/DEFINE="TARGET=OpenVMS" gen-soccon
34 # error Please define TARGET
50 struct line
*first
= NULL
, *last
= NULL
;
52 #define TXT(_text) add_line(_text, NULL, NULL);
58 #define itoad(n) f_itoa ("%d", n)
59 #define itoax(n) f_itoa ("16#%08x#", n)
61 #define CND(name,comment) add_line(#name, itoad (name), comment);
62 /* Constant (decimal) */
64 #define CNX(name,comment) add_line(#name, itoax (name), comment);
65 /* Constant (hexadecimal) */
67 #define CN_(name,comment) add_line(#name, name, comment);
68 /* Constant (generic) */
70 #define STR(p) STR1(p)
74 /* Generate output spec */
76 char *f_itoa (char *, int);
79 void add_line (char *, char*, char*);
84 TXT("------------------------------------------------------------------------------")
86 TXT("-- GNAT COMPILER COMPONENTS --")
88 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
92 TXT("-- Copyright (C) 2000-2005 Free Software Foundation, Inc. --")
94 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
95 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
96 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
97 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
98 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
99 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
100 TXT("-- for more details. You should have received a copy of the GNU General --")
101 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
102 TXT("-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --")
103 TXT("-- Boston, MA 02110-1301, USA. --")
105 TXT("-- As a special exception, if other files instantiate generics from this --")
106 TXT("-- unit, or you link this unit with other files to produce an executable, --")
107 TXT("-- this unit does not by itself cause the resulting executable to be --")
108 TXT("-- covered by the GNU General Public License. This exception does not --")
109 TXT("-- however invalidate any other reasons why the executable file might be --")
110 TXT("-- covered by the GNU Public License. --")
112 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
113 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
115 TXT("------------------------------------------------------------------------------")
117 TXT("-- This package provides target dependent definitions of constant for use")
118 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
119 TXT("-- directly with'ed by an applications program.")
121 TXT("-- This is the version for " STR (TARGET
))
122 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
123 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
125 TXT("package GNAT.Sockets.Constants is")
127 TXT(" --------------")
128 TXT(" -- Families --")
129 TXT(" --------------")
135 CND(AF_INET
, "IPv4 address family")
140 CND(AF_INET6
, "IPv6 address family")
148 #define SOCK_STREAM -1
150 CND(SOCK_STREAM
, "Stream socket")
153 #define SOCK_DGRAM -1
155 CND(SOCK_DGRAM
, "Datagram socket")
157 TXT(" -------------------")
158 TXT(" -- Socket errors --")
159 TXT(" -------------------")
165 CND(EACCES
, "Permission denied")
168 #define EADDRINUSE -1
170 CND(EADDRINUSE
, "Address already in use")
172 #ifndef EADDRNOTAVAIL
173 #define EADDRNOTAVAIL -1
175 CND(EADDRNOTAVAIL
, "Cannot assign address")
178 #define EAFNOSUPPORT -1
180 CND(EAFNOSUPPORT
, "Addr family not supported")
185 CND(EALREADY
, "Operation in progress")
190 CND(EBADF
, "Bad file descriptor")
193 #define ECONNABORTED -1
195 CND(ECONNABORTED
, "Connection aborted")
198 #define ECONNREFUSED -1
200 CND(ECONNREFUSED
, "Connection refused")
203 #define ECONNRESET -1
205 CND(ECONNRESET
, "Connection reset by peer")
208 #define EDESTADDRREQ -1
210 CND(EDESTADDRREQ
, "Destination addr required")
215 CND(EFAULT
, "Bad address")
220 CND(EHOSTDOWN
, "Host is down")
223 #define EHOSTUNREACH -1
225 CND(EHOSTUNREACH
, "No route to host")
228 #define EINPROGRESS -1
230 CND(EINPROGRESS
, "Operation now in progress")
235 CND(EINTR
, "Interrupted system call")
240 CND(EINVAL
, "Invalid argument")
245 CND(EIO
, "Input output error")
250 CND(EISCONN
, "Socket already connected")
255 CND(ELOOP
, "Too many symbolic lynks")
260 CND(EMFILE
, "Too many open files")
265 CND(EMSGSIZE
, "Message too long")
268 #define ENAMETOOLONG -1
270 CND(ENAMETOOLONG
, "Name too long")
275 CND(ENETDOWN
, "Network is down")
280 CND(ENETRESET
, "Disconn. on network reset")
283 #define ENETUNREACH -1
285 CND(ENETUNREACH
, "Network is unreachable")
290 CND(ENOBUFS
, "No buffer space available")
293 #define ENOPROTOOPT -1
295 CND(ENOPROTOOPT
, "Protocol not available")
300 CND(ENOTCONN
, "Socket not connected")
305 CND(ENOTSOCK
, "Operation on non socket")
308 #define EOPNOTSUPP -1
310 CND(EOPNOTSUPP
, "Operation not supported")
313 #define EPFNOSUPPORT -1
315 CND(EPFNOSUPPORT
, "Unknown protocol family")
317 #ifndef EPROTONOSUPPORT
318 #define EPROTONOSUPPORT -1
320 CND(EPROTONOSUPPORT
, "Unknown protocol")
323 #define EPROTOTYPE -1
325 CND(EPROTOTYPE
, "Unknown protocol type")
330 CND(ESHUTDOWN
, "Cannot send once shutdown")
332 #ifndef ESOCKTNOSUPPORT
333 #define ESOCKTNOSUPPORT -1
335 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
340 CND(ETIMEDOUT
, "Connection timed out")
343 #define ETOOMANYREFS -1
345 CND(ETOOMANYREFS
, "Too many references")
348 #define EWOULDBLOCK -1
350 CND(EWOULDBLOCK
, "Operation would block")
352 TXT(" -----------------")
353 TXT(" -- Host errors --")
354 TXT(" -----------------")
357 #ifndef HOST_NOT_FOUND
358 #define HOST_NOT_FOUND -1
360 CND(HOST_NOT_FOUND
, "Unknown host")
365 CND(TRY_AGAIN
, "Host name lookup failure")
370 CND(NO_DATA
, "No data record for name")
373 #define NO_RECOVERY -1
375 CND(NO_RECOVERY
, "Non recoverable errors")
377 TXT(" -------------------")
378 TXT(" -- Control flags --")
379 TXT(" -------------------")
385 CND(FIONBIO
, "Set/clear non-blocking io")
390 CND(FIONREAD
, "How many bytes to read")
392 TXT(" --------------------")
393 TXT(" -- Shutdown modes --")
394 TXT(" --------------------")
400 CND(SHUT_RD
, "No more recv")
405 CND(SHUT_WR
, "No more send")
410 CND(SHUT_RDWR
, "No more recv/send")
412 TXT(" ---------------------")
413 TXT(" -- Protocol levels --")
414 TXT(" ---------------------")
418 #define SOL_SOCKET -1
420 CND(SOL_SOCKET
, "Options for socket level")
423 #define IPPROTO_IP -1
425 CND(IPPROTO_IP
, "Dummy protocol for IP")
428 #define IPPROTO_UDP -1
430 CND(IPPROTO_UDP
, "UDP")
433 #define IPPROTO_TCP -1
435 CND(IPPROTO_TCP
, "TCP")
437 TXT(" -------------------")
438 TXT(" -- Request flags --")
439 TXT(" -------------------")
445 CND(MSG_OOB
, "Process out-of-band data")
450 CND(MSG_PEEK
, "Peek at incoming data")
455 CND(MSG_EOR
, "Send end of record")
458 #define MSG_WAITALL -1
460 CND(MSG_WAITALL
, "Wait for full reception")
463 #define MSG_NOSIGNAL -1
465 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
468 # define MSG_Forced_Flags "MSG_NOSIGNAL"
470 # define MSG_Forced_Flags "0"
472 CN_(MSG_Forced_Flags
, "")
473 TXT(" -- Flags set on all send(2) calls")
476 TXT(" --------------------")
477 TXT(" -- Socket options --")
478 TXT(" --------------------")
482 #define TCP_NODELAY -1
484 CND(TCP_NODELAY
, "Do not coalesce packets")
487 #define SO_REUSEADDR -1
489 CND(SO_REUSEADDR
, "Bind reuse local address")
492 #define SO_KEEPALIVE -1
494 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
499 CND(SO_LINGER
, "Defer close to flush data")
502 #define SO_BROADCAST -1
504 CND(SO_BROADCAST
, "Can send broadcast msgs")
509 CND(SO_SNDBUF
, "Set/get send buffer size")
514 CND(SO_RCVBUF
, "Set/get recv buffer size")
517 #define SO_SNDTIMEO -1
519 CND(SO_SNDTIMEO
, "Emission timeout")
522 #define SO_RCVTIMEO -1
524 CND(SO_RCVTIMEO
, "Reception timeout")
529 CND(SO_ERROR
, "Get/clear error status")
531 #ifndef IP_MULTICAST_IF
532 #define IP_MULTICAST_IF -1
534 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
536 #ifndef IP_MULTICAST_TTL
537 #define IP_MULTICAST_TTL -1
539 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
541 #ifndef IP_MULTICAST_LOOP
542 #define IP_MULTICAST_LOOP -1
544 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
546 #ifndef IP_ADD_MEMBERSHIP
547 #define IP_ADD_MEMBERSHIP -1
549 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
551 #ifndef IP_DROP_MEMBERSHIP
552 #define IP_DROP_MEMBERSHIP -1
554 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
557 TXT(" -------------------")
558 TXT(" -- System limits --")
559 TXT(" -------------------")
563 #define IOV_MAX INT_MAX
565 CND(IOV_MAX
, "Maximum writev iovcnt")
568 TXT("end GNAT.Sockets.Constants;")
576 int text_max
= 0, value_max
= 0, l
;
579 #define UPD_MAX(x) do { \
581 if (l > x ## _max) x ## _max = l; \
584 for (p
= first
; p
!= NULL
; p
= p
->next
) {
585 if (p
->value
!= NULL
) {
590 sprintf (fmt
, " %%-%ds : constant := %%%ds;%%s%%s\n",
591 text_max
, value_max
);
593 for (p
= first
; p
!= NULL
; p
= p
->next
) {
594 if (p
->value
== NULL
) {
595 printf ("%s\n", p
->text
);
597 char *comment_sep
= (strlen (p
->comment
) > 0)
599 printf (fmt
, p
->text
, p
->value
, comment_sep
, p
->comment
);
605 f_itoa (char *fmt
, int n
) {
607 sprintf (buf
, fmt
, n
);
608 ret
= malloc (strlen (buf
) + 1);
615 add_line (char *_text
, char *_value
, char *_comment
) {
616 struct line
*l
= (struct line
*) malloc (sizeof (struct line
));
619 l
->comment
= _comment
;