printing/printfsp.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    printing backend routines for smbd - using files_struct rather
00004    than only snum
00005    Copyright (C) Andrew Tridgell 1992-2000
00006    
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include "includes.h"
00023 
00024 extern struct current_user current_user;
00025 
00026 /***************************************************************************
00027 open a print file and setup a fsp for it. This is a wrapper around
00028 print_job_start().
00029 ***************************************************************************/
00030 
00031 NTSTATUS print_fsp_open(connection_struct *conn, const char *fname,
00032                         files_struct **result)
00033 {
00034         int jobid;
00035         SMB_STRUCT_STAT sbuf;
00036         files_struct *fsp;
00037         fstring name;
00038         NTSTATUS status;
00039 
00040         status = file_new(conn, &fsp);
00041         if(!NT_STATUS_IS_OK(status)) {
00042                 return status;
00043         }
00044 
00045         fstrcpy( name, "Remote Downlevel Document");
00046         if (fname) {
00047                 const char *p = strrchr(fname, '/');
00048                 fstrcat(name, " ");
00049                 if (!p) {
00050                         p = fname;
00051                 }
00052                 fstrcat(name, p);
00053         }
00054 
00055         jobid = print_job_start(&current_user, SNUM(conn), name, NULL);
00056         if (jobid == -1) {
00057                 status = map_nt_error_from_unix(errno);
00058                 file_free(fsp);
00059                 return status;
00060         }
00061 
00062         /* Convert to RAP id. */
00063         fsp->rap_print_jobid = pjobid_to_rap(lp_const_servicename(SNUM(conn)), jobid);
00064         if (fsp->rap_print_jobid == 0) {
00065                 /* We need to delete the entry in the tdb. */
00066                 pjob_delete(lp_const_servicename(SNUM(conn)), jobid);
00067                 file_free(fsp);
00068                 return NT_STATUS_ACCESS_DENIED; /* No errno around here */
00069         }
00070 
00071         /* setup a full fsp */
00072         fsp->fh->fd = print_job_fd(lp_const_servicename(SNUM(conn)),jobid);
00073         GetTimeOfDay(&fsp->open_time);
00074         fsp->vuid = current_user.vuid;
00075         fsp->fh->pos = -1;
00076         fsp->can_lock = True;
00077         fsp->can_read = False;
00078         fsp->access_mask = FILE_GENERIC_WRITE;
00079         fsp->can_write = True;
00080         fsp->print_file = True;
00081         fsp->modified = False;
00082         fsp->oplock_type = NO_OPLOCK;
00083         fsp->sent_oplock_break = NO_BREAK_SENT;
00084         fsp->is_directory = False;
00085         string_set(&fsp->fsp_name,print_job_fname(lp_const_servicename(SNUM(conn)),jobid));
00086         fsp->wbmpx_ptr = NULL;      
00087         fsp->wcp = NULL; 
00088         SMB_VFS_FSTAT(fsp,fsp->fh->fd, &sbuf);
00089         fsp->mode = sbuf.st_mode;
00090         fsp->inode = sbuf.st_ino;
00091         fsp->dev = sbuf.st_dev;
00092 
00093         conn->num_files_open++;
00094 
00095         *result = fsp;
00096         return NT_STATUS_OK;
00097 }
00098 
00099 /****************************************************************************
00100  Print a file - called on closing the file.
00101 ****************************************************************************/
00102 
00103 void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
00104 {
00105         uint32 jobid;
00106         fstring sharename;
00107 
00108         if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
00109                 /*
00110                  * Truncate the job. print_job_end will take
00111                  * care of deleting it for us. JRA.
00112                  */
00113                 sys_ftruncate(fsp->fh->fd, 0);
00114         }
00115 
00116         if (fsp->fsp_name) {
00117                 string_free(&fsp->fsp_name);
00118         }
00119 
00120         if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
00121                 DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n",
00122                         (unsigned int)fsp->rap_print_jobid ));
00123                 return;
00124         }
00125 
00126         print_job_end(SNUM(fsp->conn),jobid, close_type);
00127 }

Sambaに対してSat Aug 29 21:23:14 2009に生成されました。  doxygen 1.4.7