add directory gnu

This commit is contained in:
gohigh
2024-02-19 00:24:47 -05:00
parent 32616db5a4
commit a40f4cadb0
5086 changed files with 1860970 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
#
# Sub-makefile for POSIX portion of the library.
#
subdir := posix
headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
glob.h wordexp.h fnmatch.h gnu/wait.h gnu/types.h getopt.h \
posix1_lim.h posix2_lim.h posix_opt.h local_lim.h tar.h
distribute := confstr.h
routines := \
uname \
__times \
__wait __waitpid __wait3 __wait4 \
alarm sleep pause \
__fork __vfork _exit \
__execve execve execv execle execl execvp execlp \
__getpid __getppid \
__getuid __geteuid __getgid __getegid __getgrps __setuid __setgid \
__getpgrp __setpgrp __setsid setpgid \
getlogin setlogin \
__pathconf __sysconf __fpathcon \
glob fnmatch \
confstr \
getopt getopt1
routines := $(sort $(foreach f,$(routines),$f $(f:__%=%)))
aux := init-posix environ
tests := tstgetopt
others := getconf
include ../Rules
# Make the standalone glob/fnmatch package.
glob.tar.Z: glob.tar
compress -c $< > $@-tmp
mv $@-tmp $@
glob.tar: glob/COPYING.LIB glob/Makefile \
glob/fnmatch.h glob/glob.h glob/fnmatch.c glob/glob.c
tar ch$(verbose)f $@ $^
glob/%.c: %.c
$(..)ansidecl -trad $< | indent -stdin -gnu > $@-tmp
mv $@-tmp $@
glob/%.h: %.h
$(..)ansidecl -trad $< | indent -stdin -gnu > $@-tmp
mv $@-tmp $@

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <stddef.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <confstr.h>
/* If BUF is not NULL, fill in at most LEN characters of BUF
with the value corresponding to NAME. Return the number
of characters required to hold NAME's entire value. */
size_t
DEFUN(confstr, (name, buf, len),
int name AND char *buf AND size_t len)
{
CONST char *string;
size_t string_len;
switch (name)
{
case _CS_PATH:
{
static CONST char cs_path[] = CS_PATH;
string = cs_path;
string_len = sizeof(cs_path);
}
break;
default:
errno = EINVAL;
return 0;
}
if (buf != NULL)
(void) strncpy(buf, string, len);
return string_len;
}

View File

@@ -0,0 +1,29 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#undef environ
#ifdef HAVE_GNU_LD
#include <gnu-stabs.h>
symbol_alias(__environ, environ);
#endif

View File

@@ -0,0 +1,48 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
#ifndef HAVE_GNU_LD
#define __environ environ
#endif
/* Execute PATH with all arguments after PATH until
a NULL pointer and environment from `environ'. */
int
DEFUN(execl, (path), CONST char *path AND CONST char *arg DOTS)
{
CONST char *argv[1024];
register unsigned int i;
va_list args;
va_start(args, path);
argv[0] = arg;
i = 1;
do
{
argv[i] = va_arg(args, CONST char *);
} while (argv[i++] != NULL);
va_end(args);
return __execve(path, (char *CONST *) argv, __environ);
}

View File

@@ -0,0 +1,45 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
/* Execute PATH with all arguments after PATH until a NULL pointer,
and the argument after that for environment. */
int
DEFUN(execle, (path), CONST char *path AND CONST char *arg DOTS)
{
CONST char *argv[1024], *CONST *envp;
register unsigned int i;
va_list args;
va_start(args, arg);
argv[0] = arg;
i = 1;
do
{
argv[i] = va_arg(args, CONST char *);
} while (argv[i++] != NULL);
envp = va_arg(args, CONST char *CONST *);
va_end(args);
return __execve(path, (char *CONST *) argv, (char *CONST *) envp);
}

View File

@@ -0,0 +1,45 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
/* Execute FILE, searching in the `PATH' environment variable if
it contains no slashes, with all arguments after FILE until a
NULL pointer and environment from `environ'. */
int
DEFUN(execlp, (file), CONST char *file AND CONST char *arg DOTS)
{
CONST char *argv[1024];
register unsigned int i;
va_list args;
va_start(args, file);
argv[0] = arg;
i = 1;
do
{
argv[i] = va_arg(args, CONST char *);
} while (argv[i++] != NULL);
va_end(args);
return execvp(file, (char *CONST *) argv);
}

View File

@@ -0,0 +1,31 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#ifndef HAVE_GNU_LD
#define __environ environ
#endif
/* Execute PATH with arguments ARGV and environment from `environ'. */
int
DEFUN(execv, (path, argv), CONST char *path AND char *CONST argv[])
{
return __execve(path, argv, __environ);
}

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <unistd.h>
#undef execve
function_alias(execve, __execve, int, (p, a, e),
DEFUN(execve, (p, a, e),
CONST char *p AND char *CONST a[] AND char *CONST e[]))

View File

@@ -0,0 +1,111 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <limits.h>
#include <sys/types.h>
#ifndef HAVE_GNU_LD
#define __environ environ
#endif
/* Execute FILE, searching in the `PATH' environment variable if it contains
no slashes, with arguments ARGV and environment from `environ'. */
int
DEFUN(execvp, (file, argv), CONST char *file AND char *CONST argv[])
{
char name[PATH_MAX];
if (strchr(file, '/') == NULL)
{
char *path, *p;
struct stat st;
size_t len;
uid_t uid;
gid_t gid;
int ngroups;
gid_t groups[NGROUPS_MAX];
path = getenv("PATH");
if (path == NULL)
{
/* There is no `PATH' in the environment.
The default search path is the current directory
followed by the path `confstr' returns for `_CS_PATH'. */
len = confstr(_CS_PATH, (char *) NULL, 0);
path = (char *) __alloca(1 + len);
path[0] = ':';
(void) confstr(_CS_PATH, path + 1, len);
}
len = strlen(file) + 1;
uid = geteuid();
gid = getegid();
ngroups = getgroups(sizeof(groups) / sizeof(groups[0]), groups);
p = path;
do
{
path = p;
p = strchr(path, ':');
if (p == NULL)
p = strchr(path, '\0');
if (p == path)
/* Two adjacent colons, or a colon at the beginning or the end
of `PATH' means to search the current directory. */
(void) memcpy(name, file, len);
else
{
/* Construct the pathname to try. */
(void) memcpy(name, path, p - path);
name[p - path] = '/';
(void) memcpy(&name[(p - path) + 1], file, len);
}
if (stat(name, &st) == 0 && S_ISREG(st.st_mode))
{
int bit = S_IXOTH;
if (st.st_uid == uid)
bit = S_IXUSR;
else if (st.st_gid == gid)
bit = S_IXGRP;
else
{
register int i;
for (i = 0; i < ngroups; ++i)
if (st.st_gid == groups[i])
{
bit = S_IXGRP;
break;
}
}
if (st.st_mode & bit)
{
file = name;
break;
}
}
} while (*p++ != '\0');
}
return __execve(file, argv, __environ);
}

View File

@@ -0,0 +1,171 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/* IGNORE(@ */
#include <ansidecl.h>
/* @) */
#include <errno.h>
#include <fnmatch.h>
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
extern int errno;
#endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
int
DEFUN(fnmatch, (pattern, string, flags),
CONST char *pattern AND CONST char *string AND int flags)
{
register CONST char *p = pattern, *n = string;
register char c;
if ((flags & ~__FNM_FLAGS) != 0)
{
errno = EINVAL;
return -1;
}
while ((c = *p++) != '\0')
{
switch (c)
{
case '?':
if (*n == '\0')
return FNM_NOMATCH;
else if ((flags & FNM_PATHNAME) && *n == '/')
return FNM_NOMATCH;
else if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
return FNM_NOMATCH;
break;
case '\\':
if (!(flags & FNM_NOESCAPE))
c = *p++;
if (*n != c)
return FNM_NOMATCH;
break;
case '*':
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
if (((flags & FNM_PATHNAME) && *n == '/') ||
(c == '?' && *n == '\0'))
return FNM_NOMATCH;
if (c == '\0')
return 0;
{
char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
for (--p; *n != '\0'; ++n)
if ((c == '[' || *n == c1) &&
fnmatch(p, n, flags & ~FNM_PERIOD) == 0)
return 0;
return FNM_NOMATCH;
}
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
register int not;
if (*n == '\0')
return FNM_NOMATCH;
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
return FNM_NOMATCH;
not = (*p == '!' || *p == '^');
if (not)
++p;
c = *p++;
for (;;)
{
register char cstart = c, cend = c;
if (!(flags & FNM_NOESCAPE) && c == '\\')
cstart = cend = *p++;
if (c == '\0')
/* [ (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
if ((flags & FNM_PATHNAME) && c == '/')
/* [/] can never match. */
return FNM_NOMATCH;
if (c == '-' && *p != ']')
{
cend = *p++;
if (!(flags & FNM_NOESCAPE) && cend == '\\')
cend = *p++;
if (cend == '\0')
return FNM_NOMATCH;
c = *p++;
}
if (*n >= cstart && *n <= cend)
goto matched;
if (c == ']')
break;
}
if (!not)
return FNM_NOMATCH;
break;
matched:;
/* Skip the rest of the [...] that already matched. */
while (c != ']')
{
if (c == '\0')
/* [... (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
if (!(flags & FNM_NOESCAPE) && c == '\\')
/* 1003.2d11 is unclear if this is right. %%% */
++p;
}
if (not)
return FNM_NOMATCH;
}
break;
default:
if (c != *n)
return FNM_NOMATCH;
}
++n;
}
if (*n == '\0')
return 0;
return FNM_NOMATCH;
}

View File

