/* * This program must be called with the constant name as the CONSTANT_NAME * define. If this is not the case, then a generic version which takes a * symbol to undefine as the first argument will be built. */ #include #ifdef HAVE_SYS_CONF_H # ifdef HAVE_SYS_PARAM_H # include # endif # ifdef HAVE_TIME_H # include # endif #include #endif #ifdef HAVE_SYS_FILE_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SYS_SYSTEMINFO_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #include #endif #ifdef HAVE_POLL_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #ifdef HAVE_STDIO_H #include #endif #ifdef HAVE_STROPTS_H #include #endif #ifdef HAVE_TERMIO_H #include #endif #ifdef HAVE_TERMIOS_H #include #endif #ifdef HAVE_WINDOWS_H #define Win32_Winsock #include /* This directive is checked only for mingw32 2.8.1 */ #if (_WIN32_WINNT >= 0x0400) #include #endif /* Absent declarations */ #define POLLIN 1 #define POLLPRI 2 #define POLLOUT 4 /* Undefine cygwin specific declarations to replace them */ #undef EINTR #undef EWOULDBLOCK #undef EINPROGRESS #undef EALREADY #undef EISCONN #undef ECONNREFUSED /* Replace with Windows sockets declaration */ #define EINTR WSAEINTR #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EISCONN WSAEISCONN #define ECONNREFUSED WSAECONNREFUSED #endif #include static char * capitalize (char *name) { int beginning = 1; char *result = (char *) malloc (strlen (name) + 1); char *ptr; for (ptr = result; *name; ptr++, name++) { *ptr = *name; if (beginning) { beginning = 0; } else if (*ptr == '_') { beginning = 1; } else if (isupper(*ptr)) { *ptr = tolower(*ptr); } } *ptr = '\0'; return result; } static void output (char *name, int value) { char *capitalized = capitalize (name); if (value >= 0) { printf (" %-20s : constant := 16#%04X#;\n", capitalized, value); } else { printf (" %-20s : constant := %d;\n", capitalized, value); } } int main (int argc, char *argv[]) { #ifdef CONSTANT_NAME output (argv[1], CONSTANT_NAME); #else output (argv[1], -1); #endif exit (0); }