summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-03-26 01:46:20 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-03-26 01:46:20 -0500
commitdf2737fd0a3d597b91934794a5ae61f81eba6df8 (patch)
tree7251f05e91ef2d948f27002a2ae4117ab8433088
parent1b77f8f48a5bbb81430ae13a348a0902bfefc07e (diff)
downloadshimmy-0.4.tar.gz
shimmy-0.4.tar.bz2
shimmy-0.4.tar.xz
shimmy-0.4.zip
getconf: Add POSIX2_LINE_MAX and INT_MAX variablesv0.4
-rw-r--r--getconf/getconf.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/getconf/getconf.c b/getconf/getconf.c
index 9dba3ec..8ede268 100644
--- a/getconf/getconf.c
+++ b/getconf/getconf.c
@@ -24,6 +24,9 @@ typedef struct variable_mapping
/* For variables that are valid, but undefined in this implementation */
#define _UNDEFINED_VARIABLE_ 0x7FEEDFEE
+#define SHIMMY_POSIX2_LINE_MAX 0x7FEEDFED
+#define SHIMMY_INT_MAX 0x7FEEDFEC
+
const var_map_t sysconf_vars[] = {
/* max */
{ "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX },
@@ -315,10 +318,13 @@ const var_map_t sysconf_vars[] = {
{ "_XOPEN_UUCP", _UNDEFINED_VARIABLE_ },
#endif
#if defined(_SC_XOPEN_VERSION)
- { "_XOPEN_VERSION", _SC_XOPEN_VERSION }
+ { "_XOPEN_VERSION", _SC_XOPEN_VERSION },
#else /* NetBSD */
- { "_XOPEN_VERSION", _UNDEFINED_VARIABLE_ }
+ { "_XOPEN_VERSION", _UNDEFINED_VARIABLE_ },
#endif
+
+ { "POSIX2_LINE_MAX", SHIMMY_POSIX2_LINE_MAX },
+ { "INT_MAX", SHIMMY_INT_MAX }
};
@@ -410,11 +416,20 @@ int do_system_var(char *environment, char *system_var)
return 0;
}
- errno = 0;
-
- val = sysconf(sysconf_vars[var].value);
- if(errno != 0)
+ switch(sysconf_vars[var].value)
{
+ case SHIMMY_POSIX2_LINE_MAX:
+ val = LINE_MAX;
+ break;
+ case SHIMMY_INT_MAX:
+ val = INT_MAX;
+ break;
+ default:
+ errno = 0;
+
+ val = sysconf(sysconf_vars[var].value);
+ if(errno != 0)
+ {
/* We know that this is a valid symbol, so don't break
* expectations (see _POSIX_TRACE_LOG in FreeBSD).
*
@@ -425,8 +440,9 @@ int do_system_var(char *environment, char *system_var)
* a result in getconf. So, I feel this is the
* strictest way to conform.
*/
- printf("undefined\n");
- return 0;
+ printf("undefined\n");
+ return 0;
+ }
}
printf("%ld\n", val);