ypclnt_new.c revision 225736
175295Sdes/*- 275295Sdes * Copyright (c) 2002 Networks Associates Technology, Inc. 375295Sdes * All rights reserved. 475295Sdes * 575295Sdes * This software was developed for the FreeBSD Project by ThinkSec AS and 675295Sdes * NAI Labs, the Security Research Division of Network Associates, Inc. 775295Sdes * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 875295Sdes * DARPA CHATS research program. 975295Sdes * 1075295Sdes * Redistribution and use in source and binary forms, with or without 1175295Sdes * modification, are permitted provided that the following conditions 1275295Sdes * are met: 1375295Sdes * 1. Redistributions of source code must retain the above copyright 1475295Sdes * notice, this list of conditions and the following disclaimer. 1575295Sdes * 2. Redistributions in binary form must reproduce the above copyright 1675295Sdes * notice, this list of conditions and the following disclaimer in the 1775295Sdes * documentation and/or other materials provided with the distribution. 1875295Sdes * 3. The name of the author may not be used to endorse or promote 1975295Sdes * products derived from this software without specific prior written 2075295Sdes * permission. 2175295Sdes * 2275295Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2375295Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2475295Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2575295Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2675295Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2775295Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2875295Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29143592Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30143592Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31143592Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32143592Sdes * SUCH DAMAGE. 33143592Sdes * 3475295Sdes * $FreeBSD: stable/9/lib/libypclnt/ypclnt_new.c 94575 2002-04-13 06:20:02Z des $ 3575295Sdes */ 3675295Sdes 3784811Sjhb#include <stdlib.h> 3875295Sdes#include <string.h> 3975295Sdes 4075295Sdes#include "ypclnt.h" 4177965Sdes 4275295Sdesypclnt_t * 4375295Sdesypclnt_new(const char *domain, const char *map, const char *server) 4475295Sdes{ 4575295Sdes ypclnt_t *ypclnt; 4675295Sdes 4775295Sdes if ((ypclnt = calloc(1, sizeof *ypclnt)) == NULL) 4875295Sdes return (NULL); 4975295Sdes if (domain != NULL && (ypclnt->domain = strdup(domain)) == NULL) 5085128Sdes goto fail; 5185128Sdes if (map != NULL && (ypclnt->map = strdup(map)) == NULL) 5275295Sdes goto fail; 5375295Sdes if (server != NULL && (ypclnt->server = strdup(server)) == NULL) 5475295Sdes goto fail; 55168764Sdes return (ypclnt); 56168764Sdes fail: 57168764Sdes free(ypclnt->domain); 58168764Sdes free(ypclnt->map); 5985940Sdes free(ypclnt->server); 6085940Sdes free(ypclnt); 6185940Sdes return (NULL); 6285940Sdes} 6375295Sdes