Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / lib / libutil / compat / compat_passwd.c
blob6ecfe85c24a3a4f63685a417a7eb1e5ddb8423d7
1 /* $NetBSD: compat_passwd.c,v 1.1.2.1 2008/12/28 01:14:32 christos Exp $ */
3 /*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
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. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/cdefs.h>
39 #if defined(LIBC_SCCS) && !defined(lint)
40 __RCSID("$NetBSD: compat_passwd.c,v 1.1.2.1 2008/12/28 01:14:32 christos Exp $");
41 #endif /* LIBC_SCCS and not lint */
43 #define __LIBC12_SOURCE__
45 #include <stdint.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <pwd.h>
49 #include <compat/include/pwd.h>
50 #include <util.h>
51 #include <compat/util.h>
53 __warn_references(pw_scan,
54 "warning: reference to compatibility pw_scan(); "
55 "include <pwd.h> to generate correct reference")
56 __warn_references(pw_copy,
57 "warning: reference to compatibility pw_copy(); "
58 "include <util.h> to generate correct reference")
59 __warn_references(pw_copyx,
60 "warning: reference to compatibility pw_copyx(); "
61 "include <util.h> to generate correct reference")
62 __warn_references(pw_getpwconf,
63 "warning: reference to compatibility pw_getpwconf(); "
64 "include <pwd.h> to generate correct reference")
66 int
67 pw_scan(char *buf, struct passwd50 *p, int *flags)
69 struct passwd px;
70 int rv = __pw_scan50(buf, &px, flags);
71 passwd_to_passwd50(&px, p);
72 return rv;
75 void
76 pw_copy(int ffd, int tfd, struct passwd50 *pw50, struct passwd50 *opw50)
78 struct passwd pw, opw;
79 passwd50_to_passwd(pw50, &pw);
80 if (opw50)
81 passwd50_to_passwd(opw50, &opw);
82 __pw_copy50(ffd, tfd, &pw, opw50 ? &opw : NULL);
85 int
86 pw_copyx(int ffd, int tfd, struct passwd50 *pw50, struct passwd50 *opw50,
87 char *errbuf, size_t errbufsiz)
89 struct passwd pw, opw;
90 passwd50_to_passwd(pw50, &pw);
91 if (opw50)
92 passwd50_to_passwd(opw50, &opw);
93 return __pw_copyx50(ffd, tfd, &pw, opw50 ? &opw : NULL, errbuf,
94 errbufsiz);
97 void
98 pw_getpwconf(char *buf, size_t len, const struct passwd50 *p, const char *opt)
100 struct passwd px;
101 passwd50_to_passwd(p, &px);
102 __pw_getpwconf50(buf, len, &px, opt);