diff options
-rw-r--r-- | source3/include/proto.h | 7 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 362 |
2 files changed, 0 insertions, 369 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 4aee813f0d..00ec31abc3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4722,13 +4722,6 @@ void notify_printer_byname( const char *printername, uint32 change, const char * /* The following definitions come from printing/nt_printing.c */ bool nt_printing_init(struct messaging_context *msg_ctx); -int get_builtin_ntforms(nt_forms_struct **list); -bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form); -int get_ntforms(nt_forms_struct **list); -int write_ntforms(nt_forms_struct **list, int number); -bool add_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int *count); -bool delete_a_form(nt_forms_struct **list, const char *del_name, int *count, WERROR *ret); -void update_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int count); int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8 *buf, int buflen); int unpack_devicemode(TALLOC_CTX *mem_ctx, const uint8 *buf, int buflen, diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index aa1e2f7cbd..51ae10649d 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -86,133 +86,6 @@ const struct generic_mapping job_generic_mapping = { JOB_ALL_ACCESS }; -/* We need one default form to support our default printer. Msoft adds the -forms it wants and in the ORDER it wants them (note: DEVMODE papersize is an -array index). Letter is always first, so (for the current code) additions -always put things in the correct order. */ -static const nt_forms_struct default_forms[] = { - {"Letter",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, - {"Letter Small",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, - {"Tabloid",0x1,0x44368,0x696b8,0x0,0x0,0x44368,0x696b8}, - {"Ledger",0x1,0x696b8,0x44368,0x0,0x0,0x696b8,0x44368}, - {"Legal",0x1,0x34b5c,0x56d10,0x0,0x0,0x34b5c,0x56d10}, - {"Statement",0x1,0x221b4,0x34b5c,0x0,0x0,0x221b4,0x34b5c}, - {"Executive",0x1,0x2cf56,0x411cc,0x0,0x0,0x2cf56,0x411cc}, - {"A0",0x1,0xcd528,0x122488,0x0,0x0,0xcd528,0x122488}, - {"A1",0x1,0x91050,0xcd528,0x0,0x0,0x91050,0xcd528}, - {"A3",0x1,0x48828,0x668a0,0x0,0x0,0x48828,0x668a0}, - {"A4",0x1,0x33450,0x48828,0x0,0x0,0x33450,0x48828}, - {"A4 Small",0x1,0x33450,0x48828,0x0,0x0,0x33450,0x48828}, - {"A5",0x1,0x24220,0x33450,0x0,0x0,0x24220,0x33450}, - {"B4 (JIS)",0x1,0x3ebe8,0x58de0,0x0,0x0,0x3ebe8,0x58de0}, - {"B5 (JIS)",0x1,0x2c6f0,0x3ebe8,0x0,0x0,0x2c6f0,0x3ebe8}, - {"Folio",0x1,0x34b5c,0x509d8,0x0,0x0,0x34b5c,0x509d8}, - {"Quarto",0x1,0x347d8,0x43238,0x0,0x0,0x347d8,0x43238}, - {"10x14",0x1,0x3e030,0x56d10,0x0,0x0,0x3e030,0x56d10}, - {"11x17",0x1,0x44368,0x696b8,0x0,0x0,0x44368,0x696b8}, - {"Note",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, - {"Envelope #9",0x1,0x18079,0x37091,0x0,0x0,0x18079,0x37091}, - {"Envelope #10",0x1,0x19947,0x3ae94,0x0,0x0,0x19947,0x3ae94}, - {"Envelope #11",0x1,0x1be7c,0x40565,0x0,0x0,0x1be7c,0x40565}, - {"Envelope #12",0x1,0x1d74a,0x44368,0x0,0x0,0x1d74a,0x44368}, - {"Envelope #14",0x1,0x1f018,0x47504,0x0,0x0,0x1f018,0x47504}, - {"C size sheet",0x1,0x696b8,0x886d0,0x0,0x0,0x696b8,0x886d0}, - {"D size sheet",0x1,0x886d0,0xd2d70,0x0,0x0,0x886d0,0xd2d70}, - {"E size sheet",0x1,0xd2d70,0x110da0,0x0,0x0,0xd2d70,0x110da0}, - {"Envelope DL",0x1,0x1adb0,0x35b60,0x0,0x0,0x1adb0,0x35b60}, - {"Envelope C5",0x1,0x278d0,0x37e88,0x0,0x0,0x278d0,0x37e88}, - {"Envelope C3",0x1,0x4f1a0,0x6fd10,0x0,0x0,0x4f1a0,0x6fd10}, - {"Envelope C4",0x1,0x37e88,0x4f1a0,0x0,0x0,0x37e88,0x4f1a0}, - {"Envelope C6",0x1,0x1bd50,0x278d0,0x0,0x0,0x1bd50,0x278d0}, - {"Envelope C65",0x1,0x1bd50,0x37e88,0x0,0x0,0x1bd50,0x37e88}, - {"Envelope B4",0x1,0x3d090,0x562e8,0x0,0x0,0x3d090,0x562e8}, - {"Envelope B5",0x1,0x2af80,0x3d090,0x0,0x0,0x2af80,0x3d090}, - {"Envelope B6",0x1,0x2af80,0x1e848,0x0,0x0,0x2af80,0x1e848}, - {"Envelope",0x1,0x1adb0,0x38270,0x0,0x0,0x1adb0,0x38270}, - {"Envelope Monarch",0x1,0x18079,0x2e824,0x0,0x0,0x18079,0x2e824}, - {"6 3/4 Envelope",0x1,0x167ab,0x284ec,0x0,0x0,0x167ab,0x284ec}, - {"US Std Fanfold",0x1,0x5c3e1,0x44368,0x0,0x0,0x5c3e1,0x44368}, - {"German Std Fanfold",0x1,0x34b5c,0x4a6a0,0x0,0x0,0x34b5c,0x4a6a0}, - {"German Legal Fanfold",0x1,0x34b5c,0x509d8,0x0,0x0,0x34b5c,0x509d8}, - {"B4 (ISO)",0x1,0x3d090,0x562e8,0x0,0x0,0x3d090,0x562e8}, - {"Japanese Postcard",0x1,0x186a0,0x24220,0x0,0x0,0x186a0,0x24220}, - {"9x11",0x1,0x37cf8,0x44368,0x0,0x0,0x37cf8,0x44368}, - {"10x11",0x1,0x3e030,0x44368,0x0,0x0,0x3e030,0x44368}, - {"15x11",0x1,0x5d048,0x44368,0x0,0x0,0x5d048,0x44368}, - {"Envelope Invite",0x1,0x35b60,0x35b60,0x0,0x0,0x35b60,0x35b60}, - {"Reserved48",0x1,0x1,0x1,0x0,0x0,0x1,0x1}, - {"Reserved49",0x1,0x1,0x1,0x0,0x0,0x1,0x1}, - {"Letter Extra",0x1,0x3ae94,0x4a6a0,0x0,0x0,0x3ae94,0x4a6a0}, - {"Legal Extra",0x1,0x3ae94,0x5d048,0x0,0x0,0x3ae94,0x5d048}, - {"Tabloid Extra",0x1,0x4a6a0,0x6f9f0,0x0,0x0,0x4a6a0,0x6f9f0}, - {"A4 Extra",0x1,0x397c2,0x4eb16,0x0,0x0,0x397c2,0x4eb16}, - {"Letter Transverse",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, - {"A4 Transverse",0x1,0x33450,0x48828,0x0,0x0,0x33450,0x48828}, - {"Letter Extra Transverse",0x1,0x3ae94,0x4a6a0,0x0,0x0,0x3ae94,0x4a6a0}, - {"Super A",0x1,0x376b8,0x56ea0,0x0,0x0,0x376b8,0x56ea0}, - {"Super B",0x1,0x4a768,0x76e58,0x0,0x0,0x4a768,0x76e58}, - {"Letter Plus",0x1,0x34b5c,0x4eb16,0x0,0x0,0x34b5c,0x4eb16}, - {"A4 Plus",0x1,0x33450,0x50910,0x0,0x0,0x33450,0x50910}, - {"A5 Transverse",0x1,0x24220,0x33450,0x0,0x0,0x24220,0x33450}, - {"B5 (JIS) Transverse",0x1,0x2c6f0,0x3ebe8,0x0,0x0,0x2c6f0,0x3ebe8}, - {"A3 Extra",0x1,0x4e9d0,0x6ca48,0x0,0x0,0x4e9d0,0x6ca48}, - {"A5 Extra",0x1,0x2a7b0,0x395f8,0x0,0x0,0x2a7b0,0x395f8}, - {"B5 (ISO) Extra",0x1,0x31128,0x43620,0x0,0x0,0x31128,0x43620}, - {"A2",0x1,0x668a0,0x91050,0x0,0x0,0x668a0,0x91050}, - {"A3 Transverse",0x1,0x48828,0x668a0,0x0,0x0,0x48828,0x668a0}, - {"A3 Extra Transverse",0x1,0x4e9d0,0x6ca48,0x0,0x0,0x4e9d0,0x6ca48}, - {"Japanese Double Postcard",0x1,0x30d40,0x24220,0x0,0x0,0x30d40,0x24220}, - {"A6",0x1,0x19a28,0x24220,0x0,0x0,0x19a28,0x24220}, - {"Japanese Envelope Kaku #2",0x1,0x3a980,0x510e0,0x0,0x0,0x3a980,0x510e0}, - {"Japanese Envelope Kaku #3",0x1,0x34bc0,0x43a08,0x0,0x0,0x34bc0,0x43a08}, - {"Japanese Envelope Chou #3",0x1,0x1d4c0,0x395f8,0x0,0x0,0x1d4c0,0x395f8}, - {"Japanese Envelope Chou #4",0x1,0x15f90,0x320c8,0x0,0x0,0x15f90,0x320c8}, - {"Letter Rotated",0x1,0x44368,0x34b5c,0x0,0x0,0x44368,0x34b5c}, - {"A3 Rotated",0x1,0x668a0,0x48828,0x0,0x0,0x668a0,0x48828}, - {"A4 Rotated",0x1,0x48828,0x33450,0x0,0x0,0x48828,0x33450}, - {"A5 Rotated",0x1,0x33450,0x24220,0x0,0x0,0x33450,0x24220}, - {"B4 (JIS) Rotated",0x1,0x58de0,0x3ebe8,0x0,0x0,0x58de0,0x3ebe8}, - {"B5 (JIS) Rotated",0x1,0x3ebe8,0x2c6f0,0x0,0x0,0x3ebe8,0x2c6f0}, - {"Japanese Postcard Rotated",0x1,0x24220,0x186a0,0x0,0x0,0x24220,0x186a0}, - {"Double Japan Postcard Rotated",0x1,0x24220,0x30d40,0x0,0x0,0x24220,0x30d40}, - {"A6 Rotated",0x1,0x24220,0x19a28,0x0,0x0,0x24220,0x19a28}, - {"Japan Envelope Kaku #2 Rotated",0x1,0x510e0,0x3a980,0x0,0x0,0x510e0,0x3a980}, - {"Japan Envelope Kaku #3 Rotated",0x1,0x43a08,0x34bc0,0x0,0x0,0x43a08, 0x34bc0}, - {"Japan Envelope Chou #3 Rotated",0x1,0x395f8,0x1d4c0,0x0,0x0,0x395f8,0x1d4c0}, - {"Japan Envelope Chou #4 Rotated",0x1,0x320c8,0x15f90,0x0,0x0,0x320c8,0x15f90}, - {"B6 (JIS)",0x1,0x1f400,0x2c6f0,0x0,0x0,0x1f400,0x2c6f0}, - {"B6 (JIS) Rotated",0x1,0x2c6f0,0x1f400,0x0,0x0,0x2c6f0,0x1f400}, - {"12x11",0x1,0x4a724,0x443e1,0x0,0x0,0x4a724,0x443e1}, - {"Japan Envelope You #4",0x1,0x19a28,0x395f8,0x0,0x0,0x19a28,0x395f8}, - {"Japan Envelope You #4 Rotated",0x1,0x395f8,0x19a28,0x0,0x0,0x395f8,0x19a28}, - {"PRC 16K",0x1,0x2de60,0x3f7a0,0x0,0x0,0x2de60,0x3f7a0}, - {"PRC 32K",0x1,0x1fbd0,0x2cec0,0x0,0x0,0x1fbd0,0x2cec0}, - {"PRC 32K(Big)",0x1,0x222e0,0x318f8,0x0,0x0,0x222e0,0x318f8}, - {"PRC Envelope #1",0x1,0x18e70,0x28488,0x0,0x0,0x18e70,0x28488}, - {"PRC Envelope #2",0x1,0x18e70,0x2af80,0x0,0x0,0x18e70,0x2af80}, - {"PRC Envelope #3",0x1,0x1e848,0x2af80,0x0,0x0,0x1e848,0x2af80}, - {"PRC Envelope #4",0x1,0x1adb0,0x32c80,0x0,0x0,0x1adb0,0x32c80}, - {"PRC Envelope #5",0x1,0x1adb0,0x35b60,0x0,0x0,0x1adb0,0x35b60}, - {"PRC Envelope #6",0x1,0x1d4c0,0x38270,0x0,0x0,0x1d4c0,0x38270}, - {"PRC Envelope #7",0x1,0x27100,0x38270,0x0,0x0,0x27100,0x38270}, - {"PRC Envelope #8",0x1,0x1d4c0,0x4b708,0x0,0x0,0x1d4c0,0x4b708}, - {"PRC Envelope #9",0x1,0x37e88,0x4f1a0,0x0,0x0,0x37e88,0x4f1a0}, - {"PRC Envelope #10",0x1,0x4f1a0,0x6fd10,0x0,0x0,0x4f1a0,0x6fd10}, - {"PRC 16K Rotated",0x1,0x3f7a0,0x2de60,0x0,0x0,0x3f7a0,0x2de60}, - {"PRC 32K Rotated",0x1,0x2cec0,0x1fbd0,0x0,0x0,0x2cec0,0x1fbd0}, - {"PRC 32K(Big) Rotated",0x1,0x318f8,0x222e0,0x0,0x0,0x318f8,0x222e0}, - {"PRC Envelope #1 Rotated",0x1,0x28488,0x18e70,0x0,0x0,0x28488,0x18e70}, - {"PRC Envelope #2 Rotated",0x1,0x2af80,0x18e70,0x0,0x0,0x2af80,0x18e70}, - {"PRC Envelope #3 Rotated",0x1,0x2af80,0x1e848,0x0,0x0,0x2af80,0x1e848}, - {"PRC Envelope #4 Rotated",0x1,0x32c80,0x1adb0,0x0,0x0,0x32c80,0x1adb0}, - {"PRC Envelope #5 Rotated",0x1,0x35b60,0x1adb0,0x0,0x0,0x35b60,0x1adb0}, - {"PRC Envelope #6 Rotated",0x1,0x38270,0x1d4c0,0x0,0x0,0x38270,0x1d4c0}, - {"PRC Envelope #7 Rotated",0x1,0x38270,0x27100,0x0,0x0,0x38270,0x27100}, - {"PRC Envelope #8 Rotated",0x1,0x4b708,0x1d4c0,0x0,0x0,0x4b708,0x1d4c0}, - {"PRC Envelope #9 Rotated",0x1,0x4f1a0,0x37e88,0x0,0x0,0x4f1a0,0x37e88}, - {"PRC Envelope #10 Rotated",0x1,0x6fd10,0x4f1a0,0x0,0x0,0x6fd10,0x4f1a0} -}; - static const struct print_architecture_table_node archi_table[]= { {"Windows 4.0", SPL_ARCH_WIN40, 0 }, @@ -660,241 +533,6 @@ static NTSTATUS driver_unix_convert(connection_struct *conn, } /**************************************************************************** - Get builtin form struct list. -****************************************************************************/ - -int get_builtin_ntforms(nt_forms_struct **list) -{ - *list = (nt_forms_struct *)memdup(&default_forms[0], sizeof(default_forms)); - if (!*list) { - return 0; - } - return ARRAY_SIZE(default_forms); -} - -/**************************************************************************** - get a builtin form struct -****************************************************************************/ - -bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form) -{ - int i; - DEBUGADD(6,("Looking for builtin form %s \n", form_name)); - for (i=0; i<ARRAY_SIZE(default_forms); i++) { - if (strequal(form_name,default_forms[i].name)) { - DEBUGADD(6,("Found builtin form %s \n", form_name)); - memcpy(form,&default_forms[i],sizeof(*form)); - return true; - } - } - - return false; -} - -/**************************************************************************** - get a form struct list. -****************************************************************************/ - -int get_ntforms(nt_forms_struct **list) -{ - TDB_DATA kbuf, newkey, dbuf; - nt_forms_struct form; - int ret; - int i; - int n = 0; - - *list = NULL; - - for (kbuf = tdb_firstkey(tdb_forms); - kbuf.dptr; - newkey = tdb_nextkey(tdb_forms, kbuf), free(kbuf.dptr), kbuf=newkey) - { - if (strncmp((const char *)kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) != 0) - continue; - - dbuf = tdb_fetch(tdb_forms, kbuf); - if (!dbuf.dptr) - continue; - - fstrcpy(form.name, (const char *)kbuf.dptr+strlen(FORMS_PREFIX)); - ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "dddddddd", - &i, &form.flag, &form.width, &form.length, &form.left, - &form.top, &form.right, &form.bottom); - SAFE_FREE(dbuf.dptr); - if (ret != dbuf.dsize) - continue; - - *list = SMB_REALLOC_ARRAY(*list, nt_forms_struct, n+1); - if (!*list) { - DEBUG(0,("get_ntforms: Realloc fail.\n")); - return 0; - } - (*list)[n] = form; - n++; - } - - - return n; -} - -/**************************************************************************** -write a form struct list -****************************************************************************/ - -int write_ntforms(nt_forms_struct **list, int number) -{ - TALLOC_CTX *ctx = talloc_tos(); - char *buf = NULL; - char *key = NULL; - int len; - TDB_DATA dbuf; - int i; - - for (i=0;i<number;i++) { - /* save index, so list is rebuilt in correct order */ - len = tdb_pack(NULL, 0, "dddddddd", - i, (*list)[i].flag, (*list)[i].width, (*list)[i].length, - (*list)[i].left, (*list)[i].top, (*list)[i].right, - (*list)[i].bottom); - if (!len) { - continue; - } - buf = TALLOC_ARRAY(ctx, char, len); - if (!buf) { - return 0; - } - len = tdb_pack((uint8 *)buf, len, "dddddddd", - i, (*list)[i].flag, (*list)[i].width, (*list)[i].length, - (*list)[i].left, (*list)[i].top, (*list)[i].right, - (*list)[i].bottom); - key = talloc_asprintf(ctx, "%s%s", FORMS_PREFIX, (*list)[i].name); - if (!key) { - return 0; - } - dbuf.dsize = len; - dbuf.dptr = (uint8 *)buf; - if (tdb_store_bystring(tdb_forms, key, dbuf, TDB_REPLACE) != 0) { - TALLOC_FREE(key); - TALLOC_FREE(buf); - break; - } - TALLOC_FREE(key); - TALLOC_FREE(buf); - } - - return i; -} - -/**************************************************************************** -add a form struct at the end of the list -****************************************************************************/ -bool add_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int *count) -{ - int n=0; - bool update; - - /* - * NT tries to add forms even when - * they are already in the base - * only update the values if already present - */ - - update=False; - - for (n=0; n<*count; n++) { - if ( strequal((*list)[n].name, form->form_name) ) { - update=True; - break; - } - } - - if (update==False) { - if((*list=SMB_REALLOC_ARRAY(*list, nt_forms_struct, n+1)) == NULL) { - DEBUG(0,("add_a_form: failed to enlarge forms list!\n")); - return False; - } - fstrcpy((*list)[n].name, form->form_name); - (*count)++; - } - - (*list)[n].flag = form->flags; - (*list)[n].width = form->size.width; - (*list)[n].length = form->size.height; - (*list)[n].left = form->area.left; - (*list)[n].top = form->area.top; - (*list)[n].right = form->area.right; - (*list)[n].bottom = form->area.bottom; - - DEBUG(6,("add_a_form: Successfully %s form [%s]\n", - update ? "updated" : "added", form->form_name)); - - return True; -} - -/**************************************************************************** - Delete a named form struct. -****************************************************************************/ - -bool delete_a_form(nt_forms_struct **list, const char *del_name, int *count, WERROR *ret) -{ - char *key = NULL; - int n=0; - - *ret = WERR_OK; - - for (n=0; n<*count; n++) { - if (!strncmp((*list)[n].name, del_name, strlen(del_name))) { - DEBUG(103, ("delete_a_form, [%s] in list\n", del_name)); - break; - } - } - - if (n == *count) { - DEBUG(10,("delete_a_form, [%s] not found\n", del_name)); - *ret = WERR_INVALID_FORM_NAME; - return False; - } - - if (asprintf(&key, "%s%s", FORMS_PREFIX, (*list)[n].name) < 0) { - *ret = WERR_NOMEM; - return false; - } - if (tdb_delete_bystring(tdb_forms, key) != 0) { - SAFE_FREE(key); - *ret = WERR_NOMEM; - return False; - } - SAFE_FREE(key); - return true; -} - -/**************************************************************************** - Update a form struct. -****************************************************************************/ - -void update_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int count) -{ - int n=0; - - DEBUG(106, ("[%s]\n", form->form_name)); - for (n=0; n<count; n++) { - DEBUGADD(106, ("n [%d]:[%s]\n", n, (*list)[n].name)); - if (!strncmp((*list)[n].name, form->form_name, strlen(form->form_name))) - break; - } - - if (n==count) return; - - (*list)[n].flag = form->flags; - (*list)[n].width = form->size.width; - (*list)[n].length = form->size.height; - (*list)[n].left = form->area.left; - (*list)[n].top = form->area.top; - (*list)[n].right = form->area.right; - (*list)[n].bottom = form->area.bottom; -} - -/**************************************************************************** Function to do the mapping between the long architecture name and the short one. ****************************************************************************/ |