summaryrefslogtreecommitdiff
path: root/src/cups/backend_common.h
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-09-25 08:33:05 +0200
committerDidier Raboud <odyx@debian.org>2018-09-25 08:33:05 +0200
commite50542121e724e851fc5d6c68bb773f80c0bc12c (patch)
tree655c3f6331a6e8fd8b09ceb4da8f5896484ae16a /src/cups/backend_common.h
parent9dd97a029bf391c42b1dc76f2f7c5e386bb8f466 (diff)
New upstream version 5.3.1
Diffstat (limited to 'src/cups/backend_common.h')
-rw-r--r--src/cups/backend_common.h149
1 files changed, 97 insertions, 52 deletions
diff --git a/src/cups/backend_common.h b/src/cups/backend_common.h
index 4e489fc..3fd58db 100644
--- a/src/cups/backend_common.h
+++ b/src/cups/backend_common.h
@@ -1,7 +1,7 @@
/*
* CUPS Backend common code
*
- * (c) 2013-2017 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2013-2018 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
@@ -18,11 +18,12 @@
* for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* [http://www.gnu.org/licenses/gpl-2.0.html]
*
+ * SPDX-License-Identifier: GPL-2.0+
+ *
*/
#include <stdio.h>
@@ -87,46 +88,51 @@
/* To enumerate supported devices */
enum {
- P_ANY = 0,
- P_ES1,
- P_ES2_20,
- P_ES3_30,
- P_ES40,
- P_CP790,
- P_CP_XXX,
- P_CP10,
- P_CP910,
- P_KODAK_6800,
- P_KODAK_6850,
- P_KODAK_1400_805,
- P_KODAK_605,
- P_KODAK_305,
- P_SHINKO_S2145,
- P_SHINKO_S1245,
- P_SHINKO_S6245,
- P_SHINKO_S6145,
- P_SHINKO_S6145D,
- P_SONY_UPDR150,
- P_SONY_UPCR10,
- P_MITSU_D70X,
- P_MITSU_D80,
- P_MITSU_K60,
- P_MITSU_9550,
- P_MITSU_9550S,
- P_MITSU_9600,
- P_MITSU_9800,
- P_MITSU_9800S,
- P_MITSU_9810,
- P_MITSU_P93D,
- P_MITSU_P95D,
- P_DNP_DS40,
- P_DNP_DS80,
- P_DNP_DS80D,
- P_CITIZEN_CW01,
- P_DNP_DSRX1,
- P_DNP_DS620,
- P_DNP_DS820,
- P_FUJI_ASK300,
+ P_UNKNOWN = 0,
+ P_CP_XXX = 1,
+ P_CP10 = 2,
+ P_CP790 = 3,
+ P_CP900 = 4,
+ P_CP910 = 5,
+ P_ES1 = 6,
+ P_ES2_20 = 7,
+ P_ES3_30 = 8,
+ P_ES40 = 9,
+ P_KODAK_1400_805 = 10,
+ P_KODAK_6800 = 11,
+ P_KODAK_6850 = 12,
+ P_KODAK_305 = 13,
+ P_KODAK_605 = 14,
+ P_SHINKO_S1245 = 15,
+ P_SHINKO_S2145 = 16,
+ P_SHINKO_S6145 = 17,
+ P_SHINKO_S6145D = 18,
+ P_SHINKO_S6245 = 19,
+ P_SONY_UPCR10 = 20,
+ P_SONY_UPDR150 = 21,
+ P_MITSU_9550 = 22,
+ P_MITSU_9550S = 23,
+ P_MITSU_9600 = 24,
+ P_MITSU_9800 = 25,
+ P_MITSU_9800S = 26,
+ P_MITSU_9810 = 27,
+ P_MITSU_D70X = 28,
+ P_MITSU_D80 = 29,
+ P_MITSU_D90 = 30,
+ P_MITSU_K60 = 31,
+ P_MITSU_P93D = 32,
+ P_MITSU_P95D = 33,
+ P_CITIZEN_CW01 = 34,
+ P_CITIZEN_OP900II = 35,
+ P_DNP_DS40 = 36,
+ P_DNP_DS620 = 37,
+ P_DNP_DS80 = 38,
+ P_DNP_DS80D = 39,
+ P_DNP_DS820 = 40,
+ P_DNP_DSRX1 = 41,
+ P_FUJI_ASK300 = 42,
+ P_MAGICARD = 43,
+ P_SONY_UPD89x = 44,
P_END,
};
@@ -135,31 +141,56 @@ struct device_id {
uint16_t pid;
int type; /* P_** */
char *manuf_str;
+ char *prefix;
+};
+
+struct marker {
+ const char *color; /* Eg "#00FFFF" */
+ const char *name; /* Eg "CK9015 (4x6)" */
+ int levelmax; /* Max media count, eg '600', or '-1' */
+ int levelnow; /* Remaining media, -3, -2, -1, 0..N. See CUPS. */
};
+#define BACKEND_FLAG_JOBLIST 0x00000001
+
/* Backend Functions */
struct dyesub_backend {
- char *name;
- char *version;
- char *uri_prefix;
+ const char *name;
+ const char *version;
+ const char **uri_prefixes;
+ uint32_t flags;
void (*cmdline_usage)(void); /* Optional */
void *(*init)(void);
- void (*attach)(void *ctx, struct libusb_device_handle *dev,
+ int (*attach)(void *ctx, struct libusb_device_handle *dev, int type,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid);
void (*teardown)(void *ctx);
int (*cmdline_arg)(void *ctx, int argc, char **argv);
- int (*read_parse)(void *ctx, int data_fd);
- int (*main_loop)(void *ctx, int copies);
+ int (*read_parse)(void *ctx, const void **job, int data_fd, int copies);
+ void (*cleanup_job)(const void *job);
+ int (*main_loop)(void *ctx, const void *job);
int (*query_serno)(struct libusb_device_handle *dev, uint8_t endp_up, uint8_t endp_down, char *buf, int buf_len); /* Optional */
- struct device_id devices[];
+ int (*query_markers)(void *ctx, struct marker **markers, int *count);
+ const struct device_id devices[];
+};
+
+#define DYESUB_MAX_JOB_ENTRIES 2
+
+struct dyesub_joblist {
+ // TODO: mutex/lock
+ struct dyesub_backend *backend;
+ void *ctx;
+ int num_entries;
+ int copies;
+ const void *entries[DYESUB_MAX_JOB_ENTRIES];
};
/* Exported functions */
int send_data(struct libusb_device_handle *dev, uint8_t endp,
- uint8_t *buf, int len);
+ const uint8_t *buf, int len);
int read_data(struct libusb_device_handle *dev, uint8_t endp,
uint8_t *buf, int buflen, int *readlen);
-int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint16_t idProduct);
+
+void dump_markers(struct marker *markers, int marker_count, int full);
void print_license_blurb(void);
void print_help(char *argv0, struct dyesub_backend *backend);
@@ -167,6 +198,12 @@ void print_help(char *argv0, struct dyesub_backend *backend);
uint16_t uint16_to_packed_bcd(uint16_t val);
uint32_t packed_bcd_to_uint32(char *in, int len);
+/* Job list manipulation */
+struct dyesub_joblist *dyesub_joblist_create(struct dyesub_backend *backend, void *ctx);
+int dyesub_joblist_addjob(struct dyesub_joblist *list, const void *job);
+void dyesub_joblist_cleanup(const struct dyesub_joblist *list);
+int dyesub_joblist_print(const struct dyesub_joblist *list);
+
/* Global data */
extern int terminate;
extern int dyesub_debug;
@@ -175,6 +212,14 @@ extern int extra_vid;
extern int extra_pid;
extern int extra_type;
extern int copies;
+extern int test_mode;
+
+enum {
+ TEST_MODE_NONE = 0,
+ TEST_MODE_NOPRINT,
+ TEST_MODE_NOATTACH,
+ TEST_MODE_MAX,
+};
#if defined(BACKEND)
extern struct dyesub_backend BACKEND;