00001 /* 00002 Using sysconf 00003 Sec. 1.5.5 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 00022 #include "defs.h" 00023 #include <sys/utsname.h> 00024 00025 int main(void) 00026 { 00027 bool lookup, optsymdefined; 00028 char *when, *sc_symb; 00029 struct utsname name; 00030 FILE *out = fopen("/aup/c1/susopen.txt", "w"); 00031 00032 /*[sysconf1]*/ 00033 long value; 00034 00035 #if defined(_POSIX_ASYNCHRONOUS_IO) 00036 printf("_POSIX_ASYNCHRONOUS_IO = %ld\n", (long)_POSIX_ASYNCHRONOUS_IO); 00037 #else 00038 printf("_POSIX_ASYNCHRONOUS_IO undefined\n"); 00039 #endif 00040 #if defined(_SC_ASYNCHRONOUS_IO) 00041 errno = 0; 00042 if ((value = sysconf(_SC_ASYNCHRONOUS_IO)) == -1) 00043 if (errno == EINVAL) 00044 EC_FAIL 00045 else 00046 printf("sysconf(...) = unsupported\n"); 00047 else 00048 printf("sysconf(...) = %ld\n", value); 00049 #else 00050 printf("_SC_ASYNCHRONOUS_IO undefined\n"); 00051 #endif 00052 /*[]*/ 00053 { 00054 /*[sysconf2]*/ 00055 long value; 00056 00057 #if defined(_SC_ATEXIT_MAX) 00058 errno = 0; 00059 if ((value = sysconf(_SC_ATEXIT_MAX)) == -1) 00060 if (errno == EINVAL) 00061 EC_FAIL 00062 else 00063 printf("max atexit registrations: unlimited\n"); 00064 else 00065 printf("max atexit registrations: %ld\n", value); 00066 #else 00067 printf("_SC_ATEXIT_MAX undefined\n"); 00068 #endif 00069 /*[]*/ 00070 printf("LONG_MAX = %ld\n", LONG_MAX); 00071 } 00072 00073 ec_null( out ) 00074 ec_neg1( uname(&name) ) 00075 #if 0 00076 printf("sysname = %s\n", name.sysname); 00077 printf("nodename = %s\n", name.nodename); 00078 printf("release = %s\n", name.release); 00079 printf("version = %s\n", name.version); 00080 printf("machine = %s\n", name.machine); 00081 #endif 00082 printf("_POSIX_VERSION = %ld\n", _POSIX_VERSION); 00083 #ifdef _XOPEN_UNIX 00084 printf("_XOPEN_VERSION = %ld\n", (long)_XOPEN_VERSION); 00085 #else 00086 printf("_XOPEN_UNIX undefined\n"); 00087 #endif 00088 return 0; 00089 00090 EC_CLEANUP_BGN 00091 exit(EXIT_FAILURE); 00092 EC_CLEANUP_END 00093 }