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.
28 /* Information for print jobs */
30 pid_t pid; /* which process launched the job */
31 int sysjob; /* the system (lp) job number */
32 int fd; /* file descriptor of open file if open */
33 time_t starttime; /* when the job started spooling */
34 int status; /* the status of this job */
35 size_t size; /* the size of the job so far */
36 int page_count; /* then number of pages so far */
37 bool spooled; /* has it been sent to the spooler yet? */
38 bool smbjob; /* set if the job is a SMB job */
39 fstring filename; /* the filename used to spool the file */
40 fstring jobname; /* the job name given to us by the client */
41 fstring user; /* the user who started the job */
42 fstring clientmachine; /* The client machine which started this job */
43 fstring queuename; /* service number of printer for this job */
44 struct spoolss_DeviceMode *devmode;
47 /* Information for print interfaces */
50 /* value of the 'printing' option for this service */
51 enum printing_types type;
53 int (*queue_get)(const char *printer_name,
54 enum printing_types printing_type,
56 print_queue_struct **q,
57 print_status_struct *status);
58 int (*queue_pause)(int snum);
59 int (*queue_resume)(int snum);
60 int (*job_delete)(const char *sharename, const char *lprm_command, struct printjob *pjob);
61 int (*job_pause)(int snum, struct printjob *pjob);
62 int (*job_resume)(int snum, struct printjob *pjob);
63 int (*job_submit)(int snum, struct printjob *pjob);
66 extern struct printif generic_printif;
69 extern struct printif cups_printif;
70 #endif /* HAVE_CUPS */
73 extern struct printif iprint_printif;
74 #endif /* HAVE_IPRINT */
76 /* PRINT_MAX_JOBID is now defined in local.h */
77 #define UNIX_JOB_START PRINT_MAX_JOBID
78 #define NEXT_JOBID(j) ((j+1) % PRINT_MAX_JOBID > 0 ? (j+1) % PRINT_MAX_JOBID : 1)
80 #define MAX_CACHE_VALID_TIME 3600
81 #define CUPS_DEFAULT_CONNECTION_TIMEOUT 30
83 #ifndef PRINT_SPOOL_PREFIX
84 #define PRINT_SPOOL_PREFIX "smbprn."
86 #define PRINT_DATABASE_VERSION 7
88 /* There can be this many printing tdb's open, plus any locked ones. */
89 #define MAX_PRINT_DBS_OPEN 1
92 struct tdb_print_db *next, *prev;
99 * Used for print notify
102 #define NOTIFY_PID_LIST_KEY "NOTIFY_PID_LIST"
104 /* The following definitions come from printing/printspoolss.c */
106 NTSTATUS print_spool_open(files_struct *fsp,
108 uint16_t current_vuid);
110 int print_spool_write(files_struct *fsp, const char *data, uint32_t size,
111 SMB_OFF_T offset, uint32_t *written);
113 void print_spool_end(files_struct *fsp, enum file_close_type close_type);
115 void print_spool_terminate(struct connection_struct *conn,
116 struct print_file_data *print_file);
118 /* The following definitions come from printing/printing.c */
120 uint32 sysjob_to_jobid(int unix_jobid);
121 bool print_notify_register_pid(int snum);
122 bool print_notify_deregister_pid(int snum);
123 bool print_job_exists(const char* sharename, uint32 jobid);
124 char *print_job_fname(const char* sharename, uint32 jobid);
125 struct spoolss_DeviceMode *print_job_devmode(const char* sharename, uint32 jobid);
126 bool print_job_set_name(struct tevent_context *ev,
127 struct messaging_context *msg_ctx,
128 const char *sharename, uint32 jobid, const char *name);
129 bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t jobid, char **name);
130 WERROR print_job_delete(const struct auth_serversupplied_info *server_info,
131 struct messaging_context *msg_ctx,
132 int snum, uint32_t jobid);
133 bool print_job_pause(const struct auth_serversupplied_info *server_info,
134 struct messaging_context *msg_ctx,
135 int snum, uint32 jobid, WERROR *errcode);
136 bool print_job_resume(const struct auth_serversupplied_info *server_info,
137 struct messaging_context *msg_ctx,
138 int snum, uint32 jobid, WERROR *errcode);
139 ssize_t print_job_write(struct tevent_context *ev,
140 struct messaging_context *msg_ctx,
141 int snum, uint32 jobid, const char *buf, size_t size);
142 int print_queue_length(struct messaging_context *msg_ctx, int snum,
143 print_status_struct *pstatus);
144 WERROR print_job_start(const struct auth_serversupplied_info *server_info,
145 struct messaging_context *msg_ctx,
146 const char *clientmachine,
147 int snum, const char *docname, const char *filename,
148 struct spoolss_DeviceMode *devmode, uint32_t *_jobid);
149 void print_job_endpage(struct messaging_context *msg_ctx,
150 int snum, uint32 jobid);
151 NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
152 uint32 jobid, enum file_close_type close_type);
153 int print_queue_status(struct messaging_context *msg_ctx, int snum,
154 print_queue_struct **ppqueue,
155 print_status_struct *status);
156 WERROR print_queue_pause(const struct auth_serversupplied_info *server_info,
157 struct messaging_context *msg_ctx, int snum);
158 WERROR print_queue_resume(const struct auth_serversupplied_info *server_info,
159 struct messaging_context *msg_ctx, int snum);
160 WERROR print_queue_purge(const struct auth_serversupplied_info *server_info,
161 struct messaging_context *msg_ctx, int snum);
162 uint16 pjobid_to_rap(const char* sharename, uint32 jobid);
163 bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid);
164 void rap_jobid_delete(const char* sharename, uint32 jobid);
165 bool print_backend_init(struct messaging_context *msg_ctx);
166 void start_background_queue(struct tevent_context *ev,
167 struct messaging_context *msg);
168 void printing_end(void);
170 /* The following definitions come from printing/lpq_parse.c */
172 bool parse_lpq_entry(enum printing_types printing_type,char *line,
173 print_queue_struct *buf,
174 print_status_struct *status,bool first);
175 uint32_t print_parse_jobid(const char *fname);
177 /* The following definitions come from printing/printing_db.c */
179 struct tdb_print_db *get_print_db_byname(const char *printername);
180 void release_print_db( struct tdb_print_db *pdb);
181 void close_all_print_db(void);
182 TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char *printer_name, bool cleanlist);
184 #endif /* PRINTING_H_ */