From 5fd83771641d15c418f747bd343ba6738d3875f7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 9 May 2021 14:20:58 -0400 Subject: Import macOS userland adv_cmds-176 basic_cmds-55 bootstrap_cmds-116.100.1 developer_cmds-66 diskdev_cmds-667.40.1 doc_cmds-53.60.1 file_cmds-321.40.3 mail_cmds-35 misc_cmds-34 network_cmds-606.40.1 patch_cmds-17 remote_cmds-63 shell_cmds-216.60.1 system_cmds-880.60.2 text_cmds-106 --- system_cmds/getconf.tproj/pathconf.gperf | 88 ++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 system_cmds/getconf.tproj/pathconf.gperf (limited to 'system_cmds/getconf.tproj/pathconf.gperf') diff --git a/system_cmds/getconf.tproj/pathconf.gperf b/system_cmds/getconf.tproj/pathconf.gperf new file mode 100644 index 0000000..ebb317f --- /dev/null +++ b/system_cmds/getconf.tproj/pathconf.gperf @@ -0,0 +1,88 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/pathconf.gperf,v 1.4 2003/08/22 17:32:07 markm Exp $ + */ + +#include + +#include +#include +#ifdef APPLE_GETCONF_UNDERSCORE +#include +#endif /* APPLE_GETCONF_UNDERSCORE */ + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +%} +struct map { const char *name; int key; int valid; }; +%% +FILESIZEBITS, _PC_FILESIZEBITS +LINK_MAX, _PC_LINK_MAX +MAX_CANON, _PC_MAX_CANON +MAX_INPUT, _PC_MAX_INPUT +NAME_MAX, _PC_NAME_MAX +PATH_MAX, _PC_PATH_MAX +PIPE_BUF, _PC_PIPE_BUF +POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN +POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE +POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE +POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE +POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN +POSIX2_SYMLINKS, _PC_2_SYMLINKS +SYMLINK_MAX, _PC_SYMLINK_MAX +TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED +TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX +TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT +TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT +TRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT +_POSIX_ASYNC_IO, _PC_ASYNC_IO +_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED +_POSIX_NO_TRUNC, _PC_NO_TRUNC +_POSIX_PATH_MAX, _PC_PATH_MAX +_POSIX_PRIO_IO, _PC_PRIO_IO +_POSIX_SYNC_IO, _PC_SYNC_IO +_POSIX_VDISABLE, _PC_VDISABLE +%% +int +find_pathconf(const char *name, int *key) +{ + const struct map *rv; +#ifdef APPLE_GETCONF_UNDERSCORE + char *alt; +#endif /* APPLE_GETCONF_UNDERSCORE */ + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#ifdef APPLE_GETCONF_UNDERSCORE + if(*name == '_') + alt = (char *)name + 1; + else { + if((alt = (char *)alloca(strlen(name) + 2)) == NULL) + return 0; + *alt = '_'; + strcpy(alt + 1, name); + } + rv = in_word_set(alt); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#endif /* APPLE_GETCONF_UNDERSCORE */ + return 0; +} -- cgit v1.2.3-56-ge451