-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathepl_bid_utils.c
147 lines (135 loc) · 3.65 KB
/
epl_bid_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
Copyright (c) 2003 Hin-Tak Leung
*/
/**
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**/
#include <stdlib.h>
#include <string.h>
#include "epl_job.h"
#include "epl_bid.h"
void epl_bid_init(EPL_job_info *epl_job_info)
{
switch (epl_job_info->connectivity)
{
case VIA_NOWHERE:
epl_null_init(epl_job_info);
break;
#ifdef HAVE_LIBUSB
case VIA_LIBUSB:
epl_libusb_init(epl_job_info);
break;
#endif
#ifdef HAVE_KERNEL_USB_DEVICE
case VIA_KERNEL_USB:
epl_kernel_init(epl_job_info);
break;
#endif
#ifdef HAVE_KERNEL_1284
case VIA_KERNEL_1284:
/* we may check the id string if we work out how... */
break;
#endif
#ifdef HAVE_LIBIEEE1284
case VIA_LIBIEEE1284:
epl_libieee1284_init(epl_job_info);
break;
#endif
default:
fprintf(stderr,"Unknown transport method: %d\n", epl_job_info->connectivity);
exit(1);
break;
}
}
void epl_bid_prejob(EPL_job_info *epl_job_info)
{
if(epl_job_info->model == MODEL_5700L)
{
/* this 2-byte code is for 5700L only, careful!! */
char byte[] = {0x00, 0x00};
byte[0] = 0x06;
epl_write_bid(epl_job_info, byte, 2);
byte[0] = 0x05;
epl_write_bid(epl_job_info, byte, 2);
}
}
void epl_bid_mid(EPL_job_info *epl_job_info)
{
if(epl_job_info->model == MODEL_5700L)
{
/* this 2-byte code is for 5700L only, careful!! */
char byte[] = {0x07, 0x00};
epl_write_bid(epl_job_info, byte, 2);
}
}
void epl_bid_end(EPL_job_info *epl_job_info)
{
switch (epl_job_info->connectivity)
{
#ifdef HAVE_LIBUSB
case VIA_LIBUSB:
epl_libusb_end(epl_job_info);
break;
#endif
#ifdef HAVE_LIBIEEE1284
case VIA_LIBIEEE1284:
epl_libieee1284_end(epl_job_info);
break;
#endif
default:
/* kernel devices don't need closing? */
break;
}
}
int epl_identify(char *string)
{
#ifdef EPL_DEBUG
fprintf(stderr, "called identification for \"%s\"\n",string);
#endif
if(strstr(string, "EPL-5700L"))
{
fprintf(stderr, "Confirmed EPL-5700L\n");
return MODEL_5700L;
}
else if(strstr(string, "EPL-5800L"))
{
fprintf(stderr, "Confirmed EPL-5800L\n");
return MODEL_5800L;
}
else if(strstr(string, "EPL-5900L"))
{
fprintf(stderr, "Confirmed EPL-5900L\n");
return MODEL_5900L;
}
else if(strstr(string, "EPL-6100L"))
{
fprintf(stderr, "Confirmed EPL-6100L\n");
return MODEL_6100L;
}
else if(strstr(string, "EPL-6200L"))
{
fprintf(stderr, "Confirmed EPL-6200L\n");
return MODEL_6200L;
}
fprintf(stderr, "so, what printer is this?\n");
return MODEL_UNKNOWN;
}