diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/nss/coreconf/nsinstall | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/nss/coreconf/nsinstall')
-rw-r--r-- | security/nss/coreconf/nsinstall/Makefile | 42 | ||||
-rw-r--r-- | security/nss/coreconf/nsinstall/nsinstall.c | 407 | ||||
-rw-r--r-- | security/nss/coreconf/nsinstall/nsinstall.gyp | 21 | ||||
-rw-r--r-- | security/nss/coreconf/nsinstall/pathsub.c | 272 | ||||
-rw-r--r-- | security/nss/coreconf/nsinstall/pathsub.h | 48 | ||||
-rw-r--r-- | security/nss/coreconf/nsinstall/sunos4.h | 134 |
6 files changed, 924 insertions, 0 deletions
diff --git a/security/nss/coreconf/nsinstall/Makefile b/security/nss/coreconf/nsinstall/Makefile new file mode 100644 index 000000000..1850bcb93 --- /dev/null +++ b/security/nss/coreconf/nsinstall/Makefile @@ -0,0 +1,42 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = ../.. +CORE_DEPTH = ../.. + +MODULE = coreconf + +CSRCS = nsinstall.c pathsub.c + +PROGRAM = nsinstall + +# Indicate that this directory builds build tools. +INTERNAL_TOOLS = 1 + + +include $(DEPTH)/coreconf/config.mk + +ifeq (,$(filter-out OS2 WIN%,$(OS_TARGET))) +PROGRAM = +else +TARGETS = $(PROGRAM) +INSTALL = true +endif + +ifdef NATIVE_CC +CC=$(NATIVE_CC) +endif + +ifdef NATIVE_FLAGS +OS_CFLAGS=$(NATIVE_FLAGS) +endif + +include $(DEPTH)/coreconf/rules.mk + +# Redefine MAKE_OBJDIR for just this directory +define MAKE_OBJDIR +if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); fi +endef + diff --git a/security/nss/coreconf/nsinstall/nsinstall.c b/security/nss/coreconf/nsinstall/nsinstall.c new file mode 100644 index 000000000..3df0ae6b0 --- /dev/null +++ b/security/nss/coreconf/nsinstall/nsinstall.c @@ -0,0 +1,407 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** Netscape portable install command. +*/ +#include <stdio.h> /* OSF/1 requires this before grp.h, so put it first */ +#include <assert.h> +#include <fcntl.h> +#include <string.h> +#if defined(_WINDOWS) +#include <windows.h> +typedef unsigned int mode_t; +#else +#include <grp.h> +#include <pwd.h> +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <utime.h> +#endif +#include <sys/types.h> +#include <sys/stat.h> +#include "pathsub.h" + +#define HAVE_LCHOWN + +#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(NTO) || defined(DARWIN) || defined(BEOS) || defined(__riscos__) +#undef HAVE_LCHOWN +#endif + +#define HAVE_FCHMOD + +#if defined(BEOS) +#undef HAVE_FCHMOD +#endif + +#ifdef LINUX +#include <getopt.h> +#endif + +#if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC) +#if !defined(S_ISLNK) && defined(S_IFLNK) +#define S_ISLNK(a) (((a) & S_IFMT) == S_IFLNK) +#endif +#endif + +#if defined(SNI) +extern int fchmod(int fildes, mode_t mode); +#endif + + +#ifdef GETCWD_CANT_MALLOC +/* + * this should probably go into a utility library in case other applications + * need it. + */ +static char * +getcwd_do_malloc(char *path, int len) { + + if (!path) { + path = malloc(PATH_MAX +1); + if (!path) return NULL; + } + return getcwd(path, PATH_MAX); +} +#define GETCWD getcwd_do_malloc +#else +#define GETCWD getcwd +#endif + + +static void +usage(void) +{ + fprintf(stderr, + "usage: %s [-C cwd] [-L linkprefix] [-m mode] [-o owner] [-g group]\n" + " %*s [-DdltR] file [file ...] directory\n", + program, (int)strlen(program), ""); + exit(2); +} + +/* this is more-or-less equivalent to mkdir -p */ +static int +mkdirs(char *path, mode_t mode) +{ + char * cp; + int rv; + struct stat sb; + + if (!path || !path[0]) + fail("Null pointer or empty string passed to mkdirs()"); + while (*path == '/' && path[1] == '/') + path++; + for (cp = strrchr(path, '/'); cp && cp != path && *(cp - 1) == '/'; cp--); + if (cp && cp != path) { + *cp = '\0'; + if ((stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) && + mkdirs(path, mode) < 0) { + return -1; + } + *cp = '/'; + } + rv = mkdir(path, mode); + if (rv) { + if (errno != EEXIST) + fail("mkdirs cannot make %s", path); + fprintf(stderr, "directory creation race: %s\n", path); + if (!stat(path, &sb) && S_ISDIR(sb.st_mode)) + rv = 0; + } + return rv; +} + +static uid_t +touid(char *owner) +{ + struct passwd *pw; + uid_t uid; + char *cp; + + if (!owner || !owner[0]) + fail("Null pointer or empty string passed to touid()"); + pw = getpwnam(owner); + if (pw) + return pw->pw_uid; + uid = strtol(owner, &cp, 0); + if (uid == 0 && cp == owner) + fail("cannot find uid for %s", owner); + return uid; +} + +static gid_t +togid(char *group) +{ + struct group *gr; + gid_t gid; + char *cp; + + if (!group || !group[0]) + fail("Null pointer or empty string passed to togid()"); + gr = getgrnam(group); + if (gr) + return gr->gr_gid; + gid = strtol(group, &cp, 0); + if (gid == 0 && cp == group) + fail("cannot find gid for %s", group); + return gid; +} + +void * const uninit = (void *)0xdeadbeef; + +int +main(int argc, char **argv) +{ + char * base = uninit; + char * bp = uninit; + char * cp = uninit; + char * cwd = 0; + char * group = 0; + char * linkname = 0; + char * linkprefix = 0; + char * name = uninit; + char * owner = 0; + char * todir = uninit; + char * toname = uninit; + + int bnlen = -1; + int cc = 0; + int dodir = 0; + int dolink = 0; + int dorelsymlink = 0; + int dotimes = 0; + int exists = 0; + int fromfd = -1; + int len = -1; + int lplen = 0; + int onlydir = 0; + int opt = -1; + int tdlen = -1; + int tofd = -1; + int wc = -1; + + mode_t mode = 0755; + + uid_t uid = -1; + gid_t gid = -1; + + struct stat sb; + struct stat tosb; + struct utimbuf utb; + char buf[BUFSIZ]; + + program = strrchr(argv[0], '/'); + if (!program) + program = strrchr(argv[0], '\\'); + program = program ? program+1 : argv[0]; + + + while ((opt = getopt(argc, argv, "C:DdlL:Rm:o:g:t")) != EOF) { + switch (opt) { + case 'C': cwd = optarg; break; + case 'D': onlydir = 1; break; + case 'd': dodir = 1; break; + case 'l': dolink = 1; break; + case 'L': + linkprefix = optarg; + lplen = strlen(linkprefix); + dolink = 1; + break; + case 'R': dolink = dorelsymlink = 1; break; + case 'm': + mode = strtoul(optarg, &cp, 8); + if (mode == 0 && cp == optarg) + usage(); + break; + case 'o': owner = optarg; break; + case 'g': group = optarg; break; + case 't': dotimes = 1; break; + default: usage(); + } + } + + argc -= optind; + argv += optind; + if (argc < 2 - onlydir) + usage(); + + todir = argv[argc-1]; + if ((stat(todir, &sb) < 0 || !S_ISDIR(sb.st_mode)) && + mkdirs(todir, 0777) < 0) { + fail("cannot mkdir -p %s", todir); + } + if (onlydir) + return 0; + + if (!cwd) { + cwd = GETCWD(0, PATH_MAX); + if (!cwd) + fail("could not get CWD"); + } + + /* make sure we can get into todir. */ + xchdir(todir); + todir = GETCWD(0, PATH_MAX); + if (!todir) + fail("could not get CWD in todir"); + tdlen = strlen(todir); + + /* back to original directory. */ + xchdir(cwd); + + uid = owner ? touid(owner) : -1; + gid = group ? togid(group) : -1; + + while (--argc > 0) { + name = *argv++; + len = strlen(name); + base = xbasename(name); + bnlen = strlen(base); + toname = (char*)xmalloc(tdlen + 1 + bnlen + 1); + sprintf(toname, "%s/%s", todir, base); +retry: + exists = (lstat(toname, &tosb) == 0); + + if (dodir) { + /* -d means create a directory, always */ + if (exists && !S_ISDIR(tosb.st_mode)) { + int rv = unlink(toname); + if (rv) + fail("cannot unlink %s", toname); + exists = 0; + } + if (!exists && mkdir(toname, mode) < 0) { + /* we probably have two nsinstall programs in a race here. */ + if (errno == EEXIST && !stat(toname, &sb) && + S_ISDIR(sb.st_mode)) { + fprintf(stderr, "directory creation race: %s\n", toname); + goto retry; + } + fail("cannot make directory %s", toname); + } + if ((owner || group) && chown(toname, uid, gid) < 0) + fail("cannot change owner of %s", toname); + } else if (dolink) { + if (*name == '/') { + /* source is absolute pathname, link to it directly */ + linkname = 0; + } else { + if (linkprefix) { + /* -L implies -l and prefixes names with a $cwd arg. */ + len += lplen + 1; + linkname = (char*)xmalloc(len + 1); + sprintf(linkname, "%s/%s", linkprefix, name); + } else if (dorelsymlink) { + /* Symlink the relative path from todir to source name. */ + linkname = (char*)xmalloc(PATH_MAX); + + if (*todir == '/') { + /* todir is absolute: skip over common prefix. */ + lplen = relatepaths(todir, cwd, linkname); + strcpy(linkname + lplen, name); + } else { + /* todir is named by a relative path: reverse it. */ + reversepath(todir, name, len, linkname); + xchdir(cwd); + } + + len = strlen(linkname); + } + name = linkname; + } + + /* Check for a pre-existing symlink with identical content. */ + if (exists && + (!S_ISLNK(tosb.st_mode) || + readlink(toname, buf, sizeof buf) != len || + strncmp(buf, name, len) != 0)) { + int rmrv; + rmrv = (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname); + if (rmrv < 0) { + fail("destination exists, cannot remove %s", toname); + } + exists = 0; + } + if (!exists && symlink(name, toname) < 0) { + if (errno == EEXIST) { + fprintf(stderr, "symlink creation race: %s\n", toname); + fail("symlink was attempted in working directory %s " + "from %s to %s.\n", cwd, name, toname); + goto retry; + } + diagnosePath(toname); + fail("cannot make symbolic link %s", toname); + } +#ifdef HAVE_LCHOWN + if ((owner || group) && lchown(toname, uid, gid) < 0) + fail("cannot change owner of %s", toname); +#endif + + if (linkname) { + free(linkname); + linkname = 0; + } + } else { + /* Copy from name to toname, which might be the same file. */ + fromfd = open(name, O_RDONLY); + if (fromfd < 0 || fstat(fromfd, &sb) < 0) + fail("cannot access %s", name); + if (exists && + (!S_ISREG(tosb.st_mode) || access(toname, W_OK) < 0)) { + int rmrv; + rmrv = (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname); + if (rmrv < 0) { + fail("destination exists, cannot remove %s", toname); + } + } + tofd = open(toname, O_CREAT | O_WRONLY, 0666); + if (tofd < 0) + fail("cannot create %s", toname); + + bp = buf; + while ((cc = read(fromfd, bp, sizeof buf)) > 0) { + while ((wc = write(tofd, bp, cc)) > 0) { + if ((cc -= wc) == 0) + break; + bp += wc; + } + if (wc < 0) + fail("cannot write to %s", toname); + } + if (cc < 0) + fail("cannot read from %s", name); + + if (ftruncate(tofd, sb.st_size) < 0) + fail("cannot truncate %s", toname); + if (dotimes) { + utb.actime = sb.st_atime; + utb.modtime = sb.st_mtime; + if (utime(toname, &utb) < 0) + fail("cannot set times of %s", toname); + } +#ifdef HAVE_FCHMOD + if (fchmod(tofd, mode) < 0) +#else + if (chmod(toname, mode) < 0) +#endif + fail("cannot change mode of %s", toname); + + if ((owner || group) && fchown(tofd, uid, gid) < 0) + fail("cannot change owner of %s", toname); + + /* Must check for delayed (NFS) write errors on close. */ + if (close(tofd) < 0) + fail("close reports write error on %s", toname); + close(fromfd); + } + + free(toname); + } + + free(cwd); + free(todir); + return 0; +} + diff --git a/security/nss/coreconf/nsinstall/nsinstall.gyp b/security/nss/coreconf/nsinstall/nsinstall.gyp new file mode 100644 index 000000000..efff6bcba --- /dev/null +++ b/security/nss/coreconf/nsinstall/nsinstall.gyp @@ -0,0 +1,21 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +{ + 'includes': [ + '../../coreconf/config.gypi' + ], + 'targets': [ + { + 'target_name': 'nsinstall', + 'type': 'executable', + 'sources': [ + 'nsinstall.c', + 'pathsub.c' + ] + } + ], + 'variables': { + 'module': 'coreconf' + } +}
\ No newline at end of file diff --git a/security/nss/coreconf/nsinstall/pathsub.c b/security/nss/coreconf/nsinstall/pathsub.c new file mode 100644 index 000000000..a42a9f30a --- /dev/null +++ b/security/nss/coreconf/nsinstall/pathsub.c @@ -0,0 +1,272 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* +** Pathname subroutines. +*/ +#if defined(FREEBSD) || defined(BSDI) || defined(DARWIN) +#include <sys/types.h> +#endif /* FREEBSD */ +#include <dirent.h> +#include <errno.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "pathsub.h" +#ifdef USE_REENTRANT_LIBC +#include "libc_r.h" +#endif /* USE_REENTRANT_LIBC */ + +char *program; + +void +fail(char *format, ...) +{ + int error; + va_list ap; + +#ifdef USE_REENTRANT_LIBC + R_STRERROR_INIT_R(); +#endif + + error = errno; + fprintf(stderr, "%s: ", program); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + if (error) { + +#ifdef USE_REENTRANT_LIBC + R_STRERROR_R(errno); + fprintf(stderr, ": %s", r_strerror_r); +#else + fprintf(stderr, ": %s", strerror(errno)); +#endif + } + + putc('\n', stderr); + abort(); + exit(1); +} + +char * +getcomponent(char *path, char *name) +{ + if (*path == '\0') + return 0; + if (*path == '/') { + *name++ = '/'; + } else { + do { + *name++ = *path++; + } while (*path != '/' && *path != '\0'); + } + *name = '\0'; + while (*path == '/') + path++; + return path; +} + +#ifdef UNIXWARE +/* The static buffer in Unixware's readdir is too small. */ +struct dirent * readdir(DIR *d) +{ + static struct dirent *buf = NULL; +#define MAX_PATH_LEN 1024 + + if (buf == NULL) + buf = (struct dirent *)xmalloc(sizeof(struct dirent) + MAX_PATH_LEN) ; + return readdir_r(d, buf); +} +#endif + +/* APPARENT BUG - ignores argument "dir", uses ".." instead. */ +char * +ino2name(ino_t ino, char *dir) +{ + DIR *dp; + struct dirent *ep; + char *name; + + dp = opendir(".."); /* XXX */ + if (!dp) + fail("cannot read parent directory"); + for (;;) { + if (!(ep = readdir(dp))) + fail("cannot find current directory"); + if (ep->d_ino == ino) + break; + } + name = xstrdup(ep->d_name); + closedir(dp); + return name; +} + +void * +xmalloc(size_t size) +{ + void *p; + + if (size <= 0) + fail("attempted to allocate %u bytes", size); + p = malloc(size); + if (!p) + fail("cannot allocate %u bytes", size); + return p; +} + +char * +xstrdup(char *s) +{ + if (!s || !s[0]) + fail("Null pointer or empty string passed to xstrdup()"); + return strcpy((char*)xmalloc(strlen(s) + 1), s); +} + +char * +xbasename(char *path) +{ + char *cp; + + if (!path || !path[0]) + fail("Null pointer or empty string passed to xbasename()"); + while ((cp = strrchr(path, '/')) && cp[1] == '\0') + *cp = '\0'; + if (!cp) return path; + return cp + 1; +} + +void +xchdir(char *dir) +{ + if (!dir || !dir[0]) + fail("Null pointer or empty string passed to xchdir()"); + if (chdir(dir) < 0) + fail("cannot change directory to %s", dir); +} + +int +relatepaths(char *from, char *to, char *outpath) +{ + char *cp, *cp2; + int len; + char buf[NAME_MAX]; + + if (!from || *from != '/') + fail("relatepaths: from path does not start with /"); + if (!to || *to != '/') + fail("relatepaths: to path does not start with /"); + + for (cp = to, cp2 = from; *cp == *cp2; cp++, cp2++) + if (*cp == '\0') + break; + while (cp[-1] != '/') + cp--, cp2--; + if (cp - 1 == to) { + /* closest common ancestor is /, so use full pathname */ + len = strlen(strcpy(outpath, to)); + if (outpath[len] != '/') { + outpath[len++] = '/'; + outpath[len] = '\0'; + } + } else { + len = 0; + while ((cp2 = getcomponent(cp2, buf)) != 0) { + strcpy(outpath + len, "../"); + len += 3; + } + while ((cp = getcomponent(cp, buf)) != 0) { + sprintf(outpath + len, "%s/", buf); + len += strlen(outpath + len); + } + } + return len; +} + +void +reversepath(char *inpath, char *name, int len, char *outpath) +{ + char *cp, *cp2; + char buf[NAME_MAX]; + struct stat sb; + + cp = strcpy(outpath + PATH_MAX - (len + 1), name); + cp2 = inpath; + while ((cp2 = getcomponent(cp2, buf)) != 0) { + if (strcmp(buf, ".") == 0) + continue; + if (strcmp(buf, "..") == 0) { + if (stat(".", &sb) < 0) + fail("cannot stat current directory"); + name = ino2name(sb.st_ino, ".."); + len = strlen(name); + cp -= len + 1; + strcpy(cp, name); + cp[len] = '/'; + free(name); + xchdir(".."); + } else { + cp -= 3; + strncpy(cp, "../", 3); + xchdir(buf); + } + } + strcpy(outpath, cp); +} + +void +diagnosePath(const char * path) +{ + char * myPath; + char * slash; + int rv; + struct stat sb; + char buf[BUFSIZ]; + + if (!path || !path[0]) + fail("Null pointer or empty string passed to mkdirs()"); + myPath = strdup(path); + if (!myPath) + fail("strdup() failed!"); + do { + rv = lstat(myPath, &sb); + if (rv < 0) { + perror(myPath); + } else if (S_ISLNK(sb.st_mode)) { + rv = readlink(myPath, buf, sizeof(buf) - 1); + if (rv < 0) { + perror("readlink"); + buf[0] = 0; + } else { + buf[rv] = 0; + } + fprintf(stderr, "%s is a link to %s\n", myPath, buf); + } else if (S_ISDIR(sb.st_mode)) { + fprintf(stderr, "%s is a directory\n", myPath); + rv = access(myPath, X_OK); + if (rv < 0) { + fprintf(stderr, "%s: no search permission\n", myPath); + } + } else { + fprintf(stderr, "%s is a file !?!\n", myPath); + rv = access(myPath, F_OK); + if (rv < 0) { + fprintf(stderr, "%s does not exist\n", myPath); + } + } + + /* chop path off one level. */ + slash = strrchr(myPath, '/'); + if (!slash) + slash = strrchr(myPath, '\\'); + if (!slash) + slash = myPath; + *slash = 0; + } while (myPath[0]); + free(myPath); +} diff --git a/security/nss/coreconf/nsinstall/pathsub.h b/security/nss/coreconf/nsinstall/pathsub.h new file mode 100644 index 000000000..aea523b16 --- /dev/null +++ b/security/nss/coreconf/nsinstall/pathsub.h @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef pathsub_h___ +#define pathsub_h___ +/* +** Pathname subroutines. +** +** Brendan Eich, 8/29/95 +*/ +#include <limits.h> +#include <sys/types.h> + +#if SUNOS4 +#include "sunos4.h" +#endif + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/* + * Just keep sane lengths + */ +#undef NAME_MAX +#define NAME_MAX 256 + +extern char *program; + +extern void fail(char *format, ...); +extern char *getcomponent(char *path, char *name); +extern char *ino2name(ino_t ino, char *dir); +extern void *xmalloc(size_t size); +extern char *xstrdup(char *s); +extern char *xbasename(char *path); +extern void xchdir(char *dir); + +/* Relate absolute pathnames from and to returning the result in outpath. */ +extern int relatepaths(char *from, char *to, char *outpath); + +/* NOTE: changes current working directory -- caveat emptor */ +extern void reversepath(char *inpath, char *name, int len, char *outpath); + +/* stats every directory in path, reports results. */ +extern void diagnosePath(const char * path); + +#endif /* pathsub_h___ */ diff --git a/security/nss/coreconf/nsinstall/sunos4.h b/security/nss/coreconf/nsinstall/sunos4.h new file mode 100644 index 000000000..3ba064f98 --- /dev/null +++ b/security/nss/coreconf/nsinstall/sunos4.h @@ -0,0 +1,134 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef pr_sunos4_h___ +#define pr_sunos4_h___ + +#ifndef SVR4 + +/* +** Hodge podge of random missing prototypes for the Sunos4 system +*/ +#include <stdio.h> +#include <stdarg.h> +#include <time.h> +#include <limits.h> +#include <sys/types.h> + +#define PATH_MAX _POSIX_PATH_MAX + +struct timeval; +struct timezone; +struct itimerval; +struct sockaddr; +struct stat; +struct tm; + +/* ctype.h */ +extern int tolower(int); +extern int toupper(int); + +/* errno.h */ +extern char *sys_errlist[]; +extern int sys_nerr; + +#define strerror(e) sys_errlist[((unsigned)(e) < sys_nerr) ? e : 0] + +extern void perror(const char *); + +/* getopt */ +extern char *optarg; +extern int optind; +extern int getopt(int argc, char **argv, char *spec); + +/* math.h */ +extern int srandom(long val); +extern long random(void); + +/* memory.h */ +#define memmove(to,from,len) bcopy((char*)(from),(char*)(to),len) + +extern void bcopy(const char *, char *, int); + +/* signal.h */ +/* +** SunOS4 sigaction hides interrupts by default, so we can safely define +** SA_RESTART to 0 (HP-UX is a counter-example -- its sigaction does not +** hide interrupts but lacks an SA_RESTART option; you must use sigvector +** and tweak the sigcontext from within each signal handler!). +*/ +#define SA_RESTART 0 +#define SA_SIGINFO 0 + +/* stdio.h */ +extern int printf(const char *, ...); +extern int fprintf(FILE *, const char *, ...); +extern int vprintf(const char *, va_list); +extern int vfprintf(FILE *, const char *, va_list); +extern char *vsprintf(char *, const char *, va_list); +extern int scanf(const char *, ...); +extern int sscanf(const char *, const char *, ...); +extern int fscanf(FILE *, const char *, ...); +extern int fgetc(FILE *); +extern int fputc(int, FILE *); +extern int fputs(const char *, FILE *); +extern int puts(const char *); +extern int fread(void *, size_t, size_t, FILE *); +extern int fwrite(const char *, int, int, FILE *); +extern int fseek(FILE *, long, int); +extern long ftell(FILE *); +extern int rewind(FILE *); +extern int fflush(FILE *); +extern int _flsbuf(unsigned char, FILE *); +extern int fclose(FILE *); +extern int remove(const char *); +extern int setvbuf(FILE *, char *, int, size_t); +extern int system(const char *); +extern FILE *popen(const char *, const char *); +extern int pclose(FILE *); + +/* stdlib.h */ +#define strtoul strtol + +extern int isatty(int fildes); +extern long strtol(const char *, char **, int); +extern int putenv(const char *); +extern void srand48(long); +extern long lrand48(void); +extern double drand48(void); + +/* string.h */ +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); +extern int strcoll(const char *, const char *); + +/* time.h */ +extern time_t mktime(struct tm *); +extern size_t strftime(char *, size_t, const char *, const struct tm *); +extern int gettimeofday(struct timeval *, struct timezone *); +extern int setitimer(int, struct itimerval *, struct itimerval *); +extern time_t time(time_t *); +extern time_t timegm(struct tm *); +extern struct tm *localtime(const time_t *); +extern struct tm *gmtime(const time_t *); + +/* unistd.h */ +extern int rename(const char *, const char *); +extern int ioctl(int, int, int *arg); +extern int connect(int, struct sockaddr *, int); +extern int readlink(const char *, char *, int); +extern int symlink(const char *, const char *); +extern int ftruncate(int, off_t); +extern int fchmod(int, mode_t); +extern int fchown(int, uid_t, gid_t); +extern int lstat(const char *, struct stat *); +extern int fstat(int, struct stat *); +extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +extern int gethostname(char *, int); +extern char *getwd(char *); +extern int getpagesize(void); + +#endif /* SVR4 */ + +#endif /* pr_sunos4_h___ */ |