/* * libptouch — internal declarations (not installed) * * Author: knb * Email: knb@artif.org */ #ifndef LIBPTOUCH_INTERNAL_H #define LIBPTOUCH_INTERNAL_H #include "libptouch.h" #include #include struct libptouch_ctx { libptouch_err_t last_code; char last_msg[256]; int usb_open; struct libusb_context *usb_ctx; struct libusb_device_handle *usb_handle; int claimed_interface; /* -1 if none */ uint8_t bulk_out_ep; uint8_t bulk_in_ep; uint16_t usb_pid; /* 0 if USB not open; used to pick 128- vs 560-dot raster */ }; /* ctx に最終エラー(コードとメッセージ)を記録する。公開 API のエラー返却前に使う。 */ void ptouch_set_error(libptouch_ctx *ctx, libptouch_err_t code, const char *msg); /* libusb のエラー番号を人が読めるメッセージにして ptouch_set_error に渡す。 */ void ptouch_set_error_usb(libptouch_ctx *ctx, int libusb_err, const char *what); /* bulk OUT 転送。成功時 0、失敗時 libusb の負のエラーコード。 */ int ptouch_bulk_out(libusb_device_handle *h, uint8_t ep, const uint8_t *data, int len, unsigned int timeout_ms); /* bulk IN で len バイトを揃えるまで読む。成功時 0、失敗時 libusb の負のエラーコード。 */ int ptouch_bulk_in_exact(libusb_device_handle *h, uint8_t ep, uint8_t *buf, int len, unsigned int timeout_ms); /* ctx の bulk OUT エンドポイントへ buf を送る。印刷ジョブのチャンク送信用。 */ libptouch_err_t ptouch_bulk_send_job(libptouch_ctx *ctx, const uint8_t *buf, size_t len, const char *what); #endif /* LIBPTOUCH_INTERNAL_H */