Browse Source

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"
OPENBSD_2_0
downsj 28 years ago
parent
commit
b2f1975b66
12 changed files with 114 additions and 68 deletions
  1. +2
    -2
      src/lib/libutil/Makefile
  2. +3
    -1
      src/lib/libutil/getmaxpartitions.c
  3. +3
    -1
      src/lib/libutil/getrawpartition.c
  4. +4
    -2
      src/lib/libutil/login.c
  5. +4
    -2
      src/lib/libutil/login_tty.c
  6. +4
    -2
      src/lib/libutil/logout.c
  7. +4
    -2
      src/lib/libutil/logwtmp.c
  8. +7
    -8
      src/lib/libutil/opendev.c
  9. +0
    -45
      src/lib/libutil/opendev.h
  10. +3
    -1
      src/lib/libutil/passwd.c
  11. +4
    -2
      src/lib/libutil/pty.c
  12. +76
    -0
      src/lib/libutil/util.h

+ 2
- 2
src/lib/libutil/Makefile View File

@ -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


+ 3
- 1
src/lib/libutil/getmaxpartitions.c View File

@ -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 <sys/param.h>
#include <sys/sysctl.h>
#include <util.h>
#include "util.h"
int
getmaxpartitions()


+ 3
- 1
src/lib/libutil/getrawpartition.c View File

@ -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 <sys/param.h>
#include <sys/sysctl.h>
#include <util.h>
#include "util.h"
int
getrawpartition()


+ 4
- 2
src/lib/libutil/login.c View File

@ -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 <sys/types.h>
@ -43,7 +44,8 @@ static char *rcsid = "$Id: login.c,v 1.2 1996/05/22 11:35:05 deraadt Exp $";
#include <stdlib.h>
#include <utmp.h>
#include <stdio.h>
#include <util.h>
#include "util.h"
void
login(ut)


+ 4
- 2
src/lib/libutil/login_tty.c View File

@ -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 <sys/param.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <util.h>
#include "util.h"
int
login_tty(fd)


+ 4
- 2
src/lib/libutil/logout.c View File

@ -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 <sys/types.h>
@ -44,7 +45,8 @@ static char *rcsid = "$Id: logout.c,v 1.2 1996/05/22 11:35:07 deraadt Exp $";
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <util.h>
#include "util.h"
typedef struct utmp UTMP;


+ 4
- 2
src/lib/libutil/logwtmp.c View File

@ -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 <sys/types.h>
@ -44,7 +45,8 @@ static char *rcsid = "$Id: logwtmp.c,v 1.2 1996/05/22 11:35:08 deraadt Exp $";
#include <string.h>
#include <unistd.h>
#include <utmp.h>
#include <util.h>
#include "util.h"
void
logwtmp(line, name, host)


+ 7
- 8
src/lib/libutil/opendev.c View File

@ -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 <sys/disklabel.h>
#include <paths.h>
#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;
}


+ 0
- 45
src/lib/libutil/opendev.h View File

@ -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 <sys/types.h>
/*
* 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 <sys/cdefs.h>
__BEGIN_DECLS
int opendev __P((char *, int, int, mode_t, char **));
__END_DECLS
#endif /* _OPENDEV_H_ */

+ 3
- 1
src/lib/libutil/passwd.c View File

@ -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 <paths.h>
#include <signal.h>
#include <limits.h>
#include <util.h>
#include "util.h"
static void pw_cont __P((int sig));


+ 4
- 2
src/lib/libutil/pty.c View File

@ -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 <sys/cdefs.h>
@ -47,7 +48,8 @@ static char *rcsid = "$Id: pty.c,v 1.2 1996/05/22 11:35:11 deraadt Exp $";
#include <stdio.h>
#include <string.h>
#include <grp.h>
#include <util.h>
#include "util.h"
#ifdef i386
/* PCVT conflicts with ttyv*. */


+ 76
- 0
src/lib/libutil/util.h View File

@ -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 <pwd.h>
#include <utmp.h>
#include <termios.h>
#include <sys/ttycom.h>
#include <sys/types.h>
#include <sys/cdefs.h>
/*
* 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_ */

Loading…
Cancel
Save