+\f
+/************************************************************************/
+/* printer helpers */
+/************************************************************************/
+
+static void
+signal_open_printer_error (struct device *d)
+{
+ invalid_operation ("Failed to open printer", DEVICE_CONNECTION (d));
+}
+
+
+/* Helper function */
+static int
+msprinter_init_device_internal (struct device *d, char* printer_name)
+{
+ DEVICE_MSPRINTER_NAME(d) = xstrdup (printer_name);
+
+ if (!OpenPrinter (printer_name, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
+ {
+ DEVICE_MSPRINTER_HPRINTER (d) = NULL;
+ return 0;
+ }
+
+ DEVICE_MSPRINTER_HDC (d) = CreateDC ("WINSPOOL", printer_name,
+ NULL, NULL);
+ if (DEVICE_MSPRINTER_HDC (d) == NULL)
+ return 0;
+
+ DEVICE_MSPRINTER_HCDC(d) =
+ CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d));
+
+ DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
+ * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
+ > 1) ? Qcolor : Qmono;
+ return 1;
+}
+
+static void
+msprinter_delete_device_internal (struct device *d)
+{
+ if (DEVICE_MSPRINTER_HPRINTER (d))
+ ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
+ if (DEVICE_MSPRINTER_HDC (d))
+ DeleteDC (DEVICE_MSPRINTER_HDC (d));
+ if (DEVICE_MSPRINTER_HCDC (d))
+ DeleteDC (DEVICE_MSPRINTER_HCDC (d));
+ if (DEVICE_MSPRINTER_NAME (d))
+ xfree (DEVICE_MSPRINTER_NAME (d));
+
+ DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
+}
+
+static int
+msprinter_reinit_device (struct device *d, char* devname)
+{
+ msprinter_delete_device_internal (d);
+ return msprinter_init_device_internal (d, devname);
+}
+
+Lisp_Object
+msprinter_default_printer (void)
+{
+ Extbyte name[666];
+ Bufbyte *nameint;
+
+ if (GetProfileString (XETEXT ("windows"), XETEXT ("device"), NULL, name,
+ sizeof (name) / XETCHAR_SIZE) <= 0)
+ return Qnil;
+ EXTERNAL_TO_C_STRING (name, nameint, Qmswindows_tstr);
+
+ if (name[0] == '\0')
+ return Qnil;
+ strtok (name, ",");
+
+ return build_string (name);
+}
+
+\f
+/************************************************************************/
+/* printer methods */
+/************************************************************************/
+
+static void
+msprinter_init_device (struct device *d, Lisp_Object props)
+{
+ char* printer_name;
+ DEVMODE *pdm;
+ size_t dm_size;
+
+ d->device_data = xnew_and_zero (struct msprinter_device);
+
+ DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
+ DEVICE_MSPRINTER_DEVMODE(d) = Qnil;
+
+ /* We do not use printer fon list as we do with the display
+ device. Rather, we allow GDI to pick the closest match to the
+ display font. */
+ DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
+
+ CHECK_STRING (DEVICE_CONNECTION (d));
+
+ TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d),
+ C_STRING_ALLOCA, printer_name,
+ Qmswindows_tstr);
+
+ if (!msprinter_init_device_internal (d, printer_name))
+ signal_open_printer_error (d);
+
+ /* Determine DEVMODE size and store the default DEVMODE */
+ dm_size = DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
+ printer_name, NULL, NULL, 0);
+ if (dm_size <= 0)
+ signal_open_printer_error (d);
+
+ pdm = (DEVMODE*) xmalloc (dm_size);
+ DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
+ printer_name, pdm,
+ NULL, DM_OUT_BUFFER);
+
+ assert (DEVMODE_SIZE (pdm) <= dm_size);
+
+ DEVICE_MSPRINTER_DEVMODE(d) =
+ allocate_devmode (pdm, 0, printer_name, d);
+
+}
+
+static void
+msprinter_delete_device (struct device *d)
+{
+ if (d->device_data)
+ {
+ msprinter_delete_device_internal (d);
+
+ /* Disassociate the selected devmode with the device */
+ if (!NILP (DEVICE_MSPRINTER_DEVMODE (d)))
+ {
+ XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d))->device = Qnil;
+ DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
+ }
+
+ xfree (d->device_data);
+ }
+}
+
+static Lisp_Object
+msprinter_device_system_metrics (struct device *d,
+ enum device_metrics m)
+{
+ switch (m)
+ {
+ /* Device sizes - pixel and mm */
+#define FROB(met, index1, index2) \
+ case DM_##met: \
+ return build_devicecaps_cons \
+ (DEVICE_MSPRINTER_HDC(d), index1, index2);
+
+ FROB (size_device, PHYSICALWIDTH, PHYSICALHEIGHT);
+ FROB (size_device_mm, HORZSIZE, VERTSIZE);
+ FROB (size_workspace, HORZRES, VERTRES);
+ FROB (offset_workspace, PHYSICALOFFSETX, PHYSICALOFFSETY);
+ FROB (device_dpi, LOGPIXELSX, LOGPIXELSY);
+#undef FROB
+
+ case DM_num_bit_planes:
+ /* this is what X means by bitplanes therefore we ought to be
+ consistent. num planes is always 1 under mswindows and
+ therefore useless */
+ return make_int (GetDeviceCaps (DEVICE_MSPRINTER_HDC(d), BITSPIXEL));
+
+ case DM_num_color_cells: /* Printers are non-palette devices */
+ case DM_slow_device: /* Animation would be a really bad idea */
+ case DM_security: /* Not provided by windows */
+ return Qzero;
+ }
+
+ /* Do not know such property */
+ return Qunbound;
+}
+
+static void
+msprinter_mark_device (struct device *d)
+{
+ mark_object (DEVICE_MSPRINTER_FONTLIST (d));
+ mark_object (DEVICE_MSPRINTER_DEVMODE (d));
+}
+
+\f
+/************************************************************************/
+/* printer Lisp subroutines */
+/************************************************************************/
+
+static void
+global_free_2_maybe (HGLOBAL hg1, HGLOBAL hg2)
+{
+ if (hg1 != NULL)
+ GlobalFree (hg1);
+ if (hg2 != NULL)
+ GlobalFree (hg2);
+}
+
+static HGLOBAL
+devmode_to_hglobal (Lisp_Devmode *ldm)
+{
+ HGLOBAL hg = GlobalAlloc (GHND, XDEVMODE_SIZE (ldm));
+ memcpy (GlobalLock (hg), ldm->devmode, XDEVMODE_SIZE (ldm));
+ GlobalUnlock (hg);
+ return hg;
+}
+
+/* Returns 0 if the printer has been deleted due to a fatal I/O error,
+ 1 otherwise. */
+static int
+sync_printer_with_devmode (struct device* d, DEVMODE* devmode_in,
+ DEVMODE* devmode_out, char* devname)
+{
+ /* Change connection if the device changed */
+ if (devname != NULL
+ && stricmp (devname, DEVICE_MSPRINTER_NAME(d)) != 0)
+ {
+ Lisp_Object new_connection = build_ext_string (devname, Qmswindows_tstr);
+ struct gcpro gcpro1;
+
+ GCPRO1 (new_connection);
+ DEVICE_CONNECTION (d) = Qnil;
+ if (!NILP (Ffind_device (new_connection, Qmsprinter)))
+ {
+ /* We are in trouble - second msprinter for the same device.
+ Nothing wrong on the Windows side, just forge a unique
+ connection name. Use the memory address of d as a unique
+ suffix. */
+ char* new_connext = alloca (strlen (devname + 11));
+ sprintf (new_connext, "%s:%X", devname, d->header.uid);
+ new_connection = build_ext_string (devname, Qmswindows_tstr);
+ }
+ DEVICE_CONNECTION (d) = new_connection;
+ UNGCPRO;
+
+ /* Reinitialize printer. The device can pop off in process */
+ if (!msprinter_reinit_device (d, devname))
+ {
+ /* Kaboom! */
+ delete_device_internal (d, 1, 0, 1);
+ return 0;
+ }
+ }
+
+ /* Apply the new devmode to the printer */
+ DocumentProperties (NULL,
+ DEVICE_MSPRINTER_HPRINTER(d),
+ DEVICE_MSPRINTER_NAME(d),
+ devmode_out, devmode_in,
+ DM_IN_BUFFER | DM_OUT_BUFFER);
+
+ /* #### ResetDC fails sometimes, Bill only knows why.
+ The solution below looks more like a workaround to me,
+ although it might be fine. --kkm */
+ if (ResetDC (DEVICE_MSPRINTER_HDC (d), devmode_out) == NULL)
+ {
+ DeleteDC (DEVICE_MSPRINTER_HDC (d));
+ DEVICE_MSPRINTER_HDC (d) =
+ CreateDC ("WINSPOOL", DEVICE_MSPRINTER_NAME(d), NULL, devmode_out);
+ }
+
+ return 1;
+}
+
+static void
+handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode)
+{
+ DEVNAMES* devnames = (DEVNAMES*) GlobalLock (hDevNames);
+ char *new_name = devnames ? (char*)devnames + devnames->wDeviceOffset : NULL;
+ DEVMODE* devmode = (DEVMODE*) GlobalLock (hDevMode);
+
+ /* Size and name may have changed */
+ ldm->devmode = xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
+ if (new_name)
+ {
+ if (ldm->printer_name)
+ xfree (ldm->printer_name);
+ ldm->printer_name = xstrdup (new_name);
+ }
+
+ if (!NILP (ldm->device))
+ {
+ /* Apply the new devmode to the printer and get a compete one back */
+ struct device *d = XDEVICE (ldm->device);
+ if (!sync_printer_with_devmode (d, devmode, ldm->devmode, new_name))
+ {
+ global_free_2_maybe (hDevNames, hDevMode);
+ error ("Printer device initialization I/O error, device deleted.");
+ }
+ }
+ else
+ {
+ /* Just copy the devmode structure */
+ memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode));
+ }
+}
+
+static void
+ensure_not_printing (struct device *d)
+{
+ if (!NILP (DEVICE_FRAME_LIST (d)))
+ {
+ Lisp_Object device;
+ XSETDEVICE (device, d);
+ invalid_operation ("Cannot change settings while print job is active",
+ device);
+ }
+}
+
+static Lisp_Devmode *
+decode_devmode (Lisp_Object dev)
+{
+ if (DEVMODEP (dev))
+ return XDEVMODE (dev);
+ else
+ {
+ ensure_not_printing (XDEVICE (dev));
+ return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (XDEVICE (dev)));
+ }
+}
+
+/*
+ * DEV can be either a printer or devmode
+ */
+static Lisp_Object
+print_dialog_worker (Lisp_Object dev, DWORD flags)
+{
+ Lisp_Devmode *ldm = decode_devmode (dev);
+ PRINTDLG pd;
+
+ memset (&pd, 0, sizeof (pd));
+ pd.lStructSize = sizeof (pd);
+ pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
+ pd.hDevMode = devmode_to_hglobal (ldm);
+ pd.Flags = flags | PD_USEDEVMODECOPIESANDCOLLATE;
+ pd.nMinPage = 0;
+ pd.nMaxPage = 0xFFFF;
+
+ if (!PrintDlg (&pd))
+ {
+ global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+ return Qnil;
+ }
+
+ handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
+
+ /* Finally, build the resulting plist */
+ {
+ Lisp_Object result = Qnil;
+ struct gcpro gcpro1;
+ GCPRO1 (result);
+
+ /* Do consing in reverse order.
+ Number of copies */
+ result = Fcons (Qcopies, Fcons (make_int (pd.nCopies), result));
+
+ /* Page range */
+ if (pd.Flags & PD_PAGENUMS)
+ {
+ result = Fcons (Qto_page, Fcons (make_int (pd.nToPage), result));
+ result = Fcons (Qfrom_page, Fcons (make_int (pd.nFromPage), result));
+ result = Fcons (Qselected_page_button, Fcons (Qpages, result));
+ }
+ else if (pd.Flags & PD_SELECTION)
+ result = Fcons (Qselected_page_button, Fcons (Qselection, result));
+ else
+ result = Fcons (Qselected_page_button, Fcons (Qall, result));
+
+ /* Device name */
+ result = Fcons (Qname, Fcons (build_ext_string (ldm->printer_name,
+ Qmswindows_tstr),
+ result));
+ UNGCPRO;
+
+ global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+ return result;
+ }
+}
+
+Lisp_Object
+mswindows_handle_print_dialog_box (struct frame *f, Lisp_Object keys)
+{
+ Lisp_Object device = Qunbound, settings = Qunbound;
+ DWORD flags = PD_NOSELECTION;
+
+ {
+ EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
+ {
+ if (EQ (key, Q_device))
+ {
+ device = wrap_device (decode_device (value));
+ CHECK_MSPRINTER_DEVICE (device);
+ }
+ else if (EQ (key, Q_printer_settings))
+ {
+ CHECK_DEVMODE (value);
+ settings = value;
+ }
+ else if (EQ (key, Q_allow_pages))
+ {
+ if (NILP (value))
+ flags |= PD_NOPAGENUMS;
+ }
+ else if (EQ (key, Q_allow_selection))
+ {
+ if (!NILP (value))
+ flags &= ~PD_NOSELECTION;
+ }
+ else if (EQ (key, Q_selected_page_button))
+ {
+ if (EQ (value, Qselection))
+ flags |= PD_SELECTION;
+ else if (EQ (value, Qpages))
+ flags |= PD_PAGENUMS;
+ else if (!EQ (value, Qall))
+ invalid_argument ("Invalid value for :selected-page-button",
+ value);
+ }
+ else
+ syntax_error ("Unrecognized print-dialog keyword", key);
+ }
+ }
+
+ if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
+ (!UNBOUNDP (device) && !UNBOUNDP (settings)))
+ syntax_error ("Exactly one of :device and :printer-settings must be given",
+ keys);
+
+ return print_dialog_worker (!UNBOUNDP (device) ? device : settings, flags);
+}
+
+int
+mswindows_get_default_margin (Lisp_Object prop)
+{
+ if (EQ (prop, Qleft_margin)) return 1440;
+ if (EQ (prop, Qright_margin)) return 1440;
+ if (EQ (prop, Qtop_margin)) return 720;
+ if (EQ (prop, Qbottom_margin)) return 720;
+ ABORT ();
+ return 0;
+}
+
+static int
+plist_get_margin (Lisp_Object plist, Lisp_Object prop, int mm_p)
+{
+ Lisp_Object val =
+ Fplist_get (plist, prop, make_int (mswindows_get_default_margin (prop)));
+ if (!INTP (val))
+ invalid_argument ("Margin value must be an integer", val);
+
+ return MulDiv (XINT (val), mm_p ? 254 : 100, 144);
+}
+
+static Lisp_Object
+plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
+{
+ Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 254 : 100));
+ return Fcons (prop, Fcons (val, plist));
+}
+
+Lisp_Object
+mswindows_handle_page_setup_dialog_box (struct frame *f, Lisp_Object keys)
+{
+ Lisp_Object device = Qunbound, settings = Qunbound;
+ Lisp_Object plist = Qnil;
+
+ {
+ EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
+ {
+ if (EQ (key, Q_device))
+ {
+ device = wrap_device (decode_device (value));
+ CHECK_MSPRINTER_DEVICE (device);
+ }
+ else if (EQ (key, Q_printer_settings))
+ {
+ CHECK_DEVMODE (value);
+ settings = value;
+ }
+ else if (EQ (key, Q_properties))
+ {
+ CHECK_LIST (value);
+ plist = value;
+ }
+ else
+ syntax_error ("Unrecognized page-setup dialog keyword", key);
+ }
+ }
+
+ if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
+ (!UNBOUNDP (device) && !UNBOUNDP (settings)))
+ syntax_error ("Exactly one of :device and :printer-settings must be given",
+ keys);
+
+ if (UNBOUNDP (device))
+ device = settings;
+
+ {
+ Lisp_Devmode *ldm = decode_devmode (device);
+ PAGESETUPDLG pd;
+ TCHAR measure[2];
+ int data;
+
+ GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IMEASURE,
+ measure, sizeof(measure));
+ data = (strcmp (measure, "0"));
+
+ memset (&pd, 0, sizeof (pd));
+ pd.lStructSize = sizeof (pd);
+ pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
+ pd.Flags = PSD_MARGINS;
+ pd.rtMargin.left = plist_get_margin (plist, Qleft_margin, !data);
+ pd.rtMargin.top = plist_get_margin (plist, Qtop_margin, !data);
+ pd.rtMargin.right = plist_get_margin (plist, Qright_margin, !data);
+ pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin, !data);
+ pd.hDevMode = devmode_to_hglobal (ldm);
+
+ if (!PageSetupDlg (&pd))
+ {
+ global_free_2_maybe (pd.hDevNames, pd.hDevMode);
+ return Qnil;
+ }
+
+ if (pd.hDevMode)
+ handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
+
+ /* Finally, build the resulting plist */
+ {
+ Lisp_Object result = Qnil;
+ int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS;
+ result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom,
+ mm_p);
+ result = plist_set_margin (result, Qright_margin, pd.rtMargin.right,
+ mm_p);
+ result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p);
+ result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p);
+ return result;
+ }
+ }
+}
+
+DEFUN ("msprinter-get-settings", Fmsprinter_get_settings, 1, 1, 0, /*
+Return the settings object currently used by DEVICE.
+The object returned is not a copy, but rather a pointer to the
+original one. Use `msprinter-settings-copy' to create a copy of it.
+*/
+ (device))
+{
+ struct device *d = decode_device (device);
+ XSETDEVICE (device, d);
+ CHECK_MSPRINTER_DEVICE (device);
+ return DEVICE_MSPRINTER_DEVMODE (d);
+}
+
+DEFUN ("msprinter-select-settings", Fmsprinter_select_settings, 2, 2, 0, /*
+Select SETTINGS object into a DEVICE.
+The settings from the settings object are immediately applied to the
+printer, possibly changing even the target printer itself, and all
+future changes are applied synchronously to the printer device and the
+selected printer object, until a different settings object is selected
+into the same printer.
+
+A settings object can be selected to no more than one printer at a time.
+
+If the supplied settings object is not specialized, it is specialized
+for the printer immediately upon selection. The object can be
+despecialized after it is unselected by calling the function
+`msprinter-settings-despecialize'.
+
+Return value is the previously selected settings object.
+*/
+ (device, settings))
+{
+ Lisp_Devmode *ldm;
+ struct device *d = decode_device (device);
+
+ struct gcpro gcpro1;
+ GCPRO1 (settings);
+
+ XSETDEVICE (device, d);
+ CHECK_MSPRINTER_DEVICE (device);
+ CHECK_DEVMODE (settings);
+ ldm = XDEVMODE (settings);
+
+ if (!NILP (ldm->device))
+ invalid_operation ("The object is currently selected into a device",
+ settings);
+
+ /* If the object being selected is de-specialized, then its
+ size is perhaps not enough to receive the new devmode. We can ask
+ for printer's devmode size here, because despecialized settings
+ cannot force switching to a different printer, as they supply no
+ printer name at all. */
+ if (ldm->printer_name == NULL)
+ {
+ size_t dm_size =
+ DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
+ DEVICE_MSPRINTER_NAME(d), NULL, NULL, 0);
+ if (dm_size <= 0)
+ invalid_operation ("Unable to specialize settings, printer error",
+ device);
+
+ assert (XDEVMODE_SIZE (ldm) <= dm_size);
+ ldm->devmode = xrealloc (ldm->devmode, dm_size);
+ }
+
+ /* If we bail out on signal here, no damage is done, except that
+ the storage for the DEVMODE structure might be reallocated to
+ hold a larger one - not a big deal */
+ if (!sync_printer_with_devmode (d, ldm->devmode, ldm->devmode,
+ ldm->printer_name))
+ error ("Printer device initialization I/O error, device deleted.");
+
+ if (ldm->printer_name == NULL)
+ ldm->printer_name = xstrdup (DEVICE_MSPRINTER_NAME(d));
+
+ {
+ Lisp_Object old_mode = DEVICE_MSPRINTER_DEVMODE (d);
+ ldm->device = device;
+ XDEVMODE (old_mode)->device = Qnil;
+ DEVICE_MSPRINTER_DEVMODE (d) = settings;
+ UNGCPRO;
+ return old_mode;
+ }
+}
+
+DEFUN ("msprinter-apply-settings", Fmsprinter_apply_settings, 2, 2, 0, /*
+Apply settings from a SETTINGS object to a 'msprinter DEVICE.
+The settings from the settings object are immediately applied to the
+printer, possibly changing even the target printer itself. The SETTING
+object is not modified, unlike `msprinter-select-settings', and the
+supplied object is not changed. The changes are immediately recorded
+into the settings object which is currently selected into the printer
+device.
+
+Return value is the currently selected settings object.
+*/
+ (device, settings))
+{
+ Lisp_Devmode *ldm_current, *ldm_new;
+ struct device *d = decode_device (device);
+
+ struct gcpro gcpro1;
+ GCPRO1 (settings);
+
+ XSETDEVICE (device, d);
+ CHECK_MSPRINTER_DEVICE (device);
+ CHECK_DEVMODE (settings);
+ ldm_new = XDEVMODE (settings);
+ ldm_current = XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
+
+ /* If the supplied devmode is not specialized, then the current
+ devmode size will always be sufficient, as the printer does
+ not change. If it is specialized, we must reallocate the current
+ devmode storage to match with the supplied one, as it has the right
+ size for the new printer, if it is going to change. The correct
+ way is to use the largest of the two though, to keep the old
+ contents unchanged in case of preliminary exit.
+ */
+ if (ldm_new->printer_name)
+ ldm_current->devmode =
+ (DEVMODE*) xrealloc (ldm_current->devmode,
+ max (XDEVMODE_SIZE (ldm_new),
+ XDEVMODE_SIZE (ldm_current)));
+
+ if (!sync_printer_with_devmode (d, ldm_new->devmode,
+ ldm_current->devmode,
+ ldm_new->printer_name))
+ error ("Printer device initialization I/O error, device deleted.");
+
+ if (ldm_new->printer_name != NULL)
+ {
+ xfree (ldm_current->printer_name);
+ ldm_current->printer_name = xstrdup (ldm_new->printer_name);
+ }
+
+ UNGCPRO;
+ return DEVICE_MSPRINTER_DEVMODE (d);
+}
+\f
+/************************************************************************/
+/* devmode */
+/************************************************************************/
+
+static void
+print_devmode (Lisp_Object obj, Lisp_Object printcharfun,
+ int escapeflag)