yp_dbdelete.c revision 26236
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 *
3226236Swpaul *	$Id: yp_dbdelete.c,v 1.1 1996/12/26 05:43:03 wpaul Exp wpaul $
3326236Swpaul *
3426236Swpaul */
3526236Swpaul#include <stdio.h>
3626236Swpaul#include <stdlib.h>
3726236Swpaul#include <fcntl.h>
3826236Swpaul#include <string.h>
3926236Swpaul#include <limits.h>
4026236Swpaul#include <unistd.h>
4126236Swpaul#include <db.h>
4226236Swpaul#include <sys/stat.h>
4326236Swpaul#include <errno.h>
4426236Swpaul#include <paths.h>
4526236Swpaul#include <rpcsvc/yp.h>
4626236Swpaul#include "ypxfr_extern.h"
4726236Swpaul
4826236Swpaul#ifndef lint
4926236Swpaulstatic const char rcsid[] = "$Id: yp_dbdelete.c,v 1.1 1996/12/26 05:43:03 wpaul Exp wpaul $";
5026236Swpaul#endif
5126236Swpaul
5226236Swpaulint yp_del_record(dbp,key)
5326236Swpaul	DB *dbp;
5426236Swpaul	DBT *key;
5526236Swpaul{
5626236Swpaul	int rval;
5726236Swpaul
5826236Swpaul	if ((rval = (dbp->del)(dbp,key,0))) {
5926236Swpaul		switch(rval) {
6026236Swpaul		case 1:
6126236Swpaul			return(YP_FALSE);
6226236Swpaul			break;
6326236Swpaul		case -1:
6426236Swpaul		default:
6526236Swpaul			(void)(dbp->close)(dbp);
6626236Swpaul			return(YP_BADDB);
6726236Swpaul			break;
6826236Swpaul		}
6926236Swpaul	}
7026236Swpaul
7126236Swpaul	return(YP_TRUE);
7226236Swpaul}
73