©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/ckstdvers.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 /* ckstdvers.c
00043  *
00044  * A simple test programme to print out the POSIX version
00045  * and the X/Open version claimed by the system
00046  * It also does some simple validity checks on the combination
00047  * of values returned.  A sister programme ckvers does
00048  * similar things and attempts to put out a pretty report.
00049  * This program is intended to look at more specific details.
00050  *
00051  * Author: Andrew Josey (ajosey@xopen.org)
00052  * If you have any suggestions or improvements please send
00053  * them to the author.
00054  *
00055  * Version: 0.1
00056  * Date: 15 Sep 1996
00057  *
00058  * Version: 0.2
00059  * Date: 18 Sep 1996
00060  * Updated by adding _POSIX_JOB_CONTROL, _POSIX_SAVED_IDS, _POSIX2_C_VERSION
00061  * and _POSIX2_VERSION
00062  *
00063  * Version: 0.3
00064  * Date: 9 June 1998
00065  * Add in UNIX 98 support. Checks for _POSIX_THREADS
00066  */
00067 
00068 #define _POSIX_SOURCE
00069 /* Note for that UNIX 98 that _XOPEN_SOURCE should be set to 500 */
00070 
00071 #define _XOPEN_SOURCE 500 /* mjr added 500; was blank */
00072 #define _XOPEN_SOURCE_EXTENDED 1
00073 
00074 #include <unistd.h>
00075 #include <stdio.h>
00076 
00077 int main(void)
00078 {
00079 
00080     int posix, xsh, xcu, xopen_unix =0;
00081     long user_sc_value;
00082 
00083 #ifdef _POSIX_VERSION
00084     switch (_POSIX_VERSION) {
00085 
00086     case 199009L: /* classic dot1 - ISO version */
00087         (void) printf("_POSIX_VERSION=%ldL (ISO 9945-1:1990[IEEE Std POSIX.1-1990])\n", _POSIX_VERSION);
00088         posix=90;
00089         break;
00090     case 198808L:  /* classic dot 1 - non ISO version */
00091         (void) printf("_POSIX_VERSION=%ldL (IEEE Std POSIX.1-1988)\n", _POSIX_VERSION);
00092         posix=88;
00093         break;
00094     case 199309L: /* POSIX realtime */
00095         (void) printf("_POSIX_VERSION=%ldL (IEEE Std POSIX.1b-1993)\n", _POSIX_VERSION);
00096         posix=93;
00097         break;
00098     case 199506L:  /* POSIX threads */
00099         (void) printf("_POSIX_VERSION=%ldL (ISO 9945-1:1996 [IEEE Std POSIX.1-1996])\n", _POSIX_VERSION);
00100         posix=95;
00101         break;
00102     default:
00103         (void) printf("Unknown _POSIX_VERSION=%ldL\n", _POSIX_VERSION);
00104         break;
00105     }
00106 
00107     /* check consistency with sysconf */
00108     user_sc_value = sysconf(_SC_VERSION);
00109     if ( user_sc_value != _POSIX_VERSION )
00110         (void) printf("Warning: sysconf(_SC_VERSION) returned %ld, expected %ld\n", user_sc_value, _POSIX_VERSION); /* mjr changed from dL to ld */
00111 
00112 
00113 #else
00114 (void) printf("_POSIX_VERSION not defined\n");
00115 #endif
00116 
00117 #ifdef _POSIX_JOB_CONTROL
00118     (void) printf("\t_POSIX_JOB_CONTROL supported\n");
00119 #else
00120     (void) printf("\t_POSIX_JOB_CONTROL not supported\n");
00121 #endif
00122 
00123 #ifdef _POSIX_SAVED_IDS
00124     (void) printf("\t_POSIX_SAVED_IDS supported\n");
00125 #else
00126     (void) printf("\t_POSIX_SAVED_IDS not supported\n");
00127 #endif
00128 
00129     if (posix >= 95 ) {
00130 #ifdef _POSIX_THREADS
00131     (void) printf("\t_POSIX_THREADS supported\n");
00132 #else
00133     (void) printf("\t_POSIX_THREADS not supported\n");
00134 #endif
00135 #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
00136     (void) printf("\t_POSIX_THREAD_SAFE_FUNCTIONS supported\n");
00137 #else
00138     (void) printf("\t_POSIX_THREAD_SAFE_FUNCTIONS not supported\n");
00139 #endif
00140 #ifdef _POSIX_THREAD_ATTR_STACKADDR
00141     (void) printf("\t_POSIX_THREAD_ATTR_STACKADDR supported\n");
00142 #else
00143     (void) printf("\t_POSIX_THREAD_ATTR_STACKADDR not supported\n");
00144 #endif
00145 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
00146     (void) printf("\t_POSIX_THREAD_ATTR_STACKSIZE supported\n");
00147 #else
00148     (void) printf("\t_POSIX_THREAD_ATTR_STACKSIZE not supported\n");
00149 #endif
00150     }
00151 
00152 
00153 
00154 #ifdef _XOPEN_VERSION
00155     switch (_XOPEN_VERSION) {
00156 
00157     case 3:
00158         (void) printf("_XOPEN_VERSION=%d (XPG3 System Interfaces)\n", _XOPEN_VERSION);
00159         xsh=3;
00160         break;
00161     case 4:
00162         (void) printf("_XOPEN_VERSION=%d (XPG4 System Interfaces)\n", _XOPEN_VERSION);
00163         xsh=4;
00164         break;
00165     case 500:
00166         (void) printf("_XOPEN_VERSION=%d (XSH5 System Interfaces)\n", _XOPEN_VERSION);
00167         xsh=5;
00168         break;
00169     default:
00170         (void) printf("Unknown _XOPEN_VERSION=%d\n", _XOPEN_VERSION);
00171         break;
00172     }
00173 
00174 #ifdef _POSIX2_C_VERSION
00175     if ( _POSIX2_C_VERSION == 199209L )
00176         (void) printf("_POSIX2_C_VERSION=199209L : ISO POSIX.2 C Languages Binding is supported\n");
00177     else
00178         (void) printf("_POSIX2_C_VERSION != 199209L : ISO POSIX.2 C Language Binding not supported\n");
00179 #else
00180     (void) printf("_POSIX2_C_VERSION not defined: ISO POSIX.2 C Language Binding  not supported\n");
00181 #endif
00182 
00183 #else
00184 (void) printf("_XOPEN_VERSION not defined\n");
00185 #endif
00186 
00187 
00188 #ifdef _XOPEN_XCU_VERSION
00189     switch (_XOPEN_XCU_VERSION) {
00190 
00191     case 3:
00192         (void) printf("_XOPEN_XCU_VERSION=%d (Historical Commands)\n", _XOPEN_XCU_VERSION);
00193         xcu=3;
00194         break;
00195     case 4:
00196         (void) printf("_XOPEN_XCU_VERSION=%d (POSIX.2 Commands)\n", _XOPEN_XCU_VERSION);
00197         xcu=4;
00198         break;
00199     case 5:
00200         (void) printf("_XOPEN_XCU_VERSION=%d (POSIX.2 Commands)\n", _XOPEN_XCU_VERSION);
00201         xcu=5;
00202         break;
00203     default:
00204         (void) printf("Unknown _XOPEN_XCU_VERSION=%d\n", _XOPEN_XCU_VERSION);
00205         break;
00206     }
00207 #else
00208 (void) printf("_XOPEN_XCU_VERSION not defined\n");
00209 #endif
00210 
00211 #ifdef _POSIX2_VERSION
00212     if ( _POSIX2_VERSION == 199209L )
00213         (void) printf("_POSIX2_VERSION=199209L : ISO POSIX.2 is supported\n");
00214     else
00215         (void) printf("_POSIX2_VERSION != 199209L : ISO POSIX.2 not supported\n");
00216 #else
00217     (void) printf("_POSIX2_VERSION not defined: ISO POSIX.2 not supported\n");
00218 #endif
00219 
00220 #ifdef _XOPEN_UNIX
00221     (void) printf("_XOPEN_UNIX support is claimed\n");
00222     xopen_unix=1;
00223 #else
00224     (void) printf("_XOPEN_UNIX is not supported\n");
00225 #endif
00226 
00227 /* check valid combinations */
00228 
00229 #if (defined(_POSIX_SOURCE) && defined(_XOPEN_SOURCE) && defined(_XOPEN_XCU_VERSION) && defined(_XOPEN_VERSION))
00230 
00231     if ( xopen_unix == 1 )  {
00232 
00233         if (  xcu != 4 && xcu != 5 )
00234             (void) printf("Invalid value found for _XOPEN_XCU_VERSION (%d) when _XOPEN_UNIX is supported\n", _XOPEN_XCU_VERSION);
00235         if ( xsh != 4  && xsh != 5 ) /* mjr changed from 500 to 5 */
00236             (void) printf("Invalid value found for _XOPEN_VERSION (%d) when _XOPEN_UNIX is supported\n", _XOPEN_VERSION);
00237         if ( posix < 90 )
00238             (void) printf("Invalid value found for _POSIX_VERSION (%ld) when _XOPEN_UNIX is supported\n", _POSIX_VERSION);
00239 
00240     }
00241 
00242     if ( xsh == 4) {
00243         if ( posix < 90)
00244             (void) printf("Invalid value found for _POSIX_VERSION (%ld) when _XOPEN_VERSION is set to 4\n", _POSIX_VERSION);
00245 
00246     if ( (xcu != 3) && (xcu != 4))
00247             (void) printf("Invalid value found for _XOPEN_XCU_VERSION (%d) when _XOPEN_VERSION is set to 4\n", _XOPEN_XCU_VERSION);
00248 
00249     }
00250 #endif
00251     return 0;
00252 }

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