libutil.h revision 68488
1224133Sdim/*
2224133Sdim * Copyright (c) 1996  Peter Wemm <peter@FreeBSD.org>.
3224133Sdim * All rights reserved.
4224133Sdim *
5224133Sdim * Redistribution and use in source and binary forms, with or without
6224133Sdim * modification, is permitted provided that the following conditions
7224133Sdim * are met:
8224133Sdim * 1. Redistributions of source code must retain the above copyright
9224133Sdim *    notice, this list of conditions and the following disclaimer.
10224133Sdim * 2. Redistributions in binary form must reproduce the above copyright
11224133Sdim *    notice, this list of conditions and the following disclaimer in the
12224133Sdim *    documentation and/or other materials provided with the distribution.
13224133Sdim *
14224133Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15224133Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16224133Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17224133Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18224133Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19239462Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20224133Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21224133Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22224133Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23224133Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24224133Sdim * SUCH DAMAGE.
25224133Sdim *
26224133Sdim * $FreeBSD: head/lib/libutil/libutil.h 68488 2000-11-08 11:57:03Z murray $
27224133Sdim */
28224133Sdim
29224133Sdim#ifndef _LIBUTIL_H_
30224133Sdim#define	_LIBUTIL_H_
31224133Sdim
32224133Sdim#include <sys/cdefs.h>
33224133Sdim
34224133Sdim#define PROPERTY_MAX_NAME	64
35224133Sdim#define PROPERTY_MAX_VALUE	512
36224133Sdim
37224133Sdim/* for properties.c */
38224133Sdimtypedef struct _property {
39224133Sdim	struct _property *next;
40224133Sdim	char *name;
41224133Sdim	char *value;
42224133Sdim} *properties;
43224133Sdim
44224133Sdim/* Avoid pulling in all the include files for no need */
45224133Sdimstruct termios;
46224133Sdimstruct winsize;
47224133Sdimstruct utmp;
48224133Sdimstruct in_addr;
49224133Sdim
50224133Sdim__BEGIN_DECLS
51224133Sdimvoid	login __P((struct utmp *_ut));
52224133Sdimint	login_tty __P((int _fd));
53224133Sdimint	logout __P((const char *_line));
54224133Sdimvoid	logwtmp __P((const char *_line, const char *_name, const char *_host));
55224133Sdimvoid	trimdomain __P((char *_fullhost, int _hostsize));
56224133Sdimint	openpty __P((int *_amaster, int *_aslave, char *_name,
57224133Sdim		     struct termios *_termp, struct winsize *_winp));
58224133Sdimint	forkpty __P((int *_amaster, char *_name,
59224133Sdim		     struct termios *_termp, struct winsize *_winp));
60224133Sdimconst char *uu_lockerr __P((int _uu_lockresult));
61224133Sdimint	uu_lock __P((const char *_ttyname));
62224133Sdimint	uu_unlock __P((const char *_ttyname));
63224133Sdimint	uu_lock_txfr __P((const char *_ttyname, pid_t _pid));
64224133Sdimint	_secure_path __P((const char *_path, uid_t _uid, gid_t _gid));
65224133Sdimproperties properties_read __P((int fd));
66224133Sdimvoid	properties_free __P((properties list));
67224133Sdimchar	*property_find __P((properties list, const char *name));
68224133Sdimchar	*auth_getval __P((const char *name));
69224133Sdimint	realhostname __P((char *host, size_t hsize, const struct in_addr *ip));
70224133Sdimstruct sockaddr;
71224133Sdimint	realhostname_sa __P((char *host, size_t hsize, struct sockaddr *addr,
72224133Sdim			     int addrlen));
73224133Sdim#ifdef _STDIO_H_	/* avoid adding new includes */
74224133Sdimchar   *fparseln __P((FILE *, size_t *, size_t *, const char[3], int));
75224133Sdim#endif
76224133Sdim__END_DECLS
77224133Sdim
78224133Sdim#define UU_LOCK_INUSE (1)
79224133Sdim#define UU_LOCK_OK (0)
80224133Sdim#define UU_LOCK_OPEN_ERR (-1)
81224133Sdim#define UU_LOCK_READ_ERR (-2)
82224133Sdim#define UU_LOCK_CREAT_ERR (-3)
83224133Sdim#define UU_LOCK_WRITE_ERR (-4)
84224133Sdim#define UU_LOCK_LINK_ERR (-5)
85224133Sdim#define UU_LOCK_TRY_ERR (-6)
86224133Sdim#define UU_LOCK_OWNER_ERR (-7)
87224133Sdim
88224133Sdim/* return values from realhostname() */
89224133Sdim#define HOSTNAME_FOUND		(0)
90224133Sdim#define HOSTNAME_INCORRECTNAME	(1)
91224133Sdim#define HOSTNAME_INVALIDADDR	(2)
92224133Sdim#define HOSTNAME_INVALIDNAME	(3)
93224133Sdim
94224133Sdim/* fparseln(3) */
95224133Sdim#define	FPARSELN_UNESCESC	0x01
96224133Sdim#define	FPARSELN_UNESCCONT	0x02
97224133Sdim#define	FPARSELN_UNESCCOMM	0x04
98224133Sdim#define	FPARSELN_UNESCREST	0x08
99239462Sdim#define	FPARSELN_UNESCALL	0x0f
100224133Sdim
101224133Sdim#endif /* !_LIBUTIL_H_ */
102224133Sdim