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 */
28 * To build using DEC C:
30 * CC/DEFINE="TARGET=""OpenVMS""" gen-soccon
34 * Note: OpenVMS versions older than 8.3 provide an incorrect value in
35 * the DEC C header files for MSG_WAITALL. To generate the VMS version
36 * of g-soccon.ads, gen-soccon should be run on an 8.3 or later machine.
40 # error Please define TARGET
61 struct line *first = NULL, *last = NULL;
63 #define TXT(_text) add_line(_text, NULL, NULL);
69 #define itoad(n) f_itoa ("%d", (n))
70 #define itoax(n) f_itoa ("16#%08x#", (n))
72 #define CND(name,comment) add_line(#name, itoad (name), comment);
73 /* Constant (decimal) */
75 #define CNX(name,comment) add_line(#name, itoax (name), comment);
76 /* Constant (hexadecimal) */
78 #define CN_(name,comment) add_line(#name, name, comment);
79 /* Constant (generic) */
81 #define STR(p) STR1(p)
85 /* Generate output spec */
87 char *f_itoa (char *, int);
90 void add_line (char *, char*, char*);
93 unsigned int _CRT_fmode = _O_BINARY;
99 TXT("------------------------------------------------------------------------------")
101 TXT("-- GNAT COMPILER COMPONENTS --")
103 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
107 TXT("-- Copyright (C) 2000-2007, Free Software Foundation, Inc. --")
109 TXT("-- GNAT is free software; you can redistribute it and/or modify it under --")
110 TXT("-- terms of the GNU General Public License as published by the Free Soft- --")
111 TXT("-- ware Foundation; either version 2, or (at your option) any later ver- --")
112 TXT("-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --")
113 TXT("-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --")
114 TXT("-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --")
115 TXT("-- for more details. You should have received a copy of the GNU General --")
116 TXT("-- Public License distributed with GNAT; see file COPYING. If not, write --")
117 TXT("-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --")
118 TXT("-- Boston, MA 02110-1301, USA. --")
120 TXT("-- As a special exception, if other files instantiate generics from this --")
121 TXT("-- unit, or you link this unit with other files to produce an executable, --")
122 TXT("-- this unit does not by itself cause the resulting executable to be --")
123 TXT("-- covered by the GNU General Public License. This exception does not --")
124 TXT("-- however invalidate any other reasons why the executable file might be --")
125 TXT("-- covered by the GNU Public License. --")
127 TXT("-- GNAT was originally developed by the GNAT team at New York University. --")
128 TXT("-- Extensive contributions were provided by Ada Core Technologies Inc. --")
130 TXT("------------------------------------------------------------------------------")
132 TXT("-- This package provides target dependent definitions of constant for use")
133 TXT("-- by the GNAT.Sockets package (g-socket.ads). This package should not be")
134 TXT("-- directly with'ed by an applications program.")
136 TXT("-- This is the version for " TARGET)
137 TXT("-- This file is generated automatically, do not modify it by hand! Instead,")
138 TXT("-- make changes to gen-soccon.c and re-run it on each target.")
140 TXT("package GNAT.Sockets.Constants is")
142 TXT(" --------------")
143 TXT(" -- Families --")
144 TXT(" --------------")
150 CND(AF_INET, "IPv4 address family")
155 CND(AF_INET6, "IPv6 address family")
163 #define SOCK_STREAM -1
165 CND(SOCK_STREAM, "Stream socket")
168 #define SOCK_DGRAM -1
170 CND(SOCK_DGRAM, "Datagram socket")
172 TXT(" -------------------")
173 TXT(" -- Socket errors --")
174 TXT(" -------------------")
180 CND(EACCES, "Permission denied")
183 #define EADDRINUSE -1
185 CND(EADDRINUSE, "Address already in use")
187 #ifndef EADDRNOTAVAIL
188 #define EADDRNOTAVAIL -1
190 CND(EADDRNOTAVAIL, "Cannot assign address")
193 #define EAFNOSUPPORT -1
195 CND(EAFNOSUPPORT, "Addr family not supported")
200 CND(EALREADY, "Operation in progress")
205 CND(EBADF, "Bad file descriptor")
208 #define ECONNABORTED -1
210 CND(ECONNABORTED, "Connection aborted")
213 #define ECONNREFUSED -1
215 CND(ECONNREFUSED, "Connection refused")
218 #define ECONNRESET -1
220 CND(ECONNRESET, "Connection reset by peer")
223 #define EDESTADDRREQ -1
225 CND(EDESTADDRREQ, "Destination addr required")
230 CND(EFAULT, "Bad address")
235 CND(EHOSTDOWN, "Host is down")
238 #define EHOSTUNREACH -1
240 CND(EHOSTUNREACH, "No route to host")
243 #define EINPROGRESS -1
245 CND(EINPROGRESS, "Operation now in progress")
250 CND(EINTR, "Interrupted system call")
255 CND(EINVAL, "Invalid argument")
260 CND(EIO, "Input output error")
265 CND(EISCONN, "Socket already connected")
270 CND(ELOOP, "Too many symbolic lynks")
275 CND(EMFILE, "Too many open files")
280 CND(EMSGSIZE, "Message too long")
283 #define ENAMETOOLONG -1
285 CND(ENAMETOOLONG, "Name too long")
290 CND(ENETDOWN, "Network is down")
295 CND(ENETRESET, "Disconn. on network reset")
298 #define ENETUNREACH -1
300 CND(ENETUNREACH, "Network is unreachable")
305 CND(ENOBUFS, "No buffer space available")
308 #define ENOPROTOOPT -1
310 CND(ENOPROTOOPT, "Protocol not available")
315 CND(ENOTCONN, "Socket not connected")
320 CND(ENOTSOCK, "Operation on non socket")
323 #define EOPNOTSUPP -1
325 CND(EOPNOTSUPP, "Operation not supported")
328 #define EPFNOSUPPORT -1
330 CND(EPFNOSUPPORT, "Unknown protocol family")
332 #ifndef EPROTONOSUPPORT
333 #define EPROTONOSUPPORT -1
335 CND(EPROTONOSUPPORT, "Unknown protocol")
338 #define EPROTOTYPE -1
340 CND(EPROTOTYPE, "Unknown protocol type")
345 CND(ESHUTDOWN, "Cannot send once shutdown")
347 #ifndef ESOCKTNOSUPPORT
348 #define ESOCKTNOSUPPORT -1
350 CND(ESOCKTNOSUPPORT, "Socket type not supported")
355 CND(ETIMEDOUT, "Connection timed out")
358 #define ETOOMANYREFS -1
360 CND(ETOOMANYREFS, "Too many references")
363 #define EWOULDBLOCK -1
365 CND(EWOULDBLOCK, "Operation would block")
367 TXT(" -----------------")
368 TXT(" -- Host errors --")
369 TXT(" -----------------")
372 #ifndef HOST_NOT_FOUND
373 #define HOST_NOT_FOUND -1
375 CND(HOST_NOT_FOUND, "Unknown host")
380 CND(TRY_AGAIN, "Host name lookup failure")
385 CND(NO_DATA, "No data record for name")
388 #define NO_RECOVERY -1
390 CND(NO_RECOVERY, "Non recoverable errors")
392 TXT(" -------------------")
393 TXT(" -- Control flags --")
394 TXT(" -------------------")
400 CND(FIONBIO, "Set/clear non-blocking io")
405 CND(FIONREAD, "How many bytes to read")
407 TXT(" --------------------")
408 TXT(" -- Shutdown modes --")
409 TXT(" --------------------")
415 CND(SHUT_RD, "No more recv")
420 CND(SHUT_WR, "No more send")
425 CND(SHUT_RDWR, "No more recv/send")
427 TXT(" ---------------------")
428 TXT(" -- Protocol levels --")
429 TXT(" ---------------------")
433 #define SOL_SOCKET -1
435 CND(SOL_SOCKET, "Options for socket level")
438 #define IPPROTO_IP -1
440 CND(IPPROTO_IP, "Dummy protocol for IP")
443 #define IPPROTO_UDP -1
445 CND(IPPROTO_UDP, "UDP")
448 #define IPPROTO_TCP -1
450 CND(IPPROTO_TCP, "TCP")
452 TXT(" -------------------")
453 TXT(" -- Request flags --")
454 TXT(" -------------------")
460 CND(MSG_OOB, "Process out-of-band data")
465 CND(MSG_PEEK, "Peek at incoming data")
470 CND(MSG_EOR, "Send end of record")
473 #define MSG_WAITALL -1
475 CND(MSG_WAITALL, "Wait for full reception")
478 #define MSG_NOSIGNAL -1
480 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
483 # define MSG_Forced_Flags "MSG_NOSIGNAL"
485 # define MSG_Forced_Flags "0"
487 CN_(MSG_Forced_Flags, "")
488 TXT(" -- Flags set on all send(2) calls")
491 TXT(" --------------------")
492 TXT(" -- Socket options --")
493 TXT(" --------------------")
497 #define TCP_NODELAY -1
499 CND(TCP_NODELAY, "Do not coalesce packets")
502 #define SO_REUSEADDR -1
504 CND(SO_REUSEADDR, "Bind reuse local address")
507 #define SO_REUSEPORT -1
509 CND(SO_REUSEPORT, "Bind reuse port number")
512 #define SO_KEEPALIVE -1
514 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
519 CND(SO_LINGER, "Defer close to flush data")
522 #define SO_BROADCAST -1
524 CND(SO_BROADCAST, "Can send broadcast msgs")
529 CND(SO_SNDBUF, "Set/get send buffer size")
534 CND(SO_RCVBUF, "Set/get recv buffer size")
537 #define SO_SNDTIMEO -1
539 CND(SO_SNDTIMEO, "Emission timeout")
542 #define SO_RCVTIMEO -1
544 CND(SO_RCVTIMEO, "Reception timeout")
549 CND(SO_ERROR, "Get/clear error status")
551 #ifndef IP_MULTICAST_IF
552 #define IP_MULTICAST_IF -1
554 CND(IP_MULTICAST_IF, "Set/get mcast interface")
556 #ifndef IP_MULTICAST_TTL
557 #define IP_MULTICAST_TTL -1
559 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
561 #ifndef IP_MULTICAST_LOOP
562 #define IP_MULTICAST_LOOP -1
564 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
566 #ifndef IP_ADD_MEMBERSHIP
567 #define IP_ADD_MEMBERSHIP -1
569 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
571 #ifndef IP_DROP_MEMBERSHIP
572 #define IP_DROP_MEMBERSHIP -1
574 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
577 TXT(" -------------------")
578 TXT(" -- System limits --")
579 TXT(" -------------------")
583 #define IOV_MAX INT_MAX
585 CND(IOV_MAX, "Maximum writev iovcnt")
588 TXT(" ----------------------")
589 TXT(" -- Type definitions --")
590 TXT(" ----------------------")
595 TXT(" -- Sizes (in bytes) of the components of struct timeval")
597 #define SIZEOF_tv_sec (sizeof tv.tv_sec)
598 CND(SIZEOF_tv_sec, "tv_sec")
599 #define SIZEOF_tv_usec (sizeof tv.tv_usec)
600 CND(SIZEOF_tv_usec, "tv_usec")
604 TXT(" ----------------------------------------")
605 TXT(" -- Properties of supported interfaces --")
606 TXT(" ----------------------------------------")
609 CND(Need_Netdb_Buffer, "Need buffer for Netdb ops")
613 TXT(" --------------------------------")
614 TXT(" -- VxWorks-specific constants --")
615 TXT(" --------------------------------")
617 TXT(" -- These constants may be used only within the VxWorks version of")
618 TXT(" -- GNAT.Sockets.Thin.")
621 CND(OK, "VxWorks generic success")
622 CND(ERROR, "VxWorks generic error")
627 TXT(" ------------------------------")
628 TXT(" -- MinGW-specific constants --")
629 TXT(" ------------------------------")
631 TXT(" -- These constants may be used only within the MinGW version of")
632 TXT(" -- GNAT.Sockets.Thin.")
635 CND(WSASYSNOTREADY, "System not ready")
636 CND(WSAVERNOTSUPPORTED, "Version not supported")
637 CND(WSANOTINITIALISED, "Winsock not intialized")
638 CND(WSAEDISCON, "Disconnected")
643 TXT(" ----------------------")
644 TXT(" -- Additional flags --")
645 TXT(" ----------------------")
647 TXT(" Thread_Blocking_IO : constant Boolean := True;")
648 TXT(" -- Set False for contexts where socket i/o are process blocking")
651 TXT("end GNAT.Sockets.Constants;")
659 int text_max = 0, value_max = 0, l;
662 #define UPD_MAX(x) do { \
664 if (l > x ## _max) x ## _max = l; \
667 for (p = first; p != NULL; p = p->next) {
668 if (p->value != NULL) {
673 sprintf (fmt, " %%-%ds : constant := %%%ds;%%s%%s\n",
674 text_max, value_max);
676 for (p = first; p != NULL; p = p->next) {
677 if (p->value == NULL) {
678 printf ("%s\n", p->text);
680 char *comment_sep = (strlen (p->comment) > 0)
682 printf (fmt, p->text, p->value, comment_sep, p->comment);
688 f_itoa (char *fmt, int n) {
690 sprintf (buf, fmt, n);
691 ret = malloc (strlen (buf) + 1);
698 add_line (char *_text, char *_value, char *_comment) {
699 struct line *l = (struct line *) malloc (sizeof (struct line));
703 l->comment = _comment;