summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/memcpy.c16
-rw-r--r--lib/memset.c29
-rw-r--r--lib/strcspn.c43
-rw-r--r--lib/strpbrk.c39
-rw-r--r--lib/strspn.c44
-rw-r--r--lib/strstr.c116
-rw-r--r--lib/xalloca.h47
-rw-r--r--lib/xdirent.h53
-rw-r--r--lib/xfnmatch.h34
-rw-r--r--lib/xobstack.h29
-rw-r--r--lib/xstddef.h32
-rw-r--r--lib/xstdlib.h28
-rw-r--r--lib/xstring.h44
-rw-r--r--lib/xsysstat.h70
-rw-r--r--lib/xunistd.h44
15 files changed, 668 insertions, 0 deletions
diff --git a/lib/memcpy.c b/lib/memcpy.c
new file mode 100644
index 0000000..dba7d56
--- /dev/null
+++ b/lib/memcpy.c
@@ -0,0 +1,16 @@
+/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined
+ if the source overlaps with the destination.
+ Return DESTADDR. */
+
+char *
+memcpy (destaddr, srcaddr, len)
+ char *destaddr;
+ const char *srcaddr;
+ int len;
+{
+ char *dest = destaddr;
+
+ while (len-- > 0)
+ *destaddr++ = *srcaddr++;
+ return dest;
+}
diff --git a/lib/memset.c b/lib/memset.c
new file mode 100644
index 0000000..0e819f2
--- /dev/null
+++ b/lib/memset.c
@@ -0,0 +1,29 @@
+/* memset.c -- set an area of memory to a given value
+ Copyright (C) 1991 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. */
+
+char *
+memset (str, c, len)
+ char *str;
+ int c;
+ unsigned len;
+{
+ register char *st = str;
+
+ while (len-- > 0)
+ *st++ = c;
+ return str;
+}
diff --git a/lib/strcspn.c b/lib/strcspn.c
new file mode 100644
index 0000000..a17357e
--- /dev/null
+++ b/lib/strcspn.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+/* Return the length of the maximum inital segment of S
+ which contains no characters from REJECT. */
+size_t
+strcspn (s, reject)
+ register const char *s;
+ register const char *reject;
+{
+ register size_t count = 0;
+
+ while (*s != '\0')
+ if (strchr (reject, *s++) == NULL)
+ ++count;
+ else
+ return count;
+
+ return count;
+}
diff --git a/lib/strpbrk.c b/lib/strpbrk.c
new file mode 100644
index 0000000..3e60201
--- /dev/null
+++ b/lib/strpbrk.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Find the first ocurrence in S of any character in ACCEPT. */
+char *
+strpbrk (s, accept)
+ register const char *s;
+ register const char *accept;
+{
+ while (*s != '\0')
+ {
+ const char *a = accept;
+ while (*a != '\0')
+ if (*a++ == *s)
+ return (char *) s;
+ ++s;
+ }
+
+ return 0;
+}
diff --git a/lib/strspn.c b/lib/strspn.c
new file mode 100644
index 0000000..89b45ad
--- /dev/null
+++ b/lib/strspn.c
@@ -0,0 +1,44 @@
+/* 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 <string.h>
+
+
+/* Return the length of the maximum initial segment
+ of S which contains only characters in ACCEPT. */
+size_t
+DEFUN(strspn, (s, accept), CONST char *s AND CONST char *accept)
+{
+ register CONST char *p;
+ register CONST char *a;
+ register size_t count = 0;
+
+ for (p = s; *p != '\0'; ++p)
+ {
+ for (a = accept; *a != '\0'; ++a)
+ if (*p == *a)
+ break;
+ if (*a == '\0')
+ return count;
+ else
+ ++count;
+ }
+
+ return count;
+}
diff --git a/lib/strstr.c b/lib/strstr.c
new file mode 100644
index 0000000..cdee621
--- /dev/null
+++ b/lib/strstr.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/*
+ * My personal strstr() implementation that beats most other algorithms.
+ * Until someone tells me otherwise, I assume that this is the
+ * fastest implementation of strstr() in C.
+ * I deliberately chose not to comment it. You should have at least
+ * as much fun trying to understand it, as I had to write it :-).
+ *
+ * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
+
+#include <string.h>
+#include <sys/types.h>
+
+typedef unsigned chartype;
+
+char *
+strstr (phaystack, pneedle)
+ const char *phaystack;
+ const char *pneedle;
+{
+ register const unsigned char *haystack, *needle;
+ register chartype b, c;
+
+ haystack = (const unsigned char *) phaystack;
+ needle = (const unsigned char *) pneedle;
+
+ b = *needle;
+ if (b != '\0')
+ {
+ haystack--; /* possible ANSI violation */
+ do
+ {
+ c = *++haystack;
+ if (c == '\0')
+ goto ret0;
+ }
+ while (c != b);
+
+ c = *++needle;
+ if (c == '\0')
+ goto foundneedle;
+ ++needle;
+ goto jin;
+
+ for (;;)
+ {
+ register chartype a;
+ register const unsigned char *rhaystack, *rneedle;
+
+ do
+ {
+ a = *++haystack;
+ if (a == '\0')
+ goto ret0;
+ if (a == b)
+ break;
+ a = *++haystack;
+ if (a == '\0')
+ goto ret0;
+shloop: }
+ while (a != b);
+
+jin: a = *++haystack;
+ if (a == '\0')
+ goto ret0;
+
+ if (a != c)
+ goto shloop;
+
+ rhaystack = haystack-- + 1;
+ rneedle = needle;
+ a = *rneedle;
+
+ if (*rhaystack == a)
+ do
+ {
+ if (a == '\0')
+ goto foundneedle;
+ ++rhaystack;
+ a = *++needle;
+ if (*rhaystack != a)
+ break;
+ if (a == '\0')
+ goto foundneedle;
+ ++rhaystack;
+ a = *++needle;
+ }
+ while (*rhaystack == a);
+
+ needle = rneedle; /* took the register-poor aproach */
+
+ if (a == '\0')
+ break;
+ }
+ }
+foundneedle:
+ return (char*) haystack;
+ret0:
+ return 0;
+}
diff --git a/lib/xalloca.h b/lib/xalloca.h
new file mode 100644
index 0000000..b28632a
--- /dev/null
+++ b/lib/xalloca.h
@@ -0,0 +1,47 @@
+/* xalloca.h -- alloca declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xalloca_h_
+#define _xalloca_h_ 1
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifndef alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+# else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#define ALLOCA(t, n) ((t *) alloca (sizeof (t) * (n)))
+
+#endif /* _xalloca_h_ */
diff --git a/lib/xdirent.h b/lib/xdirent.h
new file mode 100644
index 0000000..0420fdf
--- /dev/null
+++ b/lib/xdirent.h
@@ -0,0 +1,53 @@
+/* xdirent.h -- dirent declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xdirent_h_
+#define _xdirent_h_
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+#endif
+#if HAVE_NDIR_H
+# include <ndir.h>
+#endif
+#if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+#endif
+#if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+#endif
+
+/* Interpret `HAVE_LINK' as meaning `UN*X style' directory structure
+ (e.g., A single root called `/', with `/' separating links), and
+ !HAVE_LINK as `DOS|OS/2|Windows style' (e.g., Multiple root volues
+ named `x:', with `\' separating links). */
+
+#if HAVE_LINK
+# define IS_ABSOLUTE(_dir_) ((_dir_)[0] == '/')
+# define SLASH_STRING "/"
+# define SLASH_CHAR '/'
+# define DOT_DOT_SLASH "../"
+#else
+/* NEEDSWORK: prefer forward-slashes as a user-configurable option. */
+# define IS_ABSOLUTE(_dir_) ((_dir_)[1] == ':')
+# define SLASH_STRING "\\/"
+# define SLASH_CHAR '\\'
+# define DOT_DOT_SLASH "..\\"
+#endif
+
+#endif /* not _xdirent_h_ */
diff --git a/lib/xfnmatch.h b/lib/xfnmatch.h
new file mode 100644
index 0000000..a8ed2e0
--- /dev/null
+++ b/lib/xfnmatch.h
@@ -0,0 +1,34 @@
+/* xfnmatch.h -- fnmatch declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xfnmatch_h_
+#define _xfnmatch_h_
+
+#include <fnmatch.h>
+
+#ifndef FNM_FILE_NAME
+# define FNM_FILE_NAME FNM_PATHNAME
+#endif
+
+#if HAVE_LINK
+# define MAYBE_FNM_CASEFOLD 0
+#else
+# define MAYBE_FNM_CASEFOLD FNM_CASEFOLD
+#endif
+
+#endif /* not _xfnmatch_h_ */
diff --git a/lib/xobstack.h b/lib/xobstack.h
new file mode 100644
index 0000000..38281cb
--- /dev/null
+++ b/lib/xobstack.h
@@ -0,0 +1,29 @@
+/* xobstack.h -- obstack declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xobstack_h_
+#define _xobstack_h_
+
+#include <obstack.h>
+#include "xmalloc.h"
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+#define OBSTACK_ALLOC(obs, t, n) ((t *)obstack_alloc ((obs), (n)*sizeof(t)))
+
+#endif /* not _xobstack_h_ */
diff --git a/lib/xstddef.h b/lib/xstddef.h
new file mode 100644
index 0000000..e05c339
--- /dev/null
+++ b/lib/xstddef.h
@@ -0,0 +1,32 @@
+/* xstddef.h -- stddef declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xstddef_h_
+#define _xstddef_h_
+
+#if HAVE_STDDEF_H
+# include <stddef.h>
+#endif
+
+#ifndef offsetof
+# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define cardinalityof(ARRAY) (sizeof (ARRAY) / sizeof ((ARRAY)[0]))
+
+#endif /* not _xstddef_h_ */
diff --git a/lib/xstdlib.h b/lib/xstdlib.h
new file mode 100644
index 0000000..99335e7
--- /dev/null
+++ b/lib/xstdlib.h
@@ -0,0 +1,28 @@
+/* xstdlib.h -- stdlib declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _xstdlib_h_
+#define _xstdlib_h_ 1
+
+#if defined STDC_HEADERS || defined _LIBC || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *getenv ();
+#endif
+
+#endif /* _xstdlib_h_ */
diff --git a/lib/xstring.h b/lib/xstring.h
new file mode 100644
index 0000000..c6f79e0
--- /dev/null
+++ b/lib/xstring.h
@@ -0,0 +1,44 @@
+/* xstring.h - string declarations wrapper wrapper
+ Copyright (C) 1986, 1995, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _xstring_h_
+#define _xstring_h_
+
+#define dirname sidestep_dirname_declaration
+#define basename sidestep_basename_declaration
+#ifdef HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#else
+# include <strings.h>
+char *memchr ();
+#endif
+#undef dirname
+#undef basename
+
+#define strequ(s1, s2) (strcmp ((s1), (s2)) == 0)
+#define strnequ(s1, s2, n) (strncmp ((s1), (s2), (n)) == 0)
+
+#if !HAVE_STRNDUP
+extern char *strndup __P((char const *, size_t n));
+#endif
+extern char *basename __P((char const *));
+extern char *dirname __P((char const *));
+
+#endif /* not _xstring_h_ */
diff --git a/lib/xsysstat.h b/lib/xsysstat.h
new file mode 100644
index 0000000..8c96541
--- /dev/null
+++ b/lib/xsysstat.h
@@ -0,0 +1,70 @@
+/* xsysstat.h -- sys/stat declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _xsysstat_h_
+#define _xsysstat_h_
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#ifdef STAT_MACROS_BROKEN
+#undef S_ISBLK
+#undef S_ISCHR
+#undef S_ISDIR
+#undef S_ISFIFO
+#undef S_ISLNK
+#undef S_ISMPB
+#undef S_ISMPC
+#undef S_ISNWK
+#undef S_ISREG
+#undef S_ISSOCK
+#endif /* STAT_MACROS_BROKEN. */
+
+#if !defined(S_ISBLK) && defined(S_IFBLK)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#endif
+#if !defined(S_ISCHR) && defined(S_IFCHR)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#endif
+#if !defined(S_ISDIR) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#if !defined(S_ISREG) && defined(S_IFREG)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#if !defined(S_ISFIFO) && defined(S_IFIFO)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#endif
+#if !defined(S_ISLNK) && defined(S_IFLNK)
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#endif
+#if !defined(S_ISSOCK) && defined(S_IFSOCK)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+#endif
+#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
+#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+#endif
+#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
+#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+#endif
+
+#endif /* not _xsysstat_h_ */
diff --git a/lib/xunistd.h b/lib/xunistd.h
new file mode 100644
index 0000000..bfd3a97
--- /dev/null
+++ b/lib/xunistd.h
@@ -0,0 +1,44 @@
+/* xunistd.h -- unistd declarations wrapper
+ Copyright (C) 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#define sbrk sidestep_sbrk_declaration
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#undef sbrk
+void *sbrk ();
+
+#ifndef _POSIX_VERSION
+off_t lseek ();
+#endif
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif