kopia lustrzana https://gitlab.com/sane-project/backends
Moved device init code to sane_get_devices()
Moved device init code from sane_init() to the newly created sane_reload_devices() function, which is now called from sane_get_devices(). This means that device initialization now happens when sane_get_devices() is called, not when sane_init() is called.merge-requests/1/head
rodzic
046441ad6c
commit
37b45c4f76
|
@ -7359,14 +7359,6 @@ attach_one_usb (const char* dev)
|
||||||
SANE_Status
|
SANE_Status
|
||||||
sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
{
|
{
|
||||||
FILE* fp;
|
|
||||||
|
|
||||||
char line[PATH_MAX];
|
|
||||||
const char* cp = 0;
|
|
||||||
char* word;
|
|
||||||
int linenumber = 0;
|
|
||||||
int model_num = 0;
|
|
||||||
|
|
||||||
authorize = authorize; /* silence gcc */
|
authorize = authorize; /* silence gcc */
|
||||||
|
|
||||||
DBG_INIT();
|
DBG_INIT();
|
||||||
|
@ -7379,16 +7371,30 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
SANE_CURRENT_MAJOR, V_MINOR, BACKEND_BUILD);
|
SANE_CURRENT_MAJOR, V_MINOR, BACKEND_BUILD);
|
||||||
|
|
||||||
/* must come first */
|
/* must come first */
|
||||||
sanei_usb_init ();
|
|
||||||
sanei_thread_init ();
|
sanei_thread_init ();
|
||||||
|
|
||||||
if (version_code)
|
if (version_code)
|
||||||
*version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BACKEND_BUILD);
|
*version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BACKEND_BUILD);
|
||||||
|
|
||||||
|
return SANE_STATUS_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SANE_Status
|
||||||
|
sane_reload_devices (void)
|
||||||
|
{
|
||||||
|
FILE* fp;
|
||||||
|
|
||||||
|
char line[PATH_MAX];
|
||||||
|
const char* cp = 0;
|
||||||
|
char* word;
|
||||||
|
int linenumber = 0;
|
||||||
|
int model_num = 0;
|
||||||
|
|
||||||
|
sanei_usb_init ();
|
||||||
fp = sanei_config_open (AVISION_CONFIG_FILE);
|
fp = sanei_config_open (AVISION_CONFIG_FILE);
|
||||||
if (fp <= (FILE*)0)
|
if (fp <= (FILE*)0)
|
||||||
{
|
{
|
||||||
DBG (1, "sane_init: No config file present!\n");
|
DBG (1, "sane_reload_devices: No config file present!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7400,13 +7406,13 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
word = NULL;
|
word = NULL;
|
||||||
++ linenumber;
|
++ linenumber;
|
||||||
|
|
||||||
DBG (5, "sane_init: parsing config line \"%s\"\n",
|
DBG (5, "sane_reload_devices: parsing config line \"%s\"\n",
|
||||||
line);
|
line);
|
||||||
|
|
||||||
cp = sanei_config_get_string (line, &word);
|
cp = sanei_config_get_string (line, &word);
|
||||||
|
|
||||||
if (!word || cp == line) {
|
if (!word || cp == line) {
|
||||||
DBG (5, "sane_init: config file line %d: ignoring empty line\n",
|
DBG (5, "sane_reload_devices: config file line %d: ignoring empty line\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
if (word) {
|
if (word) {
|
||||||
free (word);
|
free (word);
|
||||||
|
@ -7416,13 +7422,13 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!word) {
|
if (!word) {
|
||||||
DBG (1, "sane_init: config file line %d: could not be parsed\n",
|
DBG (1, "sane_reload_devices: config file line %d: could not be parsed\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (word[0] == '#') {
|
if (word[0] == '#') {
|
||||||
DBG (5, "sane_init: config file line %d: ignoring comment line\n",
|
DBG (5, "sane_reload_devices: config file line %d: ignoring comment line\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
free (word);
|
free (word);
|
||||||
word = NULL;
|
word = NULL;
|
||||||
|
@ -7436,57 +7442,57 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
cp = sanei_config_get_string (cp, &word);
|
cp = sanei_config_get_string (cp, &word);
|
||||||
|
|
||||||
if (strcmp (word, "disable-gamma-table") == 0) {
|
if (strcmp (word, "disable-gamma-table") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: disable-gamma-table\n",
|
DBG (3, "sane_reload_devices: config file line %d: disable-gamma-table\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
disable_gamma_table = SANE_TRUE;
|
disable_gamma_table = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "disable-calibration") == 0) {
|
else if (strcmp (word, "disable-calibration") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: disable-calibration\n",
|
DBG (3, "sane_reload_devices: config file line %d: disable-calibration\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
disable_calibration = SANE_TRUE;
|
disable_calibration = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "force-calibration") == 0) {
|
else if (strcmp (word, "force-calibration") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: force-calibration\n",
|
DBG (3, "sane_reload_devices: config file line %d: force-calibration\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
force_calibration = SANE_TRUE;
|
force_calibration = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "force-a4") == 0) {
|
else if (strcmp (word, "force-a4") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: enabling force-a4\n",
|
DBG (3, "sane_reload_devices: config file line %d: enabling force-a4\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
force_a4 = SANE_TRUE;
|
force_a4 = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "force-a3") == 0) {
|
else if (strcmp (word, "force-a3") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: enabling force-a3\n",
|
DBG (3, "sane_reload_devices: config file line %d: enabling force-a3\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
force_a3 = SANE_TRUE;
|
force_a3 = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "static-red-calib") == 0) {
|
else if (strcmp (word, "static-red-calib") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: static red calibration\n",
|
DBG (3, "sane_reload_devices: config file line %d: static red calibration\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
static_calib_list [0] = SANE_TRUE;
|
static_calib_list [0] = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "static-green-calib") == 0) {
|
else if (strcmp (word, "static-green-calib") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: static green calibration\n",
|
DBG (3, "sane_reload_devices: config file line %d: static green calibration\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
static_calib_list [1] = SANE_TRUE;
|
static_calib_list [1] = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "static-blue-calib") == 0) {
|
else if (strcmp (word, "static-blue-calib") == 0) {
|
||||||
DBG (3, "sane_init: config file line %d: static blue calibration\n",
|
DBG (3, "sane_reload_devices: config file line %d: static blue calibration\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
static_calib_list [2] = SANE_TRUE;
|
static_calib_list [2] = SANE_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DBG (1, "sane_init: config file line %d: options unknown!\n",
|
DBG (1, "sane_reload_devices: config file line %d: options unknown!\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "usb") == 0) {
|
else if (strcmp (word, "usb") == 0) {
|
||||||
DBG (2, "sane_init: config file line %d: trying to attach USB:`%s'\n",
|
DBG (2, "sane_reload_devices: config file line %d: trying to attach USB:`%s'\n",
|
||||||
linenumber, line);
|
linenumber, line);
|
||||||
/* try to attach USB device */
|
/* try to attach USB device */
|
||||||
sanei_usb_attach_matching_devices (line, attach_one_usb);
|
sanei_usb_attach_matching_devices (line, attach_one_usb);
|
||||||
}
|
}
|
||||||
else if (strcmp (word, "scsi") == 0) {
|
else if (strcmp (word, "scsi") == 0) {
|
||||||
DBG (2, "sane_init: config file line %d: trying to attach SCSI: %s'\n",
|
DBG (2, "sane_reload_devices: config file line %d: trying to attach SCSI: %s'\n",
|
||||||
linenumber, line);
|
linenumber, line);
|
||||||
|
|
||||||
/* the last time I verified (2003-03-18) this function
|
/* the last time I verified (2003-03-18) this function
|
||||||
|
@ -7494,9 +7500,9 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
sanei_config_attach_matching_devices (line, attach_one_scsi);
|
sanei_config_attach_matching_devices (line, attach_one_scsi);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG (1, "sane_init: config file line %d: OBSOLETE !! use the scsi keyword!\n",
|
DBG (1, "sane_reload_devices: config file line %d: OBSOLETE !! use the scsi keyword!\n",
|
||||||
linenumber);
|
linenumber);
|
||||||
DBG (1, "sane_init: (see man sane-avision for details): trying to attach SCSI: %s'\n",
|
DBG (1, "sane_reload_devices: (see man sane-avision for details): trying to attach SCSI: %s'\n",
|
||||||
line);
|
line);
|
||||||
|
|
||||||
/* the last time I verified (2003-03-18) this function
|
/* the last time I verified (2003-03-18) this function
|
||||||
|
@ -7527,7 +7533,7 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
|
|
||||||
if (attaching_hw->usb_vendor != 0 && attaching_hw->usb_product != 0 )
|
if (attaching_hw->usb_vendor != 0 && attaching_hw->usb_product != 0 )
|
||||||
{
|
{
|
||||||
DBG (1, "sane_init: Trying to find USB device %.4x %.4x ...\n",
|
DBG (1, "sane_reload_devices: Trying to find USB device %.4x %.4x ...\n",
|
||||||
attaching_hw->usb_vendor,
|
attaching_hw->usb_vendor,
|
||||||
attaching_hw->usb_product);
|
attaching_hw->usb_product);
|
||||||
|
|
||||||
|
@ -7535,7 +7541,7 @@ sane_init (SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||||||
if (sanei_usb_find_devices (attaching_hw->usb_vendor,
|
if (sanei_usb_find_devices (attaching_hw->usb_vendor,
|
||||||
attaching_hw->usb_product,
|
attaching_hw->usb_product,
|
||||||
attach_one_usb) != SANE_STATUS_GOOD) {
|
attach_one_usb) != SANE_STATUS_GOOD) {
|
||||||
DBG (1, "sane_init: error during USB device detection!\n");
|
DBG (1, "sane_reload_devices: error during USB device detection!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++ model_num;
|
++ model_num;
|
||||||
|
@ -7576,6 +7582,8 @@ sane_get_devices (const SANE_Device*** device_list, SANE_Bool local_only)
|
||||||
|
|
||||||
DBG (3, "sane_get_devices:\n");
|
DBG (3, "sane_get_devices:\n");
|
||||||
|
|
||||||
|
sane_reload_devices ();
|
||||||
|
|
||||||
if (devlist)
|
if (devlist)
|
||||||
free (devlist);
|
free (devlist);
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue