©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c1/ckvers.c

Go to the documentation of this file.
00001 /*
00002     Program to display POSIX and X/Open version info
00003     AUP2, Sec. 1.5 (not in book)
00004     Not written by Marc Rochkind.
00005 
00006     The Example Files are provided "as is," without any warranty;
00007     without even the implied warranty of merchantability or fitness
00008     for a particular purpose. The author and his publisher are not
00009     responsible for any damages, direct or incidental, resulting
00010     from the use or non-use of these Example Files.
00011 
00012     The Example Files may contain defects, and some contain deliberate
00013     coding mistakes that were included for educational reasons.
00014     You are responsible for determining if and how the Example Files
00015     are to be used.
00016 */
00017 /*
00018  * (C) Copyright 1996 X/Open Company Limited
00019  *
00020  * Permission to use, copy, modify, and distribute this software and its
00021  * documentation for any purpose and without fee is hereby granted, provided
00022  * that the above copyright notice appear in all copies and that both that
00023  * copyright notice and this permission notice appear in supporting
00024  * documentation, and that the name of X/OPEN not be used in
00025  * advertising or publicity pertaining to distribution of the software
00026  * without specific, written prior permission.  X/OPEN make
00027  * no representations about the suitability of this software for any purpose.
00028  * It is provided "as is" without express or implied warranty.
00029  *
00030  * X/OPEN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00031  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
00032  * EVENT SHALL X/OPEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00033  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
00034  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
00035  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00036  * PERFORMANCE OF THIS SOFTWARE.
00037  *
00038  * X/Open and the 'X' symbol are trademarks of X/Open Company Limited in
00039  * the UK and other countries.
00040  */
00041 
00042 /* ckvers.c
00043  * A simple programme to print out the POSIX version
00044  * and the X/Open version claimed by the system
00045  * It also does some simple validity checks on the combination
00046  * of values returned.
00047  *
00048  * Author: Andrew Josey (ajosey@xopen.org)
00049  * Any suggestions/improvements should be sent to the author.
00050  *
00051  * Version: 1.0
00052  *
00053  * Date: 23 Sep 1996 - Original version.
00054  *
00055  * Version 1.1 8th June 1998
00056  *
00057  * Update referenced URL to be  http://www.opengroup.org/
00058  * and other changes to cope with UNIX 98
00059  * This program should now be compiled with the -DCKVERS_UNIX98
00060  * switch when checking for UNIX 98
00061  *
00062  * Version 2.0 16th Sept 2002
00063  *
00064  * Updated by Marc Rochkind (rochkind@basepath.com) to include
00065  * the Single UNIX Specification Version 3 (SUSv3).
00066  * This program should be compiled with -DCKVERS_SUSV3 to
00067  * enable checking for SUSV3. (Note: Some systems capable
00068  * of Unix98 support (_XOPEN_VERSION == 500) when _XOPEN_SOURCE is
00069  * set to 500 revert to _XOPEN_VERSION == 4 if _XOPEN_SOURCE is
00070  * set to 600. So, if you don't get 600 when you set -DCKVERS_SUSV3,
00071  * you should go ahead and try -DCKVERS_UNIX98 as well.
00072  *
00073  * At the time of writing the brand name for the UNIX mark for
00074  * the Single UNIX Specification Version 3 is yet to be finalized.
00075  *
00076  */
00077 
00078 #define _POSIX_SOURCE
00079 #ifdef CKVERS_UNIX98   /* command-line def to switch to UNIX 98 check */
00080 #define _XOPEN_SOURCE 500  /* for UNIX 98 */
00081 #elif CKVERS_SUSV3
00082 #define _XOPEN_SOURCE 600  /* for the Single UNIX Specification Version 3 */
00083 #else
00084 #define _XOPEN_SOURCE
00085 #define _XOPEN_SOURCE_EXTENDED 1
00086 #endif
00087 
00088 #include <unistd.h>
00089 #include <stdio.h>
00090 #ifdef _POSIX_VERSION
00091 #include <sys/utsname.h>
00092 #endif
00093 
00094 /* define TESTBED to emulate SUSv3 */
00095 #ifdef TESTBED
00096 #undef _XOPEN_XCU_VERSION
00097 #define _XOPEN_VERSION 600
00098 #define _POSIX_VERSION 200112L
00099 #define _POSIX2_VERSION 200112L
00100 #endif
00101 
00102 #define CKVERS_VERSION "Ckvers Release 2.0 16-Sept-2002"
00103 
00104 int main(void)
00105 {
00106     int ckvers_posix, ckvers_xsh, ckvers_xcu, ckvers_xopen_unix =0;
00107     int ckvers_posix2clb, ckvers_posix2 =0;
00108 #ifdef _POSIX_VERSION
00109     struct utsname ckvers_unames;
00110 #endif
00111 
00112     (void) printf("\t\t%s\n\t\tSUMMARY REPORT\n\n",CKVERS_VERSION);
00113 
00114 #ifdef _POSIX_VERSION
00115     if (uname(&ckvers_unames) != -1)
00116         {
00117          (void) printf("\tSystem: %s %s %s %s %s\n",
00118               ckvers_unames.sysname, ckvers_unames.nodename,
00119               ckvers_unames.release, ckvers_unames.version,
00120               ckvers_unames.machine);
00121     }
00122 
00123 #ifdef CKVERS_UNIX98
00124     (void) printf("\n\tNotice: Compiled to check for UNIX 98 claims\n");
00125     (void) printf("\tIf warnings occur, recompile with -DCKVERS_SUSV3\n");
00126     (void) printf("\tor without any version symbol.\n");
00127 #elif CKVERS_SUSV3
00128     (void) printf("\n\tNotice: Compiled to check for SUS v3 claims\n");
00129     (void) printf("\tIf warnings occur, recompile with -DCKVERS_UNIX98\n");
00130     (void) printf("\tor without any version symbol.\n");
00131 #endif
00132 
00133     (void) printf("\n\tPOSIX SUPPORT: ");
00134 
00135     switch (_POSIX_VERSION) {
00136 
00137     case 199009L: /* classic dot1 - ISO version */
00138         (void) printf("IEEE Std POSIX.1-1990/ISO 9945-1:1990\n");
00139         ckvers_posix=1990;
00140         break;
00141     case 198808L:  /* classic dot 1 - non ISO version */
00142         (void) printf("IEEE Std POSIX.1-1988\n");
00143         ckvers_posix=1988;
00144         break;
00145     case 199309L: /* POSIX realtime */
00146         (void) printf("IEEE Std POSIX.1b-1993 [Realtime]\n");
00147         ckvers_posix=1993;
00148         break;
00149     case 199506L:  /* POSIX threads */
00150         (void) printf("IEEE Std POSIX.1-1996/ISO 9945-1:1996\n");
00151         ckvers_posix=1995;
00152         break;
00153     case 200112L:  /* the POSIX 1003.1 revision,
00154         replaces 1003.1-1990 and all its amendments,
00155         and replaces 1003.2-1992 and all its amendments.
00156         Developed by the Austin Group.
00157         ISO Status: Draft International Standard (Sep 2002)
00158         DIS 9945-1 (Base Definitions),
00159         DIS 9945-2 (System Interfaces),
00160         DIS 9945-3 (Shell and Utilities),
00161         DIS 9945-4 (Rationale) */
00162         (void) printf("IEEE Std POSIX.1-2001\n");
00163         ckvers_posix=2001;
00164         break;
00165     default:
00166         (void) printf("Unknown _POSIX_VERSION=%ldL\n", _POSIX_VERSION);
00167     }
00168 
00169 /* POSIX.2 C Language Bindings */
00170 #if (_XOPEN_VERSION - 600 == 0) || (_POSIX_VERSION == 200112L )
00171     /*
00172         For 1003.1-2001/SUSv3 _POSIX2_C_VERSION has been removed.
00173             since the functionality is now mandatory
00174     */
00175 
00176     (void) printf("\tFor POSIX 1003.1-2001:\n\t\tthe former ISO POSIX.2 C Language Binding is required.\n");
00177 #else
00178     (void) printf("\tPOSIX.2 C Language Binding: ");
00179 
00180 #ifdef _POSIX2_C_VERSION
00181     if ( _POSIX2_C_VERSION == 199209L ) {
00182         ckvers_posix2clb = 1;
00183         (void) printf("supported\n");
00184     }
00185     else
00186         (void) printf("not supported\n");
00187 #else
00188     (void) printf("not supported\n");
00189 #endif
00190 #endif /* _XOPEN_VERSION */
00191 /* POSIX.2 Shell & Utilities */
00192     (void) printf("\tPOSIX Shell & Utilities: ");
00193 #ifdef _POSIX2_VERSION
00194     /*
00195         _POSIX2_VERSION has been incremented for POSIX 1003.1-2001
00196     */
00197     if ( _POSIX2_VERSION == 199209L ) {
00198         ckvers_posix2 = 1;
00199         (void) printf("ISO POSIX 1003.2-1993 supported\n");
00200     }
00201     else if ( _POSIX2_VERSION == 200112L ) {
00202         ckvers_posix2 = 2001;
00203         (void) printf("POSIX 1003.1-2001 Shell & Utilities\n");
00204     }
00205     else
00206         (void) printf("not supported\n");
00207 #else
00208     (void) printf("not supported\n");
00209 #endif
00210 
00211 
00212 #else
00213 (void) printf("\n\tPOSIX is not supported\n");
00214 #endif
00215 
00216 
00217     (void) printf("\n\tX/OPEN SUPPORT:\n");
00218 #ifdef _XOPEN_VERSION
00219     (void) printf("\tSYSTEM INTERFACES & HEADERS: ");
00220     switch (_XOPEN_VERSION) {
00221 
00222     case 3:
00223         (void) printf("XPG3\n");
00224         ckvers_xsh=3;
00225         break;
00226     case 4:
00227         (void) printf("XPG4\n");
00228         ckvers_xsh=4;
00229         break;
00230     case 500:
00231         (void) printf("XSH 5 claimed for UNIX 98\n");
00232         ckvers_xsh=500;
00233         break;
00234     case 600:
00235         (void) printf("XSH 6 claimed for SUS v.3\n");
00236         ckvers_xsh=600;
00237         break;
00238     default:
00239         (void) printf("Unknown _XOPEN_VERSION=%d\n", _XOPEN_VERSION);
00240     }
00241 #else
00242     (void) printf("\tSYSTEM INTERFACES & HEADERS NOT SUPPORTED\n");
00243 #endif
00244 
00245 
00246 #if (_XOPEN_VERSION - 600 == 0)
00247     (void) printf("\tCOMMANDS & UTILITIES: ");
00248     /*
00249         For the Single UNIX Specification Version 3 ,
00250         the value is unspecified
00251     */
00252     ckvers_xcu=6;
00253     (void) printf("XCU6/IEEE Std POSIX 1003.1-2001\n");
00254 
00255 #elif _XOPEN_XCU_VERSION
00256     (void) printf("\tCOMMANDS & UTILITIES: ");
00257     switch (_XOPEN_XCU_VERSION) {
00258 
00259     case 3:
00260         (void) printf("XPG3/ XPG4 Historical Commands\n");
00261         ckvers_xcu=3;
00262         break;
00263     case 4:
00264         (void) printf("XPG4/IEEE Std POSIX.2-1992/ISO 9945-2:1993\n");
00265         ckvers_xcu=4;
00266         break;
00267     case 5:
00268         (void) printf("XCU5/IEEE Std POSIX.2-1992/ISO 9945-2:1993\n");
00269         ckvers_xcu=5;
00270         break;
00271     default:
00272         (void) printf("Unknown _XOPEN_XCU_VERSION=%d\n", _XOPEN_XCU_VERSION);
00273         break;
00274     }
00275 #endif
00276     if (( ckvers_xcu >= 4 ) && (ckvers_posix2 < 1) )
00277         (void) printf("\tWarning: POSIX Shell & Utilities not supported, but required when XCU 4 or later is claimed (%ld)\n\n", _POSIX_VERSION); /* fmt added by mjr */
00278     else  if (ckvers_xcu == 0)
00279         (void) printf("\tCOMMANDS & UTILITIES NOT SUPPORTED\n");
00280 
00281 
00282 #ifdef _XOPEN_UNIX
00283     (void) printf("\tX/OPEN UNIX SUPPORT IS CLAIMED\n");
00284     ckvers_xopen_unix=1;
00285 #else
00286     (void) printf("\tX/OPEN UNIX is not supported\n");
00287 #endif
00288 
00289 /* check valid combinations */
00290 
00291 /* for XSH6 _XOPEN_XCU_VERSION is unspecified */
00292 
00293 #if (_XOPEN_VERSION - 600 == 0)
00294 
00295     if ( ckvers_xopen_unix == 1 )  {
00296 
00297     if ( ckvers_xsh == 600) {
00298         if ( ckvers_posix < 2001) {
00299             (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when XSH6 support (for SUS v.3) is claimed\n", _POSIX_VERSION);
00300             (void) printf("\tWarning: Expected _POSIX_VERSION equals 200112L , got %ld\n", _POSIX_VERSION);
00301         }
00302         if ( (ckvers_posix2 < 2001))
00303             (void) printf("\tWarning: Unexpected value found for Commands & Utilities (%d) when XCU6 is claimed\n", _POSIX2_VERSION);
00304             (void) printf("\tWarning: Expected _POSIX2_VERSION equals 200112L , got %ld\n", _POSIX2_VERSION);
00305     }
00306 
00307     (void) printf("\n\tIf there are no Warnings output above, then");
00308 
00309     (void) printf("\n\tThis could be a UNIX system conforming to the Single UNIX Specification Version 3");
00310     (void) printf("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n");
00311     }
00312 
00313 #elif (defined(_POSIX_SOURCE) && defined(_XOPEN_SOURCE) && defined(_XOPEN_XCU_VERSION) && defined(_XOPEN_VERSION))
00314 
00315     if ( ckvers_xopen_unix == 1 )  {
00316 
00317         if (  ckvers_xcu != 4 && ckvers_xcu != 5 ) {
00318             (void) printf("\tWarning: Invalid value found for Commands & Utilities (%d) when X/OPEN UNIX is claimed\n", _XOPEN_XCU_VERSION);
00319         }
00320         if ( ckvers_xsh != 4 && ckvers_xsh != 500 && ckvers_xsh != 600)
00321             (void) printf("\tWarning: Invalid value found for System Interfaces & Headers (%d) when X/OPEN UNIX is claimed\n", _XOPEN_VERSION);
00322         if ( ckvers_posix < 1990 )
00323             (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when X/OPEN UNIX is claimed\n", _POSIX_VERSION);
00324         if ( ckvers_posix2clb < 1 )
00325             (void) printf("\tWarning: POSIX.2 CLB not supported, but required when X/OPEN UNIX is claimed (%ld)\n\n", _POSIX_VERSION); /* fmt added by mjr */
00326 
00327     }
00328 
00329     if ( ckvers_xsh == 4) {
00330         if ( ckvers_posix < 1990)
00331             (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when XPG4 is claimed\n", _POSIX_VERSION);
00332 
00333     if ( (ckvers_xcu != 3) && (ckvers_xcu != 4))
00334             (void) printf("\tWarning: Invalid value found for Commands & Utilities (%d) when XPG4 is claimed\n", _XOPEN_XCU_VERSION);
00335 
00336     }
00337     if ( ckvers_xsh == 500) {
00338         if ( ckvers_posix < 1995)
00339             (void) printf("\tWarning: Invalid value found for POSIX support (%ld) when XSH5 support (for UNIX 98) is claimed\n", _POSIX_VERSION);
00340         if ( (ckvers_xcu != 5)) {
00341             (void) printf("\tWarning: Unexpected value found for Commands & Utilities (%d) when XSH5 is claimed\n", _XOPEN_XCU_VERSION);
00342             (void) printf("\tWarning: Expected _XOPEN_XCU_VERSION equals 5 , got %ld\n", (long)_XOPEN_XCU_VERSION);
00343         }
00344     }
00345 
00346     if ( ckvers_xopen_unix == 1 )  {
00347 
00348         (void) printf("\n\tIf there are no Warnings output above, then");
00349 
00350         (void) printf("\n\tThis could be a UNIX system conforming to the Single UNIX Specification");
00351 #if _XOPEN_VERSION - 500 == 0
00352         (void) printf(", Version 2\n");
00353 #else
00354         (void) printf("\n");
00355 #endif
00356         (void) printf("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n");
00357     } else {
00358 
00359         if (ckvers_xsh == 4) {
00360             if ( ckvers_xcu == 3 )
00361                 (void) printf("\n\tThis could be an XPG4 Base system\n");
00362             else if (ckvers_xcu == 4)
00363                 (void) printf("\n\tThis could be an XPG4 Base or XPG4 Base 95 system\n");
00364         (void) printf("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n");
00365         }
00366         else if (ckvers_xsh == 3) {
00367                 (void) printf("\n\tThis could be an XPG3 Base system\n");
00368                 (void) printf("\n\tPlease check the branded products catalogue for confirmation\n\thttp://www.opengroup.org/regproducts/\n");
00369         }
00370     }
00371 #endif
00372     return 0;
00373 }
00374 

Generated on Fri Apr 23 10:56:53 2004 for AUP2 Example Source by doxygen 1.3.1