/* * (C) Copyright 1996 X/Open Company Limited * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of X/OPEN not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. X/OPEN make * no representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. * * X/OPEN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL X/OPEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * X/Open and the 'X' symbol are trademarks of X/Open Company Limited in * the UK and other countries. */ /* ckvers.c * A simple programme to print out the POSIX version * and the X/Open version claimed by the system * It also does some simple validity checks on the combination * of values returned. * * Author: Andrew Josey (ajosey@xopen.org) * Any suggestions/improvements should be sent to the author. * * Version: 1.0 * * Date: 23 Sep 1996 - Original version. * * Version 1.1 8th June 1998 * * Update referenced URL to be http://www.opengroup.org/ * and other changes to cope with UNIX 98 * This program should now be compiled with the -DCKVERS_UNIX98 * switch when checking for UNIX 98 */ #define _POSIX_SOURCE #ifndef CKVERS_UNIX98 /* command line definition to switch to UNIX 98 check*/ #define _XOPEN_SOURCE #define _XOPEN_SOURCE_EXTENDED 1 #else #define _XOPEN_SOURCE 500 /* for UNIX 98 */ #endif #include #include #ifdef _POSIX_VERSION #include #endif #define CKVERS_VERSION "Ckvers Release 1.1 6/8/1998" int main(void) { int ckvers_posix, ckvers_xsh, ckvers_xcu, ckvers_xopen_unix =0; int ckvers_posix2clb, ckvers_posix2 =0; #ifdef _POSIX_VERSION struct utsname ckvers_unames; #endif (void) printf ("\t\t%s\n\t\tSUMMARY REPORT\n\n",CKVERS_VERSION); #ifdef _POSIX_VERSION if (uname(&ckvers_unames) != -1) { (void) printf("\tSystem: %s %s %s %s %s\n", ckvers_unames.sysname, ckvers_unames.nodename, ckvers_unames.release, ckvers_unames.version, ckvers_unames.machine); } #ifdef CKVERS_UNIX98 (void) printf ("\n\tNotice: Compiled to check for UNIX 98 claims\n"); (void) printf ("\tIf warnings occur, recompile without -DCKVERS_UNIX98\n"); #endif (void) printf("\n\tPOSIX SUPPORT: "); switch (_POSIX_VERSION) { case 199009L: /* classic dot1 - ISO version */ (void) printf("IEEE Std POSIX.1-1990/ISO 9945-1:1990\n"); ckvers_posix=90; break; case 198808L: /* classic dot 1 - non ISO version */ (void) printf("IEEE Std POSIX.1-1988\n"); ckvers_posix=88; break; case 199309L: /* POSIX realtime */ (void) printf("IEEE Std POSIX.1b-1993 [Realtime]\n"); ckvers_posix=93; break; case 199506L: /* POSIX threads */ (void) printf("IEEE Std POSIX.1-1996/ISO 9945-1:1996\n"); ckvers_posix=95; break; default: (void) printf("Unknown _POSIX_VERSION=%ldL\n", _POSIX_VERSION); break; } /* POSIX.2 C Language Bindings */ (void) printf("\tISO POSIX.2 C Language Binding: "); #ifdef _POSIX2_C_VERSION if ( _POSIX2_C_VERSION == 199209L ) { ckvers_posix2clb = 1; (void) printf("supported\n"); } else (void) printf("not supported\n"); #else (void) printf("not supported\n"); #endif /* POSIX.2 Shell & Utilities */ (void) printf("\tISO POSIX.2 Shell & Utilities: "); #ifdef _POSIX2_VERSION if ( _POSIX2_VERSION == 199209L ) { ckvers_posix2 = 1; (void) printf("supported\n"); } else (void) printf("not supported\n"); #else (void) printf("not supported\n"); #endif #else (void) printf("\n\tPOSIX is not supported\n"); #endif (void) printf ("\n\tX/OPEN SUPPORT:\n"); #ifdef _XOPEN_VERSION (void) printf ("\tSYSTEM INTERFACES & HEADERS: "); switch (_XOPEN_VERSION) { case 3: (void) printf("XPG3\n"); ckvers_xsh=3; break; case 4: (void) printf("XPG4\n"); ckvers_xsh=4; break; case 500: (void) printf("XSH 5 claimed for UNIX 98\n"); ckvers_xsh=500; break; default: (void) printf("Unknown _XOPEN_VERSION=%d\n", _XOPEN_VERSION); break; } #else (void) printf("\tSYSTEM INTERFACES & HEADERS NOT SUPPORTED\n"); #endif #ifdef _XOPEN_XCU_VERSION (void) printf ("\tCOMMANDS & UTILITIES: "); switch (_XOPEN_XCU_VERSION) { case 3: (void) printf("XPG3/ XPG4 Historical Commands\n"); ckvers_xcu=3; break; case 4: (void) printf("XPG4/IEEE Std POSIX.2-1992/ISO 9945-2:1993\n"); ckvers_xcu=4; break; case 5: (void) printf("XCU5/IEEE Std POSIX.2-1992/ISO 9945-2:1993\n"); ckvers_xcu=5; break; default: (void) printf("Unknown _XOPEN_XCU_VERSION=%d\n", _XOPEN_XCU_VERSION); break; } if ( (ckvers_xcu == 4 || ckvers_xcu == 5) && ckvers_posix2 < 1 ) (void) printf("\tWarning: POSIX.2 not supported, but required when XCU 4 or 5 is claimed\n\n", _POSIX_VERSION); #else (void) printf("\tCOMMANDS & UTILITIES NOT SUPPORTED\n"); #endif #ifdef _XOPEN_UNIX (void) printf("\tX/OPEN UNIX SUPPORT IS CLAIMED\n"); ckvers_xopen_unix=1; #else (void) printf("\tX/OPEN UNIX is not supported\n"); #endif /* check valid combinations */ #if (defined(_POSIX_SOURCE) && defined(_XOPEN_SOURCE) && defined(_XOPEN_XCU_VERSION) && defined(_XOPEN_VERSION)) if ( ckvers_xopen_unix == 1 ) { if ( ckvers_xcu != 4 && ckvers_xcu != 5 ) (void) printf("\tWarning: Invalid value found for Commands & Utilities (%d) when X/OPEN UNIX is claimed\n", _XOPEN_XCU_VERSION); if ( ckvers_xsh != 4 && ckvers_xsh != 500) (void) printf("\tWarning: Invalid value found for System Interfaces & Headers (%d) when X/OPEN UNIX is claimed\n", _XOPEN_VERSION); if ( ckvers_posix < 90 ) (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when X/OPEN UNIX is claimed\n", _POSIX_VERSION); if ( ckvers_posix2clb < 1 ) (void) printf("\tWarning: POSIX.2 CLB not supported, but required when X/OPEN UNIX is claimed\n\n", _POSIX_VERSION); } if ( ckvers_xsh == 4) { if ( ckvers_posix < 90) (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when XPG4 is claimed\n", _POSIX_VERSION); if ( (ckvers_xcu != 3) && (ckvers_xcu != 4)) (void) printf("\tWarning: Invalid value found for Commands & Utilities (%d) when XPG4 is claimed\n", _XOPEN_XCU_VERSION); } if ( ckvers_xsh == 500) { if ( ckvers_posix < 96) (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when XSH5 support (for UNIX 98) is claimed\n", _POSIX_VERSION); if ( (ckvers_xcu != 5)) (void) printf("\tWarning: Unexpected value found for Commands & Utilities (%d) when XSH5 is claimed\n", _XOPEN_XCU_VERSION); } (void) printf ("\n\tIf there are no Warnings output above, then"); if (ckvers_xopen_unix == 1) { (void) printf ("\n\tThis could be a UNIX system conforming to the Single UNIX Specification"); #if _XOPEN_VERSION - 500 == 0 (void) printf (", Version 2\n"); #else (void) printf ("\n"); #endif (void) printf ("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n"); } else { if (ckvers_xsh == 4) { if ( ckvers_xcu == 3 ) (void) printf ("\n\tThis could be an XPG4 Base system\n"); else if (ckvers_xcu == 4) (void) printf ("\n\tThis could be an XPG4 Base or XPG4 Base 95 system\n"); (void) printf ("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n"); } else if (ckvers_xsh == 3) { (void) printf ("\n\tThis could be an XPG3 Base system\n"); (void) printf ("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n"); } } #endif return 0; }