source: branches/samba-3.3.x/source/librpc/ndr/ndr_misc.c

Last change on this file was 206, checked in by Herwig Bauernfeind, 16 years ago

Import Samba 3.3 branch at 3.0.0 level (psmedley's port)

File size: 2.6 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 UUID/GUID/policy_handle functions
5
6 Copyright (C) Theodore Ts'o 1996, 1997,
7 Copyright (C) Jim McDonough 2002.
8 Copyright (C) Andrew Tridgell 2003.
9 Copyright (C) Stefan (metze) Metzmacher 2004.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "includes.h"
26
27/**
28 * see if a range of memory is all zero. A NULL pointer is considered
29 * to be all zero
30 */
31bool all_zero(const uint8_t *ptr, size_t size)
32{
33 int i;
34 if (!ptr) return True;
35 for (i=0;i<size;i++) {
36 if (ptr[i]) return False;
37 }
38 return True;
39}
40
41void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid)
42{
43 ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid));
44}
45
46bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1,
47 const struct ndr_syntax_id *i2)
48{
49 return GUID_equal(&i1->uuid, &i2->uuid)
50 && (i1->if_version == i2->if_version);
51}
52
53enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r)
54{
55 if (ndr_flags & NDR_SCALARS) {
56 NDR_CHECK(ndr_push_align(ndr, 4));
57 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS,
58 (uint32_t)r->pid));
59#ifdef CLUSTER_SUPPORT
60 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS,
61 (uint32_t)r->vnn));
62#endif
63 }
64 if (ndr_flags & NDR_BUFFERS) {
65 }
66 return NDR_ERR_SUCCESS;
67}
68
69enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r)
70{
71 if (ndr_flags & NDR_SCALARS) {
72 uint32_t pid;
73 NDR_CHECK(ndr_pull_align(ndr, 4));
74 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pid));
75#ifdef CLUSTER_SUPPORT
76 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->vnn));
77#endif
78 r->pid = (pid_t)pid;
79 }
80 if (ndr_flags & NDR_BUFFERS) {
81 }
82 return NDR_ERR_SUCCESS;
83}
84
85void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r)
86{
87 ndr_print_struct(ndr, name, "server_id");
88 ndr->depth++;
89 ndr_print_uint32(ndr, "id", (uint32_t)r->pid);
90#ifdef CLUSTER_SUPPORT
91 ndr_print_uint32(ndr, "vnn", (uint32_t)r->vnn);
92#endif
93 ndr->depth--;
94}
Note: See TracBrowser for help on using the repository browser.