Call explicitly cancel.

merge-requests/213/head^2
thierry1970 2020-01-09 16:58:12 +01:00 zatwierdzone przez Thierry HUCHARD
rodzic 2c12635b23
commit 1b3f0c9bc0
1 zmienionych plików z 712 dodań i 711 usunięć

Wyświetl plik

@ -124,9 +124,9 @@ escl_add_in_list(ESCL_Device *current)
}
current = escl_free_device(current);
return (SANE_STATUS_NO_MEM);
}
}
/**
/**
* \fn SANE_Status escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type)
* \brief Function that browses my list ('for' loop) and returns the "escl_add_in_list" function to
* adds all the element needed to my list :
@ -134,9 +134,9 @@ escl_add_in_list(ESCL_Device *current)
*
* \return escl_add_in_list(current)
*/
SANE_Status
escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type)
{
SANE_Status
escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type)
{
char tmp[PATH_MAX] = { 0 };
char *model = NULL;
ESCL_Device *current = NULL;
@ -161,18 +161,18 @@ escl_device_add(int port_nb, const char *model_name, char *ip_address, char *typ
current->ip_address = strdup(ip_address);
current->type = strdup(type);
return escl_add_in_list(current);
}
}
/**
/**
* \fn static inline size_t max_string_size(const SANE_String_Const strings[])
* \brief Function that browses the string ('for' loop) and counts the number of character in the string.
* --> this allows to know the maximum size of the string.
*
* \return max_size + 1 (the size max)
*/
static inline size_t
max_string_size(const SANE_String_Const strings[])
{
static inline size_t
max_string_size(const SANE_String_Const strings[])
{
size_t max_size = 0;
int i = 0;
@ -182,9 +182,9 @@ max_string_size(const SANE_String_Const strings[])
max_size = size;
}
return (max_size + 1);
}
}
/**
/**
* \fn static SANE_Device *convertFromESCLDev(ESCL_Device *cdev)
* \brief Function that checks if the url of the received scanner is secured or not (http / https).
* --> if the url is not secured, our own url will be composed like "http://'ip':'port'".
@ -195,9 +195,9 @@ max_string_size(const SANE_String_Const strings[])
*
* \return sdev (structure that contains the elements of the url)
*/
static SANE_Device *
convertFromESCLDev(ESCL_Device *cdev)
{
static SANE_Device *
convertFromESCLDev(ESCL_Device *cdev)
{
char tmp[PATH_MAX] = { 0 };
SANE_Device *sdev = (SANE_Device*) calloc(1, sizeof(SANE_Device));
if (!sdev) {
@ -231,18 +231,18 @@ convertFromESCLDev(ESCL_Device *cdev)
goto freevendor;
}
return (sdev);
freevendor:
freevendor:
free((void*)sdev->vendor);
freemodel:
freemodel:
free((void*)sdev->model);
freename:
freename:
free((void*)sdev->name);
freedev:
freedev:
free((void*)sdev);
return NULL;
}
}
/**
/**
* \fn SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize)
* \brief Function that's called before any other SANE function ; it's the first SANE function called.
* --> this function checks the SANE config. and can check the authentication of the user if
@ -251,9 +251,9 @@ freedev:
*
* \return SANE_STATUS_GOOD (everything is OK)
*/
SANE_Status
sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize)
{
SANE_Status
sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize)
{
DBG_INIT();
DBG (10, "escl sane_init\n");
SANE_Status status = SANE_STATUS_GOOD;
@ -263,18 +263,18 @@ sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize)
if (status != SANE_STATUS_GOOD)
return (status);
return (SANE_STATUS_GOOD);
}
}
/**
/**
* \fn void sane_exit(void)
* \brief Function that must be called to terminate use of a backend.
* This function will first close all device handles that still might be open.
* --> by freeing all the elements of my list.
* After this function, no function other than 'sane_init' may be called.
*/
void
sane_exit(void)
{
void
sane_exit(void)
{
DBG (10, "escl sane_exit\n");
ESCL_Device *next = NULL;
@ -288,9 +288,9 @@ sane_exit(void)
list_devices_primary = NULL;
devlist = NULL;
curl_global_cleanup();
}
}
/**
/**
* \fn static SANE_Status attach_one_config(SANEI_Config *config, const char *line)
* \brief Function that implements a configuration file to the user :
* if the user can't detect some devices, he will be able to force their detection with this config' file to use them.
@ -299,9 +299,9 @@ sane_exit(void)
*
* \return escl_add_in_list(escl_device) if the parsing worked, SANE_STATUS_GOOD otherwise.
*/
static SANE_Status
attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
{
static SANE_Status
attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
{
int port = 0;
SANE_Status status;
static ESCL_Device *escl_device = NULL;
@ -349,18 +349,18 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
if (status == SANE_STATUS_GOOD)
escl_device = NULL;
return status;
}
}
/**
/**
* \fn SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
* \brief Function that searches for connected devices and places them in our 'device_list'. ('for' loop)
* If the attribute 'local_only' is worth SANE_FALSE, we only returns the connected devices locally.
*
* \return SANE_STATUS_GOOD if devlist != NULL ; SANE_STATUS_NO_MEM otherwise.
*/
SANE_Status
sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
{
SANE_Status
sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
{
if (local_only) /* eSCL is a network-only protocol */
return (device_list ? SANE_STATUS_GOOD : SANE_STATUS_INVAL);
@ -391,9 +391,9 @@ sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
devlist[i] = 0;
*device_list = devlist;
return (devlist) ? SANE_STATUS_GOOD : SANE_STATUS_NO_MEM;
}
}
/**
/**
* \fn static SANE_Status init_options(SANE_String_Const name, escl_sane_t *s)
* \brief Function thzt initializes all the needed options of the received scanner
* (the resolution / the color / the margins) thanks to the informations received with
@ -401,9 +401,9 @@ sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only)
*
* \return status (if everything is OK, status = SANE_STATUS_GOOD)
*/
static SANE_Status
init_options(SANE_String_Const name, escl_sane_t *s)
{
static SANE_Status
init_options(SANE_String_Const name, escl_sane_t *s)
{
DBG (10, "escl init_options\n");
SANE_Status status = SANE_STATUS_GOOD;
int i = 0;
@ -547,9 +547,9 @@ init_options(SANE_String_Const name, escl_sane_t *s)
else
s->val[OPT_SCAN_SOURCE].s = strdup (s->scanner->Sources[0]);
return (status);
}
}
/**
/**
* \fn SANE_Status sane_open(SANE_String_Const name, SANE_Handle *h)
* \brief Function that establishes a connection with the device named by 'name',
* and returns a 'handler' using 'SANE_Handle *h', representing it.
@ -558,9 +558,9 @@ init_options(SANE_String_Const name, escl_sane_t *s)
*
* \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL)
*/
SANE_Status
sane_open(SANE_String_Const name, SANE_Handle *h)
{
SANE_Status
sane_open(SANE_String_Const name, SANE_Handle *h)
{
DBG (10, "escl sane_open\n");
SANE_Status status;
escl_sane_t *handler = NULL;
@ -599,17 +599,17 @@ sane_open(SANE_String_Const name, SANE_Handle *h)
handler->end_read = SANE_FALSE;
*h = handler;
return (status);
}
}
/**
/**
* \fn void sane_cancel(SANE_Handle h)
* \brief Function that's used to, immediately or as quickly as possible, cancel the currently
* pending operation of the device represented by 'SANE_Handle h'.
* This functions calls the 'escl_scanner' functions, that resets the scan operations.
*/
void
sane_cancel(SANE_Handle h)
{
void
sane_cancel(SANE_Handle h)
{
DBG (10, "escl sane_cancel\n");
escl_sane_t *handler = h;
if (handler->scanner->tmp)
@ -619,24 +619,24 @@ sane_cancel(SANE_Handle h)
}
handler->cancel = SANE_TRUE;
escl_scanner(handler->name, handler->result);
}
}
/**
/**
* \fn void sane_close(SANE_Handle h)
* \brief Function that closes the communication with the device represented by 'SANE_Handle h'.
* This function must release the resources that were allocated to the opening of 'h'.
*/
void
sane_close(SANE_Handle h)
{
void
sane_close(SANE_Handle h)
{
DBG (10, "escl sane_close\n");
if (h != NULL) {
free(h);
h = NULL;
}
}
}
/**
/**
* \fn const SANE_Option_Descriptor *sane_get_option_descriptor(SANE_Handle h, SANE_Int n)
* \brief Function that retrieves a descriptor from the n number option of the scanner
* represented by 'h'.
@ -644,18 +644,18 @@ sane_close(SANE_Handle h)
*
* \return s->opt + n
*/
const SANE_Option_Descriptor *
sane_get_option_descriptor(SANE_Handle h, SANE_Int n)
{
const SANE_Option_Descriptor *
sane_get_option_descriptor(SANE_Handle h, SANE_Int n)
{
DBG (10, "escl sane_get_option_descriptor\n");
escl_sane_t *s = h;
if ((unsigned) n >= NUM_OPTIONS || n < 0)
return (0);
return (&s->opt[n]);
}
}
/**
/**
* \fn SANE_Status sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int *i)
* \brief Function that defines the actions to perform for the 'n' option of the machine,
* represented by 'h', if the action is 'a'.
@ -668,9 +668,9 @@ sane_get_option_descriptor(SANE_Handle h, SANE_Int n)
*
* \return SANE_STATUS_GOOD if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL
*/
SANE_Status
sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int *i)
{
SANE_Status
sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int *i)
{
DBG (10, "escl sane_control_option\n");
escl_sane_t *handler = h;
@ -735,18 +735,18 @@ sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int
}
}
return (SANE_STATUS_GOOD);
}
}
/**
/**
* \fn SANE_Status sane_start(SANE_Handle h)
* \brief Function that initiates aquisition of an image from the device represented by handle 'h'.
* This function calls the "escl_newjob" function and the "escl_scan" function.
*
* \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL)
*/
SANE_Status
sane_start(SANE_Handle h)
{
SANE_Status
sane_start(SANE_Handle h)
{
DBG (10, "escl sane_start\n");
SANE_Status status = SANE_STATUS_GOOD;
escl_sane_t *handler = h;
@ -843,6 +843,7 @@ sane_start(SANE_Handle h)
DBG(10, "2-Size Image [%dx%d|%dx%d]\n", 0, 0, w, he);
if (handler->scanner->source > 0)
escl_scanner(handler->name, handler->result);
if (status != SANE_STATUS_GOOD)
return (status);
handler->ps.depth = 8;