diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-23 23:56:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-23 23:56:59 +0000 |
commit | 6372ddbab3389d1e44cb013fd178b6e4b2a10763 (patch) | |
tree | a6e7be6f92da154a893e5581294fea27a2029982 /Build/extra/djgpp/pathconf.c | |
parent | 8294cc19d41a8405e05ec257dd5111b8c18ed4e8 (diff) |
move source/extra up a level to Build/extra, to clarify that they are not part of TL
git-svn-id: svn://tug.org/texlive/trunk@46418 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/extra/djgpp/pathconf.c')
-rw-r--r-- | Build/extra/djgpp/pathconf.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Build/extra/djgpp/pathconf.c b/Build/extra/djgpp/pathconf.c new file mode 100644 index 00000000000..71483684e04 --- /dev/null +++ b/Build/extra/djgpp/pathconf.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include <errno.h> +#include <stdlib.h> +#include <ctype.h> +#include <unistd.h> +#include <fcntl.h> +#include <limits.h> + +#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower (c) : (c)) + +long +pathconf(const char *path, int name) +{ + switch (name) + { + case _PC_LINK_MAX: return LINK_MAX; + case _PC_MAX_CANON: return MAX_CANON; + case _PC_MAX_INPUT: return MAX_INPUT; + case _PC_NAME_MAX: case _PC_PATH_MAX: + { + int name_max, path_max; + int e = errno; + char *lfnenv = getenv ("LFN"); + + if (!lfnenv || TOLOWER (*lfnenv) != 'n') + { + errno = 0; + _get_volume_info (path, &name_max, &path_max, 0); + if (!errno) + { + errno = e; + return (name == _PC_NAME_MAX) ? name_max : path_max; + } + } + return (name == _PC_NAME_MAX) ? NAME_MAX : PATH_MAX; + } + case _PC_PIPE_BUF: return PIPE_BUF; + case _PC_CHOWN_RESTRICTED: return _POSIX_CHOWN_RESTRICTED; + case _PC_NO_TRUNC: return _POSIX_NO_TRUNC; + case _PC_VDISABLE: return _POSIX_VDISABLE; + + default: + errno = EINVAL; + return -1; + } +} |