17 #include <cups/cups.h> 78 res = (ppi / 72.0) * 25.4;
85 int bufferlen, searchlen, is_located, i;
88 bufferlen = strlen(buffer);
89 searchlen = strlen(search);
92 for(i = 0; i < (bufferlen - searchlen); i++)
94 if(!strncmp(&buffer[i], search, searchlen))
97 sprintf(&buffer[i],
"%s%s", replace, temp);
98 bufferlen = strlen(buffer);
110 if(!custom_jscript.
param1[0])
113 sprintf(command,
"%s\r\n", custom_jscript.
param1);
114 sprintf(buf,
"%d", page);
126 if(!custom_jscript.
param3[0])
129 sprintf(command,
"%s\r\n", custom_jscript.
param3);
130 sprintf(buf,
"\r\n");
161 strcpy(command,
"S ");
162 strcat(command, s_opt.
ptype);
163 sprintf(part1,
";%.2f,%.2f,", s_opt.
x0, s_opt.
y0);
164 strcat(command, part1);
174 if (dx > printwidth) {
178 if (strncmp(s_opt.
ptype,
"e", 1) == 0) {
185 sprintf(part2,
"%.2f,%.2f,%.1f", ho, dy, (dx - s_opt.
x0));
187 strcat(command, part2);
189 if(custom_jscript.
param4[0])
190 strcat(command, custom_jscript.
param4);
192 strcat(command,
"\r\n");
219 strcpy(command,
"C ");
220 strcat(command, c_opt.
amount);
221 strcat(command,
",");
222 strcat(command, c_opt.
disp1);
225 strcpy(command,
"C e");
226 strcat(command,
",");
227 strcat(command, c_opt.
disp1);
230 strcpy(command,
"C ERROR!!!");
232 strcat(command,
"\r\n");
261 strcpy(command,
"P ");
262 strcat(command, p_opt.
disp);
263 strcat(command,
"\r\n");
287 strcpy(command,
"H ");
288 strcat(command, h_opt.
speed);
289 strcat(command,
",");
290 strcat(command, h_opt.
heat);
291 strcat(command,
",");
292 strcat(command, h_opt.
type);
295 strcat(command,
",R1");
297 strcat(command,
"\r\n");
317 if ((strncmp(d_opt.
dispx,
"0.0", 3) == 0 ||
318 strncmp(d_opt.
dispx,
"-0.0", 4) == 0) &&
319 (strncmp(d_opt.
dispy,
"0.0", 3) == 0 ||
320 strncmp(d_opt.
dispy,
"-0.0", 4) == 0) ) {
323 strcpy(command,
"D ");
324 strcat(command, d_opt.
dispx);
325 strcat(command,
",");
326 strcat(command, d_opt.
dispy);
327 strcat(command,
"\r\n");
403 strcpy (command,
"O ");
408 strcat(command,
",M");
411 strcat(command,
",R");
417 strcat(command,
",E");
421 strcat(command,
",T");
423 if(custom_jscript.
param2[0])
424 strcat(command, custom_jscript.
param2);
426 strcat(command,
"\r\n");
448 strcpy(command,
"C p,");
449 strcat(command, perfo_opt.
disp);
450 strcat(command,
"\r\n");
470 strcpy(command,
"O C");
471 strcat(command, perfo_opt.
depth);
472 strcat(command,
"\r\n");
494 switch (pp_opt.
mode) {
496 strcpy (command,
"C s,");
497 strcat(command, pp_opt.
disp);
498 strcat(command,
"\r\n");
503 strcpy (command,
"C sp,");
504 strcat(command, pp_opt.
disp);
505 strcat(command,
"\r\n");
524 strcpy (command,
"f");
525 strcat(command,
"\r\n");
530 imm_cmd.
pause[0] == value)
532 strcpy (command,
"p1");
533 strcat(command,
"\r\n");
556 strcpy(h_opt.
heat, choice->text);
576 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
577 strcpy(h_opt.
type,
"T");
579 strcpy(h_opt.
type,
"D");
600 strcpy(h_opt.
speed, choice->text);
620 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
645 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
670 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
695 if (choice != NULL && strcmp(choice->choice,
"BFA") == 0) {
698 else if (choice != NULL && strcmp(choice->choice,
"BFS") == 0) {
702 fprintf(stderr,
"ERROR: Backfeed Mode - Unknown choice '%s'. Setting to 'D'\n", choice->choice);
724 if (choice != NULL && strcmp(choice->choice,
"FFS") == 0) {
727 else if (choice != NULL && strcmp(choice->choice,
"FFE") == 0) {
730 else if (choice != NULL && strcmp(choice->choice,
"FFD") == 0) {
734 else if (choice != NULL && strcmp(choice->choice,
"PSS") == 0) {
735 strcpy(imm_cmd.
pause,
"S");
737 else if (choice != NULL && strcmp(choice->choice,
"PSD") == 0) {
738 strcpy(imm_cmd.
pause,
"D");
742 fprintf(stderr,
"ERROR: Immediate command - Unknown choice '%s'\n", choice->choice);
763 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
801 if(!strcmp(choice->choice,
"True"))
822 static void set_PeelOffDisp (ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
826 if (choice_dir != NULL && strcmp(choice_dir->choice,
"PODIRM") == 0) {
827 strcpy(p_opt.
disp,
"-");
828 strcat(p_opt.
disp, num);
831 strcpy(p_opt.
disp, num);
852 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
877 if (strncmp(choice->choice,
"LSD", 3) == 0) {
880 else if (strncmp(choice->choice,
"LSR", 3) == 0) {
883 else if (strncmp(choice->choice,
"LSE", 3) == 0) {
886 fprintf(stderr,
"ERROR: Label Sensor - Option is not available ...\n");
910 strcpy(num, choice_vk->text);
912 strcat(num, choice_nk->text);
913 s_opt.
x0 = atof(num);
934 static void set_DisplacementY(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
936 strcpy(num, choice_dir->text);
937 strcat(num, choice_vk->text);
939 strcat(num, choice_nk->text);
940 s_opt.
y0 = atof(num);
960 static void set_LabelGap(ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
963 s_opt.
gap = atof(num);
984 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
1016 fprintf(stderr,
"ERROR: Cutter Mode - Option is not available ...\n");
1039 strcpy(c_opt.
amount, choice->text);
1060 static void set_CutterOffset1(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
1063 strcpy(c_opt.
disp1, choice_dir->text);
1064 strcat(c_opt.
disp1, num);
1088 if (choice != NULL && (strcmp(choice->choice,
"True") == 0 || strcmp(choice->choice,
"true") == 0)) {
1117 strcpy(perfo_opt.
depth, num);
1138 static void set_PerfoOffset(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
1141 strcpy(perfo_opt.
disp, choice_dir->text);
1142 strcat(perfo_opt.
disp, num);
1198 strcpy(pp_opt.
disp, choice_dir->text);
1199 strcat(pp_opt.
disp, num);
1219 static void set_GlobalObjectOff (ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk) {
1223 if (choice_dir != NULL && strcmp(choice_dir->choice,
"GOOXDIRN") == 0) {
1224 strcpy(d_opt.
dispx,
"-");
1225 strcat(d_opt.
dispx, num);
1227 else if (choice_dir != NULL && strcmp(choice_dir->choice,
"GOOXDIRP") == 0) {
1228 strcpy(d_opt.
dispx, num);
1230 else if (choice_dir != NULL && strcmp(choice_dir->choice,
"GOOYDIRN") == 0) {
1231 strcpy(d_opt.
dispy,
"-");
1232 strcat(d_opt.
dispy, num);
1234 else if (choice_dir != NULL && strcmp(choice_dir->choice,
"GOOYDIRP") == 0) {
1235 strcpy(d_opt.
dispy, num);
1255 ppd_choice_t *choice;
1256 ppd_choice_t *choice_dir;
1257 ppd_choice_t *choice_vk;
1258 ppd_choice_t *choice_nk;
1396 custom_jscript.
param1[0] = 0;
1397 custom_jscript.
param2[0] = 0;
1398 custom_jscript.
param3[0] = 0;
1399 custom_jscript.
param4[0] = 0;
static void set_CutterInterval(ppd_choice_t *choice)
Extracts the cutter interval.
#define CAB_PREPRINT_MODE_CUT_CHOICE
static void set_image_optimization(ppd_choice_t *choice)
#define OPT_CAB_LABEL_ROTATE
#define OPT_CAB_PRN_HEAD_OFF_X_VK
char depth[5]
Additional cutting time factor to influence the perforation.
#define CAB_PREPRINT_MODE_PERFO_CHOICE
#define OPT_CAB_LABEL_SENSOR
static void setCutterMode(ppd_choice_t *choice)
Extracts the cutter mode.
#define CAB_PREPRINT_MODE_OFF_CHOICE
#define OPT_CAB_PRN_HEAD_OFF_X_NK
char disp[5]
Displacement for the first cut.
static int set_Perforation(ppd_choice_t *choice)
Handles the perforation cutter installation option.
char dispy[5]
Displacement y in mm.
Struktur für Einstellungen des Schneidemessers.
#define OPT_CAB_GLBL_OBJ_OFF_Y_DIR
char param1[CUSTOM_JSCRIPT_PARAM_MAX]
int get_p_option_cmd(char *command)
#define OPT_CAB_PRE_PRINT_DIR_OFFSET
int rotate
Rotate the label contents 180 degrees.
int mirrored
Mirrowed label printing.
int get_preprint_opt(char *command)
Assembles the command for the per-print option (C-Command)
char disp1[5]
Displacement for the first cut.
#define CAB_CUTTER_MODE_EXL_CHOICE
int get_o_option_cmd(char *command)
Structure heat level, speed and kind of printing method.
static preprint_options_t pp_opt
Pre-Printing options.
int mode
Cutting mode: Job start/end or amount of labels.
char backfeed[2]
Backfeed Modus: 'D' or 'P'.
int isPrePrintPerforate()
Return, wether the pre-print option is set to 'Perforate'.
char param2[CUSTOM_JSCRIPT_PARAM_MAX]
#define OPT_CAB_PERFO_VK_DEPTH
static void set_LabelRotate(ppd_choice_t *choice)
Extracts, whether the label should be rotated.
#define OPT_CAB_PRN_HEAD_OFF_Y_NK
void get_s_option_cmd(char *command, cups_page_header2_t *header, double printwidth)
#define OPT_CAB_IMAGE_OPTIMIZATION
#define OPT_CAB_PERFO_VK_OFFSET
char speed[4]
Print speed in mm.
static void set_DisplacementX(ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Extracts the label offset for x-direction.
static o_options_t o_opt
Print options.
#define OPT_CAB_IGNORE_PAPEREND
#define OPT_CAB_FORMFEED_MODE
#define CAB_CUTTER_MODE_EOJ_CHOICE
#define FALSE
Boolean define used for FALSE.
char heat[4]
Heating (-10 up to 10)
static c_options_t c_opt
Cutter parameters.
#define OPT_CAB_PRE_PRINT_NK_OFFSET
#define OPT_CAB_PRE_PRINT_VK_OFFSET
static void calcNumberOpt(char *res, char *vk, char *nk)
Puts two strings to a number together.
#define OPT_CAB_CUTTER_MODE
#define OPT_CAB_LABEL_GAP_VK
#define OPT_CAB_RIBBON_SAVER
#define OPT_CAB_BACKFEED_MODE
#define OPT_CAB_GLBL_OBJ_OFF_X_VK
#define OPT_CAB_CUTTER_OFFS_1DIR
static int setPrePrintingMode(ppd_choice_t *choice)
Extracts the pre-printing mode.
#define OPT_CAB_TEAR_OFF_MODE
#define OPT_CAB_LABEL_GAP_NK
#define OPT_CAB_PRN_METHOD
#define CAB_LABEL_SENSOR_REFLEX
char amount[5]
Amount of label after which a cut is processed.
static void set_Heat(ppd_choice_t *choice)
Extracts the heat options.
void get_perfo_depth(char *command)
Assembles the command for the perforation depth (C-Command)
static void set_Speed(ppd_choice_t *choice)
Extracts the printing speed setting.
double gap
Gap between two labels.
int installed
Flag, set to TRUE (1) if a perforation cutter is installed.
static h_options_t h_opt
Printing parameters.
int installed
Peel-Off is switch on ...
#define OPT_CAB_GLBL_OBJ_OFF_X_DIR
int isPerfoCutterInstalled()
Return, wether a perforation cutter is installed.
int get_immediate_cmd(char *command, const char *type, const char value)
static void set_LabelGap(ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles the gap between labels.
#define OPT_CAB_PEEL_OFF_VKV
int get_d_option_cmd(char *command)
int isRibbonSaveSelected()
Return, wether the RibbonSave is active.
#define OPT_CAB_PERFO_NK_OFFSET
#define OPT_CAB_CUTTER_OFFS_1NK
Struktur für das Definieren der Etikettengröße.
static d_options_t d_opt
Global object offset.
char ptype[4]
Labelsensing mode.
#define OPT_CAB_PRN_HEAD_OFF_Y_DIR
static void set_PeelOffDisp(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles and extract the peel-off displacement.
#define CAB_LABEL_SENSOR_ENDLESS
char disp[5]
Displacement in mm.
#define OPT_CAB_PEEL_OFF_DIR
char param3[CUSTOM_JSCRIPT_PARAM_MAX]
#define CAB_LABEL_SENSOR_GAP
#define OPT_CAB_PERFO_DIR_OFFSET
#define CUSTOM_JSCRIPT_PARAM_MAX
int ignore_paperend
Ignore paper end.
static void set_PrePrintingOffset(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles the pre-printing displacement.
static void set_GlobalObjectOff(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles and extract the global offset displacement.
char param4[CUSTOM_JSCRIPT_PARAM_MAX]
static void set_ImmediateCommand(ppd_choice_t *choice)
Handles the immediate commands.
#define OPT_CAB_PERFO_NK_DEPTH
static void set_DisplacementY(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Extracts the label offset for y-direction Format: "dir|vk.nk".
Struktur für Einstellungen des Perforationsschneidemessers.
#define CAB_LABEL_SENSOR_ERROR
char dispx[5]
Displacement x in mm.
int get_option_image_optimization()
static immediate_commands_t imm_cmd
Immediate commands.
static void set_PerfoDepth(ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles the perforation depth factor.
static void set_TearOffMode(ppd_choice_t *choice)
Handles the rotation of a label.
#define OPT_CAB_CUTTER_OFFS_1VK
int get_custom_jscript1_cmd(char *command, int page)
char disp[5]
Displacement for the first action.
void handleMarkedPPDOptions(ppd_file_t *ppd)
static void set_PerfoOffset(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles the perforation displacement.
Structure for printing parameters.
#define OPT_CAB_PEEL_OFF_NKV
int get_custom_jscript3_cmd(char *command)
static void set_BackfeedMode(ppd_choice_t *choice)
Handles the backfeed mode setting.
static void set_PrintMethod(ppd_choice_t *choice)
Handles the setting for the printing method.
#define OPT_CAB_GLBL_OBJ_OFF_Y_VK
Struktur für Einstellungen der Pre-Printing Option.
Structure for the global object offset.
#define OPT_CAB_PRE_PRINT_MODE
#define OPT_CAB_GLBL_OBJ_OFF_Y_NK
#define OPT_CAB_PAUSE_MODE
double y0
Vertical displacement.
int tear_off
Enables the "tear off mode" ...
static custom_jscript_t custom_jscript
static p_options_t p_opt
Peel-Off mode.
#define OPT_CAB_PRN_HEAD_OFF_Y_VK
double x0
Horizontal displacement.
#define OPT_CAB_CUTTER_INTERVAL
static void set_Cutter(ppd_choice_t *choice)
Handles the cutter installation option.
static perfo_options_t perfo_opt
Perforation options.
#define OPT_CAB_GLBL_OBJ_OFF_X_NK
int installed
Flag, set to TRUE (1) if a cutter is installed.
static void set_PeelOffMode(ppd_choice_t *choice)
Checks whether the peel-off sensor is marked as installed.
static double convPPItomm(unsigned int ppi)
Converts the pixels per inch in millimeters.
static void set_CutterOffset1(ppd_choice_t *choice_dir, ppd_choice_t *choice_vk, ppd_choice_t *choice_nk)
Assembles the cutting displacement.
static void set_ribbon_saver(ppd_choice_t *choice)
static void set_replace(ppd_choice_t *choice)
void get_perfo_offset(char *command)
Assembles the command for the perforation offset (C-Command)
Structure for the peel-off modi.
static void set_LabelMirrored(ppd_choice_t *choice)
Handles whether the label should be mirrored.
static s_options_t s_opt
Label size.
#define OPT_CAB_LABEL_MIRRORED
Perforate before printing.
int get_c_option_cmd(char *command)
#define OPT_CAB_PERFORATION_ENABLE
static void set_LabelSensor(ppd_choice_t *choice)
Extract the kind of label sensor mode to be used.
static void set_IgnorePaperend(ppd_choice_t *choice)
Handles the 'ignore paperend' setting.
Cut after a certain amount of x labels.
char type[2]
Method of printing.
static int replace_string_section(char *buffer, const char *search, const char *replace)
void get_h_option_cmd(char *command)