X-Git-Url: http://git.samba.org/?p=amitay%2Fsamba.git;a=blobdiff_plain;f=source3%2Finclude%2Fnt_printing.h;h=7ebacc6985434b7298accb60efc2d5a7e5f8a5be;hp=23d474c957888d704707f2f6e1c90da7749ddf97;hb=99b2da4504307b6eefc6afbd502d931d29625ea0;hpb=d9f51cd143d142bfa0f581f98cb1c2e889f3e8ef diff --git a/source3/include/nt_printing.h b/source3/include/nt_printing.h index 23d474c9578..7ebacc69854 100644 --- a/source3/include/nt_printing.h +++ b/source3/include/nt_printing.h @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,232 +16,20 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifndef NT_PRINTING_H_ #define NT_PRINTING_H_ -#define ORIENTATION 0x00000001L -#define PAPERSIZE 0x00000002L -#define PAPERLENGTH 0x00000004L -#define PAPERWIDTH 0x00000008L -#define SCALE 0x00000010L -#define COPIES 0x00000100L -#define DEFAULTSOURCE 0x00000200L -#define PRINTQUALITY 0x00000400L -#define COLOR 0x00000800L -#define DUPLEX 0x00001000L -#define YRESOLUTION 0x00002000L -#define TTOPTION 0x00004000L -#define COLLATE 0x00008000L -#define FORMNAME 0x00010000L -#define LOGPIXELS 0x00020000L -#define BITSPERPEL 0x00040000L -#define PELSWIDTH 0x00080000L -#define PELSHEIGHT 0x00100000L -#define DISPLAYFLAGS 0x00200000L -#define DISPLAYFREQUENCY 0x00400000L -#define PANNINGWIDTH 0x00800000L -#define PANNINGHEIGHT 0x01000000L - -#define ORIENT_PORTRAIT 1 -#define ORIENT_LANDSCAPE 2 - -#define PAPER_FIRST PAPER_LETTER -#define PAPER_LETTER 1 /* Letter 8 1/2 x 11 in */ -#define PAPER_LETTERSMALL 2 /* Letter Small 8 1/2 x 11 in */ -#define PAPER_TABLOID 3 /* Tabloid 11 x 17 in */ -#define PAPER_LEDGER 4 /* Ledger 17 x 11 in */ -#define PAPER_LEGAL 5 /* Legal 8 1/2 x 14 in */ -#define PAPER_STATEMENT 6 /* Statement 5 1/2 x 8 1/2 in */ -#define PAPER_EXECUTIVE 7 /* Executive 7 1/4 x 10 1/2 in */ -#define PAPER_A3 8 /* A3 297 x 420 mm */ -#define PAPER_A4 9 /* A4 210 x 297 mm */ -#define PAPER_A4SMALL 10 /* A4 Small 210 x 297 mm */ -#define PAPER_A5 11 /* A5 148 x 210 mm */ -#define PAPER_B4 12 /* B4 (JIS) 250 x 354 */ -#define PAPER_B5 13 /* B5 (JIS) 182 x 257 mm */ -#define PAPER_FOLIO 14 /* Folio 8 1/2 x 13 in */ -#define PAPER_QUARTO 15 /* Quarto 215 x 275 mm */ -#define PAPER_10X14 16 /* 10x14 in */ -#define PAPER_11X17 17 /* 11x17 in */ -#define PAPER_NOTE 18 /* Note 8 1/2 x 11 in */ -#define PAPER_ENV_9 19 /* Envelope #9 3 7/8 x 8 7/8 */ -#define PAPER_ENV_10 20 /* Envelope #10 4 1/8 x 9 1/2 */ -#define PAPER_ENV_11 21 /* Envelope #11 4 1/2 x 10 3/8 */ -#define PAPER_ENV_12 22 /* Envelope #12 4 \276 x 11 */ -#define PAPER_ENV_14 23 /* Envelope #14 5 x 11 1/2 */ -#define PAPER_CSHEET 24 /* C size sheet */ -#define PAPER_DSHEET 25 /* D size sheet */ -#define PAPER_ESHEET 26 /* E size sheet */ -#define PAPER_ENV_DL 27 /* Envelope DL 110 x 220mm */ -#define PAPER_ENV_C5 28 /* Envelope C5 162 x 229 mm */ -#define PAPER_ENV_C3 29 /* Envelope C3 324 x 458 mm */ -#define PAPER_ENV_C4 30 /* Envelope C4 229 x 324 mm */ -#define PAPER_ENV_C6 31 /* Envelope C6 114 x 162 mm */ -#define PAPER_ENV_C65 32 /* Envelope C65 114 x 229 mm */ -#define PAPER_ENV_B4 33 /* Envelope B4 250 x 353 mm */ -#define PAPER_ENV_B5 34 /* Envelope B5 176 x 250 mm */ -#define PAPER_ENV_B6 35 /* Envelope B6 176 x 125 mm */ -#define PAPER_ENV_ITALY 36 /* Envelope 110 x 230 mm */ -#define PAPER_ENV_MONARCH 37 /* Envelope Monarch 3.875 x 7.5 in */ -#define PAPER_ENV_PERSONAL 38 /* 6 3/4 Envelope 3 5/8 x 6 1/2 in */ -#define PAPER_FANFOLD_US 39 /* US Std Fanfold 14 7/8 x 11 in */ -#define PAPER_FANFOLD_STD_GERMAN 40 /* German Std Fanfold 8 1/2 x 12 in */ -#define PAPER_FANFOLD_LGL_GERMAN 41 /* German Legal Fanfold 8 1/2 x 13 in */ - -#define PAPER_LAST PAPER_FANFOLD_LGL_GERMAN -#define PAPER_USER 256 - -#define BIN_FIRST BIN_UPPER -#define BIN_UPPER 1 -#define BIN_ONLYONE 1 -#define BIN_LOWER 2 -#define BIN_MIDDLE 3 -#define BIN_MANUAL 4 -#define BIN_ENVELOPE 5 -#define BIN_ENVMANUAL 6 -#define BIN_AUTO 7 -#define BIN_TRACTOR 8 -#define BIN_SMALLFMT 9 -#define BIN_LARGEFMT 10 -#define BIN_LARGECAPACITY 11 -#define BIN_CASSETTE 14 -#define BIN_FORMSOURCE 15 -#define BIN_LAST BIN_FORMSOURCE - -#define BIN_USER 256 /* device specific bins start here */ - -#define RES_DRAFT (-1) -#define RES_LOW (-2) -#define RES_MEDIUM (-3) -#define RES_HIGH (-4) - -#define COLOR_MONOCHROME 1 -#define COLOR_COLOR 2 - -#define DUP_SIMPLEX 1 -#define DUP_VERTICAL 2 -#define DUP_HORIZONTAL 3 - -#define TT_BITMAP 1 /* print TT fonts as graphics */ -#define TT_DOWNLOAD 2 /* download TT fonts as soft fonts */ -#define TT_SUBDEV 3 /* substitute device fonts for TT fonts */ - -#define COLLATE_FALSE 0 -#define COLLATE_TRUE 1 - -typedef struct nt_printer_driver_info_level_3 -{ - uint32 cversion; - - fstring name; - fstring environment; - fstring driverpath; - fstring datafile; - fstring configfile; - fstring helpfile; - fstring monitorname; - fstring defaultdatatype; - fstring *dependentfiles; -} NT_PRINTER_DRIVER_INFO_LEVEL_3; - -/* SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure */ -typedef struct { - uint32 version; - fstring name; - fstring environment; - fstring driverpath; - fstring datafile; - fstring configfile; - fstring helpfile; - fstring monitorname; - fstring defaultdatatype; - fstring mfgname; - fstring oemurl; - fstring hardwareid; - fstring provider; - fstring *dependentfiles; - fstring *previousnames; -} NT_PRINTER_DRIVER_INFO_LEVEL_6; - - -typedef struct nt_printer_driver_info_level -{ - NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3; - NT_PRINTER_DRIVER_INFO_LEVEL_6 *info_6; -} NT_PRINTER_DRIVER_INFO_LEVEL; - -/* predefined registry key names for printer data */ - -#define SPOOL_PRINTERDATA_KEY "PrinterDriverData" -#define SPOOL_DSSPOOLER_KEY "DsSpooler" -#define SPOOL_DSDRIVER_KEY "DsDriver" -#define SPOOL_DSUSER_KEY "DsUser" -#define SPOOL_PNPDATA_KEY "PnPData" -#define SPOOL_OID_KEY "OID" - -/* predefined value names for printer data */ -#define SPOOL_REG_ASSETNUMBER "assetNumber" -#define SPOOL_REG_BYTESPERMINUTE "bytesPerMinute" -#define SPOOL_REG_DEFAULTPRIORITY "defaultPriority" -#define SPOOL_REG_DRIVERNAME "driverName" -#define SPOOL_REG_DRIVERVERSION "driverVersion" -#define SPOOL_REG_FLAGS "flags" -#define SPOOL_REG_LOCATION "location" -#define SPOOL_REG_OPERATINGSYSTEM "operatingSystem" -#define SPOOL_REG_OPERATINGSYSTEMHOTFIX "operatingSystemHotfix" -#define SPOOL_REG_OPERATINGSYSTEMSERVICEPACK "operatingSystemServicePack" -#define SPOOL_REG_OPERATINGSYSTEMVERSION "operatingSystemVersion" -#define SPOOL_REG_PORTNAME "portName" -#define SPOOL_REG_PRINTATTRIBUTES "printAttributes" -#define SPOOL_REG_PRINTBINNAMES "printBinNames" -#define SPOOL_REG_PRINTCOLLATE "printCollate" -#define SPOOL_REG_PRINTCOLOR "printColor" -#define SPOOL_REG_PRINTDUPLEXSUPPORTED "printDuplexSupported" -#define SPOOL_REG_PRINTENDTIME "printEndTime" -#define SPOOL_REG_PRINTERNAME "printerName" -#define SPOOL_REG_PRINTFORMNAME "printFormName" -#define SPOOL_REG_PRINTKEEPPRINTEDJOBS "printKeepPrintedJobs" -#define SPOOL_REG_PRINTLANGUAGE "printLanguage" -#define SPOOL_REG_PRINTMACADDRESS "printMACAddress" -#define SPOOL_REG_PRINTMAXCOPIES "printMaxCopies" -#define SPOOL_REG_PRINTMAXRESOLUTIONSUPPORTED "printMaxResolutionSupported" -#define SPOOL_REG_PRINTMAXXEXTENT "printMaxXExtent" -#define SPOOL_REG_PRINTMAXYEXTENT "printMaxYExtent" -#define SPOOL_REG_PRINTMEDIAREADY "printMediaReady" -#define SPOOL_REG_PRINTMEDIASUPPORTED "printMediaSupported" -#define SPOOL_REG_PRINTMEMORY "printMemory" -#define SPOOL_REG_PRINTMINXEXTENT "printMinXExtent" -#define SPOOL_REG_PRINTMINYEXTENT "printMinYExtent" -#define SPOOL_REG_PRINTNETWORKADDRESS "printNetworkAddress" -#define SPOOL_REG_PRINTNOTIFY "printNotify" -#define SPOOL_REG_PRINTNUMBERUP "printNumberUp" -#define SPOOL_REG_PRINTORIENTATIONSSUPPORTED "printOrientationsSupported" -#define SPOOL_REG_PRINTOWNER "printOwner" -#define SPOOL_REG_PRINTPAGESPERMINUTE "printPagesPerMinute" -#define SPOOL_REG_PRINTRATE "printRate" -#define SPOOL_REG_PRINTRATEUNIT "printRateUnit" -#define SPOOL_REG_PRINTSEPARATORFILE "printSeparatorFile" -#define SPOOL_REG_PRINTSHARENAME "printShareName" -#define SPOOL_REG_PRINTSPOOLING "printSpooling" -#define SPOOL_REG_PRINTSTAPLINGSUPPORTED "printStaplingSupported" -#define SPOOL_REG_PRINTSTARTTIME "printStartTime" -#define SPOOL_REG_PRINTSTATUS "printStatus" -#define SPOOL_REG_PRIORITY "priority" -#define SPOOL_REG_SERVERNAME "serverName" -#define SPOOL_REG_SHORTSERVERNAME "shortServerName" -#define SPOOL_REG_UNCNAME "uNCName" -#define SPOOL_REG_URL "url" -#define SPOOL_REG_VERSIONNUMBER "versionNumber" +#include "client.h" +#include "../librpc/gen_ndr/srv_spoolss.h" /* container for a single registry key */ typedef struct { - char *name; - REGVAL_CTR values; + char *name; + struct regval_ctr *values; } NT_PRINTER_KEY; /* container for all printer data */ @@ -251,47 +39,6 @@ typedef struct { NT_PRINTER_KEY *keys; } NT_PRINTER_DATA; -typedef struct ntdevicemode -{ - fstring devicename; - fstring formname; - - uint16 specversion; - uint16 driverversion; - uint16 size; - uint16 driverextra; - uint16 orientation; - uint16 papersize; - uint16 paperlength; - uint16 paperwidth; - uint16 scale; - uint16 copies; - uint16 defaultsource; - uint16 printquality; - uint16 color; - uint16 duplex; - uint16 yresolution; - uint16 ttoption; - uint16 collate; - uint16 logpixels; - - uint32 fields; - uint32 bitsperpel; - uint32 pelswidth; - uint32 pelsheight; - uint32 displayflags; - uint32 displayfrequency; - uint32 icmmethod; - uint32 icmintent; - uint32 mediatype; - uint32 dithertype; - uint32 reserved1; - uint32 reserved2; - uint32 panningwidth; - uint32 panningheight; - uint8 *private; -} NT_DEVICEMODE; - typedef struct nt_printer_info_level_2 { uint32 attributes; @@ -307,15 +54,15 @@ typedef struct nt_printer_info_level_2 fstring sharename; fstring portname; fstring drivername; - pstring comment; + char comment[1024]; fstring location; - NT_DEVICEMODE *devmode; + struct spoolss_DeviceMode *devmode; fstring sepfile; fstring printprocessor; fstring datatype; fstring parameters; - NT_PRINTER_DATA data; - SEC_DESC_BUF *secdesc_buf; + NT_PRINTER_DATA *data; + struct sec_desc_buf *secdesc_buf; uint32 changeid; uint32 c_setprinter; uint32 setuptime; @@ -338,21 +85,6 @@ typedef struct uint32 bottom; } nt_forms_struct; -/* -typedef struct _form -{ - uint32 flags; - uint32 name_ptr; - uint32 size_x; - uint32 size_y; - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; - UNISTR2 name; -} FORM; -*/ - #ifndef SAMBA_PRINTER_PORT_NAME #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port" #endif @@ -373,18 +105,13 @@ typedef struct _form #define NE_HEADER_MAJOR_VER_OFFSET 63 /* Portable Executable format */ -#define PE_HEADER_SIZE 248 +#define PE_HEADER_SIZE 24 #define PE_HEADER_SIGNATURE_OFFSET 0 #define PE_HEADER_SIGNATURE 0x00004550 #define PE_HEADER_MACHINE_OFFSET 4 #define PE_HEADER_MACHINE_I386 0x14c #define PE_HEADER_NUMBER_OF_SECTIONS 6 -#define PE_HEADER_MAJOR_OS_VER_OFFSET 64 -#define PE_HEADER_MINOR_OS_VER_OFFSET 66 -#define PE_HEADER_MAJOR_IMG_VER_OFFSET 68 -#define PE_HEADER_MINOR_IMG_VER_OFFSET 70 -#define PE_HEADER_MAJOR_SS_VER_OFFSET 72 -#define PE_HEADER_MINOR_SS_VER_OFFSET 74 +#define PE_HEADER_OPTIONAL_HEADER_SIZE 20 #define PE_HEADER_SECT_HEADER_SIZE 40 #define PE_HEADER_SECT_NAME_OFFSET 0 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16 @@ -430,4 +157,137 @@ typedef struct { SPOOLSS_NOTIFY_MSG_GROUP *msg_groups; } SPOOLSS_NOTIFY_MSG_CTR; +#define SPLHND_PRINTER 1 +#define SPLHND_SERVER 2 +#define SPLHND_PORTMON_TCP 3 +#define SPLHND_PORTMON_LOCAL 4 + +/* structure to store the printer handles */ +/* and a reference to what it's pointing to */ +/* and the notify info asked about */ +/* that's the central struct */ +typedef struct _Printer{ + struct _Printer *prev, *next; + bool document_started; + bool page_started; + uint32 jobid; /* jobid in printing backend */ + int printer_type; + fstring servername; + fstring sharename; + uint32 type; + uint32 access_granted; + struct { + uint32 flags; + uint32 options; + fstring localmachine; + uint32 printerlocal; + struct spoolss_NotifyOption *option; + struct policy_handle client_hnd; + bool client_connected; + uint32 change; + /* are we in a FindNextPrinterChangeNotify() call? */ + bool fnpcn; + struct messaging_context *msg_ctx; + } notify; + struct { + fstring machine; + fstring user; + } client; + + /* devmode sent in the OpenPrinter() call */ + struct spoolss_DeviceMode *devmode; + + /* TODO cache the printer info2 structure */ + struct spoolss_PrinterInfo2 *info2; + +} Printer_entry; + +/* + * The printer attributes. + * I #defined all of them (grabbed form MSDN) + * I'm only using: + * ( SHARED | NETWORK | RAW_ONLY ) + * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file + */ + +#define PRINTER_ATTRIBUTE_SAMBA (PRINTER_ATTRIBUTE_RAW_ONLY|\ + PRINTER_ATTRIBUTE_SHARED|\ + PRINTER_ATTRIBUTE_LOCAL) +#define PRINTER_ATTRIBUTE_NOT_SAMBA (PRINTER_ATTRIBUTE_NETWORK) + +#define DRIVER_ANY_VERSION 0xffffffff +#define DRIVER_MAX_VERSION 4 + +struct print_architecture_table_node { + const char *long_archi; + const char *short_archi; + int version; +}; + +bool nt_printing_init(struct messaging_context *msg_ctx); + +WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx, + const char *devicename, + struct spoolss_DeviceMode **devmode); + +WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx, + struct spoolss_security_descriptor **secdesc); + +WERROR spoolss_map_to_os2_driver(TALLOC_CTX *mem_ctx, const char **pdrivername); + +const char *get_short_archi(const char *long_archi); + +bool print_access_check(struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, int snum, + int access_type); + +WERROR nt_printer_publish(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + struct spoolss_PrinterInfo2 *pinfo2, + int action); + +bool is_printer_published(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + char *servername, char *printer, struct GUID *guid, + struct spoolss_PrinterInfo2 **info2); + +WERROR check_published_printers(struct messaging_context *msg_ctx); + +bool driver_info_ctr_to_info8(struct spoolss_AddDriverInfoCtr *r, + struct spoolss_DriverInfo8 *_info8); + +bool printer_driver_in_use(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + const struct spoolss_DriverInfo8 *r); +bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + struct spoolss_DriverInfo8 *r); +bool delete_driver_files(struct auth_serversupplied_info *server_info, + const struct spoolss_DriverInfo8 *r); + +WERROR move_driver_to_download_area(struct pipes_struct *p, + struct spoolss_AddDriverInfoCtr *r, + WERROR *perr); + +WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx, + struct pipes_struct *rpc_pipe, + struct spoolss_AddDriverInfoCtr *r); + +void map_printer_permissions(struct security_descriptor *sd); + +void map_job_permissions(struct security_descriptor *sd); + +bool print_time_access_check(struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + const char *servicename); + +void nt_printer_remove(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + struct messaging_context *msg_ctx, + const char *printer); + #endif /* NT_PRINTING_H_ */