r12573: Update README to recent changes in pidls namespace
[samba.git] / source4 / librpc / rpc / table.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    dcerpc utility functions
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) Jelmer Vernooij 2004
8    
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 2 of the License, or
12    (at your option) any later version.
13    
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.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #include "includes.h"
25
26 /*
27   find the pipe name for a local IDL interface
28 */
29 const char *idl_pipe_name(const struct GUID *uuid, uint32_t if_version)
30 {
31         const struct dcerpc_interface_list *l;
32         for (l=librpc_dcerpc_pipes();l;l=l->next) {
33                 if (GUID_equal(&l->table->uuid, uuid) &&
34                     l->table->if_version == if_version) {
35                         return l->table->name;
36                 }
37         }
38         return "UNKNOWN";
39 }
40
41 /*
42   find the number of calls defined by local IDL
43 */
44 int idl_num_calls(const struct GUID *uuid, uint32_t if_version)
45 {
46         const struct dcerpc_interface_list *l;
47         for (l=librpc_dcerpc_pipes();l;l=l->next){
48                 if (GUID_equal(&l->table->uuid, uuid) &&
49                     l->table->if_version == if_version) {
50                         return l->table->num_calls;
51                 }
52         }
53         return -1;
54 }
55
56
57 /*
58   find a dcerpc interface by name
59 */
60 const struct dcerpc_interface_table *idl_iface_by_name(const char *name)
61 {
62         const struct dcerpc_interface_list *l;
63         for (l=librpc_dcerpc_pipes();l;l=l->next) {
64                 if (strcasecmp(l->table->name, name) == 0) {
65                         return l->table;
66                 }
67         }
68         return NULL;
69 }
70
71 /*
72   find a dcerpc interface by uuid
73 */
74 const struct dcerpc_interface_table *idl_iface_by_uuid(const struct GUID *uuid)
75 {
76         const struct dcerpc_interface_list *l;
77         for (l=librpc_dcerpc_pipes();l;l=l->next) {
78                 if (GUID_equal(&l->table->uuid, uuid)) {
79                         return l->table;
80                 }
81         }
82         return NULL;
83 }
84
85 extern struct dcerpc_interface_list *dcerpc_pipes;
86 /*
87   return the list of registered dcerpc_pipes
88 */
89 const struct dcerpc_interface_list *librpc_dcerpc_pipes(void)
90 {
91         return dcerpc_pipes;
92 }
93
94