From 6f7aeef5d23452d060640fff99700130e2febdc8 Mon Sep 17 00:00:00 2001 From: joerg Date: Mon, 10 Apr 1995 18:48:06 +0000 Subject: 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 --- lib/libcompat/4.1/ascftime.c | 52 +++++++++++++++++++++++ lib/libcompat/4.1/cftime.3 | 99 +++++++++++++++++++++++++++++++++++++++++++ lib/libcompat/4.1/cftime.c | 53 +++++++++++++++++++++++ lib/libcompat/4.1/getpw.3 | 8 ++++ lib/libcompat/4.1/getpw.c | 58 +++++++++++++++++++++++++ lib/libcompat/4.1/gtty.c | 5 ++- lib/libcompat/4.1/stty.c | 5 ++- lib/libcompat/4.1/vlimit.3 | 2 + lib/libcompat/4.1/vtimes.3 | 2 + lib/libcompat/4.3/insque.3 | 6 +++ lib/libcompat/4.3/re_comp.3 | 1 + lib/libcompat/4.4/cuserid.3 | 82 +++++++++++++++++++++++++++++++++++ lib/libcompat/Makefile | 7 ++- lib/libcompat/regexp/regexp.3 | 2 + 14 files changed, 378 insertions(+), 4 deletions(-) create mode 100644 lib/libcompat/4.1/ascftime.c create mode 100644 lib/libcompat/4.1/cftime.3 create mode 100644 lib/libcompat/4.1/cftime.c create mode 100644 lib/libcompat/4.1/getpw.c create mode 100644 lib/libcompat/4.4/cuserid.3 (limited to 'lib/libcompat') 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 + +#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 +.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 + +#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 +#include +#include +#include + +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 @@ -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 @@ -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 +.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 , -- cgit v1.1