summaryrefslogtreecommitdiffstats
path: root/contrib/telnet/libtelnet/getent.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/telnet/libtelnet/getent.c')
-rw-r--r--contrib/telnet/libtelnet/getent.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/contrib/telnet/libtelnet/getent.c b/contrib/telnet/libtelnet/getent.c
index ee6f03f..d6e8d9c 100644
--- a/contrib/telnet/libtelnet/getent.c
+++ b/contrib/telnet/libtelnet/getent.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -40,37 +41,36 @@ static char sccsid[] = "@(#)getent.c 8.2 (Berkeley) 12/15/93";
#endif
#endif /* not lint */
-#ifdef HAS_CGETENT
#include <stdlib.h>
-#endif
+#include <string.h>
+
+#include "misc-proto.h"
static char *area;
+static char gettytab[] = "/etc/gettytab";
/*ARGSUSED*/
int
-getent(char *cp, char *name)
+getent(char *cp __unused, const char *name)
{
-#ifdef HAS_CGETENT
- char *dba[2];
+ int retval;
+ char *tempnam, *dba[2] = { gettytab, NULL };
- dba[0] = "/etc/gettytab";
- dba[1] = 0;
- return((cgetent(&area, dba, name) == 0) ? 1 : 0);
-#else
- return(0);
-#endif
+ tempnam = strdup(name);
+ retval = cgetent(&area, dba, tempnam) == 0 ? 1 : 0;
+ free(tempnam);
+ return(retval);
}
-#ifndef SOLARIS
/*ARGSUSED*/
char *
-Getstr(char *id, char **cpp)
+Getstr(const char *id, char **cpp __unused)
{
-# ifdef HAS_CGETENT
- char *answer;
- return((cgetstr(area, id, &answer) > 0) ? answer : 0);
-# else
- return(0);
-# endif
+ int retval;
+ char *answer, *tempid;
+
+ tempid = strdup(id);
+ retval = cgetstr(area, tempid, &answer);
+ free(tempid);
+ return((retval > 0) ? answer : NULL);
}
-#endif
OpenPOWER on IntegriCloud