build: ensure that the 'build' command appears in waf --help
[Samba.git] / librpc / ndr / ndr_table.c
blob7ca04173f70495df4cdaa80ce2f656516709404b
1 /*
2 Unix SMB/CIFS implementation.
4 dcerpc utility functions
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Jelmer Vernooij 2004
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "../lib/util/dlinklist.h"
25 #include "librpc/ndr/libndr.h"
26 #include "librpc/ndr/ndr_table.h"
27 #undef strcasecmp
29 static struct ndr_interface_list *ndr_interfaces;
32 register a ndr interface table
34 NTSTATUS ndr_table_register(const struct ndr_interface_table *table)
36 struct ndr_interface_list *l;
38 for (l = ndr_interfaces; l; l = l->next) {
39 if (GUID_equal(&table->syntax_id.uuid, &l->table->syntax_id.uuid)) {
40 DEBUG(0, ("Attempt to register interface %s which has the "
41 "same UUID as already registered interface %s\n",
42 table->name, l->table->name));
43 return NT_STATUS_OBJECT_NAME_COLLISION;
47 l = talloc(talloc_autofree_context(), struct ndr_interface_list);
48 l->table = table;
50 DLIST_ADD(ndr_interfaces, l);
52 return NT_STATUS_OK;
56 find the pipe name for a local IDL interface
58 const char *ndr_interface_name(const struct GUID *uuid, uint32_t if_version)
60 const struct ndr_interface_list *l;
61 for (l=ndr_table_list();l;l=l->next) {
62 if (GUID_equal(&l->table->syntax_id.uuid, uuid) &&
63 l->table->syntax_id.if_version == if_version) {
64 return l->table->name;
67 return "UNKNOWN";
71 find the number of calls defined by local IDL
73 int ndr_interface_num_calls(const struct GUID *uuid, uint32_t if_version)
75 const struct ndr_interface_list *l;
76 for (l=ndr_interfaces;l;l=l->next){
77 if (GUID_equal(&l->table->syntax_id.uuid, uuid) &&
78 l->table->syntax_id.if_version == if_version) {
79 return l->table->num_calls;
82 return -1;
87 find a dcerpc interface by name
89 const struct ndr_interface_table *ndr_table_by_name(const char *name)
91 const struct ndr_interface_list *l;
92 for (l=ndr_interfaces;l;l=l->next) {
93 if (strcasecmp(l->table->name, name) == 0) {
94 return l->table;
97 return NULL;
101 find a dcerpc interface by uuid
103 const struct ndr_interface_table *ndr_table_by_uuid(const struct GUID *uuid)
105 const struct ndr_interface_list *l;
106 for (l=ndr_interfaces;l;l=l->next) {
107 if (GUID_equal(&l->table->syntax_id.uuid, uuid)) {
108 return l->table;
111 return NULL;
115 return the list of registered dcerpc_pipes
117 const struct ndr_interface_list *ndr_table_list(void)
119 return ndr_interfaces;
123 NTSTATUS ndr_table_init(void)
125 static bool initialized = false;
127 if (initialized) return NT_STATUS_OK;
128 initialized = true;
130 ndr_table_register_builtin_tables();
132 return NT_STATUS_OK;