This commit was manufactured by cvs2svn to create branch 'SAMBA_2_2'.
[Samba.git] / source / printing / printfsp.c
blob9b5a4877ee235ed55eb7c2e86267692618b5b749
1 #define OLD_NTDOMAIN 1
3 /*
4 Unix SMB/Netbios implementation.
5 Version 3.0
6 printing backend routines for smbd - using files_struct rather
7 than only snum
8 Copyright (C) Andrew Tridgell 1992-2000
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "includes.h"
26 extern int DEBUGLEVEL;
29 /***************************************************************************
30 open a print file and setup a fsp for it. This is a wrapper around
31 print_job_start().
32 ***************************************************************************/
34 files_struct *print_fsp_open(connection_struct *conn,char *jobname)
36 int jobid;
37 SMB_STRUCT_STAT sbuf;
38 extern struct current_user current_user;
39 files_struct *fsp = file_new();
41 if(!fsp)
42 return NULL;
44 jobid = print_job_start(&current_user, SNUM(conn), jobname);
45 if (jobid == -1) {
46 file_free(fsp);
47 return NULL;
50 /* setup a full fsp */
51 fsp->print_jobid = jobid;
52 fsp->fd = print_job_fd(jobid);
53 GetTimeOfDay(&fsp->open_time);
54 fsp->vuid = current_user.vuid;
55 fsp->size = 0;
56 fsp->pos = -1;
57 fsp->can_lock = True;
58 fsp->can_read = False;
59 fsp->can_write = True;
60 fsp->share_mode = 0;
61 fsp->print_file = True;
62 fsp->modified = False;
63 fsp->oplock_type = NO_OPLOCK;
64 fsp->sent_oplock_break = NO_BREAK_SENT;
65 fsp->is_directory = False;
66 fsp->stat_open = False;
67 fsp->directory_delete_on_close = False;
68 fsp->conn = conn;
69 string_set(&fsp->fsp_name,print_job_fname(jobid));
70 fsp->wbmpx_ptr = NULL;
71 fsp->wcp = NULL;
72 conn->vfs_ops.fstat(fsp,fsp->fd, &sbuf);
73 fsp->mode = sbuf.st_mode;
74 fsp->inode = sbuf.st_ino;
75 fsp->dev = sbuf.st_dev;
77 conn->num_files_open++;
79 return fsp;
82 /****************************************************************************
83 print a file - called on closing the file
84 ****************************************************************************/
85 void print_fsp_end(files_struct *fsp)
87 print_job_end(fsp->print_jobid);
89 if (fsp->fsp_name) {
90 string_free(&fsp->fsp_name);
94 #undef OLD_NTDOMAIN