root/source4/ntvfs/print/vfs_print.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. print_connect
  2. print_disconnect
  3. print_unlink
  4. print_ioctl
  5. ntvfs_print_init

   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 3 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, see <http://www.gnu.org/licenses/>.
  18 */
  19 /*
  20   this implements the print backend, called by the NTVFS subsystem to
  21   handle requests on printing shares
  22 */
  23 
  24 #include "includes.h"
  25 #include "libcli/raw/ioctl.h"
  26 #include "ntvfs/ntvfs.h"
  27 #include "param/param.h"
  28 
  29 /*
  30   connect to a share - used when a tree_connect operation comes
  31   in. For printing shares this should check that the spool directory
  32   is available
  33 */
  34 static NTSTATUS print_connect(struct ntvfs_module_context *ntvfs,
     /* [<][>][^][v][top][bottom][index][help] */
  35                               struct ntvfs_request *req, const char *sharename)
  36 {
  37         ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
  38         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
  39 
  40         ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "LPT1:");
  41         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
  42 
  43         return NT_STATUS_OK;
  44 }
  45 
  46 /*
  47   disconnect from a share
  48 */
  49 static NTSTATUS print_disconnect(struct ntvfs_module_context *ntvfs)
     /* [<][>][^][v][top][bottom][index][help] */
  50 {
  51         return NT_STATUS_OK;
  52 }
  53 
  54 /*
  55   lots of operations are not allowed on printing shares - mostly return NT_STATUS_ACCESS_DENIED
  56 */
  57 static NTSTATUS print_unlink(struct ntvfs_module_context *ntvfs,
     /* [<][>][^][v][top][bottom][index][help] */
  58                              struct ntvfs_request *req,
  59                              union smb_unlink *unl)
  60 {
  61         return NT_STATUS_ACCESS_DENIED;
  62 }
  63 
  64 
  65 /*
  66   ioctl - used for job query
  67 */
  68 static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
     /* [<][>][^][v][top][bottom][index][help] */
  69                             struct ntvfs_request *req, union smb_ioctl *io)
  70 {
  71         char *p;
  72 
  73         if (io->generic.level != RAW_IOCTL_IOCTL) {
  74                 return NT_STATUS_NOT_IMPLEMENTED;
  75         }
  76 
  77         if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) {
  78 
  79                 /* a request for the print job id of an open print job */
  80                 io->ioctl.out.blob = data_blob_talloc(req, NULL, 32);
  81 
  82                 data_blob_clear(&io->ioctl.out.blob);
  83 
  84                 p = (char *)io->ioctl.out.blob.data;
  85                 SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
  86                 push_string(p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
  87                 push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
  88                 return NT_STATUS_OK;
  89         }
  90 
  91         return NT_STATUS_INVALID_PARAMETER;
  92 }
  93 
  94 
  95 /*
  96   initialialise the print backend, registering ourselves with the ntvfs subsystem
  97  */
  98 NTSTATUS ntvfs_print_init(void)
     /* [<][>][^][v][top][bottom][index][help] */
  99 {
 100         NTSTATUS ret;
 101         struct ntvfs_ops ops;
 102         NTVFS_CURRENT_CRITICAL_SIZES(vers);
 103 
 104         ZERO_STRUCT(ops);
 105 
 106         /* fill in the name and type */
 107         ops.name = "default";
 108         ops.type = NTVFS_PRINT;
 109         
 110         /* fill in all the operations */
 111         ops.connect = print_connect;
 112         ops.disconnect = print_disconnect;
 113         ops.unlink = print_unlink;
 114         ops.ioctl = print_ioctl;
 115 
 116         /* register ourselves with the NTVFS subsystem. We register under the name 'default'
 117            as we wish to be the default backend */
 118         ret = ntvfs_register(&ops, &vers);
 119 
 120         if (!NT_STATUS_IS_OK(ret)) {
 121                 DEBUG(0,("Failed to register PRINT backend!\n"));
 122         }
 123 
 124         return ret;
 125 }

/* [<][>][^][v][top][bottom][index][help] */