objc/
[official-gcc.git] / gcc / ada / gen-soccon.c
blobb1728df161fbc9997b31acbbf44db211d1c82fed
1 /*****************************************************************************
2 ** **
3 ** GNAT SYSTEM UTILITIES **
4 ** **
5 ** G E N - S O C C O N **
6 ** **
7 ** Copyright (C) 2004-2005 Free Software Foundation, Inc. **
8 ** **
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. **
19 ** **
20 ** GNAT was originally developed by the GNAT team at New York University. **
21 ** Extensive contributions were provided by Ada Core Technologies Inc. **
22 ** **
23 ******************************************************************************/
25 /* This program generates g-soccon.ads */
27 #include <stdio.h>
28 #include <string.h>
30 #include "gsocket.h"
32 #ifdef __MINGW32__
33 #include <winsock2.h>
34 #else
35 #include <netinet/in.h>
36 #include <netinet/tcp.h>
37 #include <sys/ioctl.h>
38 #include <netdb.h>
39 #endif
41 struct line {
42 char *text;
43 char *value;
44 char *comment;
45 struct line *next;
48 struct line *first = NULL, *last = NULL;
50 #define TXT(_text) add_line(_text, NULL, NULL);
51 /* Plain text */
53 #define _NL TXT("")
54 /* Empty line */
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) */
68 void output (void);
69 /* Generate output spec */
71 char *f_itoa (char *, int);
72 /* int to string */
74 void add_line (char *, char*, char*);
76 int
77 main (void) {
79 TXT("------------------------------------------------------------------------------")
80 TXT("-- --")
81 TXT("-- GNAT COMPILER COMPONENTS --")
82 TXT("-- --")
83 TXT("-- G N A T . S O C K E T S . C O N S T A N T S --")
84 TXT("-- --")
85 TXT("-- S p e c --")
86 TXT("-- --")
87 TXT("-- Copyright (C) 2000-2005 Free Software Foundation, Inc. --")
88 TXT("-- --")
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. --")
99 TXT("-- --")
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. --")
106 TXT("-- --")
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. --")
109 TXT("-- --")
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(" --------------")
127 #ifndef AF_INET
128 #define AF_INET -1
129 #endif
130 CND(AF_INET, "IPv4 address family")
132 #ifndef AF_INET6
133 #define AF_INET6 -1
134 #endif
135 CND(AF_INET6, "IPv6 address family")
137 TXT(" -----------")
138 TXT(" -- Modes --")
139 TXT(" -----------")
142 #ifndef SOCK_STREAM
143 #define SOCK_STREAM -1
144 #endif
145 CND(SOCK_STREAM, "Stream socket")
147 #ifndef SOCK_DGRAM
148 #define SOCK_DGRAM -1
149 #endif
150 CND(SOCK_DGRAM, "Datagram socket")
152 TXT(" -------------------")
153 TXT(" -- Socket errors --")
154 TXT(" -------------------")
157 #ifndef EACCES
158 #define EACCES -1
159 #endif
160 CND(EACCES, "Permission denied")
162 #ifndef EADDRINUSE
163 #define EADDRINUSE -1
164 #endif
165 CND(EADDRINUSE, "Address already in use")
167 #ifndef EADDRNOTAVAIL
168 #define EADDRNOTAVAIL -1
169 #endif
170 CND(EADDRNOTAVAIL, "Cannot assign address")
172 #ifndef EAFNOSUPPORT
173 #define EAFNOSUPPORT -1
174 #endif
175 CND(EAFNOSUPPORT, "Addr family not supported")
177 #ifndef EALREADY
178 #define EALREADY -1
179 #endif
180 CND(EALREADY, "Operation in progress")
182 #ifndef EBADF
183 #define EBADF -1
184 #endif
185 CND(EBADF, "Bad file descriptor")
187 #ifndef ECONNABORTED
188 #define ECONNABORTED -1
189 #endif
190 CND(ECONNABORTED, "Connection aborted")
192 #ifndef ECONNREFUSED
193 #define ECONNREFUSED -1
194 #endif
195 CND(ECONNREFUSED, "Connection refused")
197 #ifndef ECONNRESET
198 #define ECONNRESET -1
199 #endif
200 CND(ECONNRESET, "Connection reset by peer")
202 #ifndef EDESTADDRREQ
203 #define EDESTADDRREQ -1
204 #endif
205 CND(EDESTADDRREQ, "Destination addr required")
207 #ifndef EFAULT
208 #define EFAULT -1
209 #endif
210 CND(EFAULT, "Bad address")
212 #ifndef EHOSTDOWN
213 #define EHOSTDOWN -1
214 #endif
215 CND(EHOSTDOWN, "Host is down")
217 #ifndef EHOSTUNREACH
218 #define EHOSTUNREACH -1
219 #endif
220 CND(EHOSTUNREACH, "No route to host")
222 #ifndef EINPROGRESS
223 #define EINPROGRESS -1
224 #endif
225 CND(EINPROGRESS, "Operation now in progress")
227 #ifndef EINTR
228 #define EINTR -1
229 #endif
230 CND(EINTR, "Interrupted system call")
232 #ifndef EINVAL
233 #define EINVAL -1
234 #endif
235 CND(EINVAL, "Invalid argument")
237 #ifndef EIO
238 #define EIO -1
239 #endif
240 CND(EIO, "Input output error")
242 #ifndef EISCONN
243 #define EISCONN -1
244 #endif
245 CND(EISCONN, "Socket already connected")
247 #ifndef ELOOP
248 #define ELOOP -1
249 #endif
250 CND(ELOOP, "Too many symbolic lynks")
252 #ifndef EMFILE
253 #define EMFILE -1
254 #endif
255 CND(EMFILE, "Too many open files")
257 #ifndef EMSGSIZE
258 #define EMSGSIZE -1
259 #endif
260 CND(EMSGSIZE, "Message too long")
262 #ifndef ENAMETOOLONG
263 #define ENAMETOOLONG -1
264 #endif
265 CND(ENAMETOOLONG, "Name too long")
267 #ifndef ENETDOWN
268 #define ENETDOWN -1
269 #endif
270 CND(ENETDOWN, "Network is down")
272 #ifndef ENETRESET
273 #define ENETRESET -1
274 #endif
275 CND(ENETRESET, "Disconn. on network reset")
277 #ifndef ENETUNREACH
278 #define ENETUNREACH -1
279 #endif
280 CND(ENETUNREACH, "Network is unreachable")
282 #ifndef ENOBUFS
283 #define ENOBUFS -1
284 #endif
285 CND(ENOBUFS, "No buffer space available")
287 #ifndef ENOPROTOOPT
288 #define ENOPROTOOPT -1
289 #endif
290 CND(ENOPROTOOPT, "Protocol not available")
292 #ifndef ENOTCONN
293 #define ENOTCONN -1
294 #endif
295 CND(ENOTCONN, "Socket not connected")
297 #ifndef ENOTSOCK
298 #define ENOTSOCK -1
299 #endif
300 CND(ENOTSOCK, "Operation on non socket")
302 #ifndef EOPNOTSUPP
303 #define EOPNOTSUPP -1
304 #endif
305 CND(EOPNOTSUPP, "Operation not supported")
307 #ifndef EPFNOSUPPORT
308 #define EPFNOSUPPORT -1
309 #endif
310 CND(EPFNOSUPPORT, "Unknown protocol family")
312 #ifndef EPROTONOSUPPORT
313 #define EPROTONOSUPPORT -1
314 #endif
315 CND(EPROTONOSUPPORT, "Unknown protocol")
317 #ifndef EPROTOTYPE
318 #define EPROTOTYPE -1
319 #endif
320 CND(EPROTOTYPE, "Unknown protocol type")
322 #ifndef ESHUTDOWN
323 #define ESHUTDOWN -1
324 #endif
325 CND(ESHUTDOWN, "Cannot send once shutdown")
327 #ifndef ESOCKTNOSUPPORT
328 #define ESOCKTNOSUPPORT -1
329 #endif
330 CND(ESOCKTNOSUPPORT, "Socket type not supported")
332 #ifndef ETIMEDOUT
333 #define ETIMEDOUT -1
334 #endif
335 CND(ETIMEDOUT, "Connection timed out")
337 #ifndef ETOOMANYREFS
338 #define ETOOMANYREFS -1
339 #endif
340 CND(ETOOMANYREFS, "Too many references")
342 #ifndef EWOULDBLOCK
343 #define EWOULDBLOCK -1
344 #endif
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
354 #endif
355 CND(HOST_NOT_FOUND, "Unknown host")
357 #ifndef TRY_AGAIN
358 #define TRY_AGAIN -1
359 #endif
360 CND(TRY_AGAIN, "Host name lookup failure")
362 #ifndef NO_DATA
363 #define NO_DATA -1
364 #endif
365 CND(NO_DATA, "No data record for name")
367 #ifndef NO_RECOVERY
368 #define NO_RECOVERY -1
369 #endif
370 CND(NO_RECOVERY, "Non recoverable errors")
372 TXT(" -------------------")
373 TXT(" -- Control flags --")
374 TXT(" -------------------")
377 #ifndef FIONBIO
378 #define FIONBIO -1
379 #endif
380 CNX(FIONBIO, "Set/clear non-blocking io")
382 #ifndef FIONREAD
383 #define FIONREAD -1
384 #endif
385 CNX(FIONREAD, "How many bytes to read")
387 TXT(" --------------------")
388 TXT(" -- Shutdown modes --")
389 TXT(" --------------------")
392 #ifndef SHUT_RD
393 #define SHUT_RD -1
394 #endif
395 CND(SHUT_RD, "No more recv")
397 #ifndef SHUT_WR
398 #define SHUT_WR -1
399 #endif
400 CND(SHUT_WR, "No more send")
402 #ifndef SHUT_RDWR
403 #define SHUT_RDWR -1
404 #endif
405 CND(SHUT_RDWR, "No more recv/send")
407 TXT(" ---------------------")
408 TXT(" -- Protocol levels --")
409 TXT(" ---------------------")
412 #ifndef SOL_SOCKET
413 #define SOL_SOCKET -1
414 #endif
415 CND(SOL_SOCKET, "Options for socket level")
417 #ifndef IPPROTO_IP
418 #define IPPROTO_IP -1
419 #endif
420 CND(IPPROTO_IP, "Dummy protocol for IP")
422 #ifndef IPPROTO_UDP
423 #define IPPROTO_UDP -1
424 #endif
425 CND(IPPROTO_UDP, "UDP")
427 #ifndef IPPROTO_TCP
428 #define IPPROTO_TCP -1
429 #endif
430 CND(IPPROTO_TCP, "TCP")
432 TXT(" -------------------")
433 TXT(" -- Request flags --")
434 TXT(" -------------------")
437 #ifndef MSG_OOB
438 #define MSG_OOB -1
439 #endif
440 CND(MSG_OOB, "Process out-of-band data")
442 #ifndef MSG_PEEK
443 #define MSG_PEEK -1
444 #endif
445 CND(MSG_PEEK, "Peek at incoming data")
447 #ifndef MSG_EOR
448 #define MSG_EOR -1
449 #endif
450 CND(MSG_EOR, "Send end of record")
452 #ifndef MSG_WAITALL
453 #define MSG_WAITALL -1
454 #endif
455 CND(MSG_WAITALL, "Wait for full reception")
457 #ifndef MSG_NOSIGNAL
458 #define MSG_NOSIGNAL -1
459 #endif
460 CND(MSG_NOSIGNAL, "No SIGPIPE on send")
462 #ifdef __linux__
463 # define MSG_Forced_Flags "MSG_NOSIGNAL"
464 #else
465 # define MSG_Forced_Flags "0"
466 #endif
467 CN_(MSG_Forced_Flags, "")
468 TXT(" -- Flags set on all send(2) calls")
471 TXT(" --------------------")
472 TXT(" -- Socket options --")
473 TXT(" --------------------")
476 #ifndef TCP_NODELAY
477 #define TCP_NODELAY -1
478 #endif
479 CND(TCP_NODELAY, "Do not coalesce packets")
481 #ifndef SO_SNDBUF
482 #define SO_SNDBUF -1
483 #endif
484 CND(SO_SNDBUF, "Set/get send buffer size")
486 #ifndef SO_RCVBUF
487 #define SO_RCVBUF -1
488 #endif
489 CND(SO_RCVBUF, "Set/get recv buffer size")
491 #ifndef SO_REUSEADDR
492 #define SO_REUSEADDR -1
493 #endif
494 CND(SO_REUSEADDR, "Bind reuse local address")
496 #ifndef SO_KEEPALIVE
497 #define SO_KEEPALIVE -1
498 #endif
499 CND(SO_KEEPALIVE, "Enable keep-alive msgs")
501 #ifndef SO_LINGER
502 #define SO_LINGER -1
503 #endif
504 CND(SO_LINGER, "Defer close to flush data")
506 #ifndef SO_ERROR
507 #define SO_ERROR -1
508 #endif
509 CND(SO_ERROR, "Get/clear error status")
511 #ifndef SO_BROADCAST
512 #define SO_BROADCAST -1
513 #endif
514 CND(SO_BROADCAST, "Can send broadcast msgs")
516 #ifndef IP_MULTICAST_IF
517 #define IP_MULTICAST_IF -1
518 #endif
519 CND(IP_MULTICAST_IF, "Set/get mcast interface")
521 #ifndef IP_MULTICAST_TTL
522 #define IP_MULTICAST_TTL -1
523 #endif
524 CND(IP_MULTICAST_TTL, "Set/get multicast TTL")
526 #ifndef IP_MULTICAST_LOOP
527 #define IP_MULTICAST_LOOP -1
528 #endif
529 CND(IP_MULTICAST_LOOP, "Set/get mcast loopback")
531 #ifndef IP_ADD_MEMBERSHIP
532 #define IP_ADD_MEMBERSHIP -1
533 #endif
534 CND(IP_ADD_MEMBERSHIP, "Join a multicast group")
536 #ifndef IP_DROP_MEMBERSHIP
537 #define IP_DROP_MEMBERSHIP -1
538 #endif
539 CND(IP_DROP_MEMBERSHIP, "Leave a multicast group")
542 TXT("end GNAT.Sockets.Constants;")
544 output ();
545 return 0;
548 void
549 output (void) {
550 int text_max = 0, value_max = 0, l;
551 struct line *p;
552 char fmt[64];
553 #define UPD_MAX(x) do { \
554 l = strlen (p->x); \
555 if (l > x ## _max) x ## _max = l; \
556 } while (0)
558 for (p = first; p != NULL; p = p->next) {
559 if (p->value != NULL) {
560 UPD_MAX(text);
561 UPD_MAX(value);
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);
570 } else {
571 char *comment_sep = (strlen (p->comment) > 0)
572 ? " -- " : "";
573 printf (fmt, p->text, p->value, comment_sep, p->comment);
578 char *
579 f_itoa (char *fmt, int n) {
580 char buf[32];
581 sprintf (buf, fmt, n);
582 return strdup (buf);
585 void
586 add_line (char *_text, char *_value, char *_comment) {
587 struct line *l = (struct line *) malloc (sizeof (struct line));
588 l->text = _text;
589 l->value = _value;
590 l->comment = _comment;
591 l->next = NULL;
592 if (last == NULL)
593 first = last = l;
594 else {
595 last->next = l;
596 last = l;