129088Smarkm/*-
229088Smarkm * Copyright (c) 1991, 1993
329088Smarkm *	The Regents of the University of California.  All rights reserved.
429088Smarkm *
529088Smarkm * Redistribution and use in source and binary forms, with or without
629088Smarkm * modification, are permitted provided that the following conditions
729088Smarkm * are met:
829088Smarkm * 1. Redistributions of source code must retain the above copyright
929088Smarkm *    notice, this list of conditions and the following disclaimer.
1029088Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1129088Smarkm *    notice, this list of conditions and the following disclaimer in the
1229088Smarkm *    documentation and/or other materials provided with the distribution.
1329088Smarkm * 3. All advertising materials mentioning features or use of this software
1429088Smarkm *    must display the following acknowledgement:
1529088Smarkm *	This product includes software developed by the University of
1629088Smarkm *	California, Berkeley and its contributors.
1729088Smarkm * 4. Neither the name of the University nor the names of its contributors
1829088Smarkm *    may be used to endorse or promote products derived from this software
1929088Smarkm *    without specific prior written permission.
2029088Smarkm *
2129088Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2229088Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2329088Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2429088Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2529088Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2629088Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2729088Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2829088Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2929088Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3029088Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3129088Smarkm * SUCH DAMAGE.
3229088Smarkm */
3329088Smarkm
3484305Smarkm#include <sys/cdefs.h>
3587139Smarkm
3684305Smarkm__FBSDID("$FreeBSD$");
3784305Smarkm
3829088Smarkm#ifndef lint
3963248Speter#if 0
4029088Smarkmstatic char sccsid[] = "@(#)getent.c	8.2 (Berkeley) 12/15/93";
4163248Speter#endif
4229088Smarkm#endif /* not lint */
4329088Smarkm
4481965Smarkm#include <stdlib.h>
4587139Smarkm#include <string.h>
4681965Smarkm
4787139Smarkm#include "misc-proto.h"
4887139Smarkm
4929088Smarkmstatic char *area;
5087139Smarkmstatic char gettytab[] = "/etc/gettytab";
5129088Smarkm
5229088Smarkm/*ARGSUSED*/
5381965Smarkmint
5487139Smarkmgetent(char *cp __unused, const char *name)
5529088Smarkm{
5687139Smarkm	int retval;
5787139Smarkm	char *tempnam, *dba[2] = { gettytab, NULL };
5829088Smarkm
5987139Smarkm	tempnam = strdup(name);
6087139Smarkm	retval =  cgetent(&area, dba, tempnam) == 0 ? 1 : 0;
6187139Smarkm	free(tempnam);
6287139Smarkm	return(retval);
6329088Smarkm}
6429088Smarkm
6529088Smarkm/*ARGSUSED*/
6629088Smarkmchar *
6787139SmarkmGetstr(const char *id, char **cpp __unused)
6829088Smarkm{
6987139Smarkm	int retval;
7087139Smarkm	char *answer, *tempid;
7187139Smarkm
7287139Smarkm	tempid = strdup(id);
7387139Smarkm	retval = cgetstr(area, tempid, &answer);
7487139Smarkm	free(tempid);
7587139Smarkm	return((retval > 0) ? answer : NULL);
7629088Smarkm}
77