summaryrefslogtreecommitdiffstats
path: root/lib/libcompat
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-04-10 18:48:06 +0000
committerjoerg <joerg@FreeBSD.org>1995-04-10 18:48:06 +0000
commit6f7aeef5d23452d060640fff99700130e2febdc8 (patch)
treecc4fd4fba012a457776cc9830705db7f92d4ac6e /lib/libcompat
parent22aeb7b0802de48f886c9f428ae99d8a969031d1 (diff)
downloadFreeBSD-src-6f7aeef5d23452d060640fff99700130e2febdc8.zip
FreeBSD-src-6f7aeef5d23452d060640fff99700130e2febdc8.tar.gz
My libcompat cleanup.
o add missing man pages o make all man pages clearly refer to the libcompat thingie o add the information to the vtimes(3) and vlimit(3) man pages that nobody has reimplemented the functions by now o add the missing getpw.c o add code and man pages for cftime(3) and ascftime(3) -- i found them somewhere in old unfinished work
Diffstat (limited to 'lib/libcompat')
-rw-r--r--lib/libcompat/4.1/ascftime.c52
-rw-r--r--lib/libcompat/4.1/cftime.399
-rw-r--r--lib/libcompat/4.1/cftime.c53
-rw-r--r--lib/libcompat/4.1/getpw.38
-rw-r--r--lib/libcompat/4.1/getpw.c58
-rw-r--r--lib/libcompat/4.1/gtty.c5
-rw-r--r--lib/libcompat/4.1/stty.c5
-rw-r--r--lib/libcompat/4.1/vlimit.32
-rw-r--r--lib/libcompat/4.1/vtimes.32
-rw-r--r--lib/libcompat/4.3/insque.36
-rw-r--r--lib/libcompat/4.3/re_comp.31
-rw-r--r--lib/libcompat/4.4/cuserid.382
-rw-r--r--lib/libcompat/Makefile7
-rw-r--r--lib/libcompat/regexp/regexp.32
14 files changed, 378 insertions, 4 deletions
diff --git a/lib/libcompat/4.1/ascftime.c b/lib/libcompat/4.1/ascftime.c
new file mode 100644
index 0000000..e842b6e
--- /dev/null
+++ b/lib/libcompat/4.1/ascftime.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1994 Joerg Wunsch
+ *
+ * All rights reserved.
+ *
+ * This program is free software.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Joerg Wunsch
+ * 4. The name of the developer may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include <time.h>
+
+#define MAXLEN 1000 /* just a guess, only the user knows... */
+
+int
+#if __STDC__
+ascftime(char *s, const char *format, const struct tm *tmptr)
+#else
+ascftime(s, format, tmptr)
+ char *s;
+ char *format;
+ struct tm *tmptr;
+#endif
+{
+ return strftime(s, MAXLEN, format? format: "%C", tmptr);
+}
diff --git a/lib/libcompat/4.1/cftime.3 b/lib/libcompat/4.1/cftime.3
new file mode 100644
index 0000000..5c760a9
--- /dev/null
+++ b/lib/libcompat/4.1/cftime.3
@@ -0,0 +1,99 @@
+.\"
+.\" Copyright (c) 1994, 1995 Joerg Wunsch
+.\"
+.\" All rights reserved.
+.\"
+.\" This program is free software.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Joerg Wunsch
+.\" 4. The name of the developer may not be used to endorse or promote
+.\" products derived from this software without specific prior written
+.\" permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\"
+.\" $Id$
+.\"
+.Dd June 15, 1993
+.Os
+.Dt CFTIME 3
+.Sh NAME
+.Nm cftime
+.Nm ascftime
+.Nd convert date and time to string
+.Sh SYNOPSIS
+.Fd #include <time.h>
+.Ft int
+.Fn cftime "char *s" "char *format" "const time_t *clock" ;
+.Ft int
+.Fn ascftime "char *s" "const char *format" "const struct tm *tmptr" ;
+.Sh DESCRIPTION
+.Bf -symbolic
+The cftime and ascftime functions are made obsolete by strftime(3).
+.br
+They are available from the compatibility library, libcompat.
+.Ef
+.Pp
+Use of the functions
+.Nm cftime
+and
+.Nm ascftime
+is strongly deprecated, since there is no way to check for a buffer
+overflow condition. Use
+.Xr strftime 3
+instead.
+
+.Nm Ascftime
+is almost identical with
+.Xr strftime 3 ,
+with the only exception there's no parameter to tell about the
+maximal buffer length, and the
+.Fa format
+parameter defaults to
+.Dq %C
+if a
+.Em NULL
+pointer is given.
+
+.Nm Cftime
+does the same job, but it first invokes
+.Xr localtime 3
+in order to convert the given
+.Fa clock ,
+then also performs the conversions as requested by the
+.Fa format
+argument.
+
+.Sh RETURN VALUES
+The
+.Nm cftime
+and
+.Nm ascftime
+functions return the number of characters written to the output
+buffer
+.Fa s ,
+not counting the trailing null character.
+
+.Sh SEE ALSO
+.Xr localtime 3 ,
+.Xr strftime 3 .
diff --git a/lib/libcompat/4.1/cftime.c b/lib/libcompat/4.1/cftime.c
new file mode 100644
index 0000000..2e3a34b
--- /dev/null
+++ b/lib/libcompat/4.1/cftime.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1994 Joerg Wunsch
+ *
+ * All rights reserved.
+ *
+ * This program is free software.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Joerg Wunsch
+ * 4. The name of the developer may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include <time.h>
+
+#define MAXLEN 1000 /* just a guess, only the user knows... */
+
+int
+#if __STDC__
+cftime(char *s, char *format, const time_t *clock)
+#else
+cftime(s, format, clock)
+ char *s;
+ char *format;
+ time_t *clock;
+#endif
+{
+ return strftime(s, MAXLEN, format? format: "%C", localtime(clock));
+}
+
diff --git a/lib/libcompat/4.1/getpw.3 b/lib/libcompat/4.1/getpw.3
index 1568e74..4cf160c 100644
--- a/lib/libcompat/4.1/getpw.3
+++ b/lib/libcompat/4.1/getpw.3
@@ -76,3 +76,11 @@ A
.Fn getpw
function appeared in
.At v6 .
+.Sh BUGS
+The area pointed to by
+.Fa buf
+must be large enough to hold the user name.
+
+All of the bugs from
+.Xr getpwent 3
+hold valid as well.
diff --git a/lib/libcompat/4.1/getpw.c b/lib/libcompat/4.1/getpw.c
new file mode 100644
index 0000000..9fc7eb1
--- /dev/null
+++ b/lib/libcompat/4.1/getpw.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1995 Joerg Wunsch
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Joerg Wunsch
+ * 4. The name of the developer may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <string.h>
+#include <stdio.h>
+
+int
+#if __STDC__
+getpw(uid_t uid, char *buf)
+#else
+getpw(uid, buf)
+ uid_t uid;
+ char *buf;
+#endif
+{
+ struct passwd *pw;
+
+ pw = getpwuid(uid);
+ endpwent();
+
+ if(pw == 0) return -1;
+
+ strncpy(buf, pw->pw_name, L_cuserid);
+ return 0;
+}
diff --git a/lib/libcompat/4.1/gtty.c b/lib/libcompat/4.1/gtty.c
index a6a9c64..7875399 100644
--- a/lib/libcompat/4.1/gtty.c
+++ b/lib/libcompat/4.1/gtty.c
@@ -29,7 +29,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: gtty.c,v 1.1 1994/05/21 05:20:34 cgd Exp $";
+static char rcsid[] = "$Id: gtty.c,v 1.1.1.1 1994/05/27 10:33:22 rgrimes Exp $";
#endif /* not lint */
#include <sgtty.h>
@@ -39,6 +39,9 @@ static char rcsid[] = "$Id: gtty.c,v 1.1 1994/05/21 05:20:34 cgd Exp $";
* This was defined in ioctl_compat.h as:
* #define gtty(fd, tty) ioctl(fd, TIOCGETP, tty)
*/
+
+#undef gtty
+
int
gtty(fd, tty)
int fd;
diff --git a/lib/libcompat/4.1/stty.c b/lib/libcompat/4.1/stty.c
index 3e89506..91d241b 100644
--- a/lib/libcompat/4.1/stty.c
+++ b/lib/libcompat/4.1/stty.c
@@ -29,7 +29,7 @@
*/
#ifndef lint
-static char rcsid[] = "$Id: stty.c,v 1.1 1994/05/21 05:20:41 cgd Exp $";
+static char rcsid[] = "$Id: stty.c,v 1.1.1.1 1994/05/27 10:33:22 rgrimes Exp $";
#endif /* not lint */
#include <sgtty.h>
@@ -39,6 +39,9 @@ static char rcsid[] = "$Id: stty.c,v 1.1 1994/05/21 05:20:41 cgd Exp $";
* This was defined in ioctl_compat.h as:
* #define stty(fd, tty) ioctl(fd, TIOCSETP, tty)
*/
+
+#undef stty
+
int
stty(fd, tty)
int fd;
diff --git a/lib/libcompat/4.1/vlimit.3 b/lib/libcompat/4.1/vlimit.3
index 062f557..d4ed5f3 100644
--- a/lib/libcompat/4.1/vlimit.3
+++ b/lib/libcompat/4.1/vlimit.3
@@ -121,3 +121,5 @@ function appeared in
.Sh BUGS
.Dv LIM_NORAISE
no longer exists.
+
+This function has not yet been reimplemented.
diff --git a/lib/libcompat/4.1/vtimes.3 b/lib/libcompat/4.1/vtimes.3
index dc4ff4a..e02bb72 100644
--- a/lib/libcompat/4.1/vtimes.3
+++ b/lib/libcompat/4.1/vtimes.3
@@ -139,3 +139,5 @@ The
.Fn vlimit
function appeared in
.Bx 4.2 .
+.Sh BUGS
+This function has not yet been re-implemented.
diff --git a/lib/libcompat/4.3/insque.3 b/lib/libcompat/4.3/insque.3
index 2decaed..5ebecbc 100644
--- a/lib/libcompat/4.3/insque.3
+++ b/lib/libcompat/4.3/insque.3
@@ -50,6 +50,12 @@ struct qelem {
.Fn insque "(caddr_t) struct qelem *elem" "(caddr_t) struct qelem *pred"
.Fn remque "(caddr_t) struct qelem *elem"
.Sh DESCRIPTION
+.Bf -symbolic
+The insque and remque functions are considered obsolete.
+.br
+They are available from the compatibility library, libcompat.
+.Ef
+.Pp
The
.Fn insque
and
diff --git a/lib/libcompat/4.3/re_comp.3 b/lib/libcompat/4.3/re_comp.3
index 498e639..26e14139 100644
--- a/lib/libcompat/4.3/re_comp.3
+++ b/lib/libcompat/4.3/re_comp.3
@@ -47,6 +47,7 @@
.Sh DESCRIPTION
This interface is made obsolete by
.Xr regex 3 .
+It is available from the compatibility library, libcompat.
.Pp
The
.Fn re_comp
diff --git a/lib/libcompat/4.4/cuserid.3 b/lib/libcompat/4.4/cuserid.3
new file mode 100644
index 0000000..944a9a7
--- /dev/null
+++ b/lib/libcompat/4.4/cuserid.3
@@ -0,0 +1,82 @@
+.\"
+.\" Copyright (c) 1995 Joerg Wunsch
+.\"
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Joerg Wunsch
+.\" 4. The name of the developer may not be used to endorse or promote
+.\" products derived from this software without specific prior written
+.\" permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $Id$
+.\"
+.Dd April 10, 1995
+.Os
+.Dt CUSERID 3
+.Sh NAME
+.Nm cuserid
+.Nd get user name associated with effective UID
+.Sh SYNOPSIS
+.Fd #include <stdio.h>
+.Ft char *
+.Fn cuserid "char *s"
+.Sh DESCRIPTION
+.Bf -symbolic
+The cuserid function is made obsolete by getpwuid.
+.br
+It is available from the compatibility library, libcompat.
+.Ef
+.Pp
+The function
+.Nm cuserid
+gets the user name associated with the effective UID of the current
+process. If the argument
+.Fa s
+is non-zero, the name is copied to the buffer it is pointing to,
+and that address is being returned. This buffer must provide space
+for at least
+.Em L_cuserid
+characters, this constant is defined in
+.Pa Aq stdio.h .
+
+If
+.Fa s
+is zero, an internal array is used an its address will be returned.
+.Sh RETURN VALUES
+.Nm cuserid
+returns the address of an array where the name has been stored to.
+
+If the name associated with the effective UID of the current process
+could not be found, either a null pointer will be returned, or
+.Po
+if
+.Fa s
+is non-zero
+.Pc
+the buffer
+.Fa s
+will be filled with a null string.
+.Sh SEE ALSO
+.Xr getpwuid 3 ,
+.Xr geteuid 3 .
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index 3ac2c38..c06a385 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -11,16 +11,18 @@ NOPIC=
${.CURDIR}/regexp
# compat 4.1 sources
-# XXX MISSING: getpw.c tell.c vlimit.c vtimes.c
-SRCS= ftime.c gtty.c stty.c
+# XXX MISSING: tell.c vlimit.c vtimes.c
+SRCS= ascftime.c cftime.c ftime.c getpw.c gtty.c stty.c
.if (${MACHINE} == "vax")
SRCS+= reset.s
.endif
MAN3+= 4.1/ftime.3 4.1/getpw.3 4.1/stty.3 4.1/vlimit.3 4.1/vtimes.3
+MAN3+= 4.1/cftime.3
MLINKS+=stty.3 gtty.3
+MLINKS+=cftime.3 ascftime.3
# compat 4.3 sources
# XXX MISSING: ecvt.c gcvt.c sibuf.c sobuf.c strout.c
@@ -50,6 +52,7 @@ MLINKS+=re_comp.3 re_exec.3
# compat 4.4 sources
SRCS+= cuserid.c
+MAN3+= 4.4/cuserid.3
# regexp sources
SRCS+= regerror.c regexp.c regsub.c
diff --git a/lib/libcompat/regexp/regexp.3 b/lib/libcompat/regexp/regexp.3
index 0986d4e..8d3b565 100644
--- a/lib/libcompat/regexp/regexp.3
+++ b/lib/libcompat/regexp/regexp.3
@@ -51,6 +51,8 @@
.Sh DESCRIPTION
This interface is made obsolete by
.Xr regex 3 .
+.br
+It is available from the compatibility library, libcompat.
.Pp
The
.Fn regcomp ,
OpenPOWER on IntegriCloud