ypclnt_get.c revision 94575
1169691Skan/*-
2169691Skan * Copyright (c) 2002 Networks Associates Technology, Inc.
3169691Skan * All rights reserved.
4169691Skan *
5169691Skan * This software was developed for the FreeBSD Project by ThinkSec AS and
6169691Skan * NAI Labs, the Security Research Division of Network Associates, Inc.
7169691Skan * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
8169691Skan * DARPA CHATS research program.
9169691Skan *
10169691Skan * Redistribution and use in source and binary forms, with or without
11169691Skan * modification, are permitted provided that the following conditions
12169691Skan * are met:
13169691Skan * 1. Redistributions of source code must retain the above copyright
14169691Skan *    notice, this list of conditions and the following disclaimer.
15169691Skan * 2. Redistributions in binary form must reproduce the above copyright
16169691Skan *    notice, this list of conditions and the following disclaimer in the
17169691Skan *    documentation and/or other materials provided with the distribution.
18169691Skan * 3. The name of the author may not be used to endorse or promote
19169691Skan *    products derived from this software without specific prior written
20169691Skan *    permission.
21169691Skan *
22169691Skan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23169691Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24169691Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25169691Skan * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26169691Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27169691Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28169691Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29169691Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30169691Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31169691Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32169691Skan * SUCH DAMAGE.
33169691Skan *
34169691Skan * $FreeBSD: head/lib/libypclnt/ypclnt_get.c 94575 2002-04-13 06:20:02Z des $
35169691Skan */
36169691Skan
37169691Skan#include "ypclnt.h"
38169691Skan
39169691Skanchar *
40169691Skanypclnt_get(ypclnt_t *ypc, const char *key)
41169691Skan{
42169691Skan	char *value;
43169691Skan	int len, r;
44169691Skan
45169691Skan	r = yp_match(ypc->domain, ypc->map,
46169691Skan	    key, (int)strlen(key), &value, &len);
47169691Skan	if (r != 0) {
48169691Skan		ypclnt_error(ypc, __func__, "%s", yperr_string(r));
49169691Skan		return (NULL);
50169691Skan	}
51169691Skan	return (value);
52169691Skan}
53169691Skan