yp_dbdelete.c revision 30378
126236Swpaul/* 226236Swpaul * Copyright (c) 1995, 1996 326236Swpaul * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 426236Swpaul * 526236Swpaul * Redistribution and use in source and binary forms, with or without 626236Swpaul * modification, are permitted provided that the following conditions 726236Swpaul * are met: 826236Swpaul * 1. Redistributions of source code must retain the above copyright 926236Swpaul * notice, this list of conditions and the following disclaimer. 1026236Swpaul * 2. Redistributions in binary form must reproduce the above copyright 1126236Swpaul * notice, this list of conditions and the following disclaimer in the 1226236Swpaul * documentation and/or other materials provided with the distribution. 1326236Swpaul * 3. All advertising materials mentioning features or use of this software 1426236Swpaul * must display the following acknowledgement: 1526236Swpaul * This product includes software developed by Bill Paul. 1626236Swpaul * 4. Neither the name of the author nor the names of any co-contributors 1726236Swpaul * may be used to endorse or promote products derived from this software 1826236Swpaul * without specific prior written permission. 1926236Swpaul * 2026236Swpaul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 2126236Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2226236Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2326236Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE 2426236Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2526236Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2626236Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2726236Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2826236Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2926236Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3026236Swpaul * SUCH DAMAGE. 3126236Swpaul */ 3230378Scharnier 3330378Scharnier#ifndef lint 3430378Scharnierstatic const char rcsid[] = 3530378Scharnier "$Id$"; 3630378Scharnier#endif /* not lint */ 3730378Scharnier 3826236Swpaul#include <stdio.h> 3926236Swpaul#include <stdlib.h> 4026236Swpaul#include <fcntl.h> 4126236Swpaul#include <string.h> 4226236Swpaul#include <limits.h> 4326236Swpaul#include <unistd.h> 4426236Swpaul#include <db.h> 4526236Swpaul#include <sys/stat.h> 4626236Swpaul#include <errno.h> 4726236Swpaul#include <paths.h> 4826236Swpaul#include <rpcsvc/yp.h> 4926236Swpaul#include "ypxfr_extern.h" 5026236Swpaul 5126236Swpaulint yp_del_record(dbp,key) 5226236Swpaul DB *dbp; 5326236Swpaul DBT *key; 5426236Swpaul{ 5526236Swpaul int rval; 5626236Swpaul 5726236Swpaul if ((rval = (dbp->del)(dbp,key,0))) { 5826236Swpaul switch(rval) { 5926236Swpaul case 1: 6026236Swpaul return(YP_FALSE); 6126236Swpaul break; 6226236Swpaul case -1: 6326236Swpaul default: 6426236Swpaul (void)(dbp->close)(dbp); 6526236Swpaul return(YP_BADDB); 6626236Swpaul break; 6726236Swpaul } 6826236Swpaul } 6926236Swpaul 7026236Swpaul return(YP_TRUE); 7126236Swpaul} 72