2 Unix SMB/CIFS implementation.
3 printing backend routines for smbd - using files_struct rather
5 Copyright (C) Andrew Tridgell 1992-2000
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /***************************************************************************
25 open a print file and setup a fsp for it. This is a wrapper around
27 ***************************************************************************/
29 files_struct *print_fsp_open(connection_struct *conn, char *fname)
33 extern struct current_user current_user;
34 files_struct *fsp = file_new(conn);
40 fstrcpy( name, "Remote Downlevel Document");
42 char *p = strrchr(fname, '/');
49 jobid = print_job_start(¤t_user, SNUM(conn), name, NULL);
55 /* setup a full fsp */
56 fsp->print_jobid = jobid;
57 fsp->fd = print_job_fd(SNUM(conn),jobid);
58 GetTimeOfDay(&fsp->open_time);
59 fsp->vuid = current_user.vuid;
63 fsp->can_read = False;
64 fsp->can_write = True;
66 fsp->print_file = True;
67 fsp->modified = False;
68 fsp->oplock_type = NO_OPLOCK;
69 fsp->sent_oplock_break = NO_BREAK_SENT;
70 fsp->is_directory = False;
71 fsp->directory_delete_on_close = False;
73 string_set(&fsp->fsp_name,print_job_fname(SNUM(conn),jobid));
74 fsp->wbmpx_ptr = NULL;
76 conn->vfs_ops.fstat(fsp,fsp->fd, &sbuf);
77 fsp->mode = sbuf.st_mode;
78 fsp->inode = sbuf.st_ino;
79 fsp->dev = sbuf.st_dev;
81 conn->num_files_open++;
86 /****************************************************************************
87 print a file - called on closing the file
88 ****************************************************************************/
89 void print_fsp_end(files_struct *fsp, BOOL normal_close)
91 if (fsp->share_mode == FILE_DELETE_ON_CLOSE) {
93 * Truncate the job. print_job_end will take
94 * care of deleting it for us. JRA.
96 sys_ftruncate(fsp->fd, 0);
99 print_job_end(SNUM(fsp->conn),fsp->print_jobid, normal_close);
102 string_free(&fsp->fsp_name);