r26672: Janitorial: Remove uses of global_loadparm.
[bbaumbach/samba-autobuild/.git] / source4 / ntvfs / ipc / rap_server.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RAP handlers
4
5    Copyright (C) Volker Lendecke 2004
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "param/share.h"
23 #include "libcli/rap/rap.h"
24 #include "librpc/gen_ndr/srvsvc.h"
25 #include "rpc_server/common/common.h"
26 #include "param/param.h"
27
28 /* At this moment these are just dummy functions, but you might get the
29  * idea. */
30
31 NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
32                           struct loadparm_context *lp_ctx,
33                           struct rap_NetShareEnum *r)
34 {
35         NTSTATUS nterr;
36         const char **snames;
37         struct share_context *sctx;
38         struct share_config *scfg;
39         int i, j, count;
40
41         r->out.status = 0;
42         r->out.available = 0;
43         r->out.info = NULL;
44
45         nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), lp_ctx, &sctx);
46         if (!NT_STATUS_IS_OK(nterr)) {
47                 return nterr;
48         }
49
50         nterr = share_list_all(mem_ctx, sctx, &count, &snames);
51         if (!NT_STATUS_IS_OK(nterr)) {
52                 return nterr;
53         }
54
55         r->out.available = count;
56         r->out.info = talloc_array(mem_ctx,
57                                    union rap_shareenum_info, r->out.available);
58
59         for (i = 0, j = 0; i < r->out.available; i++) {
60                 if (!NT_STATUS_IS_OK(share_get_config(mem_ctx, sctx, snames[i], &scfg))) {
61                         DEBUG(3, ("WARNING: Service [%s] disappeared after enumeration!\n", snames[i]));
62                         continue;
63                 }
64                 strncpy(r->out.info[j].info1.name,
65                         snames[i],
66                         sizeof(r->out.info[0].info1.name));
67                 r->out.info[i].info1.pad = 0;
68                 r->out.info[i].info1.type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg);
69                 r->out.info[i].info1.comment = talloc_strdup(mem_ctx, share_string_option(scfg, SHARE_COMMENT, ""));
70                 talloc_free(scfg);
71                 j++;
72         }
73         r->out.available = j;
74         
75         return NT_STATUS_OK;
76 }
77
78 NTSTATUS rap_netserverenum2(TALLOC_CTX *mem_ctx,
79                             struct loadparm_context *lp_ctx,
80                             struct rap_NetServerEnum2 *r)
81 {
82         r->out.status = 0;
83         r->out.available = 0;
84         return NT_STATUS_OK;
85 }