kopia lustrzana https://gitlab.com/sane-project/backends
sanei_usb: Add support for replay testing
rodzic
a88b6241cd
commit
0122c060b7
|
@ -139,6 +139,8 @@ posix_dlsym (void *handle, const char *func)
|
||||||
#define DLL_CONFIG_FILE "dll.conf"
|
#define DLL_CONFIG_FILE "dll.conf"
|
||||||
#define DLL_ALIASES_FILE "dll.aliases"
|
#define DLL_ALIASES_FILE "dll.aliases"
|
||||||
|
|
||||||
|
#include "../include/sane/sanei_usb.h"
|
||||||
|
|
||||||
enum SANE_Ops
|
enum SANE_Ops
|
||||||
{
|
{
|
||||||
OP_INIT = 0,
|
OP_INIT = 0,
|
||||||
|
@ -1177,7 +1179,18 @@ sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_name = strchr (full_name, ':');
|
dev_name = strchr (full_name, ':');
|
||||||
if (dev_name)
|
if (dev_name && strncmp(full_name, "fakeusb", dev_name - full_name) == 0)
|
||||||
|
{
|
||||||
|
++dev_name; // skip colon
|
||||||
|
status = sanei_usb_testing_enable_replay(dev_name);
|
||||||
|
if (status != SANE_STATUS_GOOD)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
be_name = sanei_usb_testing_get_backend();
|
||||||
|
if (be_name == NULL)
|
||||||
|
return SANE_STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
else if (dev_name)
|
||||||
{
|
{
|
||||||
be_name = strndup(full_name, dev_name - full_name);
|
be_name = strndup(full_name, dev_name - full_name);
|
||||||
++dev_name; /* skip colon */
|
++dev_name; /* skip colon */
|
||||||
|
|
|
@ -180,6 +180,27 @@ struct sanei_usb_dev_descriptor
|
||||||
SANE_Byte max_packet_size;
|
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().
|
||||||
|
*/
|
||||||
|
extern SANE_Status sanei_usb_testing_enable_replay(SANE_String_Const path);
|
||||||
|
|
||||||
|
/** Initialize sanei_usb for recording.
|
||||||
|
*
|
||||||
|
* Initializes sanei_usb for recording communication with the scanner. This
|
||||||
|
* function must be called before sanei_usb_init().
|
||||||
|
*/
|
||||||
|
extern SANE_Status sanei_usb_testing_enable_record(SANE_String_Const path);
|
||||||
|
|
||||||
|
/** 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();
|
||||||
|
|
||||||
/** Initialize sanei_usb.
|
/** Initialize sanei_usb.
|
||||||
*
|
*
|
||||||
* Call this before any other sanei_usb function.
|
* Call this before any other sanei_usb function.
|
||||||
|
|
1086
sanei/sanei_usb.c
1086
sanei/sanei_usb.c
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue