18 #include "../hidint.h"
21 #ifdef HAVE_LIBDMALLOC
27 #define CRASH fprintf(stderr, "HID error: pcb called unimplemented PS function %s.\n", __FUNCTION__); abort()
29 static HID_Attribute base_lpr_options
[] = {
30 {"lprcommand", "Command to print",
31 HID_String
, 0, 0, {0, 0, 0}, 0, 0},
32 #define HA_lprcommand 0
35 #define NUM_OPTIONS (sizeof(lpr_options)/sizeof(lpr_options[0]))
37 static HID_Attribute
*lpr_options
= 0;
38 static int num_lpr_options
= 0;
39 static HID_Attr_Val
*lpr_values
;
41 static HID_Attribute
*
42 lpr_get_export_options (int *n
)
45 * We initialize the default value in this manner because the GUI
46 * HID's may want to free() this string value and replace it with a
47 * new one based on how a user fills out a print dialog.
49 if (base_lpr_options
[HA_lprcommand
].default_val
.str_value
== NULL
)
51 base_lpr_options
[HA_lprcommand
].default_val
.str_value
= strdup("lpr");
56 HID_Attribute
*ps_opts
= ps_hid
.get_export_options (&num_lpr_options
);
58 (HID_Attribute
*) calloc (num_lpr_options
, sizeof (HID_Attribute
));
59 memcpy (lpr_options
, ps_opts
, num_lpr_options
* sizeof (HID_Attribute
));
60 memcpy (lpr_options
, base_lpr_options
, sizeof (base_lpr_options
));
62 (HID_Attr_Val
*) calloc (num_lpr_options
, sizeof (HID_Attr_Val
));
70 lpr_do_export (HID_Attr_Val
* options
)
78 lpr_get_export_options (0);
79 for (i
= 0; i
< num_lpr_options
; i
++)
80 lpr_values
[i
] = lpr_options
[i
].default_val
;
84 filename
= options
[HA_lprcommand
].str_value
;
86 printf ("LPR: open %s\n", filename
);
87 f
= popen (filename
, "w");
95 ps_hid_export_to_file (f
, options
);
100 extern void hid_parse_command_line (int *argc
, char ***argv
);
103 lpr_parse_arguments (int *argc
, char ***argv
)
105 lpr_get_export_options (0);
106 hid_register_attributes (lpr_options
, num_lpr_options
);
107 hid_parse_command_line (argc
, argv
);
111 lpr_calibrate (double xval
, double yval
)
113 ps_calibrate_1 (xval
, yval
, 1);
121 lpr_get_export_options
,
124 0 /* lpr_invalidate_wh */ ,
125 0 /* lpr_invalidate_lr */ ,
126 0 /* lpr_invalidate_all */ ,
127 0 /* lpr_set_layer */ ,
128 0 /* lpr_make_gc */ ,
129 0 /* lpr_destroy_gc */ ,
130 0 /* lpr_use_mask */ ,
131 0 /* lpr_set_color */ ,
132 0 /* lpr_set_line_cap */ ,
133 0 /* lpr_set_line_width */ ,
134 0 /* lpr_set_draw_xor */ ,
135 0 /* lpr_set_draw_faded */ ,
136 0 /* lpr_set_line_cap_angle */ ,
137 0 /* lpr_draw_line */ ,
138 0 /* lpr_draw_arc */ ,
139 0 /* lpr_draw_rect */ ,
140 0 /* lpr_fill_circle */ ,
141 0 /* lpr_fill_polygon */ ,
142 0 /* lpr_fill_rect */ ,
144 0 /* lpr_shift_is_pressed */ ,
145 0 /* lpr_control_is_pressed */ ,
146 0 /* lpr_get_coords */ ,
147 0 /* lpr_set_crosshair */ ,
148 0 /* lpr_add_timer */ ,
149 0 /* lpr_stop_timer */ ,
152 0 /* lpr_confirm_dialog */ ,
153 0 /* lpr_report_dialog */ ,
154 0 /* lpr_prompt_for */ ,
155 0 /* lpr_attribute_dialog */ ,
156 0 /* lpr_show_item */ ,
164 apply_default_hid (&lpr_hid
, &ps_hid
);
165 apply_default_hid (&lpr_hid
, 0);
166 hid_register_hid (&lpr_hid
);