4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libc / net / getservbyname.c
index 993a0f7..50d207b 100644 (file)
@@ -1,23 +1,27 @@
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getservbyname.c    5.2 (Berkeley) %G%";
-#endif LIBC_SCCS and not lint
+static char sccsid[] = "@(#)getservbyname.c    8.1 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
 
 #include <netdb.h>
 
 #include <netdb.h>
+#include <string.h>
+
+extern int _serv_stayopen;
 
 struct servent *
 getservbyname(name, proto)
 
 struct servent *
 getservbyname(name, proto)
-       char *name, *proto;
+       const char *name, *proto;
 {
        register struct servent *p;
        register char **cp;
 
 {
        register struct servent *p;
        register char **cp;
 
-       setservent(0);
+       setservent(_serv_stayopen);
        while (p = getservent()) {
                if (strcmp(name, p->s_name) == 0)
                        goto gotname;
        while (p = getservent()) {
                if (strcmp(name, p->s_name) == 0)
                        goto gotname;
@@ -29,6 +33,7 @@ gotname:
                if (proto == 0 || strcmp(p->s_proto, proto) == 0)
                        break;
        }
                if (proto == 0 || strcmp(p->s_proto, proto) == 0)
                        break;
        }
-       endservent();
+       if (!_serv_stayopen)
+               endservent();
        return (p);
 }
        return (p);
 }