diff options
author | joerg <joerg@FreeBSD.org> | 1995-04-10 18:48:06 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1995-04-10 18:48:06 +0000 |
commit | 6f7aeef5d23452d060640fff99700130e2febdc8 (patch) | |
tree | cc4fd4fba012a457776cc9830705db7f92d4ac6e /lib/libcompat/4.1 | |
parent | 22aeb7b0802de48f886c9f428ae99d8a969031d1 (diff) | |
download | FreeBSD-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/4.1')
-rw-r--r-- | lib/libcompat/4.1/ascftime.c | 52 | ||||
-rw-r--r-- | lib/libcompat/4.1/cftime.3 | 99 | ||||
-rw-r--r-- | lib/libcompat/4.1/cftime.c | 53 | ||||
-rw-r--r-- | lib/libcompat/4.1/getpw.3 | 8 | ||||
-rw-r--r-- | lib/libcompat/4.1/getpw.c | 58 | ||||
-rw-r--r-- | lib/libcompat/4.1/gtty.c | 5 | ||||
-rw-r--r-- | lib/libcompat/4.1/stty.c | 5 | ||||
-rw-r--r-- | lib/libcompat/4.1/vlimit.3 | 2 | ||||
-rw-r--r-- | lib/libcompat/4.1/vtimes.3 | 2 |
9 files changed, 282 insertions, 2 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. |