Back to index

glibc  2.9
nis_checkpoint.c
Go to the documentation of this file.
00001 /* Copyright (c) 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <string.h>
00021 #include <rpcsvc/nis.h>
00022 
00023 #include "nis_xdr.h"
00024 #include "nis_intern.h"
00025 
00026 nis_result *
00027 nis_checkpoint (const_nis_name dirname)
00028 {
00029   nis_result *res;
00030 
00031   res = calloc (1, sizeof (nis_result));
00032   if (res == NULL)
00033     return NULL;
00034 
00035   if (dirname != NULL)
00036     {
00037       nis_result *res2;
00038       u_int i;
00039 
00040       res2 = nis_lookup (dirname, EXPAND_NAME);
00041       if (NIS_RES_STATUS (res2) != NIS_SUCCESS)
00042        {
00043          free (res);
00044          return res2;
00045        }
00046 
00047       /* Check if obj is really a diryectory object */
00048       if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ)
00049        {
00050          nis_freeresult (res2);
00051          NIS_RES_STATUS (res) = NIS_INVALIDOBJ;
00052          return res;
00053        }
00054 
00055       for (i = 0;
00056           i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i)
00057        {
00058          cp_result cpres;
00059 
00060          memset (&cpres, '\0', sizeof (cp_result));
00061          if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i],
00062                           1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name,
00063                           (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result,
00064                           (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS)
00065            NIS_RES_STATUS (res) = NIS_RPCERROR;
00066          else
00067            {
00068              NIS_RES_STATUS (res) = cpres.cp_status;
00069              res->zticks += cpres.cp_zticks;
00070              res->dticks += cpres.cp_dticks;
00071            }
00072        }
00073       nis_freeresult (res2);
00074     }
00075   else
00076     NIS_RES_STATUS (res) = NIS_NOSUCHNAME;
00077 
00078   return res;
00079 }