From b2f1975b66e0a83f1c96cf4ef44b1d6d06e0aa3b Mon Sep 17 00:00:00 2001 From: downsj <> Date: Mon, 17 Jun 1996 07:46:05 +0000 Subject: [PATCH] util.h: new resting place opendev.h: ok, so I merged it with util.h opendev.h: use util.h everything else: use "util.h" --- src/lib/libutil/Makefile | 4 +- src/lib/libutil/getmaxpartitions.c | 4 +- src/lib/libutil/getrawpartition.c | 4 +- src/lib/libutil/login.c | 6 ++- src/lib/libutil/login_tty.c | 6 ++- src/lib/libutil/logout.c | 6 ++- src/lib/libutil/logwtmp.c | 6 ++- src/lib/libutil/opendev.c | 15 +++--- src/lib/libutil/opendev.h | 45 ------------------ src/lib/libutil/passwd.c | 4 +- src/lib/libutil/pty.c | 6 ++- src/lib/libutil/util.h | 76 ++++++++++++++++++++++++++++++ 12 files changed, 114 insertions(+), 68 deletions(-) delete mode 100644 src/lib/libutil/opendev.h create mode 100644 src/lib/libutil/util.h diff --git a/src/lib/libutil/Makefile b/src/lib/libutil/Makefile index 49c01cfd..4b9412b0 100644 --- a/src/lib/libutil/Makefile +++ b/src/lib/libutil/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.4 1996/06/17 06:35:32 downsj Exp $ +# $OpenBSD: Makefile,v 1.5 1996/06/17 07:46:01 downsj Exp $ # $NetBSD: Makefile,v 1.8 1996/05/16 07:03:28 thorpej Exp $ LIB= util CFLAGS+=-DLIBC_SCCS -HDRS= opendev.h scsi.h +HDRS= util.h scsi.h SRCS= getmaxpartitions.c getrawpartition.c login.c login_tty.c logout.c \ logwtmp.c opendev.c passwd.c pty.c scsi.c diff --git a/src/lib/libutil/getmaxpartitions.c b/src/lib/libutil/getmaxpartitions.c index 493c885b..0afe6e7a 100644 --- a/src/lib/libutil/getmaxpartitions.c +++ b/src/lib/libutil/getmaxpartitions.c @@ -1,3 +1,4 @@ +/* $OpenBSD: getmaxpartitions.c,v 1.2 1996/06/17 07:46:01 downsj Exp $ */ /* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */ /*- @@ -42,7 +43,8 @@ static char rcsid[] = "$NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 tho #include #include -#include + +#include "util.h" int getmaxpartitions() diff --git a/src/lib/libutil/getrawpartition.c b/src/lib/libutil/getrawpartition.c index 239a030f..346701d1 100644 --- a/src/lib/libutil/getrawpartition.c +++ b/src/lib/libutil/getrawpartition.c @@ -1,3 +1,4 @@ +/* $OpenBSD: getrawpartition.c,v 1.2 1996/06/17 07:46:02 downsj Exp $ */ /* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */ /*- @@ -42,7 +43,8 @@ static char rcsid[] = "$NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thor #include #include -#include + +#include "util.h" int getrawpartition() diff --git a/src/lib/libutil/login.c b/src/lib/libutil/login.c index 2398f001..c7004070 100644 --- a/src/lib/libutil/login.c +++ b/src/lib/libutil/login.c @@ -1,3 +1,4 @@ +/* $OpenBSD: login.c,v 1.3 1996/06/17 07:46:02 downsj Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: login.c,v 1.2 1996/05/22 11:35:05 deraadt Exp $"; +static char *rcsid = "$Id: login.c,v 1.3 1996/06/17 07:46:02 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -43,7 +44,8 @@ static char *rcsid = "$Id: login.c,v 1.2 1996/05/22 11:35:05 deraadt Exp $"; #include #include #include -#include + +#include "util.h" void login(ut) diff --git a/src/lib/libutil/login_tty.c b/src/lib/libutil/login_tty.c index a72a9f45..8b88f4f6 100644 --- a/src/lib/libutil/login_tty.c +++ b/src/lib/libutil/login_tty.c @@ -1,3 +1,4 @@ +/* $OpenBSD: login_tty.c,v 1.3 1996/06/17 07:46:02 downsj Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -33,13 +34,14 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: login_tty.c,v 1.2 1996/05/22 11:35:06 deraadt Exp $"; +static char *rcsid = "$Id: login_tty.c,v 1.3 1996/06/17 07:46:02 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include -#include + +#include "util.h" int login_tty(fd) diff --git a/src/lib/libutil/logout.c b/src/lib/libutil/logout.c index a3e34793..2276167e 100644 --- a/src/lib/libutil/logout.c +++ b/src/lib/libutil/logout.c @@ -1,3 +1,4 @@ +/* $OpenBSD: logout.c,v 1.3 1996/06/17 07:46:03 downsj Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: logout.c,v 1.2 1996/05/22 11:35:07 deraadt Exp $"; +static char *rcsid = "$Id: logout.c,v 1.3 1996/06/17 07:46:03 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -44,7 +45,8 @@ static char *rcsid = "$Id: logout.c,v 1.2 1996/05/22 11:35:07 deraadt Exp $"; #include #include #include -#include + +#include "util.h" typedef struct utmp UTMP; diff --git a/src/lib/libutil/logwtmp.c b/src/lib/libutil/logwtmp.c index 9cfcf2d6..31bb3e5b 100644 --- a/src/lib/libutil/logwtmp.c +++ b/src/lib/libutil/logwtmp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: logwtmp.c,v 1.3 1996/06/17 07:46:03 downsj Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: logwtmp.c,v 1.2 1996/05/22 11:35:08 deraadt Exp $"; +static char *rcsid = "$Id: logwtmp.c,v 1.3 1996/06/17 07:46:03 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -44,7 +45,8 @@ static char *rcsid = "$Id: logwtmp.c,v 1.2 1996/05/22 11:35:08 deraadt Exp $"; #include #include #include -#include + +#include "util.h" void logwtmp(line, name, host) diff --git a/src/lib/libutil/opendev.c b/src/lib/libutil/opendev.c index 66b50e08..6603dc07 100644 --- a/src/lib/libutil/opendev.c +++ b/src/lib/libutil/opendev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opendev.c,v 1.1 1996/06/17 06:35:34 downsj Exp $ */ +/* $OpenBSD: opendev.c,v 1.2 1996/06/17 07:46:03 downsj Exp $ */ /* * Copyright (c) 1996, Jason Downs. All rights reserved. @@ -31,7 +31,7 @@ #include #include -#include "opendev.h" +#include "util.h" /* * This routine is a generic rewrite of the original code found in @@ -39,11 +39,10 @@ */ int -opendev(path, oflags, dflags, mode, realpath) +opendev(path, oflags, dflags, realpath) char *path; int oflags; int dflags; - mode_t mode; char **realpath; { int fd; @@ -51,7 +50,7 @@ opendev(path, oflags, dflags, mode, realpath) *realpath = path; - fd = open(path, oflags, mode); + fd = open(path, oflags); if ((fd < 0) && (errno == ENOENT)) { if (path[0] != '/') { if (dflags & OPENDEV_PART) { @@ -61,14 +60,14 @@ opendev(path, oflags, dflags, mode, realpath) */ (void)snprintf(namebuf, sizeof(namebuf), "%sr%s%c", _PATH_DEV, path, 'a' + RAW_PART); - fd = open(namebuf, oflags, mode); + fd = open(namebuf, oflags); } if ((dflags & OPENDEV_DRCT) && (fd < 0) && (errno == ENOENT)) { /* ..and now no partition (for tapes) */ namebuf[strlen(namebuf) - 1] = '\0'; - fd = open(namebuf, oflags, mode); + fd = open(namebuf, oflags); } *realpath = namebuf; @@ -77,7 +76,7 @@ opendev(path, oflags, dflags, mode, realpath) if ((fd < 0) && (errno == ENOENT) && (path[0] != '/')) { (void)snprintf(namebuf, sizeof(namebuf), "%sr%s", _PATH_DEV, path); - fd = open(namebuf, oflags, mode); + fd = open(namebuf, oflags); *realpath = namebuf; } diff --git a/src/lib/libutil/opendev.h b/src/lib/libutil/opendev.h deleted file mode 100644 index f81f7840..00000000 --- a/src/lib/libutil/opendev.h +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: opendev.h,v 1.1 1996/06/17 06:35:34 downsj Exp $ */ - -/* - * Copyright (c) 1996, Jason Downs. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 AUTHOR(S) 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. - */ - -#ifndef _OPENDEV_H_ -#define _OPENDEV_H_ - -#include - -/* - * opendev() specific operation flags. - */ -#define OPENDEV_PART 0x01 /* Try to open the raw partition. */ -#define OPENDEV_DRCT 0x02 /* Try to open the device directly. */ - -#include - -__BEGIN_DECLS -int opendev __P((char *, int, int, mode_t, char **)); -__END_DECLS - -#endif /* _OPENDEV_H_ */ diff --git a/src/lib/libutil/passwd.c b/src/lib/libutil/passwd.c index 0d03133d..8c7eeb5f 100644 --- a/src/lib/libutil/passwd.c +++ b/src/lib/libutil/passwd.c @@ -1,3 +1,4 @@ +/* $OpenBSD: passwd.c,v 1.3 1996/06/17 07:46:04 downsj Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. @@ -51,7 +52,8 @@ static char rcsid[] = "$NetBSD: passwd.c,v 1.1 1996/05/15 21:42:31 jtc Exp $"; #include #include #include -#include + +#include "util.h" static void pw_cont __P((int sig)); diff --git a/src/lib/libutil/pty.c b/src/lib/libutil/pty.c index 1319ae12..fa2c1cad 100644 --- a/src/lib/libutil/pty.c +++ b/src/lib/libutil/pty.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pty.c,v 1.3 1996/06/17 07:46:05 downsj Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -33,7 +34,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: pty.c,v 1.2 1996/05/22 11:35:11 deraadt Exp $"; +static char *rcsid = "$Id: pty.c,v 1.3 1996/06/17 07:46:05 downsj Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -47,7 +48,8 @@ static char *rcsid = "$Id: pty.c,v 1.2 1996/05/22 11:35:11 deraadt Exp $"; #include #include #include -#include + +#include "util.h" #ifdef i386 /* PCVT conflicts with ttyv*. */ diff --git a/src/lib/libutil/util.h b/src/lib/libutil/util.h new file mode 100644 index 00000000..95a7006e --- /dev/null +++ b/src/lib/libutil/util.h @@ -0,0 +1,76 @@ +/* $OpenBSD: util.h,v 1.1 1996/06/17 07:46:05 downsj Exp $ */ +/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ + +/*- + * Copyright (c) 1995 + * The Regents of the University of California. All rights reserved. + * Portions Copyright (c) 1996, Jason Downs. 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 the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include +#include +#include +#include +#include +#include + +/* + * opendev() specific operation flags. + */ +#define OPENDEV_PART 0x01 /* Try to open the raw partition. */ +#define OPENDEV_DRCT 0x02 /* Try to open the device directly. */ + +__BEGIN_DECLS +void login __P((struct utmp *)); +int login_tty __P((int)); +int logout __P((const char *)); +void logwtmp __P((const char *, const char *, const char *)); +int opendev __P((char *, int, int, char **)); +int pw_lock __P((int retries)); +int pw_mkdb __P((void)); +int pw_abort __P((void)); +void pw_init __P((void)); +void pw_edit __P((int notsetuid, const char *filename)); +void pw_prompt __P((void)); +void pw_copy __P((int ffd, int tfd, struct passwd *pw)); +int pw_scan __P((char *bp, struct passwd *pw, int *flags)); +void pw_error __P((const char *name, int err, int eval)); +int openpty __P((int *, int *, char *, struct termios *, + struct winsize *)); +pid_t forkpty __P((int *, char *, struct termios *, struct winsize *)); +int getmaxpartitions __P((void)); +int getrawpartition __P((void)); +__END_DECLS + +#endif /* !_UTIL_H_ */