]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nss_nisplus/nisplus-proto.c
Update.
[thirdparty/glibc.git] / nis / nss_nisplus / nisplus-proto.c
index 984530dcddfd4246379f8631617b64da82a8eb79..10f9a38e67df64f281ebecf367500715ff066ad0 100644 (file)
@@ -1,21 +1,21 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #include <nss.h>
 #include <errno.h>
@@ -29,9 +29,9 @@
 
 __libc_lock_define_initialized (static, lock)
 
-static nis_result *result = NULL;
-static nis_name tablename_val = NULL;
-static u_long tablename_len = 0;
+static nis_result *result;
+static nis_name tablename_val;
+static u_long tablename_len;
 
 #define NISENTRYVAL(idx,col,res) \
         ((res)->objects.objects_val[(idx)].EN_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
@@ -289,6 +289,7 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
     {
       nis_result *result;
       char buf[strlen (name) + 255 + tablename_len];
+      int olderr = errno;
 
       /* Search at first in the alias list, and use the correct name
          for the next search */
@@ -314,6 +315,8 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
        {
          enum nss_status status = niserr2nss (result->status);
 
+         __set_errno (olderr);
+
          nis_freeresult (result);
          return status;
        }
@@ -331,7 +334,10 @@ _nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
              return NSS_STATUS_TRYAGAIN;
            }
          else
-           return NSS_STATUS_NOTFOUND;
+           {
+             __set_errno (olderr);
+             return NSS_STATUS_NOTFOUND;
+           }
        }
       return NSS_STATUS_SUCCESS;
     }
@@ -353,6 +359,7 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
     int parse_res;
     nis_result *result;
     char buf[46 + tablename_len];
+    int olderr = errno;
 
     sprintf (buf, "[number=%d],%s", number, tablename_val);
 
@@ -362,6 +369,8 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
       {
        enum nss_status status = niserr2nss (result->status);
 
+       __set_errno (olderr);
+
        nis_freeresult (result);
        return status;
       }
@@ -379,7 +388,10 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
            return NSS_STATUS_TRYAGAIN;
          }
        else
-         return NSS_STATUS_NOTFOUND;
+         {
+           __set_errno (olderr);
+           return NSS_STATUS_NOTFOUND;
+         }
       }
     return NSS_STATUS_SUCCESS;
   }