@@ -0,0 +1,37 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
/* Bits set in the FLAGS argument to `fnmatch'. */
#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD)
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int EXFUN(fnmatch, (CONST char *__pattern, CONST char *__string,
int __flags));
#endif /* fnmatch.h */

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <unistd.h>
#undef fork
function_alias(fork, __fork, __pid_t, (),
DEFUN_VOID(fork))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef fpathconf
function_alias(fpathconf, __fpathconf, long int, (fd, name),
DEFUN(fpathconf, (fd, name), int fd AND int name))

View File

@@ -0,0 +1,134 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
struct conf
{
CONST char *name;
CONST int call_name;
CONST enum { SYSCONF, CONFSTR, PATHCONF } call;
};
static struct conf vars[] =
{
{ "LINK_MAX", _PC_LINK_MAX, PATHCONF },
{ "MAX_CANON", _PC_MAX_CANON, PATHCONF },
{ "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
{ "NAME_MAX", _PC_NAME_MAX, PATHCONF },
{ "PATH_MAX", _PC_PATH_MAX, PATHCONF },
{ "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
{ "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
{ "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
{ "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
{ "ARG_MAX", _SC_ARG_MAX, SYSCONF },
{ "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
{ "CLK_TCK", _SC_CLK_TCK, SYSCONF },
{ "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
{ "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
{ "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
{ "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
{ "_POSIX_VERSION", _SC_VERSION, SYSCONF },
{ "PATH", _CS_PATH, CONFSTR },
{ NULL, 0, SYSCONF }
};
static CONST char *program;
static void
DEFUN_VOID(usage)
{
fprintf(stderr, "Usage: %s variable_name [pathname]\n", program);
exit(2);
}
int
DEFUN(main, (argc, argv), int argc AND char **argv)
{
register CONST struct conf *c;
program = strrchr(argv[0], '/');
if (program == NULL)
program = argv[0];
else
++program;
if (argc < 2 || argc > 3)
usage();
for (c = vars; c->name != NULL; ++c)
if (!strcmp(c->name, argv[1]))
{
long int value;
size_t clen;
char *cvalue;
switch (c->call)
{
case PATHCONF:
if (argc < 3)
usage();
value = pathconf(argv[2], c->call_name);
if (value == -1)
{
fprintf(stderr, "%s: pathconf: %s: %s\n",
program, argv[2], strerror(errno));
exit(3);
}
printf("%ld\n", value);
exit(0);
case SYSCONF:
if (argc > 2)
usage();
value = sysconf(c->call_name);
printf("%ld\n", value);
exit(0);
case CONFSTR:
if (argc > 2)
usage();
clen = confstr(c->call_name, (char *) NULL, 0);
cvalue = (char *) malloc(clen);
if (cvalue == NULL)
{
fprintf(stderr, "%s: malloc: %s\n",
program, strerror(errno));
exit(3);
}
if (confstr(c->call_name, cvalue, clen) != clen)
{
fprintf(stderr, "%s: confstr: %s\n",
program, strerror(errno));
exit(3);
}
printf("%.*s\n", clen, cvalue);
exit(0);
}
}
fprintf(stderr, "%s: Unrecognized variable `%s'\n", program, argv[1]);
exit(2);
}

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef getegid
function_alias(getegid, __getegid, __gid_t, (), DEFUN_VOID(getegid))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef geteuid
function_alias(geteuid, __geteuid, __uid_t, (), DEFUN_VOID(geteuid))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef getgid
function_alias(getgid, __getgid, __gid_t, (), DEFUN_VOID(getgid))

View File

@@ -0,0 +1,24 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
function_alias(getgroups, __getgroups, int, (size, list),
DEFUN(getgroups, (size, list), int size AND __gid_t *list))

View File

@@ -0,0 +1,678 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if defined(sparc) && !defined(USG) && !defined(SVR4) && !defined(__svr4__)
#include <alloca.h>
#else
#ifdef _AIX
#pragma alloca
#else
char *alloca ();
#endif
#endif /* sparc */
#endif /* not __GNUC__ */
#ifdef LIBC
/* For when compiled as part of the GNU C library. */
#include <ansidecl.h>
#endif
#include <stdio.h>
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#undef alloca
#include <stdlib.h>
#include <string.h>
#else /* Not GNU C library. */
#define __alloca alloca
#endif /* GNU C library. */
#ifndef __STDC__
#define const
#endif
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
long-named option. Because this is not POSIX.2 compliant, it is
being phased out. */
#define GETOPT_COMPAT
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
#include "getopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = 0;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
int optind = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
#ifdef __GNU_LIBRARY__
#include <string.h>
#define my_index strchr
#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
#else
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
static char *
my_index (string, chr)
char *string;
int chr;
{
while (*string)
{
if (*string == chr)
return string;
string++;
}
return 0;
}
static void
my_bcopy (from, to, size)
char *from, *to;
int size;
{
int i;
for (i = 0; i < size; i++)
to[i] = from[i];
}
#endif /* GNU C library. */
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first of them;
`last_nonopt' is the index after the last of them. */
static int first_nonopt;
static int last_nonopt;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
static void
exchange (argv)
char **argv;
{
int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
char **temp = (char **) __alloca (nonopts_size);
/* Interchange the two blocks of data in ARGV. */
my_bcopy (&argv[first_nonopt], temp, nonopts_size);
my_bcopy (&argv[last_nonopt], &argv[first_nonopt],
(optind - last_nonopt) * sizeof (char *));
my_bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size);
/* Update records for the slots the non-options now occupy. */
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
It is only valid when a long-named option has been found by the most
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
int option_index;
optarg = 0;
/* Initialize the internal data when the first call is made.
Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
if (optind == 0)
{
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (getenv ("POSIXLY_CORRECT") != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
}
if (nextchar == NULL || *nextchar == '\0')
{
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
exchange them so that the options come first. */
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (last_nonopt != optind)
first_nonopt = optind;
/* Now skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
optind++;
last_nonopt = optind;
}
/* Special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
if (optind != argc && !strcmp (argv[optind], "--"))
{
optind++;
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (first_nonopt == last_nonopt)
first_nonopt = optind;
last_nonopt = argc;
optind = argc;
}
/* If we have done all the ARGV-elements, stop the scan
and back over any non-options that we skipped and permuted. */
if (optind == argc)
{
/* Set the next-arg-index to point at the non-options
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
#ifdef GETOPT_COMPAT
&& (longopts == NULL
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
#endif /* GETOPT_COMPAT */
)
{
if (ordering == REQUIRE_ORDER)
return EOF;
optarg = argv[optind++];
return 1;
}
/* We have found another option-ARGV-element.
Start decoding its characters. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
if (longopts != NULL
&& ((argv[optind][0] == '-'
&& (argv[optind][1] == '-' || long_only))
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
))
{
const struct option *p;
char *s = nextchar;
int exact = 0;
int ambig = 0;
const struct option *pfound = NULL;
int indfound;
while (*s && *s != '=')
s++;
/* Test all options for either exact match or abbreviated matches. */
for (p = longopts, option_index = 0; p->name;
p++, option_index++)
if (!strncmp (p->name, nextchar, s - nextchar))
{
if (s - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
indfound = option_index;
exact = 1;
break;
}
else if (pfound == NULL)
{
/* First nonexact match found. */
pfound = p;
indfound = option_index;
}
else
/* Second nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, "%s: option `%s' is ambiguous\n",
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
return '?';
}
if (pfound != NULL)
{
option_index = indfound;
optind++;
if (*s)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = s + 1;
else
{
if (opterr)
{
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
"%s: option `--%s' doesn't allow an argument\n",
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
"%s: option `%c%s' doesn't allow an argument\n",
argv[0], argv[optind - 1][0], pfound->name);
}
nextchar += strlen (nextchar);
return '?';
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr, "%s: option `%s' requires an argument\n",
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
#ifdef GETOPT_COMPAT
|| argv[optind][0] == '+'
#endif /* GETOPT_COMPAT */
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, "%s: unrecognized option `--%s'\n",
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
argv[0], argv[optind][0], nextchar);
}
nextchar += strlen (nextchar);
optind++;
return '?';
}
}
/* Look at and handle the next option-character. */
{
char c = *nextchar++;
char *temp = my_index (optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0')
optind++;
if (temp == NULL || c == ':')
{
if (opterr)
{
if (c < 040 || c >= 0177)
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
argv[0], c);
else
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
}
return '?';
}
if (temp[1] == ':')
{
if (temp[2] == ':')
{
/* This is an option that accepts an argument optionally. */
if (*nextchar != '\0')
{
optarg = nextchar;
optind++;
}
else
optarg = 0;
nextchar = NULL;
}
else
{
/* This is an option that requires an argument. */
if (*nextchar != 0)
{
optarg = nextchar;
/* If we end this ARGV-element by taking the rest as an arg,
we must advance to the next element now. */
optind++;
}
else if (optind == argc)
{
if (opterr)
fprintf (stderr, "%s: option `-%c' requires an argument\n",
argv[0], c);
c = '?';
}
else
/* We already incremented `optind' once;
increment it again when taking next ARGV-elt as argument. */
optarg = argv[optind++];
nextchar = NULL;
}
}
return c;
}
}
int
getopt (argc, argv, optstring)
int argc;
char *const *argv;
const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0);
}
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
break;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@@ -0,0 +1,113 @@
/* Declarations for getopt.
Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _GETOPT_H_
#define _GETOPT_H_
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#ifdef __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
enum _argtype
{
no_argument,
required_argument,
optional_argument
};
#ifdef __STDC__
extern int getopt (int argc, char *const *argv, const char *shortopts);
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* not __STDC__ */
#endif /* _GETOPT_H_ */

View File

@@ -0,0 +1,158 @@
/* Getopt for GNU.
Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef LIBC
/* For when compiled as part of the GNU C library. */
#include <ansidecl.h>
#endif
#include "getopt.h"
#ifndef __STDC__
#define const
#endif
#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || defined (LIBC)
#include <stdlib.h>
#else /* STDC_HEADERS or __GNU_LIBRARY__ */
char *getenv ();
#endif /* STDC_HEADERS or __GNU_LIBRARY__ */
#if !defined (NULL)
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == EOF)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <unistd.h>
#undef getpid
function_alias(getpid, __getpid, __pid_t, (),
DEFUN_VOID(getpid))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef getppid
function_alias(getppid, __getppid, __pid_t, (), DEFUN_VOID(getppid))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef getuid
function_alias(getuid, __getuid, __uid_t, (), DEFUN_VOID(getuid))

View File

@@ -0,0 +1,567 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/* IGNORE(@ */
#include <ansidecl.h>
/* @) */
#include <glob.h>
#include <fnmatch.h>
#ifdef SHELL
#include "config.h"
#endif
#include <errno.h>
#ifdef __GNU_LIBRARY__
#include <stddef.h>
#endif
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
extern int errno;
#endif
#if defined (USGr3) && !defined (DIRENT)
#define DIRENT
#endif /* USGr3 and not DIRENT. */
#if defined (Xenix) && !defined (SYSNDIR)
#define SYSNDIR
#endif /* Xenix and not SYSNDIR. */
#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__)
#ifdef USG
#include <sys/types.h>
#endif
#include <dirent.h>
#else
#if defined (USG) && !defined (sgi)
#ifdef SYSNDIR
#include <sys/ndir.h>
#else /* not SYSNDIR */
#include "ndir.h"
#endif /* SYSNDIR */
#else /* not USG */
#include <sys/types.h>
#include <sys/dir.h>
#endif /* USG */
#undef dirent
#define dirent direct
#endif /* POSIX or DIRENT or __GNU_LIBRARY__ */
#if defined(__GNU_LIBRARY__) || !defined(POSIX) && !defined(USG)
#define D_NAMLEN(d) ((d)->d_namlen)
#else
#define D_NAMLEN(d) strlen((d)->d_name)
#endif
#ifndef NULL
#define NULL 0
#endif
#if defined(POSIX) && !defined(__GNU_LIBRARY__)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
#define REAL_DIR_ENTRY(dp) 1
#else
#define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
#endif
#if defined(__GNU_LIBRARY__) || defined(POSIX)
#include <unistd.h>
#endif
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
#include <stdlib.h>
#include <string.h>
#define STDC_STRINGS
#else /* Not STDC_HEADERS and not __GNU_LIBRARY__. */
#ifdef USG
#include <string.h>
#ifndef POSIX
#include <memory.h>
#endif /* Not POSIX. */
#define STDC_STRINGS
#else /* Not USG. */
#ifdef NeXT
#include <string.h>
#else /* Not NeXT. */
#include <strings.h>
#endif /* NeXT. */
/* Declaring bcopy causes errors on systems whose declarations are different.
If the declaration is omitted, everything works fine. */
#endif /* Not USG. */
extern char *malloc ();
extern char *realloc ();
extern void free ();
extern void qsort ();
#ifdef __GNUC__
__inline
#endif
static char *
my_realloc (p, n)
char *p;
unsigned int n;
{
if (p == NULL)
return malloc (n);
return realloc (p, n);
}
#define realloc my_realloc
#define strcoll strcmp
#endif /* Not STDC_HEADERS or __GNU_LIBRARY__. */
#ifndef STDC_STRINGS
#define memcpy(d, s, n) bcopy((s), (d), (n))
#define strrchr rindex
/* memset is only used for zero here, but let's be paranoid. */
#define memset(s, better_be_zero, n) \
((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
#endif
#if !defined(__alloca) && !defined(__GNU_LIBRARY__)
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* Not GCC. */
#ifdef sparc
#include <alloca.h>
#else /* Not sparc. */
extern char *alloca ();
#endif /* sparc. */
#endif /* GCC. */
#define __alloca alloca
#endif
#ifndef __STDC__
#undef size_t
#define size_t unsigned int
#endif
static int EXFUN(glob_pattern_p, (CONST char *pattern, int quote));
static int EXFUN(glob_in_dir, (CONST char *pattern, CONST char *directory,
int flags,
int EXFUN((*errfunc), (CONST char *, int)),
glob_t *pglob));
static int EXFUN(prefix_array, (CONST char *prefix, char **array, size_t n));
static int EXFUN(collated_compare, (CONST PTR, CONST PTR));
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
it is called with the pathname that caused the error, and the
`errno' value from the failing call; if it returns non-zero
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
int
DEFUN(glob, (pattern, flags, errfunc, pglob),
CONST char *pattern AND int flags AND
int EXFUN((*errfunc), (CONST char *, int)) AND
glob_t *pglob)
{
CONST char *filename;
char *dirname;
size_t dirlen;
int status;
int oldcount;
if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
{
errno = EINVAL;
return -1;
}
/* Find the filename. */
filename = strrchr(pattern, '/');
if (filename == NULL)
{
filename = pattern;
dirname = (char *) ".";
dirlen = 0;
}
else if (filename == pattern)
{
/* "/pattern". */
dirname = (char *) "/";
dirlen = 1;
++filename;
}
else
{
dirlen = filename - pattern;
dirname = (char *) __alloca(dirlen + 1);
memcpy(dirname, pattern, dirlen);
dirname[dirlen] = '\0';
++filename;
}
if (filename[0] == '\0' && dirlen > 1)
/* "pattern/". Expand "pattern", appending slashes. */
return glob(dirname, flags|GLOB_MARK, errfunc, pglob);
if (!(flags & GLOB_APPEND))
{
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
}
oldcount = pglob->gl_pathc;
if (glob_pattern_p(dirname, !(flags & GLOB_NOESCAPE)))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
the pattern in each directory found. */
glob_t dirs;
register int i;
status = glob(dirname, ((flags & (GLOB_ERR|GLOB_NOCHECK|GLOB_NOESCAPE)) |
GLOB_NOSORT),
errfunc, &dirs);
if (status != 0)
return status;
/* We have successfully globbed the preceding directory name.
For each name we found, call glob_in_dir on it and FILENAME,
appending the results to PGLOB. */
for (i = 0; i < dirs.gl_pathc; ++i)
{
int oldcount;
#ifdef SHELL
{
/* Make globbing interruptible in the bash shell. */
extern int interrupt_state;
if (interrupt_state)
{
globfree (&dirs);
globfree (&files);
return GLOB_ABEND;
}
}
#endif /* SHELL. */
oldcount = pglob->gl_pathc;
status = glob_in_dir(filename, dirs.gl_pathv[i],
(flags | GLOB_APPEND) & ~GLOB_NOCHECK,
errfunc, pglob);
if (status == GLOB_NOMATCH)
/* No matches in this directory. Try the next. */
continue;
if (status != 0)
{
globfree (&dirs);
globfree (pglob);
return status;
}
/* Stick the directory on the front of each name. */
if (prefix_array(dirs.gl_pathv[i],
&pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount))
{
globfree (&dirs);
globfree (pglob);
return GLOB_NOSPACE;
}
}
if (pglob->gl_pathc == oldcount)
/* No matches. */
if (flags & GLOB_NOCHECK)
{
CONST size_t len = strlen (pattern) + 1;
char *patcopy = (char *) malloc (len);
if (patcopy == NULL)
return GLOB_NOSPACE;
memcpy (patcopy, pattern, len);
pglob->gl_pathv
= (char **) realloc(pglob->gl_pathv,
(pglob->gl_pathc +
((flags & GLOB_DOOFFS) ?
pglob->gl_offs : 0) +
1 + 1) *
sizeof(char *));
if (pglob->gl_pathv == NULL)
{
free (patcopy);
return GLOB_NOSPACE;
}
if (flags & GLOB_DOOFFS)
while (pglob->gl_pathc < pglob->gl_offs)
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
pglob->gl_pathv[pglob->gl_pathc++] = patcopy;
return 0;
}
else
return GLOB_NOMATCH;
}
else
{
status = glob_in_dir(filename, dirname, flags, errfunc, pglob);
if (status != 0)
return status;
if (dirlen > 0)
{
/* Stick the directory on the front of each name. */
if (prefix_array(dirname,
&pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount))
{
globfree (pglob);
return GLOB_NOSPACE;
}
}
}
if (!(flags & GLOB_NOSORT))
qsort((PTR) &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount,
sizeof(char *), collated_compare);
return 0;
}
/* Free storage allocated in PGLOB by a previous `glob' call. */
void
DEFUN(globfree, (pglob), register glob_t *pglob)
{
if (pglob->gl_pathv != NULL)
{
register int i;
for (i = 0; i < pglob->gl_pathc; ++i)
if (pglob->gl_pathv[i] != NULL)
free((PTR) pglob->gl_pathv[i]);
free((PTR) pglob->gl_pathv);
}
}
/* Do a collated comparison of A and B. */
static int
DEFUN(collated_compare, (a, b), CONST PTR a AND CONST PTR b)
{
CONST char *CONST s1 = *(CONST char *CONST *CONST) a;
CONST char *CONST s2 = *(CONST char *CONST *CONST) b;
if (s1 == s2)
return 0;
if (s1 == NULL)
return 1;
if (s2 == NULL)
return -1;
return strcoll (s1, s2);
}
/* Prepend PREFIX to each of N members of ARRAY, replacing ARRAY's
elements in place. Return nonzero if out of memory, zero if successful.
A slash is inserted between PREFIX and each elt of ARRAY.
Each old element of ARRAY is freed. */
static int
DEFUN(prefix_array, (prefix, array, n),
CONST char *prefix AND char **array AND CONST size_t n)
{
register size_t i;
CONST size_t prelen = strlen(prefix);
for (i = 0; i < n; ++i)
{
CONST size_t eltlen = strlen(array[i]) + 1;
char *new = (char *) malloc(prelen + 1 + eltlen);
if (new == NULL)
{
while (i > 0)
free((PTR) array[--i]);
return 1;
}
memcpy(new, prefix, prelen);
new[prelen] = '/';
memcpy(&new[prelen + 1], array[i], eltlen);
free((PTR) array[i]);
array[i] = new;
}
return 0;
}
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
static int
DEFUN(glob_pattern_p, (pattern, quote),
CONST char *pattern AND CONST int quote)
{
register CONST char *p;
int open = 0;
for (p = pattern; *p != '\0'; ++p)
switch (*p)
{
case '?':
case '*':
return 1;
case '\\':
if (quote)
++p;
break;
case '[':
open = 1;
break;
case ']':
if (open)
return 1;
break;
}
return 0;
}
/* Like `glob', but PATTERN is a final pathname component,
and matches are searched for in DIRECTORY.
The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
The GLOB_APPEND flag is assumed to be set (always appends). */
static int
DEFUN(glob_in_dir, (pattern, directory, flags, errfunc, pglob),
CONST char *pattern AND CONST char *directory AND int flags AND
int EXFUN((*errfunc), (CONST char *, int)) AND glob_t *pglob)
{
register DIR *stream;
register struct dirent *d;
struct globlink
{
struct globlink *next;
char *name;
};
struct globlink *names = NULL;
size_t nfound = 0;
if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
{
stream = NULL;
flags |= GLOB_NOCHECK;
}
else
{
stream = opendir(directory);
if (stream == NULL)
{
if ((errfunc != NULL && (*errfunc)(directory, errno)) ||
(flags & GLOB_ERR))
return GLOB_ABEND;
}
else
while ((d = readdir(stream)) != NULL)
if (REAL_DIR_ENTRY (d) &&
fnmatch(pattern, d->d_name,
(!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
{
struct globlink *new = (struct globlink *)
__alloca(sizeof (struct globlink));
size_t len = D_NAMLEN (d);
new->name = (char *) malloc(len +
((flags & GLOB_MARK) ? 1 : 0) + 1);
if (new->name == NULL)
goto memory_error;
memcpy ((PTR) new->name, d->d_name, len);
if (flags & GLOB_MARK)
new->name[len++] = '/';
new->name[len] = '\0';
new->next = names;
names = new;
++nfound;
}
}
if (nfound == 0 && (flags & GLOB_NOCHECK))
{
size_t len = strlen (pattern);
nfound = 1;
names = (struct globlink *) __alloca (sizeof (struct globlink));
names->next = NULL;
names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
if (names->name == NULL)
goto memory_error;
memcpy (names->name, pattern, len);
if (flags & GLOB_MARK)
names->name[len++] = '/';
names->name[len] = '\0';
}
pglob->gl_pathv
= (char **) realloc(pglob->gl_pathv,
(pglob->gl_pathc +
((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
nfound + 1) *
sizeof(char *));
if (pglob->gl_pathv == NULL)
goto memory_error;
if (flags & GLOB_DOOFFS)
while (pglob->gl_pathc < pglob->gl_offs)
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
for (; names != NULL; names = names->next)
pglob->gl_pathv[pglob->gl_pathc++] = names->name;
pglob->gl_pathv[pglob->gl_pathc] = NULL;
if (stream != NULL)
{
int save = errno;
(void) closedir (stream);
errno = save;
}
return nfound == 0 ? GLOB_NOMATCH : 0;
memory_error:
{
int save = errno;
(void) closedir (stream);
errno = save;
}
while (names != NULL)
{
if (names->name != NULL)
free((PTR) names->name);
names = names->next;
}
return GLOB_NOSPACE;
}

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _GLOB_H
#define _GLOB_H 1
/* Bits set in the FLAGS argument to `glob'. */
#define GLOB_ERR (1 << 0)/* Return on read errors. */
#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
#define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|GLOB_PERIOD)
/* Error returns from `glob'. */
#define GLOB_NOSPACE 1 /* Ran out of memory. */
#define GLOB_ABEND 2 /* Read error. */
#define GLOB_NOMATCH 3 /* No matches found. */
/* Structure describing a globbing run. */
typedef struct
{
int gl_pathc; /* Count of paths matched by the pattern. */
char **gl_pathv; /* List of matched pathnames. */
int gl_offs; /* Slots to reserve in `gl_pathv'. */
} glob_t;
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
it is called with the pathname that caused the error, and the
`errno' value from the failing call; if it returns non-zero
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
extern int EXFUN(glob, (CONST char *__pattern, int __flags,
int EXFUN((*__errfunc), (CONST char *, int)),
glob_t *__pglob));
/* Free storage allocated in PGLOB by a previous `glob' call. */
extern void EXFUN(globfree, (glob_t *__pglob));
#endif /* glob.h */

View File

@@ -0,0 +1,74 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _GNU_TYPES_H
#define _GNU_TYPES_H 1
/* Convenience types. */
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
typedef struct { long val[2]; } __quad;
typedef struct { __u_long val[2]; } __u_quad;
typedef short int __dev_t; /* Type of device numbers. */
typedef unsigned int __uid_t; /* Type of user identifications. */
typedef unsigned int __gid_t; /* Type of group identifications. */
typedef unsigned long int __ino_t; /* Type of file serial numbers. */
typedef unsigned short int __mode_t; /* Type of file attribute bitmasks. */
typedef unsigned short int __nlink_t; /* Type of file link counts. */
typedef long int __off_t; /* Type of file sizes and offsets. */
typedef int __pid_t; /* Type of process identifications. */
typedef int __ssize_t; /* Type of a byte count, or error. */
/* Everythin' else. */
typedef long int __daddr_t; /* The type of a disk address. */
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t; /* Type of a swap block maybe? */
/* fd_set for select. */
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 256
/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
#define __NFDBITS (sizeof(unsigned long int) * 8)
#define __FDELT(d) ((d) / __NFDBITS)
#define __FDMASK(d) (1 << ((d) % __NFDBITS))
typedef struct
{
unsigned long int __bits[(__FD_SETSIZE + (__NFDBITS - 1)) / __NFDBITS];
} __fd_set;
/* This line MUST be split! Otherwise m4 will not change it. */
#define __FD_ZERO(set) \
((void) memset((PTR) (set), 0, sizeof(fd_set)))
#define __FD_SET(d, set) ((set)->__bits[__FDELT(d)] |= __FDMASK(d))
#define __FD_CLR(d, set) ((set)->__bits[__FDELT(d)] &= ~__FDMASK(d))
#define __FD_ISSET(d, set) ((set)->__bits[__FDELT(d)] & __FDMASK(d))
#endif /* gnu/types.h */

View File

@@ -0,0 +1,62 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _GNU_WAIT_H
#define _GNU_WAIT_H 1
#include <gnu/types.h>
/* Bits in the third argument to waitpid. */
#define __WNOHANG 1 /* Don't block waiting. */
#define __WUNTRACED 2 /* Report status of stopped children. */
/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
/* If WIFSIGNALED(STATUS), the terminating signal. */
#define __WTERMSIG(status) ((status) & 0x7f)
/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
#define __WSTOPSIG(status) __WEXITSTATUS(status)
/* Nonzero if STATUS indicates normal termination. */
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
/* Nonzero if STATUS indicates termination by a signal. */
#ifdef __GNUC__
#define __WIFSIGNALED(status) \
(__extension__ ({ int __stat = (status); \
!WIFSTOPPED(__stat) && !WIFEXITED(__stat); }))
#else /* Not GCC. */
#define __WIFSIGNALED(status) (!__WIFSTOPPED(status) && !__WIFEXITED(status))
#endif /* GCC. */
/* Nonzero if STATUS indicates the child is stopped. */
#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
/* Nonzero if STATUS indicated the child dumped core. */
#define __WCOREDUMP(status) ((status) & 0200)
/* Macros for constructing status values. */
#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif /* gnu/wait.h */

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef pathconf
function_alias(pathconf, __pathconf, long int, (path, name),
DEFUN(pathconf, (path, name), CONST char *path AND int name))

View File

@@ -0,0 +1,87 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 2.9.2 Minimum Values Added to <limits.h>
*/
#ifndef _POSIX1_LIMITS_H
#define _POSIX1_LIMITS_H 1
/* These are the standard-mandated minimum values. */
/* Maximum length of arguments to `execve', including environment. */
#define _POSIX_ARG_MAX 4096
/* Maximum simultaneous processes per real user ID. */
#define _POSIX_CHILD_MAX 6
/* Maximum link count of a file. */
#define _POSIX_LINK_MAX 8
/* Number of bytes in a terminal canonical input queue. */
#define _POSIX_MAX_CANON 255
/* Number of bytes for which space will be
available in a terminal input queue. */
#define _POSIX_MAX_INPUT 255
/* Number of simultaneous supplementary group IDs per process. */
#define _POSIX_NGROUPS_MAX 0
/* Number of files one process can have open at once. */
#define _POSIX_OPEN_MAX 16
/* Number of bytes in a filename. */
#define _POSIX_NAME_MAX 14
/* Number of bytes in a pathname. */
#define _POSIX_PATH_MAX 255
/* Number of bytes than can be written atomically to a pipe. */
#define _POSIX_PIPE_BUF 512
/* Largest value of a `ssize_t'. */
#define _POSIX_SSIZE_MAX 32767
/* Number of streams a process can have open at once. */
#define _POSIX_STREAM_MAX 8
/* Number of bytes in `tzname'. */
#define _POSIX_TZNAME_MAX 3
/* Get the implementation-specific values for the above. */
#include <local_lim.h>
#ifndef SSIZE_MAX
#define SSIZE_MAX INT_MAX
#endif
/* This value is a guaranteed minimum maximum.
The current maximum can be got from `sysconf'. */
#ifndef NGROUPS_MAX
#define NGROUPS_MAX _POSIX_NGROUPS_MAX
#endif
#endif /* posix1_limits.h */

View File

@@ -0,0 +1,82 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _POSIX2_LIMITS_H
#define _POSIX2_LIMITS_H 1
/* The maximum `ibase' and `obase' values allowed by the `bc' utility. */
#define _POSIX2_BC_BASE_MAX 99
/* The maximum number of elements allowed in an array by the `bc' utility. */
#define _POSIX2_BC_DIM_MAX 2048
/* The maximum `scale' value allowed by the `bc' utility. */
#define _POSIX2_BC_SCALE_MAX 99
/* The maximum length of a string constant accepted by the `bc' utility. */
#define _POSIX2_BC_STRING_MAX 1000
/* The maximum number of weights that can be assigned to an entry of
the LC_COLLATE category `order' keyword in a locale definition. */
#define _POSIX2_EQUIV_CLASS_MAX 2
/* The maximum number of expressions that can be nested
within parentheses by the `expr' utility. */
#define _POSIX2_EXPR_NEST_MAX 32
/* The maximum length, in bytes, of an input line. */
#define _POSIX2_LINE_MAX 2048
/* The maximum number of repeated occurrences of a regular expression
permitted when using the interval notation `\{M,N\}'. */
#define _POSIX2_RE_DUP_MAX 255
/* These values are implementation-specific,
and may vary within the implementation.
Their precise values can be obtained from sysconf. */
#ifndef BC_BASE_MAX
#define BC_BASE_MAX _POSIX2_BC_BASE_MAX
#endif
#ifndef BC_DIM_MAX
#define BC_DIM_MAX _POSIX2_BC_DIM_MAX
#endif
#ifndef BC_SCALE_MAX
#define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX
#endif
#ifndef BC_STRING_MAX
#define BC_STRING_MAX _POSIX2_BC_STRING_MAX
#endif
#ifndef EQUIV_CLASS_MAX
#define EQUIV_CLASS_MAX _POSIX2_EQUIV_CLASS_MAX
#endif
#ifndef EXPR_NEST_MAX
#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX
#endif
#ifndef LINE_MAX
#define LINE_MAX _POSIX2_LINE_MAX
#endif
#ifndef RE_DUP_MAX
#define RE_DUP_MAX _POSIX2_RE_DUP_MAX
#endif
#endif /* posix2_limits.h */

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef setgid
function_alias(setgid, __setgid, int, (gid),
DEFUN(setgid, (gid), __gid_t gid))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <sys/types.h>
#include <gnu-stabs.h>
#undef setpgid
function_alias(setpgid, __setpgrp, int, (pid, pgid),
DEFUN(setpgid, (pid, pgid), pid_t pid AND pid_t pgid))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <unistd.h>
#undef setpgrp
function_alias(setpgrp, setpgid, int, (pid, pgid),
DEFUN(setpgrp, (pid, pgid),
int pid AND int pgid))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef setsid
function_alias(setsid, __setsid, __pid_t, (),
DEFUN_VOID(setsid))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef setuid
function_alias(setuid, __setuid, int, (uid),
DEFUN(setuid, (uid), __uid_t uid))

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 4.5.2 Process Times <sys/times.h>
*/
#ifndef _SYS_TIMES_H
#define _SYS_TIMES_H 1
#include <features.h>
#define __need_clock_t
#include <time.h>
/* Structure describing CPU time used by a process and its children. */
struct tms
{
clock_t tms_utime; /* User CPU time. */
clock_t tms_stime; /* System CPU time. */
clock_t tms_cutime; /* User CPU time of dead children. */
clock_t tms_cstime; /* System CPU time of dead children. */
};
/* Store the CPU time used by this process and all its
dead children (and their dead children) in BUFFER.
Return the elapsed real time, or (clock_t) -1 for errors.
All times are in CLK_TCKths of a second. */
extern clock_t EXFUN(__times, (struct tms *buffer));
extern clock_t EXFUN(times, (struct tms *buffer));
#ifdef __OPTIMIZE__
#define times(buffer) __times(buffer)
#endif /* Optimizing. */
#endif /* sys/times.h */

View File

@@ -0,0 +1,88 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 2.6 Primitive System Data Types <sys/types.h>
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H 1
#include <features.h>
#include <gnu/types.h>
#ifdef __USE_BSD
#define u_char __u_char
#define u_short __u_short
#define u_int __u_int
#define u_long __u_long
#define quad __quad
#define u_quad __u_quad
#endif
#define dev_t __dev_t
#define gid_t __gid_t
#define ino_t __ino_t
#define mode_t __mode_t
#define nlink_t __nlink_t
#define off_t __off_t
#define pid_t __pid_t
#define uid_t __uid_t
#ifndef ssize_t
#define ssize_t __ssize_t
#endif
#ifdef __USE_BSD
#define daddr_t __daddr_t
#define caddr_t __caddr_t
#endif
#define __need_time_t
#include <time.h>
#define __need_size_t
#include <stddef.h>
#ifdef __USE_BSD
#define FD_SETSIZE __FD_SETSIZE
#define fd_set __fd_set
#define FD_ZERO(set) __FD_ZERO(set)
#define FD_SET(d, set) __FD_SET((d), (set))
#define FD_CLR(d, set) __FD_CLR((d), (set))
#define FD_ISSET(d, set)__FD_ISSET((d), (set))
#endif
#include <gnu/time.h>
/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
(if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
after waiting the interval specified therein. Returns the number of ready
descriptors, or -1 for errors. */
extern int EXFUN(__select, (int __nfds, __fd_set *__readfds,
__fd_set *__writefds, __fd_set *__exceptfds,
struct __timeval *__timeout));
#ifdef __USE_BSD
#define select __select
#endif /* Use BSD. */
#endif /* sys/types.h */

View File

@@ -0,0 +1,61 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 4.4 System Identification <sys/utsname.h>
*/
#ifndef _SYS_UTSNAME_H
#define _SYS_UTSNAME_H 1
#include <features.h>
/* The size of the character arrays used to hold the information
in a `struct utsname'. Enlarge this as necessary. */
#define _UTSNAME_LENGTH 100
/* Structure describing the system and machine. */
struct utsname
{
/* Name of the implementation of the operating system. */
char sysname[_UTSNAME_LENGTH];
/* Name of this node on the network. */
char nodename[_UTSNAME_LENGTH];
/* Current release level of this implementation. */
char release[_UTSNAME_LENGTH];
/* Current version level of this release. */
char version[_UTSNAME_LENGTH];
/* Name of the hardware type the system is running on. */
char machine[_UTSNAME_LENGTH];
};
/* Put information about the system in NAME. */
extern int EXFUN(uname, (struct utsname *__name));
/* Store the nodename in NAME, writing no more than LEN characters. */
extern int EXFUN(__uname_getnode, (char *__name, unsigned int __len));
#endif /* sys/utsname.h */

View File

@@ -0,0 +1,148 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h>
*/
#ifndef _SYS_WAIT_H
#define _SYS_WAIT_H 1
#include <features.h>
#include <gnu/types.h>
#include <gnu/wait.h>
#define WNOHANG __WNOHANG
#define WUNTRACED __WUNTRACED
/* Encoding of the status word. */
#include <endian.h>
#ifdef __USE_BSD
union __wait
{
#ifdef __LITTLE_ENDIAN
struct
{
unsigned int __w_termsig:7;
unsigned int __w_coredump:1;
unsigned int __w_retcode:8;
unsigned int :16;
} __wait_status;
#else /* Big endian. */
struct
{
unsigned int :16;
unsigned int __w_retcode:8;
unsigned int __w_coredump:1;
unsigned int __w_termsig:7;
} __wait_status;
#endif /* Little endian. */
};
#define w_termsig __wait_status.__w_termsig
#define w_coredump __wait_status.__w_coredump
#define w_retcode __wait_status.__w_retcode
#define w_stopsig w_retcode
#ifdef __GNUC__
#define __WAIT_INT(status) \
(__extension__ ({ union { __typeof(status) __in; int __i; } __u; \
__u.__in = (status); __u.__i; }))
#else
#define __WAIT_INT(status) (*(int *) &(status))
#endif
/* This is the type of the argument to `wait'.
With GCC v2, this will be a strange union. */
/* IGNORE(@This line MUST be split! m4 will not change it otherwise.@) */
#define __WAIT_STATUS \
PTR
#else /* Don't use BSD. */
#define __WAIT_INT(status) (status)
#define __WAIT_STATUS int *
#endif /* Use BSD. */
#define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))
#define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status))
#define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status))
#define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status))
#define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status))
#define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status))
#ifdef __USE_BSD
#define WCOREDUMP(status) __WCOREDUMP(__WAIT_INT(status))
#define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig)
#define W_STOPCODE(sig) __W_STOPCODE(sig)
#endif
/* Wait for a child to die. When one does, put its status in *STAT_LOC
and return its process ID. For errors, return (pid_t) -1. */
extern __pid_t EXFUN(__wait, (__WAIT_STATUS __stat_loc));
extern __pid_t EXFUN(wait, (__WAIT_STATUS __stat_loc));
#ifdef __USE_BSD
/* Special values for the PID argument to `waitpid' and `wait4'. */
#define WAIT_ANY (-1) /* Any process. */
#define WAIT_MYPGRP 0 /* Any process in my process group. */
#endif
/* Wait for a child matching PID to die.
If PID is greater than 0, match any process whose process ID is PID.
If PID is (pid_t) -1, match any process.
If PID is (pid_t) 0, match any process with the
same process group as the current process.
If PID is less than -1, match any process whose
process group is the absolute value of PID.
If the WNOHANG bit is set in OPTIONS, and that child
is not already dead, return (pid_t) 0. If successful,
return PID and store the dead child's status in STAT_LOC.
Return (pid_t) -1 for errors. If the WUNTRACED bit is
set in OPTIONS, return status for stopped children; otherwise don't. */
extern __pid_t EXFUN(__waitpid, (__pid_t __pid, int *__stat_loc,
int __options));
#ifdef __USE_BSD
/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
return its process ID. For errors return (pid_t) -1. If USAGE is not nil,
store information about the child's resource usage (as a `struct rusage')
there. If the WUNTRACED bit is set in OPTIONS, return status for stopped
children; otherwise don't. */
extern __pid_t EXFUN(__wait3, (union __wait *__stat_loc,
int __options, PTR __usage));
#define wait3 __wait3
/* PID is like waitpid. Other args are like wait3. */
extern __pid_t EXFUN(__wait4, (__pid_t __pid, union __wait *__stat_loc,
int __options, PTR __usage));
#define wait4 __wait4
#endif /* Use BSD. */
#define waitpid __waitpid
#define wait __wait
#endif /* sys/wait.h */

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <unistd.h>
#include <gnu-stabs.h>
#undef sysconf
function_alias(sysconf, __sysconf, long int, (name),
DEFUN(sysconf, (name), int name))

View File

@@ -0,0 +1,112 @@
/* Extended tar format from POSIX.1.
Copyright (C) 1992 Free Software Foundation, Inc.
Written by David J. MacKenzie.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _TAR_H
#define _TAR_H 1
/* A tar archive consists of 512-byte blocks.
Each file in the archive has a header block followed by 0+ data blocks.
Two blocks of NUL bytes indicate the end of the archive. */
/* The fields of header blocks:
All strings are stored as ISO 646 (approximately ASCII) strings.
Fields are numeric unless otherwise noted below; numbers are ISO 646
representations of octal numbers, with leading zeros as needed.
linkname is only valid when typeflag==LNKTYPE. It doesn't use prefix;
files that are links to pathnames >100 chars long can not be stored
in a tar archive.
If typeflag=={LNKTYPE,SYMTYPE,DIRTYPE} then size must be 0.
devmajor and devminor are only valid for typeflag=={BLKTYPE,CHRTYPE}.
chksum contains the sum of all 512 bytes in the header block,
treating each byte as an 8-bit unsigned value and treating the
8 bytes of chksum as blank characters.
uname and gname are used in preference to uid and gid, if those
names exist locally.
Field Name Byte Offset Length in Bytes Field Type
name 0 100 NUL-terminated if NUL fits
mode 100 8
uid 108 8
gid 116 8
size 124 12
mtime 136 12
chksum 148 8
typeflag 156 1 see below
linkname 157 100 NUL-terminated if NUL fits
magic 257 6 must be TMAGIC (NUL term.)
version 263 2 must be TVERSION
uname 265 32 NUL-terminated
gname 297 32 NUL-terminated
devmajor 329 8
devminor 337 8
prefix 345 155 NUL-terminated if NUL fits
If the first character of prefix is '\0', the file name is name;
otherwise, it is prefix/name. Files whose pathnames don't fit in that
length can not be stored in a tar archive. */
/* The bits in mode: */
#define TSUID 04000
#define TSGID 02000
#define TSVTX 01000
#define TUREAD 00400
#define TUWRITE 00200
#define TUEXEC 00100
#define TGREAD 00040
#define TGWRITE 00020
#define TGEXEC 00010
#define TOREAD 00004
#define TOWRITE 00002
#define TOEXEC 00001
/* The values for typeflag:
Values 'A'-'Z' are reserved for custom implementations.
All other values are reserved for future POSIX.1 revisions. */
#define REGTYPE '0' /* Regular file (preferred code). */
#define AREGTYPE '\0' /* Regular file (alternate code). */
#define LNKTYPE '1' /* Hard link. */
#define SYMTYPE '2' /* Symbolic link (hard if not supported). */
#define CHRTYPE '3' /* Character special. */
#define BLKTYPE '4' /* Block special. */
#define DIRTYPE '5' /* Directory. */
#define FIFOTYPE '6' /* Named pipe. */
#define CONTTYPE '7' /* Contiguous file */
/* (regular file if not supported). */
/* Contents of magic field and its length. */
#define TMAGIC "ustar"
#define TMAGLEN 6
/* Contents of the version field and its length. */
#define TVERSION "00"
#define TVERSLEN 2
#endif /* tar.h */

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <sys/times.h>
#undef times
function_alias(times, __times, clock_t, (buf),
DEFUN(times, (buf), struct tms *buf))

View File

@@ -0,0 +1 @@
-a -b -cfoobar

View File

@@ -0,0 +1,37 @@
#include <ansidecl.h>
#include <unistd.h>
#include <stdio.h>
int main (int argc, char **argv)
{
int aflag = 0;
int bflag = 0;
char *cvalue = NULL;
int index;
int c;
while ((c = getopt (argc, argv, "abc:")) >= 0)
switch (c) {
case 'a':
aflag = 1;
break;
case 'b':
bflag = 1;
break;
case 'c':
cvalue = optarg;
break;
case '?':
fprintf (stderr, "Unknown option %c.\n", optopt);
return -1;
default:
fprintf (stderr, "This should never happen!\n");
return -1;
}
printf ("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);
for (index = optind; index < argc; index++)
printf ("Non-option argument %s\n", argv[index]);
return 0;
}

View File

@@ -0,0 +1,621 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* POSIX Standard: 2.10 Symbolic Constants <unistd.h>
*/
#ifndef _UNISTD_H
#define _UNISTD_H 1
#include <features.h>
/* These may be used to determine what facilities are present at compile time.
Their values can be obtained at run time from sysconf. */
/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988. */
#define _POSIX_VERSION 199009L
#ifdef __USE_POSIX2
#define _POSIX2_C_VERSION 199912L /* Invalid until 1003.2 is done. */
/* If defined, the implementation supports the
C Language Bindings Option. */
#define _POSIX2_C_BIND 1
/* If defined, the implementation supports the
C Language Development Utilities Option. */
#define _POSIX2_C_DEV 1
/* If defined, the implementation supports the
FORTRAN Language Development Utilities Option. */
#define _POSIX2_FORT_DEV 1
/* If defined, the implementation supports the
Software Development Utilities Option. */
#define _POSIX2_SW_DEV 1
#endif
/* Get values of POSIX options:
If these symbols are defined, the corresponding features are
always available. If not, they may be available sometimes.
The current values can be obtained with `sysconf'.
_POSIX_JOB_CONTROL Job control is supported.
_POSIX_SAVED_IDS Processes have a saved set-user-ID
and a saved set-group-ID.
If any of these symbols is defined as -1, the corresponding option is not
true for any file. If any is defined as other than -1, the corresponding
option is true for all files. If a symbol is not defined at all, the value
for a specific file can be obtained from `pathconf' and `fpathconf'.
_POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
the owner of a file. `chown' can only be used
to change the group ID of a file to a group of
which the calling process is a member.
_POSIX_NO_TRUNC Pathname components longer than
NAME_MAX generate an error.
_POSIX_VDISABLE If defined, if the value of an element of the
`c_cc' member of `struct termios' is
_POSIX_VDISABLE, no character will have the
effect associated with that element.
*/
#include <posix_opt.h>
/* Standard file descriptors. */
#define STDIN_FILENO 0 /* Standard input. */
#define STDOUT_FILENO 1 /* Standard output. */
#define STDERR_FILENO 2 /* Standard error output. */
/* All functions that are not declared anywhere else. */
#include <gnu/types.h>
#ifndef ssize_t
#define ssize_t __ssize_t
#endif
#define __need_size_t
#include <stddef.h>
/* Values for the second argument to access.
These may be OR'd together. */
#define R_OK 4 /* Test for read permission. */
#define W_OK 2 /* Test for write permission. */
#define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */
/* Test for access to NAME. */
extern int EXFUN(__access, (CONST char *__name, int __type));
extern int EXFUN(access, (CONST char *__name, int __type));
#ifdef __OPTIMIZE__
#define access(name, type) __access((name), (type))
#endif /* Optimizing. */
/* Values for the WHENCE argument to lseek. */
#ifndef _STDIO_H /* <stdio.h> has the same definitions. */
#define SEEK_SET 0 /* Seek from beginning of file. */
#define SEEK_CUR 1 /* Seek from current position. */
#define SEEK_END 2 /* Seek from end of file. */
#endif
/* Move FD's file position to OFFSET bytes from the
beginning of the file (if WHENCE is SEEK_SET),
the current position (if WHENCE is SEEK_CUR),
or the end of the file (if WHENCE is SEEK_END).
Return the old file position. */
extern __off_t EXFUN(__lseek, (int __fd, __off_t __offset, int __whence));
extern __off_t EXFUN(lseek, (int __fd, __off_t __offset, int __whence));
/* Close the file descriptor FD. */
extern int EXFUN(__close, (int __fd));
extern int EXFUN(close, (int __fd));
/* Read NBYTES into BUF from FD. Return the
number read, -1 for errors or 0 for EOF. */
extern ssize_t EXFUN(__read, (int __fd, PTR __buf, size_t __nbytes));
extern ssize_t EXFUN(read, (int __fd, PTR __buf, size_t __nbytes));
/* Write N bytes of BUF to FD. Return the number written, or -1. */
extern ssize_t EXFUN(__write, (int __fd, CONST PTR __buf, size_t __n));
extern ssize_t EXFUN(write, (int __fd, CONST PTR __buf, size_t __n));
#ifdef __OPTIMIZE__
#define lseek(fd, offset, whence) __lseek((fd), (offset), (whence))
#define close(fd) __close(fd)
#define read(fd, buf, n) __read((fd), (buf), (n))
#define write(fd, buf, n) __write((fd), (buf), (n))
#endif /* Optimizing. */
/* Create a one-way communication channel (pipe).
If successul, two file descriptors are stored in PIPEDES;
bytes written on PIPEDES[1] can be read from PIPEDES[0].
Returns 0 if successful, -1 if not. */
extern int EXFUN(pipe, (int __pipedes[2]));
/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
If SECONDS is zero, any currently scheduled alarm will be cancelled.
The function returns the number of seconds remaining until the last
alarm scheduled would have signaled, or zero if there wasn't one.
There is no return value to indicate an error, but you can set `errno'
to 0 and check its value after calling `alarm', and this might tell you.
The signal may come late due to processor scheduling. */
extern unsigned int EXFUN(alarm, (unsigned int __seconds));
/* Make the process sleep for SECONDS seconds, or until a signal arrives
and is not ignored. The function returns the number of seconds less
than SECONDS which it actually slept (thus zero if it slept the full time).
If a signal handler does a `longjmp' or modifies the handling of the
SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
signal afterwards is undefined. There is no return value to indicate
error, but if `sleep' returns SECONDS, it probably didn't work. */
extern unsigned int EXFUN(sleep, (unsigned int __seconds));
/* Suspend the process until a signal arrives.
This always returns -1 and sets `errno' to EINTR. */
extern int EXFUN(pause, (NOARGS));
/* Change the owner and group of FILE. */
extern int EXFUN(chown, (CONST char *__file AND
__uid_t __owner AND __gid_t __group));
#ifdef __USE_BSD
/* Change the owner and group of the file that FD is open on. */
extern int EXFUN(fchown, (int __fd AND __uid_t __owner AND __gid_t __group));
#endif
/* Change the process's working directory to PATH. */
extern int EXFUN(chdir, (CONST char *__path));
/* Get the pathname of the current working directory,
and put it in SIZE bytes of BUF. Returns NULL if the
directory couldn't be determined or SIZE was too small.
If successful, returns BUF. In GNU, if BUF is NULL,
an array is allocated with `malloc'; the array is SIZE
bytes long, unless SIZE <= 0, in which case it is as
big as necessary. */
extern char *EXFUN(getcwd, (char *__buf, size_t __size));
#ifdef __USE_GNU
/* Return a malloc'd string containing the current directory name.
If the environment variable `PWD' is set, and its value is correct,
that value is used. */
extern char *EXFUN(get_current_dir_name, (NOARGS));
#endif
#ifdef __USE_BSD
/* Put the absolute pathname of the current working directory in BUF.
If successful, return BUF. If not, put an error message in
BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
extern char *EXFUN(getwd, (char *__buf));
#endif
/* Duplicate FD, returning a new file descriptor on the same file. */
extern int EXFUN(dup, (int __fd));
/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
extern int EXFUN(dup2, (int __fd, int __fd2));
/* NULL-terminated array of "NAME=VALUE" environment variables. */
extern char **__environ;
extern char **environ;
/* Replace the current process, executing PATH with arguments ARGV and
environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
extern int EXFUN(__execve, (CONST char *__path, char *CONST __argv[],
char *CONST __envp[]));
extern int EXFUN(execve, (CONST char *__path, char *CONST __argv[],
char *CONST __envp[]));
#define execve __execve
/* Execute PATH with arguments ARGV and environment from `environ'. */
extern int EXFUN(execv, (CONST char *__path, char *CONST __argv[]));
/* Execute PATH with all arguments after PATH until a NULL pointer,
and the argument after that for environment. */
extern int EXFUN(execle, (CONST char *__path, CONST char *__arg, ...));
/* Execute PATH with all arguments after PATH until
a NULL pointer and environment from `environ'. */
extern int EXFUN(execl, (CONST char *__path, CONST char *__arg, ...));
/* Execute FILE, searching in the `PATH' environment variable if it contains
no slashes, with arguments ARGV and environment from `environ'. */
extern int EXFUN(execvp, (CONST char *__file, char *CONST __argv[]));
/* Execute FILE, searching in the `PATH' environment variable if
it contains no slashes, with all arguments after FILE until a
NULL pointer and environment from `environ'. */
extern int EXFUN(execlp, (CONST char *__file, CONST char *arg, ...));
#ifndef __NORETURN
#ifdef __GNUC__
/* The `volatile' keyword tells GCC that a function never returns. */
#define __NORETURN __volatile
#else /* Not GCC. */
#define __NORETURN
#endif /* GCC. */
#endif /* __NORETURN not defined. */
/* Terminate program execution with the low-order 8 bits of STATUS. */
extern __NORETURN void EXFUN(_exit, (int __status));
/* Values for the NAME argument to `pathconf' and `fpathconf'.
These correspond to the _POSIX_* symbols above, but for
specific files or file descriptors. */
#define _PC_LINK_MAX 0
#define _PC_MAX_CANON 1
#define _PC_MAX_INPUT 2
#define _PC_NAME_MAX 3
#define _PC_PATH_MAX 4
#define _PC_PIPE_BUF 5
#define _PC_CHOWN_RESTRICTED 6
#define _PC_NO_TRUNC 7
#define _PC_VDISABLE 8
/* Get file-specific configuration information about PATH. */
extern long int EXFUN(__pathconf, (CONST char *__path, int __name));
extern long int EXFUN(pathconf, (CONST char *__path, int __name));
/* Get file-specific configuration about descriptor FD. */
extern long int EXFUN(__fpathconf, (int __fd, int __name));
extern long int EXFUN(fpathconf, (int __fd, int __name));
#define pathconf __pathconf
#define fpathconf __fpathconf
/* Values for the argument to `sysconf'.
These correspond to the _POSIX_* symbols in <posix_limits.h> and above,
but may vary at run time. */
enum
{
_SC_ARG_MAX,
_SC_CHILD_MAX,
_SC_CLK_TCK,
_SC_NGROUPS_MAX,
_SC_OPEN_MAX,
_SC_STREAM_MAX,
_SC_TZNAME_MAX,
_SC_JOB_CONTROL,
_SC_SAVED_IDS,
_SC_VERSION,
/* Values for the argument to `sysconf'
corresponding to _POSIX2_* symbols. */
_SC_BC_BASE_MAX,
_SC_BC_DIM_MAX,
_SC_BC_SCALE_MAX,
_SC_BC_STRING_MAX,
_SC_EQUIV_CLASS_MAX,
_SC_EXPR_NEST_MAX,
_SC_LINE_MAX,
_SC_RE_DUP_MAX,
_SC_2_VERSION,
_SC_2_C_BIND,
_SC_2_C_DEV,
_SC_2_FORT_DEV,
_SC_2_SW_DEV
};
/* Get the value of the system variable NAME. */
extern long int EXFUN(sysconf, (int __name));
#ifdef __USE_POSIX2
/* Values for the argument to `confstr'. */
#define _CS_PATH 0 /* The default search path. */
/* Get the value of the string-valued system variable NAME. */
extern size_t EXFUN(confstr, (int __name, char *__buf, size_t __len));
#endif
/* Get the process ID of the calling process. */
extern __pid_t EXFUN(__getpid, (NOARGS));
extern __pid_t EXFUN(getpid, (NOARGS));
/* Get the process ID of the calling process's parent. */
extern __pid_t EXFUN(__getppid, (NOARGS));
extern __pid_t EXFUN(getppid, (NOARGS));
#ifdef __OPTIMIZE__
#define getpid() __getpid()
#define getppid() __getppid()
#endif /* Optimizing. */
/* Get the process group ID of process PID. */
extern __pid_t EXFUN(__getpgrp, (__pid_t __pid));
#ifndef __FAVOR_BSD
/* Get the process group ID of the calling process. */
extern __pid_t EXFUN(getpgrp, (NOARGS));
#else /* Favor BSD. */
#define getpgrp(pid) __getpgrp(pid)
#endif
/* Set the process group ID of the process matching PID to PGID.
If PID is zero, the current process's process group ID is set.
If PGID is zero, the process ID of the process is used. */
extern int EXFUN(setpgid, (__pid_t __pid, __pid_t __pgid));
#ifdef __USE_BSD
/* Set the process group of PID to PGRP. */
extern int EXFUN(setpgrp, (__pid_t __pid, __pid_t __pgrp));
#ifdef __OPTIMIZE__
#define setpgrp(pid, pgrp) setpgid((pid), (pgrp))
#endif /* Optimizing. */
#endif /* Use BSD. */
/* Create a new session with the calling process as its leader.
The process group IDs of the session and the calling process
are set to the process ID of the calling process, which is returned. */
extern __pid_t EXFUN(setsid, (NOARGS));
/* Get the real user ID of the calling process. */
extern __uid_t EXFUN(getuid, (NOARGS));
/* Get the effective user ID of the calling process. */
extern __uid_t EXFUN(geteuid, (NOARGS));
/* Get the real group ID of the calling process. */
extern __gid_t EXFUN(getgid, (NOARGS));
/* Get the effective group ID of the calling process. */
extern __gid_t EXFUN(getegid, (NOARGS));
/* If SIZE is zero, return the number of supplementary groups
the calling process is in. Otherwise, fill in the group IDs
of its supplementary groups in LIST and return the number written. */
extern int EXFUN(getgroups, (int __size, __gid_t __list[]));
/* Set the user ID of the calling process to UID.
If the calling process is the super-user, set the real
and effective user IDs, and the saved set-user-ID to UID;
if not, the effective user ID is set to UID. */
extern int EXFUN(setuid, (__uid_t __uid));
#ifdef __USE_BSD
/* Set the real user ID of the calling process to RUID,
and the effective user ID of the calling process to EUID. */
extern int EXFUN(__setreuid, (__uid_t __ruid, __uid_t __euid));
extern int EXFUN(setreuid, (__uid_t __ruid, __uid_t __euid));
#define setreuid __setreuid
#endif /* Use BSD. */
/* Set the group ID of the calling process to GID.
If the calling process is the super-user, set the real
and effective group IDs, and the saved set-group-ID to GID;
if not, the effective group ID is set to GID. */
extern int EXFUN(setgid, (__gid_t __gid));
#ifdef __USE_BSD
/* Set the real group ID of the calling process to RGID,
and the effective group ID of the calling process to EGID. */
extern int EXFUN(__setregid, (int __rgid, int __egid));
extern int EXFUN(setregid, (int __rgid, int __egid));
#ifdef __OPTIMIZE__
#define setregid(rgid, egid) __setregid((rgid), (egid))
#endif /* Optimizing. */
#endif /* Use BSD. */
/* Clone the calling process, creating an exact copy.
Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
extern __pid_t EXFUN(__fork, (NOARGS));
extern __pid_t EXFUN(fork, (NOARGS));
#define fork __fork
#ifdef __USE_BSD
/* Clone the calling process, but without copying the whole address space.
The the calling process is suspended until the the new process exits or is
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
extern __pid_t EXFUN(__vfork, (NOARGS));
extern __pid_t EXFUN(vfork, (NOARGS));
#define vfork __vfork
#endif /* Use BSD. */
/* Return the pathname of the terminal FD is open on, or NULL on errors.
The returned storage is good only until the next call to this function. */
extern char *EXFUN(ttyname, (int __fd));
/* Return 1 if FD is a valid descriptor associated
with a terminal, zero if not. */
extern int EXFUN(__isatty, (int __fd));
extern int EXFUN(isatty, (int __fd));
#ifdef __OPTIMIZE__
#define isatty(fd) __isatty(fd)
#endif /* Optimizing. */
/* Make a link to FROM named TO. */
extern int EXFUN(__link, (CONST char *__from, CONST char *__to));
extern int EXFUN(link, (CONST char *__from, CONST char *__to));
#define link __link
#ifdef __USE_BSD
/* Make a symbolic link to FROM named TO. */
extern int EXFUN(symlink, (CONST char *__from, CONST char *__to));
/* Read the contents of the symbolic link PATH into no more than
LEN bytes of BUF. The contents are not null-terminated.
Returns the number of characters read, or -1 for errors. */
extern int EXFUN(readlink, (CONST char *__path, char *__buf, size_t __len));
#endif /* Use BSD. */
/* Remove the link NAME. */
extern int EXFUN(__unlink, (CONST char *__name));
extern int EXFUN(unlink, (CONST char *__name));
#ifdef __OPTIMIZE__
#define unlink(name) __unlink(name)
#endif /* Optimizing. */
/* Remove the directory PATH. */
extern int EXFUN(rmdir, (CONST char *__path));
/* Return the foreground process group ID of FD. */
extern __pid_t EXFUN(tcgetpgrp, (int __fd));
/* Set the foreground process group ID of FD set PGRP_ID. */
extern int EXFUN(tcsetpgrp, (int __fd, __pid_t __pgrp_id));
/* Return the login name of the user. */
extern char *EXFUN(getlogin, (NOARGS));
#ifdef __USE_BSD
/* Set the login name returned by `getlogin'. */
extern int EXFUN(setlogin, (CONST char *__name));
#endif
#ifdef __USE_POSIX2
/* Process the arguments in ARGV (ARGC of them, minus
the program name) for options given in OPTS.
If `opterr' is zero, no messages are generated
for invalid options; it defaults to 1.
`optind' is the current index into ARGV.
`optarg' is the argument corresponding to the current option.
Return the option character from OPTS just read.
Return -1 when there are no more options.
For unrecognized options, or options missing arguments,
`optopt' is set to the option letter, and '?' is returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is optional.
This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument scanning,
explicitly telling `getopt' that there are no more options.
If OPTS begins with `--', then non-option arguments
are treated as arguments to the option '\0'.
This behavior is specific to the GNU `getopt'. */
extern int EXFUN(getopt, (int __argc, char *CONST *__argv,
CONST char *__opts));
extern int opterr;
extern int optind;
extern int optopt;
extern char *optarg;
#endif
#ifdef __USE_BSD
/* Put the name of the current host in no more than LEN bytes of NAME.
The result is null-terminated if LEN is large enough for the full
name and the terminator. */
extern int EXFUN(__gethostname, (char *__name, size_t __len));
extern int EXFUN(gethostname, (char *__name, size_t __len));
#ifdef __OPTIMIZE__
#define gethostname(name, len) __gethostname((name), (len))
#endif
/* Set the name of the current host to NAME, which is LEN bytes long.
This call is restricted to the super-user. */
extern int EXFUN(sethostname, (CONST char *__name, size_t __len));
/* Return the current machine's Internet number. */
extern long int EXFUN(gethostid, (NOARGS));
/* Set the current machine's Internet number to ID.
This call is restricted to the super-user. */
extern int EXFUN(sethostid, (long int __id));
/* Return the number of bytes in a page. This is the system's page size,
which is not necessarily the same as the hardware page size. */
extern size_t EXFUN(__getpagesize, (NOARGS));
extern size_t EXFUN(getpagesize, (NOARGS));
#ifdef __OPTIMIZE__
#define getpagesize() __getpagesize()
#endif /* Optimizing. */
/* Return the maximum number of file descriptors
the current process could possibly have. */
extern int EXFUN(getdtablesize, (NOARGS));
/* Make all changes done to FD actually appear on disk. */
extern int EXFUN(fsync, (int __fd));
/* Make all changes done to all files actually appear on disk. */
extern int EXFUN(sync, (NOARGS));
/* Revoke access permissions to all processes currently communicating
with the control terminal, and then send a SIGHUP signal to the process
group of the control terminal. */
extern int EXFUN(vhangup, (NOARGS));
/* Turn accounting on if NAME is an existing file. The system will then write
a record for each process as it terminates, to this file. If NAME is NULL,
turn accounting off. This call is restricted to the super-user. */
extern int EXFUN(acct, (CONST char *__name));
/* Make PATH be the root directory (the starting point for absolute paths).
This call is restricted to the super-user. */
extern int EXFUN(chroot, (CONST char *__path));
/* Make the block special device PATH available to the system for swapping.
This call is restricted to the super-user. */
extern int EXFUN(swapon, (CONST char *__path));
#endif /* Use BSD. */
#endif /* unistd.h */

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <unistd.h>
#undef vfork
function_alias(vfork, __vfork, __pid_t, (),
DEFUN_VOID(vfork))

View File

@@ -0,0 +1,25 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <sys/wait.h>
#undef wait
function_alias(wait, __wait, __pid_t, (s),
DEFUN(wait, (s), __WAIT_STATUS s))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <sys/wait.h>
#include <sys/types.h>
#undef wait3
function_alias(wait3, __wait3, pid_t, (s, o, u),
DEFUN(wait3, (s, o, u), union wait *s AND int o AND PTR u))

View File

@@ -0,0 +1,27 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <sys/wait.h>
#include <sys/types.h>
#undef wait4
function_alias(wait4, __wait4, pid_t, (p, s, o, u),
DEFUN(wait4, (p, s, o, u),
pid_t p AND union wait *s AND int o AND PTR u))

View File

@@ -0,0 +1,26 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <gnu-stabs.h>
#include <sys/wait.h>
#include <sys/types.h>
#undef waitpid
function_alias(waitpid, __waitpid, pid_t, (pid, s, o),
DEFUN(waitpid, (pid, s, o), pid_t pid AND int *s AND int o))

View File

@@ -0,0 +1,62 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _WORDEXP_H
#define _WORDEXP_H 1
#include <features.h>
/* Bits set in the FLAGS argument to `wordexp'. */
enum
{
WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
WRDE_SHOWERR= (1 << 4), /* Don't redirect stderr to /dev/null. */
WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
__WRDE_FLAGS = (WRDE_DOOFFS|WRDE_APPEND|WRDE_NOCMD|
WRDE_REUSE|WRDE_SHOWERR|WRDE_UNDEF),
};
/* Structure describing a word-expansion run. */
typedef struct
{
int we_wordc; /* Count of words matched. */
char **we_wordv; /* List of expanded words. */
int we_offs; /* Slots to reserve in `we_wordv'. */
} wordexp_t;
/* Possible nonzero return values from `wordexp'. */
enum
{
WRDE_NOSPACE = 1, /* Ran out of memory. */
WRDE_BADCHAR, /* A metacharacter appears in the wrong place. */
WRDE_BADVAL, /* Reference to undefined variable with WRDE_UNDEF. */
WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
WRDE_SYNTAX /* Shell syntax error. */
}
/* Do word expansion of WORDS into PWORDEXP. */
extern int EXFUN(wordexp, (CONST char *__words, wordexp_t *__pwordexp,
int __flags));
/* Free the storage allocated by a `wordexp' call. */
extern void EXFUN(wordfree, (wordexp_t *));
#endif /* wordexp.h */