summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-10 13:00:12 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-10 13:00:12 +0000
commitc3043695ae507b34580dc1287418ff5704b6f625 (patch)
tree1eb042e6310419d8ae66f87587ebe80cf59fb0a3 /source3
parentb36ea9a7e1fadc30a78c4eb2aabab9ff2011eacd (diff)
downloadsamba-c3043695ae507b34580dc1287418ff5704b6f625.tar.gz
samba-c3043695ae507b34580dc1287418ff5704b6f625.tar.bz2
samba-c3043695ae507b34580dc1287418ff5704b6f625.zip
rather than doing print file open processing in open.c we now handle
it in print_open_file() that removes a lot of special cases in open.c and makes the print handling code much easier to understand. there is still lots to do in printing.c, but this at least gets printing separated from the mainline code (This used to be commit e064422af335cd791752a2b54a17a13467ace041)
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/printing.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 7edb69de27..e75871b3c5 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -395,3 +395,77 @@ void load_printers(void)
if (lp_load_printers())
add_all_printers();
}
+
+
+void print_open_file(files_struct *fsp,connection_struct *conn,char *fname)
+{
+ pstring template;
+ char *p;
+ SMB_STRUCT_STAT sbuf;
+ extern struct current_user current_user;
+
+ /* see if we have sufficient disk space */
+ if (lp_minprintspace(SNUM(conn))) {
+ SMB_BIG_UINT dum1,dum2,dum3;
+ if (conn->vfs_ops.disk_free(conn->connectpath,False,&dum1,&dum2,&dum3) <
+ (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) {
+ errno = ENOSPC;
+ return;
+ }
+ }
+
+ slprintf(template, sizeof(template), "%s/smb.XXXXXX", conn->connectpath);
+ p = smbd_mktemp(template);
+ if (!p) {
+ DEBUG(2,("Error creating temporary filename in %s\n",
+ conn->connectpath));
+ errno = ENOSPC;
+ return;
+ }
+
+ fsp->fd = conn->vfs_ops.open(p,O_RDWR|O_CREAT|O_EXCL,0600);
+
+ if (fsp->fd == -1) {
+ DEBUG(3,("Error opening file %s\n",p));
+ return;
+ }
+
+ /*
+ * If the printer is marked as postscript output a leading
+ * file identifier to ensure the file is treated as a raw
+ * postscript file.
+ * This has a similar effect as CtrlD=0 in WIN.INI file.
+ * tim@fsg.com 09/06/94
+ */
+ if (lp_postscript(SNUM(conn))) {
+ DEBUG(3,("Writing postscript line\n"));
+ conn->vfs_ops.write(fsp->fd,"%!\n",3);
+ }
+
+ /* setup a full fsp */
+ conn->vfs_ops.fstat(fsp->fd, &sbuf);
+ conn->num_files_open++;
+ fsp->mode = sbuf.st_mode;
+ fsp->inode = sbuf.st_ino;
+ fsp->dev = sbuf.st_dev;
+ GetTimeOfDay(&fsp->open_time);
+ fsp->vuid = current_user.vuid;
+ fsp->size = 0;
+ fsp->pos = -1;
+ fsp->open = True;
+ fsp->can_lock = True;
+ fsp->can_read = False;
+ fsp->can_write = True;
+ fsp->share_mode = 0;
+ fsp->print_file = True;
+ fsp->modified = False;
+ fsp->oplock_type = NO_OPLOCK;
+ fsp->sent_oplock_break = NO_BREAK_SENT;
+ fsp->is_directory = False;
+ fsp->stat_open = False;
+ fsp->directory_delete_on_close = False;
+ fsp->conn = conn;
+ string_set(&fsp->fsp_name,p);
+ fsp->wbmpx_ptr = NULL;
+ fsp->wcp = NULL;
+}