diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-04-10 13:00:12 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-04-10 13:00:12 +0000 |
commit | e064422af335cd791752a2b54a17a13467ace041 (patch) | |
tree | 7c40c0621b7f55796a8adf1041964461f8242e63 | |
parent | 368b0bc1b122ece18d11854c1506517816a01a82 (diff) | |
download | samba-e064422af335cd791752a2b54a17a13467ace041.tar.gz samba-e064422af335cd791752a2b54a17a13467ace041.tar.xz samba-e064422af335cd791752a2b54a17a13467ace041.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
-rw-r--r-- | source/printing/printing.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/source/printing/printing.c b/source/printing/printing.c index 7edb69de272..e75871b3c56 100644 --- a/source/printing/printing.c +++ b/source/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; +} |