]> sourceware.org Git - glibc.git/blame - nis/nis_clone_obj.c
Update.
[glibc.git] / nis / nis_clone_obj.c
CommitLineData
26a60f90 1/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
dfd2257a
UD
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20#include <string.h>
21#include <rpc/rpc.h>
22#include <rpcsvc/nis.h>
23
91eee4dd
UD
24#include "nis_xdr.h"
25
dfd2257a
UD
26nis_object *
27nis_clone_object (const nis_object *src, nis_object *dest)
28{
29 unsigned char *addr;
26a60f90 30 unsigned long size;
dfd2257a
UD
31 XDR xdrs;
32 nis_object *res;
33
34 if (src == NULL)
35 return (NULL);
36
91eee4dd 37 size = xdr_sizeof ((xdrproc_t)_xdr_nis_object, (char *)src);
dfd2257a
UD
38 if ((addr = calloc(1, size)) == NULL)
39 return NULL;
40
41 if (dest == NULL)
42 {
43 if ((res = calloc (1, sizeof (nis_object))) == NULL)
44 {
45 free (addr);
46 return NULL;
47 }
48 }
49 else
50 res = dest;
51
52 xdrmem_create(&xdrs, addr, size, XDR_ENCODE);
91eee4dd 53 if (!_xdr_nis_object (&xdrs, (nis_object *)src))
dfd2257a
UD
54 {
55 xdr_destroy (&xdrs);
56 free (addr);
57 return NULL;
58 }
59 xdr_destroy (&xdrs);
60 xdrmem_create(&xdrs, addr, size, XDR_DECODE);
91eee4dd 61 if (!_xdr_nis_object(&xdrs, res))
dfd2257a
UD
62 {
63 xdr_destroy (&xdrs);
64 free (addr);
65 return NULL;
66 }
67 xdr_destroy (&xdrs);
68 free (addr);
69
70 return res;
71}
This page took 0.125662 seconds and 5 git commands to generate.