17 #include "../hidint.h"
19 #include "hid/common/hidnogui.h"
20 #include "hid/common/hidinit.h"
22 #ifdef HAVE_LIBDMALLOC
26 #define CRASH fprintf(stderr, \
27 _("HID error: pcb called unimplemented PS function %s.\n"), \
28 __FUNCTION__); abort()
30 static HID_Attribute base_lpr_options
[] = {
32 /* %start-doc options "98 lpr Printing Options"
34 @item --lprcommand <string>
35 Command to use for printing. Defaults to @code{lpr}. This can be used to produce
36 PDF output with a virtual PDF printer. Example: @*
37 @code{--lprcommand "lp -d CUPS-PDF-Printer"}.
39 @noindent In addition, all @ref{Postscript Export} options are valid.
42 {N_("lprcommand"), N_("Command to use for printing"),
43 HID_String
, 0, 0, {0, 0, 0}, 0, 0},
44 #define HA_lprcommand 0
47 #define NUM_OPTIONS (sizeof(lpr_options)/sizeof(lpr_options[0]))
49 static HID_Attribute
*lpr_options
= 0;
50 static int num_lpr_options
= 0;
51 static HID_Attr_Val
*lpr_values
;
53 static HID_Attribute
*
54 lpr_get_export_options (int *n
)
57 * We initialize the default value in this manner because the GUI
58 * HID's may want to free() this string value and replace it with a
59 * new one based on how a user fills out a print dialog.
61 if (base_lpr_options
[HA_lprcommand
].default_val
.str_value
== NULL
)
63 base_lpr_options
[HA_lprcommand
].default_val
.str_value
= strdup("lpr");
68 HID_Attribute
*ps_opts
= ps_hid
.get_export_options (&num_lpr_options
);
70 (HID_Attribute
*) calloc (num_lpr_options
, sizeof (HID_Attribute
));
71 memcpy (lpr_options
, ps_opts
, num_lpr_options
* sizeof (HID_Attribute
));
72 memcpy (lpr_options
, base_lpr_options
, sizeof (base_lpr_options
));
74 (HID_Attr_Val
*) calloc (num_lpr_options
, sizeof (HID_Attr_Val
));
82 lpr_do_export (HID_Attr_Val
* options
)
90 lpr_get_export_options (0);
91 for (i
= 0; i
< num_lpr_options
; i
++)
92 lpr_values
[i
] = lpr_options
[i
].default_val
;
96 filename
= options
[HA_lprcommand
].str_value
;
98 printf (_("LPR: open %s\n"), filename
);
99 f
= popen (filename
, "w");
106 ps_hid_export_to_file (f
, options
);
112 lpr_parse_arguments (int *argc
, char ***argv
)
114 lpr_get_export_options (0);
115 hid_register_attributes (lpr_options
, num_lpr_options
);
116 hid_parse_command_line (argc
, argv
);
120 lpr_calibrate (double xval
, double yval
)
122 ps_calibrate_1 (xval
, yval
, 1);
130 memset (&lpr_hid
, 0, sizeof (HID
));
132 common_nogui_init (&lpr_hid
);
133 ps_ps_init (&lpr_hid
);
135 lpr_hid
.struct_size
= sizeof (HID
);
136 lpr_hid
.name
= "lpr";
137 lpr_hid
.description
= N_("Postscript print");
140 lpr_hid
.get_export_options
= lpr_get_export_options
;
141 lpr_hid
.do_export
= lpr_do_export
;
142 lpr_hid
.parse_arguments
= lpr_parse_arguments
;
143 lpr_hid
.calibrate
= lpr_calibrate
;
145 hid_register_hid (&lpr_hid
);