diff options
Diffstat (limited to 'include/sane/sanei_usb.h')
-rw-r--r-- | include/sane/sanei_usb.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/sane/sanei_usb.h b/include/sane/sanei_usb.h index c8fff97..1c1699d 100644 --- a/include/sane/sanei_usb.h +++ b/include/sane/sanei_usb.h @@ -68,6 +68,10 @@ #include <stdlib.h> /* for size_t */ +#ifdef __cplusplus +extern "C" { +#endif + /* USB spec defines */ #ifndef USB_CLASS_PER_INTERFACE /* Also defined in libusb */ @@ -176,6 +180,57 @@ struct sanei_usb_dev_descriptor SANE_Byte max_packet_size; }; +/** Initialize sanei_usb for replay testing. + + Initializes sanei_usb for testing by mocking whole USB stack. This function + must be called before sanei_usb_init(). + + The sanei_usb subsystem also implements a "development mode". It modifies + the XML data file with the actual commands of the test run and attemps to + proceed testing until a mismatching input command is found for which + input data is required. + + A <known_commands_end/> node in the data XML file will cause sanei_usb not + to continue to the subsequent command in the XML file and instead it will + prepend all output commands before that node before an output command is + encountered. + + @param path Path to the XML data file. + @param development_mode Enables development mode. + */ +extern SANE_Status sanei_usb_testing_enable_replay(SANE_String_Const path, + int development_mode); + +/** Initialize sanei_usb for recording. + * + * Initializes sanei_usb for recording communication with the scanner. This + * function must be called before sanei_usb_init(). + * + * @param path Path to the XML data file. + * @param be_name The name of the backend to enable recording for. + */ +extern SANE_Status sanei_usb_testing_enable_record(SANE_String_Const path, + SANE_String_Const be_name); + +/** Returns backend name for testing. + * + * Returns backend name for the file registered in sanei_usb_testing_enable. + * The caller is responsible for freeing it. + */ +extern SANE_String sanei_usb_testing_get_backend(); + +/** Returns SANE_TRUE if replay testing mode is enabled, i.e. whether we are working with fake + * scan data. + */ +extern SANE_Bool sanei_usb_is_replay_mode_enabled(); + +/** Records a debug message in the captured USB data if testing mode is enabled. If testing mode + * is not enabled, this function does nothing. + * + * @param msg Message to record + */ +extern void sanei_usb_testing_record_message(SANE_String_Const message); + /** Initialize sanei_usb. * * Call this before any other sanei_usb function. @@ -521,5 +576,9 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate); extern SANE_Status sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ); +#ifdef __cplusplus +} // extern "C" +#endif + /*------------------------------------------------------*/ #endif /* sanei_usb_h */ |