1 /****************************************************************************
3 * GNAT SYSTEM UTILITIES *
5 * G E N - S O C C O N *
7 * Copyright (C) 2004-2007, 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
55 struct line
*first
= NULL
, *last
= NULL
;
57 #define TXT(_text) add_line(_text, NULL, NULL);
63 #define itoad(n) f_itoa ("%d", (n))
64 #define itoax(n) f_itoa ("16#%08x#", (n))
66 #define CND(name,comment) add_line(#name, itoad (name), comment);
67 /* Constant (decimal) */
69 #define CNX(name,comment) add_line(#name, itoax (name), comment);
70 /* Constant (hexadecimal) */
72 #define CN_(name,comment) add_line(#name, name, comment);
73 /* Constant (generic) */
75 #define STR(p) STR1(p)
79 /* Generate output spec */
81 char *f_itoa (char *, int);
84 void add_line (char *, char*, char*);
87 unsigned int _CRT_fmode
= _O_BINARY
;
93 TXT("------------------------------------------------------------------------------")
95 TXT("-- GNAT COMPILER COMPONENTS --")
97 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
101 TXT("-- Copyright (C) 2000-2007, Free Software Foundation, Inc. --")
103 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
104 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
105 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
106 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
107 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
108 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
109 TXT("-- for more details. You should have received a copy of the GNU General --")
110 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
111 TXT("-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --")
112 TXT("-- Boston, MA 02110-1301, USA. --")
114 TXT("-- As a special exception, if other files instantiate generics from this --")
115 TXT("-- unit, or you link this unit with other files to produce an executable, --")
116 TXT("-- this unit does not by itself cause the resulting executable to be --")
117 TXT("-- covered by the GNU General Public License. This exception does not --")
118 TXT("-- however invalidate any other reasons why the executable file might be --")
119 TXT("-- covered by the GNU Public License. --")
121 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
122 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
124 TXT("------------------------------------------------------------------------------")
126 TXT("-- This package provides target dependent definitions of constant for use")
127 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
128 TXT("-- directly with'ed by an applications program.")
130 TXT("-- This is the version for " TARGET
)
131 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
132 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
134 TXT("package GNAT.Sockets.Constants is")
136 TXT(" --------------")
137 TXT(" -- Families --")
138 TXT(" --------------")
144 CND(AF_INET
, "IPv4 address family")
149 CND(AF_INET6
, "IPv6 address family")
157 #define SOCK_STREAM -1
159 CND(SOCK_STREAM
, "Stream socket")
162 #define SOCK_DGRAM -1
164 CND(SOCK_DGRAM
, "Datagram socket")
166 TXT(" -------------------")
167 TXT(" -- Socket errors --")
168 TXT(" -------------------")
174 CND(EACCES
, "Permission denied")
177 #define EADDRINUSE -1
179 CND(EADDRINUSE
, "Address already in use")
181 #ifndef EADDRNOTAVAIL
182 #define EADDRNOTAVAIL -1
184 CND(EADDRNOTAVAIL
, "Cannot assign address")
187 #define EAFNOSUPPORT -1
189 CND(EAFNOSUPPORT
, "Addr family not supported")
194 CND(EALREADY
, "Operation in progress")
199 CND(EBADF
, "Bad file descriptor")
202 #define ECONNABORTED -1
204 CND(ECONNABORTED
, "Connection aborted")
207 #define ECONNREFUSED -1
209 CND(ECONNREFUSED
, "Connection refused")
212 #define ECONNRESET -1
214 CND(ECONNRESET
, "Connection reset by peer")
217 #define EDESTADDRREQ -1
219 CND(EDESTADDRREQ
, "Destination addr required")
224 CND(EFAULT
, "Bad address")
229 CND(EHOSTDOWN
, "Host is down")
232 #define EHOSTUNREACH -1
234 CND(EHOSTUNREACH
, "No route to host")
237 #define EINPROGRESS -1
239 CND(EINPROGRESS
, "Operation now in progress")
244 CND(EINTR
, "Interrupted system call")
249 CND(EINVAL
, "Invalid argument")
254 CND(EIO
, "Input output error")
259 CND(EISCONN
, "Socket already connected")
264 CND(ELOOP
, "Too many symbolic lynks")
269 CND(EMFILE
, "Too many open files")
274 CND(EMSGSIZE
, "Message too long")
277 #define ENAMETOOLONG -1
279 CND(ENAMETOOLONG
, "Name too long")
284 CND(ENETDOWN
, "Network is down")
289 CND(ENETRESET
, "Disconn. on network reset")
292 #define ENETUNREACH -1
294 CND(ENETUNREACH
, "Network is unreachable")
299 CND(ENOBUFS
, "No buffer space available")
302 #define ENOPROTOOPT -1
304 CND(ENOPROTOOPT
, "Protocol not available")
309 CND(ENOTCONN
, "Socket not connected")
314 CND(ENOTSOCK
, "Operation on non socket")
317 #define EOPNOTSUPP -1
319 CND(EOPNOTSUPP
, "Operation not supported")
322 #define EPFNOSUPPORT -1
324 CND(EPFNOSUPPORT
, "Unknown protocol family")
326 #ifndef EPROTONOSUPPORT
327 #define EPROTONOSUPPORT -1
329 CND(EPROTONOSUPPORT
, "Unknown protocol")
332 #define EPROTOTYPE -1
334 CND(EPROTOTYPE
, "Unknown protocol type")
339 CND(ESHUTDOWN
, "Cannot send once shutdown")
341 #ifndef ESOCKTNOSUPPORT
342 #define ESOCKTNOSUPPORT -1
344 CND(ESOCKTNOSUPPORT
, "Socket type not supported")
349 CND(ETIMEDOUT
, "Connection timed out")
352 #define ETOOMANYREFS -1
354 CND(ETOOMANYREFS
, "Too many references")
357 #define EWOULDBLOCK -1
359 CND(EWOULDBLOCK
, "Operation would block")
361 TXT(" -----------------")
362 TXT(" -- Host errors --")
363 TXT(" -----------------")
366 #ifndef HOST_NOT_FOUND
367 #define HOST_NOT_FOUND -1
369 CND(HOST_NOT_FOUND
, "Unknown host")
374 CND(TRY_AGAIN
, "Host name lookup failure")
379 CND(NO_DATA
, "No data record for name")
382 #define NO_RECOVERY -1
384 CND(NO_RECOVERY
, "Non recoverable errors")
386 TXT(" -------------------")
387 TXT(" -- Control flags --")
388 TXT(" -------------------")
394 CND(FIONBIO
, "Set/clear non-blocking io")
399 CND(FIONREAD
, "How many bytes to read")
401 TXT(" --------------------")
402 TXT(" -- Shutdown modes --")
403 TXT(" --------------------")
409 CND(SHUT_RD
, "No more recv")
414 CND(SHUT_WR
, "No more send")
419 CND(SHUT_RDWR
, "No more recv/send")
421 TXT(" ---------------------")
422 TXT(" -- Protocol levels --")
423 TXT(" ---------------------")
427 #define SOL_SOCKET -1
429 CND(SOL_SOCKET
, "Options for socket level")
432 #define IPPROTO_IP -1
434 CND(IPPROTO_IP
, "Dummy protocol for IP")
437 #define IPPROTO_UDP -1
439 CND(IPPROTO_UDP
, "UDP")
442 #define IPPROTO_TCP -1
444 CND(IPPROTO_TCP
, "TCP")
446 TXT(" -------------------")
447 TXT(" -- Request flags --")
448 TXT(" -------------------")
454 CND(MSG_OOB
, "Process out-of-band data")
459 CND(MSG_PEEK
, "Peek at incoming data")
464 CND(MSG_EOR
, "Send end of record")
467 #define MSG_WAITALL -1
469 CND(MSG_WAITALL
, "Wait for full reception")
472 #define MSG_NOSIGNAL -1
474 CND(MSG_NOSIGNAL
, "No SIGPIPE on send")
477 # define MSG_Forced_Flags "MSG_NOSIGNAL"
479 # define MSG_Forced_Flags "0"
481 CN_(MSG_Forced_Flags
, "")
482 TXT(" -- Flags set on all send(2) calls")
485 TXT(" --------------------")
486 TXT(" -- Socket options --")
487 TXT(" --------------------")
491 #define TCP_NODELAY -1
493 CND(TCP_NODELAY
, "Do not coalesce packets")
496 #define SO_REUSEADDR -1
498 CND(SO_REUSEADDR
, "Bind reuse local address")
501 #define SO_REUSEPORT -1
503 CND(SO_REUSEPORT
, "Bind reuse port number")
506 #define SO_KEEPALIVE -1
508 CND(SO_KEEPALIVE
, "Enable keep-alive msgs")
513 CND(SO_LINGER
, "Defer close to flush data")
516 #define SO_BROADCAST -1
518 CND(SO_BROADCAST
, "Can send broadcast msgs")
523 CND(SO_SNDBUF
, "Set/get send buffer size")
528 CND(SO_RCVBUF
, "Set/get recv buffer size")
531 #define SO_SNDTIMEO -1
533 CND(SO_SNDTIMEO
, "Emission timeout")
536 #define SO_RCVTIMEO -1
538 CND(SO_RCVTIMEO
, "Reception timeout")
543 CND(SO_ERROR
, "Get/clear error status")
545 #ifndef IP_MULTICAST_IF
546 #define IP_MULTICAST_IF -1
548 CND(IP_MULTICAST_IF
, "Set/get mcast interface")
550 #ifndef IP_MULTICAST_TTL
551 #define IP_MULTICAST_TTL -1
553 CND(IP_MULTICAST_TTL
, "Set/get multicast TTL")
555 #ifndef IP_MULTICAST_LOOP
556 #define IP_MULTICAST_LOOP -1
558 CND(IP_MULTICAST_LOOP
, "Set/get mcast loopback")
560 #ifndef IP_ADD_MEMBERSHIP
561 #define IP_ADD_MEMBERSHIP -1
563 CND(IP_ADD_MEMBERSHIP
, "Join a multicast group")
565 #ifndef IP_DROP_MEMBERSHIP
566 #define IP_DROP_MEMBERSHIP -1
568 CND(IP_DROP_MEMBERSHIP
, "Leave a multicast group")
571 TXT(" -------------------")
572 TXT(" -- System limits --")
573 TXT(" -------------------")
577 #define IOV_MAX INT_MAX
579 CND(IOV_MAX
, "Maximum writev iovcnt")
582 TXT(" ----------------------")
583 TXT(" -- Type definitions --")
584 TXT(" ----------------------")
589 TXT(" -- Sizes (in bytes) of the components of struct timeval")
591 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
592 CND(SIZEOF_tv_sec
, "tv_sec")
593 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
594 CND(SIZEOF_tv_usec
, "tv_usec")
598 TXT(" ----------------------------------------")
599 TXT(" -- Properties of supported interfaces --")
600 TXT(" ----------------------------------------")
603 CND(Need_Netdb_Buffer
, "Need buffer for Netdb ops")
607 TXT(" --------------------------------")
608 TXT(" -- VxWorks-specific constants --")
609 TXT(" --------------------------------")
611 TXT(" -- These constants may be used only within the VxWorks version of")
612 TXT(" -- GNAT.Sockets.Thin.")
615 CND(OK
, "VxWorks generic success")
616 CND(ERROR
, "VxWorks generic error")
621 TXT(" ------------------------------")
622 TXT(" -- MinGW-specific constants --")
623 TXT(" ------------------------------")
625 TXT(" -- These constants may be used only within the MinGW version of")
626 TXT(" -- GNAT.Sockets.Thin.")
629 CND(WSASYSNOTREADY
, "System not ready")
630 CND(WSAVERNOTSUPPORTED
, "Version not supported")
631 CND(WSANOTINITIALISED
, "Winsock not intialized")
632 CND(WSAEDISCON
, "Disconnected")
637 TXT(" ----------------------")
638 TXT(" -- Additional flags --")
639 TXT(" ----------------------")
641 TXT(" Thread_Blocking_IO : constant Boolean := True;")
642 TXT(" -- Set False for contexts where socket i/o are process blocking")
645 TXT("end GNAT.Sockets.Constants;")
653 int text_max
= 0, value_max
= 0, l
;
656 #define UPD_MAX(x) do { \
658 if (l > x ## _max) x ## _max = l; \
661 for (p
= first
; p
!= NULL
; p
= p
->next
) {
662 if (p
->value
!= NULL
) {
667 sprintf (fmt
, " %%-%ds : constant := %%%ds;%%s%%s\n",
668 text_max
, value_max
);
670 for (p
= first
; p
!= NULL
; p
= p
->next
) {
671 if (p
->value
== NULL
) {
672 printf ("%s\n", p
->text
);
674 char *comment_sep
= (strlen (p
->comment
) > 0)
676 printf (fmt
, p
->text
, p
->value
, comment_sep
, p
->comment
);
682 f_itoa (char *fmt
, int n
) {
684 sprintf (buf
, fmt
, n
);
685 ret
= malloc (strlen (buf
) + 1);
692 add_line (char *_text
, char *_value
, char *_comment
) {
693 struct line
*l
= (struct line
*) malloc (sizeof (struct line
));
697 l
->comment
= _comment
;