1181643Skmacy/*-
2196661Skmacy * SPDX-License-Identifier: BSD-3-Clause
3196661Skmacy *
4251195Sgibbs * Copyright (c) 2002 Networks Associates Technology, Inc.
5199960Skmacy * All rights reserved.
6196661Skmacy *
7199959Skmacy * This software was developed for the FreeBSD Project by ThinkSec AS and
8199959Skmacy * NAI Labs, the Security Research Division of Network Associates, Inc.
9199959Skmacy * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
10199959Skmacy * DARPA CHATS research program.
11199959Skmacy *
12199959Skmacy * Redistribution and use in source and binary forms, with or without
13199959Skmacy * modification, are permitted provided that the following conditions
14199959Skmacy * are met:
15199959Skmacy * 1. Redistributions of source code must retain the above copyright
16199959Skmacy *    notice, this list of conditions and the following disclaimer.
17199959Skmacy * 2. Redistributions in binary form must reproduce the above copyright
18199959Skmacy *    notice, this list of conditions and the following disclaimer in the
19199959Skmacy *    documentation and/or other materials provided with the distribution.
20199959Skmacy * 3. The name of the author may not be used to endorse or promote
21199959Skmacy *    products derived from this software without specific prior written
22199959Skmacy *    permission.
23199959Skmacy *
24199959Skmacy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25199959Skmacy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26199959Skmacy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27199959Skmacy * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28199959Skmacy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29181643Skmacy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30181643Skmacy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31181643Skmacy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32181643Skmacy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33181643Skmacy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34181643Skmacy * SUCH DAMAGE.
35181643Skmacy */
36181643Skmacy
37181643Skmacy#include <stdlib.h>
38181643Skmacy#include <string.h>
39181643Skmacy
40181643Skmacy#include "ypclnt.h"
41181643Skmacy
42181643Skmacyypclnt_t *
43181643Skmacyypclnt_new(const char *domain, const char *map, const char *server)
44181643Skmacy{
45231743Sgibbs	ypclnt_t *ypclnt;
46181643Skmacy
47181643Skmacy	if ((ypclnt = calloc(1, sizeof *ypclnt)) == NULL)
48181643Skmacy		return (NULL);
49181643Skmacy	if (domain != NULL && (ypclnt->domain = strdup(domain)) == NULL)
50181643Skmacy		goto fail;
51181643Skmacy	if (map != NULL && (ypclnt->map = strdup(map)) == NULL)
52199960Skmacy		goto fail;
53181643Skmacy	if (server != NULL && (ypclnt->server = strdup(server)) == NULL)
54255040Sgibbs		goto fail;
55186557Skmacy	return (ypclnt);
56186557Skmacy fail:
57189699Sdfr	free(ypclnt->domain);
58181643Skmacy	free(ypclnt->map);
59185605Skmacy	free(ypclnt->server);
60185605Skmacy	free(ypclnt);
61181643Skmacy	return (NULL);
62255040Sgibbs}
63255040Sgibbs