Back to index

glibc  2.9
nis_server.c
Go to the documentation of this file.
00001 /* Copyright (c) 1997, 1998 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_error
00027 nis_servstate (const nis_server *serv, const nis_tag *tags,
00028               const int numtags, nis_tag **result)
00029 {
00030   nis_taglist taglist;
00031   nis_taglist tagres;
00032 
00033   *result = 0;
00034   tagres.tags.tags_len = 0;
00035   tagres.tags.tags_val = NULL;
00036   taglist.tags.tags_len = numtags;
00037   taglist.tags.tags_val = (nis_tag *) tags;
00038 
00039   if (serv == NULL)
00040     return NIS_BADOBJECT;
00041 
00042   if (__do_niscall2 (serv, 1, NIS_SERVSTATE, (xdrproc_t) _xdr_nis_taglist,
00043                    (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist,
00044                    (caddr_t) &tagres, 0, NULL) != RPC_SUCCESS)
00045     return NIS_RPCERROR;
00046 
00047   *result = tagres.tags.tags_val;
00048 
00049   return NIS_SUCCESS;
00050 }
00051 
00052 nis_error
00053 nis_stats (const nis_server *serv, const nis_tag *tags,
00054           const int numtags, nis_tag **result)
00055 {
00056   nis_taglist taglist;
00057   nis_taglist tagres;
00058 
00059   *result = NULL;
00060   tagres.tags.tags_len = 0;
00061   tagres.tags.tags_val = NULL;
00062   taglist.tags.tags_len = numtags;
00063   taglist.tags.tags_val = (nis_tag *) tags;
00064 
00065   if (serv == NULL)
00066     return NIS_BADOBJECT;
00067 
00068   if (__do_niscall2 (serv, 1, NIS_STATUS, (xdrproc_t) _xdr_nis_taglist,
00069                    (caddr_t) &taglist, (xdrproc_t) _xdr_nis_taglist,
00070                    (caddr_t) &tagres, 0, NULL) != RPC_SUCCESS)
00071     return NIS_RPCERROR;
00072 
00073   *result = tagres.tags.tags_val;
00074 
00075   return NIS_SUCCESS;
00076 }
00077 
00078 void
00079 nis_freetags (nis_tag *tags, const int numtags)
00080 {
00081   int i;
00082 
00083   for (i = 0; i < numtags; ++i)
00084     free (tags[i].tag_val);
00085   free (tags);
00086 }