5 Unix SMB/CIFS implementation.
7 Copyright (C) Andrew Tridgell 1992-2000
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 This file defines the low-level printing system interfaces used by the
25 SAMBA printing subsystem.
27 #include "tdb_compat.h"
29 /* Extra fields above "LPQ_PRINTING" are used to map extra NT status codes. */
43 LPQ_USER_INTERVENTION
,
45 /* smbd is dooing the file spooling before passing control to spoolss */
49 typedef struct _print_queue_struct
{
50 int job
; /* normally the UNIX jobid -- see note in
51 printing.c:traverse_fn_delete() */
61 enum {LPSTAT_OK
, LPSTAT_STOPPED
, LPSTAT_ERROR
};
67 } print_status_struct
;
69 /* Information for print jobs */
71 pid_t pid
; /* which process launched the job */
72 int sysjob
; /* the system (lp) job number */
73 int fd
; /* file descriptor of open file if open */
74 time_t starttime
; /* when the job started spooling */
75 int status
; /* the status of this job */
76 size_t size
; /* the size of the job so far */
77 int page_count
; /* then number of pages so far */
78 bool spooled
; /* has it been sent to the spooler yet? */
79 bool smbjob
; /* set if the job is a SMB job */
80 fstring filename
; /* the filename used to spool the file */
81 fstring jobname
; /* the job name given to us by the client */
82 fstring user
; /* the user who started the job */
83 fstring clientmachine
; /* The client machine which started this job */
84 fstring queuename
; /* service number of printer for this job */
85 struct spoolss_DeviceMode
*devmode
;
88 /* Information for print interfaces */
91 /* value of the 'printing' option for this service */
92 enum printing_types type
;
94 int (*queue_get
)(const char *printer_name
,
95 enum printing_types printing_type
,
97 print_queue_struct
**q
,
98 print_status_struct
*status
);
99 int (*queue_pause
)(int snum
);
100 int (*queue_resume
)(int snum
);
101 int (*job_delete
)(const char *sharename
, const char *lprm_command
, struct printjob
*pjob
);
102 int (*job_pause
)(int snum
, struct printjob
*pjob
);
103 int (*job_resume
)(int snum
, struct printjob
*pjob
);
104 int (*job_submit
)(int snum
, struct printjob
*pjob
);
107 extern struct printif generic_printif
;
110 extern struct printif cups_printif
;
111 #endif /* HAVE_CUPS */
114 extern struct printif iprint_printif
;
115 #endif /* HAVE_IPRINT */
117 /* PRINT_MAX_JOBID is now defined in local.h */
118 #define UNIX_JOB_START PRINT_MAX_JOBID
119 #define NEXT_JOBID(j) ((j+1) % PRINT_MAX_JOBID > 0 ? (j+1) % PRINT_MAX_JOBID : 1)
121 #define MAX_CACHE_VALID_TIME 3600
122 #define CUPS_DEFAULT_CONNECTION_TIMEOUT 30
124 #ifndef PRINT_SPOOL_PREFIX
125 #define PRINT_SPOOL_PREFIX "smbprn."
127 #define PRINT_DATABASE_VERSION 7
130 #define DEFAULT_PRINTING PRINT_AIX
131 #define PRINTCAP_NAME "/etc/qconfig"
135 #define DEFAULT_PRINTING PRINT_HPUX
139 #define DEFAULT_PRINTING PRINT_QNX
142 #ifndef DEFAULT_PRINTING
144 #define DEFAULT_PRINTING PRINT_CUPS
145 #define PRINTCAP_NAME "cups"
147 #define DEFAULT_PRINTING PRINT_SYSV
148 #define PRINTCAP_NAME "lpstat"
150 #define DEFAULT_PRINTING PRINT_BSD
151 #define PRINTCAP_NAME "/etc/printcap"
155 #ifndef PRINTCAP_NAME
156 #define PRINTCAP_NAME "/etc/printcap"
159 /* There can be this many printing tdb's open, plus any locked ones. */
160 #define MAX_PRINT_DBS_OPEN 1
162 struct tdb_print_db
{
163 struct tdb_print_db
*next
, *prev
;
164 struct tdb_context
*tdb
;
166 fstring printer_name
;
170 * Used for print notify
173 #define NOTIFY_PID_LIST_KEY "NOTIFY_PID_LIST"
175 /* The following definitions come from printing/printspoolss.c */
177 NTSTATUS
print_spool_open(files_struct
*fsp
,
179 uint16_t current_vuid
);
181 int print_spool_write(files_struct
*fsp
, const char *data
, uint32_t size
,
182 SMB_OFF_T offset
, uint32_t *written
);
184 void print_spool_end(files_struct
*fsp
, enum file_close_type close_type
);
186 void print_spool_terminate(struct connection_struct
*conn
,
187 struct print_file_data
*print_file
);
189 /* The following definitions come from printing/printing.c */
191 uint32
sysjob_to_jobid(int unix_jobid
);
192 bool print_notify_register_pid(int snum
);
193 bool print_notify_deregister_pid(int snum
);
194 bool print_job_exists(const char* sharename
, uint32 jobid
);
195 char *print_job_fname(const char* sharename
, uint32 jobid
);
196 struct spoolss_DeviceMode
*print_job_devmode(const char* sharename
, uint32 jobid
);
197 bool print_job_set_name(struct tevent_context
*ev
,
198 struct messaging_context
*msg_ctx
,
199 const char *sharename
, uint32 jobid
, const char *name
);
200 bool print_job_get_name(TALLOC_CTX
*mem_ctx
, const char *sharename
, uint32_t jobid
, char **name
);
201 WERROR
print_job_delete(const struct auth_session_info
*server_info
,
202 struct messaging_context
*msg_ctx
,
203 int snum
, uint32_t jobid
);
204 bool print_job_pause(const struct auth_session_info
*server_info
,
205 struct messaging_context
*msg_ctx
,
206 int snum
, uint32 jobid
, WERROR
*errcode
);
207 bool print_job_resume(const struct auth_session_info
*server_info
,
208 struct messaging_context
*msg_ctx
,
209 int snum
, uint32 jobid
, WERROR
*errcode
);
210 ssize_t
print_job_write(struct tevent_context
*ev
,
211 struct messaging_context
*msg_ctx
,
212 int snum
, uint32 jobid
, const char *buf
, size_t size
);
213 int print_queue_length(struct messaging_context
*msg_ctx
, int snum
,
214 print_status_struct
*pstatus
);
215 WERROR
print_job_start(const struct auth_session_info
*server_info
,
216 struct messaging_context
*msg_ctx
,
217 const char *clientmachine
,
218 int snum
, const char *docname
, const char *filename
,
219 struct spoolss_DeviceMode
*devmode
, uint32_t *_jobid
);
220 void print_job_endpage(struct messaging_context
*msg_ctx
,
221 int snum
, uint32 jobid
);
222 NTSTATUS
print_job_end(struct messaging_context
*msg_ctx
, int snum
,
223 uint32 jobid
, enum file_close_type close_type
);
224 int print_queue_status(struct messaging_context
*msg_ctx
, int snum
,
225 print_queue_struct
**ppqueue
,
226 print_status_struct
*status
);
227 WERROR
print_queue_pause(const struct auth_session_info
*server_info
,
228 struct messaging_context
*msg_ctx
, int snum
);
229 WERROR
print_queue_resume(const struct auth_session_info
*server_info
,
230 struct messaging_context
*msg_ctx
, int snum
);
231 WERROR
print_queue_purge(const struct auth_session_info
*server_info
,
232 struct messaging_context
*msg_ctx
, int snum
);
233 uint16
pjobid_to_rap(const char* sharename
, uint32 jobid
);
234 bool rap_to_pjobid(uint16 rap_jobid
, fstring sharename
, uint32
*pjobid
);
235 void rap_jobid_delete(const char* sharename
, uint32 jobid
);
236 bool print_backend_init(struct messaging_context
*msg_ctx
);
237 void printing_end(void);
239 /* The following definitions come from printing/lpq_parse.c */
241 bool parse_lpq_entry(enum printing_types printing_type
,char *line
,
242 print_queue_struct
*buf
,
243 print_status_struct
*status
,bool first
);
244 uint32_t print_parse_jobid(const char *fname
);
246 /* The following definitions come from printing/printing_db.c */
248 struct tdb_print_db
*get_print_db_byname(const char *printername
);
249 void release_print_db( struct tdb_print_db
*pdb
);
250 void close_all_print_db(void);
251 TDB_DATA
get_printer_notify_pid_list(struct tdb_context
*tdb
, const char *printer_name
, bool cleanlist
);
253 void print_queue_receive(struct messaging_context
*msg
,
256 struct server_id server_id
,
258 #endif /* PRINTING_H_ */