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