more merging voodoo
[kai/samba.git] / source / printing / printfsp.c
1 #define OLD_NTDOMAIN 1
2
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
9    
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.
14    
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.
19    
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.
23 */
24
25 #include "includes.h"
26 extern int DEBUGLEVEL;
27
28
29 /***************************************************************************
30 open a print file and setup a fsp for it. This is a wrapper around
31 print_job_start().
32 ***************************************************************************/
33
34 files_struct *print_fsp_open(connection_struct *conn,char *jobname)
35 {
36         int jobid;
37         SMB_STRUCT_STAT sbuf;
38         extern struct current_user current_user;
39         files_struct *fsp = file_new();
40
41         if(!fsp)
42                 return NULL;
43
44         jobid = print_job_start(SNUM(conn), jobname);
45         if (jobid == -1) {
46                 file_free(fsp);
47                 return NULL;
48         }
49
50         /* setup a full fsp */
51         fsp->print_jobid = jobid;
52         fsp->fd = print_job_fd(jobid);
53         conn->vfs_ops.fstat(fsp->fd, &sbuf);
54         fsp->mode = sbuf.st_mode;
55         fsp->inode = sbuf.st_ino;
56         fsp->dev = sbuf.st_dev;
57         GetTimeOfDay(&fsp->open_time);
58         fsp->vuid = current_user.vuid;
59         fsp->size = 0;
60         fsp->pos = -1;
61         fsp->can_lock = True;
62         fsp->can_read = False;
63         fsp->can_write = True;
64         fsp->share_mode = 0;
65         fsp->print_file = True;
66         fsp->modified = False;
67         fsp->oplock_type = NO_OPLOCK;
68         fsp->sent_oplock_break = NO_BREAK_SENT;
69         fsp->is_directory = False;
70         fsp->stat_open = False;
71         fsp->directory_delete_on_close = False;
72         fsp->conn = conn;
73         string_set(&fsp->fsp_name,print_job_fname(jobid));
74         fsp->wbmpx_ptr = NULL;      
75         fsp->wcp = NULL; 
76
77         conn->num_files_open++;
78
79         return fsp;
80 }
81
82 /****************************************************************************
83 print a file - called on closing the file
84 ****************************************************************************/
85 void print_fsp_end(files_struct *fsp)
86 {
87         print_job_end(fsp->print_jobid);
88
89         if (fsp->fsp_name) {
90                 string_free(&fsp->fsp_name);
91         }
92 }
93
94 #undef OLD_NTDOMAIN