common: Change backend->attach API to allow status returns

master
Solomon Peachy 5 years ago
parent 1e6604d05a
commit 06dbf0fa91
  1. 8
      backend_canonselphy.c
  2. 8
      backend_canonselphyneo.c
  3. 2
      backend_common.c
  4. 2
      backend_common.h
  5. 14
      backend_dnpds40.c
  6. 6
      backend_kodak1400.c
  7. 8
      backend_kodak605.c
  8. 8
      backend_kodak6800.c
  9. 3
      backend_magicard.c
  10. 14
      backend_mitsu70x.c
  11. 5
      backend_mitsu9550.c
  12. 4
      backend_mitsup95d.c
  13. 7
      backend_shinkos1245.c
  14. 7
      backend_shinkos2145.c
  15. 7
      backend_shinkos6145.c
  16. 7
      backend_shinkos6245.c
  17. 6
      backend_sonyupdr150.c

@ -642,8 +642,8 @@ static void *canonselphy_init(void)
extern struct dyesub_backend canonselphy_backend;
static void canonselphy_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int canonselphy_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct canonselphy_ctx *ctx = vctx;
struct libusb_device *device;
@ -672,7 +672,11 @@ static void canonselphy_attach(void *vctx, struct libusb_device_handle *dev,
}
if (!ctx->printer) {
ERROR("Error looking up printer type!\n");
return CUPS_BACKEND_FAILED;
}
/* TODO: Query & Update Marker */
return CUPS_BACKEND_OK;
}
static void canonselphy_teardown(void *vctx) {

@ -189,8 +189,8 @@ static void *selphyneo_init(void)
extern struct dyesub_backend selphyneo_backend;
static void selphyneo_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int selphyneo_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct selphyneo_ctx *ctx = vctx;
struct libusb_device *device;
@ -204,6 +204,10 @@ static void selphyneo_attach(void *vctx, struct libusb_device_handle *dev,
device = libusb_get_device(dev);
libusb_get_device_descriptor(device, &desc);
// TODO: Query & Update Marker
return CUPS_BACKEND_OK;
}
static void selphyneo_teardown(void *vctx) {

@ -29,7 +29,7 @@
#include "backend_common.h"
#define BACKEND_VERSION "0.80"
#define BACKEND_VERSION "0.81"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif

@ -156,7 +156,7 @@ struct dyesub_backend {
const char **uri_prefixes;
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,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid);
void (*teardown)(void *ctx);
int (*cmdline_arg)(void *ctx, int argc, char **argv);

@ -548,8 +548,8 @@ static void *dnpds40_init(void)
((ctx->ver_major > (__major)) || \
(ctx->ver_major == (__major) && ctx->ver_minor >= (__minor)))
static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct dnpds40_ctx *ctx = vctx;
struct libusb_device *device;
@ -629,7 +629,7 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
libusb_get_string_descriptor_ascii(dev, desc->iManufacturer, (unsigned char*)buf, STR_LEN_MAX);
sanitize_string(buf);
if (strncmp(buf, "Dai", 3))
return 0;
return CUPS_BACKEND_FAILED;
}
#endif
#ifdef CITIZEN_ONLY /* Only allow CITIZEN printers to work. */
@ -639,7 +639,7 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
libusb_get_string_descriptor_ascii(dev, desc->iManufacturer, (unsigned char*)buf, STR_LEN_MAX);
sanitize_string(buf);
if (strncmp(buf, "CIT", 3))
return 0;
return CUPS_BACKEND_FAILED;
}
#endif
@ -779,7 +779,7 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
break;
default:
ERROR("Unknown vid/pid %04x/%04x (%d)\n", desc.idVendor, desc.idProduct, ctx->type);
return;
return CUPS_BACKEND_FAILED;
}
ctx->last_matte = -1;
@ -923,6 +923,10 @@ static void dnpds40_attach(void *vctx, struct libusb_device_handle *dev,
break;
}
}
// TODO: fail out on other errors
// TODO: Update Marker
return CUPS_BACKEND_OK;
}
static void dnpds40_teardown(void *vctx) {

@ -294,8 +294,8 @@ static void *kodak1400_init(void)
return ctx;
}
static void kodak1400_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int kodak1400_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct kodak1400_ctx *ctx = vctx;
struct libusb_device *device;
@ -312,6 +312,8 @@ static void kodak1400_attach(void *vctx, struct libusb_device_handle *dev,
ctx->type = lookup_printer_type(&kodak1400_backend,
desc.idVendor, desc.idProduct);
return CUPS_BACKEND_OK;
}
static void kodak1400_teardown(void *vctx) {

@ -234,8 +234,8 @@ static void *kodak605_init(void)
return ctx;
}
static void kodak605_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int kodak605_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct kodak605_ctx *ctx = vctx;
struct libusb_device *device;
@ -262,7 +262,11 @@ static void kodak605_attach(void *vctx, struct libusb_device_handle *dev,
/* Query media info */
if (kodak605_get_media(ctx, ctx->media)) {
ERROR("Can't query media\n");
return CUPS_BACKEND_FAILED;
}
// TODO: Update Marker
return CUPS_BACKEND_OK;
}
static void kodak605_teardown(void *vctx) {

@ -1012,8 +1012,8 @@ static void *kodak6800_init(void)
return ctx;
}
static void kodak6800_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int kodak6800_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct kodak6800_ctx *ctx = vctx;
struct libusb_device *device;
@ -1040,7 +1040,11 @@ static void kodak6800_attach(void *vctx, struct libusb_device_handle *dev,
/* Query media info */
if (kodak6800_get_mediainfo(ctx, ctx->media)) {
ERROR("Can't query media\n");
return CUPS_BACKEND_FAILED;
}
// TODO: Update Marker
return CUPS_BACKEND_OK;
}
static void kodak6800_teardown(void *vctx) {

@ -451,7 +451,7 @@ static void* magicard_init(void)
return ctx;
}
static void magicard_attach(void *vctx, struct libusb_device_handle *dev,
static int magicard_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct magicard_ctx *ctx = vctx;
@ -470,6 +470,7 @@ static void magicard_attach(void *vctx, struct libusb_device_handle *dev,
ctx->type = lookup_printer_type(&magicard_backend,
desc.idVendor, desc.idProduct);
return CUPS_BACKEND_OK;
}
static void magicard_teardown(void *vctx) {

@ -688,8 +688,8 @@ static void *mitsu70x_init(void)
return ctx;
}
static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct mitsu70x_ctx *ctx = vctx;
struct libusb_device *device;
@ -723,13 +723,13 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
ERROR("Problem resolving API Version symbol in imaging processing library, too old or not installed?\n");
DL_CLOSE(ctx->dl_handle);
ctx->dl_handle = NULL;
return;
return CUPS_BACKEND_FAILED;
}
if (ctx->GetAPIVersion() != REQUIRED_LIB_APIVERSION) {
ERROR("Image processing library API version mismatch!\n");
DL_CLOSE(ctx->dl_handle);
ctx->dl_handle = NULL;
return;
return CUPS_BACKEND_FAILED;
}
ctx->Get3DColorTable = DL_SYM(ctx->dl_handle, "CColorConv3D_Get3DColorTable");
@ -750,6 +750,7 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
ERROR("Problem resolving symbols in imaging processing library\n");
DL_CLOSE(ctx->dl_handle);
ctx->dl_handle = NULL;
return CUPS_BACKEND_FAILED;
} else {
DEBUG("Image processing library successfully loaded\n");
}
@ -777,7 +778,7 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
ret = mitsu70x_get_printerstatus(ctx, &resp);
if (ret) {
ERROR("Unable to get printer status! (%d)\n", ret);
return;
return CUPS_BACKEND_FAILED;
}
if (ctx->type == P_MITSU_D70X &&
@ -786,6 +787,9 @@ static void mitsu70x_attach(void *vctx, struct libusb_device_handle *dev,
ctx->num_decks = 2;
else
ctx->num_decks = 1;
// TODO: Update Marker
return CUPS_BACKEND_OK;
}
static void mitsu70x_teardown(void *vctx) {

@ -540,7 +540,7 @@ static void *mitsu9550_init(void)
return ctx;
}
static void mitsu9550_attach(void *vctx, struct libusb_device_handle *dev,
static int mitsu9550_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct mitsu9550_ctx *ctx = vctx;
@ -569,6 +569,9 @@ static void mitsu9550_attach(void *vctx, struct libusb_device_handle *dev,
ctx->is_98xx = 1;
ctx->last_donor = ctx->last_remain = 65535;
// TODO: Query & Update Marker
return CUPS_BACKEND_OK;
}
static void mitsu9550_teardown(void *vctx) {

@ -89,7 +89,7 @@ static void *mitsup95d_init(void)
return ctx;
}
static void mitsup95d_attach(void *vctx, struct libusb_device_handle *dev,
static int mitsup95d_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct mitsup95d_ctx *ctx = vctx;
@ -107,6 +107,8 @@ static void mitsup95d_attach(void *vctx, struct libusb_device_handle *dev,
ctx->type = lookup_printer_type(&mitsup95d_backend,
desc.idVendor, desc.idProduct);
return CUPS_BACKEND_OK;
}
static void mitsup95d_teardown(void *vctx) {

@ -1274,8 +1274,8 @@ static void *shinkos1245_init(void)
return ctx;
}
static void shinkos1245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int shinkos1245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos1245_ctx *ctx = vctx;
struct libusb_device *device;
@ -1295,6 +1295,9 @@ static void shinkos1245_attach(void *vctx, struct libusb_device_handle *dev,
ctx->jobid = jobid & 0x7f;
if (!ctx->jobid)
ctx->jobid++;
/* TODO: Query & Update Marker */
return CUPS_BACKEND_OK;
}

@ -1401,8 +1401,8 @@ static void *shinkos2145_init(void)
return ctx;
}
static void shinkos2145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int shinkos2145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos2145_ctx *ctx = vctx;
@ -1417,6 +1417,9 @@ static void shinkos2145_attach(void *vctx, struct libusb_device_handle *dev,
/* Initialize donor */
ctx->last_donor = ctx->last_remain = ctx->media_prints = 65535;
// TODO: Query & Update Marker
return CUPS_BACKEND_OK;
}
static void shinkos2145_teardown(void *vctx) {

@ -1911,8 +1911,8 @@ static void *shinkos6145_init(void)
return ctx;
}
static void shinkos6145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int shinkos6145_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos6145_ctx *ctx = vctx;
struct libusb_device *device;
@ -1956,6 +1956,9 @@ static void shinkos6145_attach(void *vctx, struct libusb_device_handle *dev,
/* Initialize donor */
ctx->last_donor = ctx->last_remain = 65535;
// TODO: Query & Update Marker
return CUPS_BACKEND_OK;
}
static void shinkos6145_teardown(void *vctx) {

@ -1493,8 +1493,8 @@ static void *shinkos6245_init(void)
return ctx;
}
static void shinkos6245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int shinkos6245_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct shinkos6245_ctx *ctx = vctx;
struct libusb_device *device;
@ -1517,6 +1517,9 @@ static void shinkos6245_attach(void *vctx, struct libusb_device_handle *dev,
/* Initialize donor */
ctx->last_donor = ctx->last_remain = 65535;
// TODO: Query & Update Marker
return CUPS_BACKEND_OK;
}
static void shinkos6245_teardown(void *vctx) {

@ -71,8 +71,8 @@ static void* updr150_init(void)
return ctx;
}
static void updr150_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
static int updr150_attach(void *vctx, struct libusb_device_handle *dev,
uint8_t endp_up, uint8_t endp_down, uint8_t jobid)
{
struct updr150_ctx *ctx = vctx;
struct libusb_device *device;
@ -91,6 +91,8 @@ static void updr150_attach(void *vctx, struct libusb_device_handle *dev,
desc.idVendor, desc.idProduct);
ctx->copies_offset = 0;
return CUPS_BACKEND_OK;
}
static void updr150_teardown(void *vctx) {

Loading…
Cancel
Save