1 /* Copyright (c) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
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.
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.
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. */
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nislib.h>
24 nis_free_attr (nis_attr
*obj
)
31 free (obj
->zattr_ndx
);
32 obj
->zattr_ndx
= NULL
;
35 if (obj
->zattr_val
.zattr_val_val
)
37 free (obj
->zattr_val
.zattr_val_val
);
38 obj
->zattr_val
.zattr_val_val
= NULL
;
39 obj
->zattr_val
.zattr_val_len
= 0;
44 nis_free_request (ib_request
*ibreq
)
48 for (i
= 0; i
< ibreq
->ibr_srch
.ibr_srch_len
; ++i
)
50 nis_free_attr (&(ibreq
->ibr_srch
.ibr_srch_val
)[i
]);
51 ibreq
->ibr_srch
.ibr_srch_val
= NULL
;
52 ibreq
->ibr_srch
.ibr_srch_len
= 0;
57 free (ibreq
->ibr_name
);
58 ibreq
->ibr_name
= NULL
;
61 if (ibreq
->ibr_cookie
.n_bytes
)
63 free (ibreq
->ibr_cookie
.n_bytes
);
64 ibreq
->ibr_cookie
.n_bytes
= NULL
;
65 ibreq
->ibr_cookie
.n_len
= 0;
70 nis_free_endpoints (endpoint
*ep
, unsigned int len
)
77 for (i
= 0; i
< len
; ++i
)
98 nis_free_servers (nis_server
*obj
, unsigned int len
)
105 for (i
= 0; i
< len
; i
++)
112 if (obj
[i
].ep
.ep_len
> 0)
114 nis_free_endpoints (obj
[i
].ep
.ep_val
, obj
[i
].ep
.ep_len
);
115 free (obj
[i
].ep
.ep_val
);
116 obj
[i
].ep
.ep_val
= NULL
;
117 obj
[i
].ep
.ep_len
= 0;
119 if (obj
[i
].pkey
.n_bytes
&& obj
[i
].pkey
.n_len
> 0)
121 free (obj
[i
].pkey
.n_bytes
);
122 obj
[i
].pkey
.n_bytes
= NULL
;
123 obj
[i
].pkey
.n_len
= 0;
129 nis_free_directory (directory_obj
*obj
)
138 if (obj
->do_servers
.do_servers_len
> 0)
140 nis_free_servers (obj
->do_servers
.do_servers_val
,
141 obj
->do_servers
.do_servers_len
);
142 free (obj
->do_servers
.do_servers_val
);
143 obj
->do_servers
.do_servers_val
= NULL
;
144 obj
->do_servers
.do_servers_len
= 0;
146 if (obj
->do_armask
.do_armask_len
> 0)
148 free (obj
->do_armask
.do_armask_val
);
149 obj
->do_armask
.do_armask_val
= NULL
;
150 obj
->do_armask
.do_armask_len
= 0;
155 nis_free_group (group_obj
*obj
)
159 if (obj
->gr_members
.gr_members_len
> 0)
161 for (i
= 0; i
< obj
->gr_members
.gr_members_len
; ++i
)
162 if (obj
->gr_members
.gr_members_val
[i
])
163 free (obj
->gr_members
.gr_members_val
[i
]);
164 free (obj
->gr_members
.gr_members_val
);
165 obj
->gr_members
.gr_members_val
= NULL
;
166 obj
->gr_members
.gr_members_len
= 0;
171 nis_free_table (table_obj
*obj
)
182 if (obj
->ta_cols
.ta_cols_val
)
186 for (i
= 0; i
< obj
->ta_cols
.ta_cols_len
; ++i
)
187 if (obj
->ta_cols
.ta_cols_val
[i
].tc_name
)
188 free (obj
->ta_cols
.ta_cols_val
[i
].tc_name
);
189 free (obj
->ta_cols
.ta_cols_val
);
190 obj
->ta_cols
.ta_cols_val
= NULL
;
191 obj
->ta_cols
.ta_cols_len
= 0;
202 nis_free_entry (entry_obj
*obj
)
213 if (obj
->en_cols
.en_cols_val
)
217 for (i
= 0; i
< obj
->en_cols
.en_cols_len
; ++i
)
218 if (obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_val
)
219 free (obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_val
);
220 free (obj
->en_cols
.en_cols_val
);
221 obj
->en_cols
.en_cols_val
= NULL
;
222 obj
->en_cols
.en_cols_len
= 0;
227 nis_free_link (link_obj
*obj
)
232 if (obj
->li_attrs
.li_attrs_val
)
236 for (i
= 0; i
< obj
->li_attrs
.li_attrs_len
; ++i
)
238 if (obj
->li_attrs
.li_attrs_val
[i
].zattr_ndx
)
239 free (obj
->li_attrs
.li_attrs_val
[i
].zattr_ndx
);
240 if (obj
->li_attrs
.li_attrs_val
[i
].zattr_val
.zattr_val_val
)
241 free (obj
->li_attrs
.li_attrs_val
[i
].zattr_val
.zattr_val_val
);
243 free (obj
->li_attrs
.li_attrs_val
);
244 obj
->li_attrs
.li_attrs_val
= NULL
;
245 obj
->li_attrs
.li_attrs_len
= 0;
256 nis_free_object (nis_object
*obj
)
269 free (obj
->zo_owner
);
270 obj
->zo_owner
= NULL
;
274 free (obj
->zo_group
);
275 obj
->zo_group
= NULL
;
279 free (obj
->zo_domain
);
280 obj
->zo_domain
= NULL
;
282 switch (obj
->zo_data
.zo_type
)
289 nis_free_directory (&obj
->zo_data
.objdata_u
.di_data
);
292 nis_free_group (&obj
->zo_data
.objdata_u
.gr_data
);
295 nis_free_table (&obj
->zo_data
.objdata_u
.ta_data
);
298 nis_free_entry (&obj
->zo_data
.objdata_u
.en_data
);
301 nis_free_link (&obj
->zo_data
.objdata_u
.li_data
);
304 if (obj
->zo_data
.objdata_u
.po_data
.po_data_val
)
306 free (obj
->zo_data
.objdata_u
.po_data
.po_data_val
);
307 obj
->zo_data
.objdata_u
.po_data
.po_data_val
= NULL
;
313 obj
->zo_data
.zo_type
= NO_OBJ
;
317 nis_freeresult (nis_result
*res
)
324 for (i
= 0; i
< res
->objects
.objects_len
; i
++)
325 nis_free_object (&(res
->objects
.objects_val
)[i
]);
327 if (res
->objects
.objects_val
!= NULL
)
328 free (res
->objects
.objects_val
);
330 if (res
->cookie
.n_bytes
!= NULL
&& res
->cookie
.n_len
> 0)
331 free (res
->cookie
.n_bytes
);