| 1 | /*	$OpenBSD: util.h,v 1.38 2022/05/11 17:23:56 millert Exp $	*/ |
| 2 | /*	$NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $	*/ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1995 |
| 6 | *	The Regents of the University of California. All rights reserved. |
| 7 | * Portions Copyright (c) 1996, Jason Downs. All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * 3. Neither the name of the University nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this software |
| 19 | * without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | * SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #ifndef _UTIL_H_ |
| 35 | #define _UTIL_H_ |
| 36 | |
| 37 | #include <sys/types.h> |
| 38 | |
| 39 | /* |
| 40 | * fparseln() specific operation flags. |
| 41 | */ |
| 42 | #define FPARSELN_UNESCESC	0x01 |
| 43 | #define FPARSELN_UNESCCONT	0x02 |
| 44 | #define FPARSELN_UNESCCOMM	0x04 |
| 45 | #define FPARSELN_UNESCREST	0x08 |
| 46 | #define FPARSELN_UNESCALL	0x0f |
| 47 | |
| 48 | /* |
| 49 | * opendev() specific operation flags. |
| 50 | */ |
| 51 | #define OPENDEV_PART	0x01		/* Try to open the raw partition. */ |
| 52 | #define OPENDEV_BLCK	0x04		/* Open block, not character device. */ |
| 53 | |
| 54 | /* |
| 55 | * uu_lock(3) specific flags. |
| 56 | */ |
| 57 | #define UU_LOCK_INUSE (1) |
| 58 | #define UU_LOCK_OK (0) |
| 59 | #define UU_LOCK_OPEN_ERR (-1) |
| 60 | #define UU_LOCK_READ_ERR (-2) |
| 61 | #define UU_LOCK_CREAT_ERR (-3) |
| 62 | #define UU_LOCK_WRITE_ERR (-4) |
| 63 | #define UU_LOCK_LINK_ERR (-5) |
| 64 | #define UU_LOCK_TRY_ERR (-6) |
| 65 | #define UU_LOCK_OWNER_ERR (-7) |
| 66 | |
| 67 | /* |
| 68 | * fmt_scaled(3) specific flags. |
| 69 | */ |
| 70 | #define	FMT_SCALED_STRSIZE	7	/* minus sign, 4 digits, suffix, null byte */ |
| 71 | |
| 72 | /* |
| 73 | * stub struct definitions. |
| 74 | */ |
| 75 | struct __sFILE; |
| 76 | struct login_cap; |
| 77 | struct passwd; |
| 78 | struct termios; |
| 79 | struct utmp; |
| 80 | struct winsize; |
| 81 | |
| 82 | __BEGIN_DECLS |
| 83 | char *fparseln(struct __sFILE *, size_t *, size_t *, const char[3], int); |
| 84 | void	login(struct utmp *); |
| 85 | int	login_tty(int); |
| 86 | int	logout(const char *); |
| 87 | void	logwtmp(const char *, const char *, const char *); |
| 88 | int	opendev(const char *, int, int, char **); |
| 89 | int	pidfile(const char *); |
| 90 | void	pw_setdir(const char *); |
| 91 | char *pw_file(const char *); |
| 92 | int	pw_lock(int); |
| 93 | int	pw_mkdb(char *, int); |
| 94 | int	pw_abort(void); |
| 95 | void	pw_init(void); |
| 96 | void	pw_edit(int, const char *); |
| 97 | void	pw_prompt(void); |
| 98 | void	pw_copy(int, int, const struct passwd *, const struct passwd *); |
| 99 | int	pw_scan(char *, struct passwd *, int *); |
| 100 | __dead void pw_error(const char *, int, int); |
| 101 | int	getptmfd(void); |
| 102 | int	openpty(int *, int *, char *, const struct termios *, |
| 103 | 	 const struct winsize *); |
| 104 | int	fdopenpty(int, int *, int *, char *, const struct termios *, |
| 105 | 	 const struct winsize *); |
| 106 | int	opendisk(const char *, int, char *, size_t, int); |
| 107 | pid_t	forkpty(int *, char *, const struct termios *, const struct winsize *); |
| 108 | pid_t	fdforkpty(int, int *, char *, const struct termios *, |
| 109 | 	 const struct winsize *); |
| 110 | int	getmaxpartitions(void); |
| 111 | int	getrawpartition(void); |
| 112 | void	login_fbtab(const char *, uid_t, gid_t); |
| 113 | int	login_check_expire(struct __sFILE *, struct passwd *, char *, int); |
| 114 | char *readlabelfs(char *, int); |
| 115 | const char *uu_lockerr(int); |
| 116 | int uu_lock(const char *); |
| 117 | int	uu_lock_txfr(const char *, pid_t); |
| 118 | int uu_unlock(const char *); |
| 119 | int	fmt_scaled(long long, char *); |
| 120 | int	scan_scaled(char *, long long *); |
| 121 | int	isduid(const char *, int); |
| 122 | int	pkcs5_pbkdf2(const char *, size_t, const uint8_t *, size_t, |
| 123 | uint8_t *, size_t, unsigned int); |
| 124 | int	bcrypt_pbkdf(const char *, size_t, const uint8_t *, size_t, |
| 125 | uint8_t *, size_t, unsigned int); |
| 126 | |
| 127 | __END_DECLS |
| 128 | |
| 129 | #endif /* !_UTIL_H_ */ |