r2249: got rid of some more mem_ctx elements in structures
[jra/samba/.git] / source4 / ntvfs / print / vfs_print.c
1 /* 
2    Unix SMB/CIFS implementation.
3    default print NTVFS backend
4    Copyright (C) Andrew Tridgell  2003
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 /*
21   this implements the print backend, called by the NTVFS subsystem to
22   handle requests on printing shares
23 */
24
25 #include "includes.h"
26
27 /*
28   connect to a share - used when a tree_connect operation comes
29   in. For printing shares this should check that the spool directory
30   is available
31 */
32 static NTSTATUS print_connect(struct smbsrv_request *req, const char *sharename)
33 {
34         return NT_STATUS_OK;
35 }
36
37 /*
38   disconnect from a share
39 */
40 static NTSTATUS print_disconnect(struct smbsrv_tcon *tcon)
41 {
42         return NT_STATUS_OK;
43 }
44
45 /*
46   lots of operations are not allowed on printing shares - mostly return NT_STATUS_ACCESS_DENIED
47 */
48 static NTSTATUS print_unlink(struct smbsrv_request *req, struct smb_unlink *unl)
49 {
50         return NT_STATUS_ACCESS_DENIED;
51 }
52
53
54 /*
55   ioctl - used for job query
56 */
57 static NTSTATUS print_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
58 {
59         char *p;
60
61         if (io->generic.level != RAW_IOCTL_IOCTL) {
62                 return NT_STATUS_NOT_IMPLEMENTED;
63         }
64
65         if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) {
66                 /* a request for the print job id of an open print job */
67                 io->ioctl.out.blob = data_blob_talloc(req, NULL, 32);
68
69                 data_blob_clear(&io->ioctl.out.blob);
70
71                 p = io->ioctl.out.blob.data;
72                 SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
73                 push_string(NULL, p+2, lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII);
74                 push_string(NULL, p+18, lp_servicename(req->tcon->service), 13, STR_TERMINATE|STR_ASCII);
75                 return NT_STATUS_OK;
76         }
77
78         return NT_STATUS_INVALID_PARAMETER;
79 }
80
81
82 /*
83   initialialise the print backend, registering ourselves with the ntvfs subsystem
84  */
85 NTSTATUS ntvfs_print_init(void)
86 {
87         NTSTATUS ret;
88         struct ntvfs_ops ops;
89
90         ZERO_STRUCT(ops);
91
92         /* fill in the name and type */
93         ops.name = "default";
94         ops.type = NTVFS_PRINT;
95         
96         /* fill in all the operations */
97         ops.connect = print_connect;
98         ops.disconnect = print_disconnect;
99         ops.unlink = print_unlink;
100         ops.ioctl = print_ioctl;
101
102         /* register ourselves with the NTVFS subsystem. We register under the name 'default'
103            as we wish to be the default backend */
104         ret = register_backend("ntvfs", &ops);
105
106         if (!NT_STATUS_IS_OK(ret)) {
107                 DEBUG(0,("Failed to register PRINT backend!\n"));
108         }
109
110         return ret;
111 }