kopia lustrzana https://gitlab.com/sane-project/backends
Fix all conflicts.
rodzic
4ed0b0fd59
commit
ba5f992737
|
@ -364,43 +364,43 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
|
|||
}
|
||||
|
||||
if (strncmp(line, "[device]", 8) == 0) {
|
||||
escl_device = escl_free_device(escl_device);
|
||||
escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device));
|
||||
if (!escl_device) {
|
||||
DBG (10, "New Escl_Device allocation failure.\n");
|
||||
return (SANE_STATUS_NO_MEM);
|
||||
}
|
||||
escl_device = escl_free_device(escl_device);
|
||||
escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device));
|
||||
if (!escl_device) {
|
||||
DBG (10, "New Escl_Device allocation failure.");
|
||||
return (SANE_STATUS_NO_MEM);
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "ip", 2) == 0) {
|
||||
const char *ip_space = sanei_config_skip_whitespace(line + 2);
|
||||
DBG (10, "New Escl_Device IP [%s].\n", (ip_space ? ip_space : "VIDE"));
|
||||
if (escl_device != NULL && ip_space != NULL) {
|
||||
DBG (10, "New Escl_Device IP Affected.\n");
|
||||
escl_device->ip_address = strdup(ip_space);
|
||||
}
|
||||
const char *ip_space = sanei_config_skip_whitespace(line + 2);
|
||||
DBG (10, "New Escl_Device IP [%s].", (ip_space ? ip_space : "VIDE"));
|
||||
if (escl_device != NULL && ip_space != NULL) {
|
||||
DBG (10, "New Escl_Device IP Affected.");
|
||||
escl_device->ip_address = strdup(ip_space);
|
||||
}
|
||||
}
|
||||
if (sscanf(line, "port %i", &port) == 1 && port != 0) {
|
||||
DBG (10, "New Escl_Device PORT [%d].\n", port);
|
||||
if (escl_device != NULL) {
|
||||
DBG (10, "New Escl_Device PORT Affected.\n");
|
||||
escl_device->port_nb = port;
|
||||
}
|
||||
DBG (10, "New Escl_Device PORT [%d].", port);
|
||||
if (escl_device != NULL) {
|
||||
DBG (10, "New Escl_Device PORT Affected.");
|
||||
escl_device->port_nb = port;
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "model", 5) == 0) {
|
||||
const char *model_space = sanei_config_skip_whitespace(line + 5);
|
||||
DBG (10, "New Escl_Device MODEL [%s].\n", (model_space ? model_space : "VIDE"));
|
||||
if (escl_device != NULL && model_space != NULL) {
|
||||
DBG (10, "New Escl_Device MODEL Affected.\n");
|
||||
escl_device->model_name = strdup(model_space);
|
||||
}
|
||||
const char *model_space = sanei_config_skip_whitespace(line + 5);
|
||||
DBG (10, "New Escl_Device MODEL [%s].", (model_space ? model_space : "VIDE"));
|
||||
if (escl_device != NULL && model_space != NULL) {
|
||||
DBG (10, "New Escl_Device MODEL Affected.");
|
||||
escl_device->model_name = strdup(model_space);
|
||||
}
|
||||
}
|
||||
if (strncmp(line, "type", 4) == 0) {
|
||||
const char *type_space = sanei_config_skip_whitespace(line + 4);
|
||||
DBG (10, "New Escl_Device TYPE [%s].\n", (type_space ? type_space : "VIDE"));
|
||||
if (escl_device != NULL && type_space != NULL) {
|
||||
DBG (10, "New Escl_Device TYPE Affected.\n");
|
||||
escl_device->type = strdup(type_space);
|
||||
}
|
||||
const char *type_space = sanei_config_skip_whitespace(line + 4);
|
||||
DBG (10, "New Escl_Device TYPE [%s].", (type_space ? type_space : "VIDE"));
|
||||
if (escl_device != NULL && type_space != NULL) {
|
||||
DBG (10, "New Escl_Device TYPE Affected.");
|
||||
escl_device->type = strdup(type_space);
|
||||
}
|
||||
}
|
||||
status = escl_check_and_add_device(escl_device);
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
|
@ -459,7 +459,7 @@ 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(const char *name_source, escl_sane_t *s)
|
||||
init_options(SANE_String_Const name_source, escl_sane_t *s)
|
||||
{
|
||||
DBG (10, "escl init_options\n");
|
||||
|
||||
|
@ -480,7 +480,6 @@ init_options(const char *name_source, escl_sane_t *s)
|
|||
}
|
||||
else
|
||||
s->scanner->source = PLATEN;
|
||||
|
||||
memset (s->opt, 0, sizeof (s->opt));
|
||||
memset (s->val, 0, sizeof (s->val));
|
||||
for (i = 0; i < NUM_OPTIONS; ++i) {
|
||||
|
@ -984,9 +983,8 @@ sane_start(SANE_Handle h)
|
|||
handler->ps.lines = he;
|
||||
handler->ps.bytes_per_line = w * bps;
|
||||
handler->scanner->work = SANE_FALSE;
|
||||
handler->ps.last_frame = SANE_TRUE;
|
||||
handler->ps.format = SANE_FRAME_RGB;
|
||||
DBG(10, "NEXT Frame [%s]\n", (handler->ps.last_frame ? "Non" : "Oui"));
|
||||
// DBG(10, "NEXT Frame [%s]\n", (handler->ps.last_frame ? "Non" : "Oui"));
|
||||
DBG(10, "Real Size Image [%dx%d|%dx%d]\n", 0, 0, w, he);
|
||||
return (status);
|
||||
}
|
||||
|
@ -1070,8 +1068,14 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len)
|
|||
*len = 0;
|
||||
free(handler->scanner->img_data);
|
||||
handler->scanner->img_data = NULL;
|
||||
if (handler->scanner->source != PLATEN) {
|
||||
SANE_Status st = escl_status(handler->device, handler->scanner->source);
|
||||
if (handler->scanner->source == PLATEN) {
|
||||
handler->scanner->work = SANE_FALSE;
|
||||
handler->ps.last_frame = SANE_TRUE;
|
||||
}
|
||||
else {
|
||||
SANE_Status st = escl_status(handler->device,
|
||||
handler->scanner->source,
|
||||
handler->result);
|
||||
DBG(10, "eSCL : command returned status %s\n", sane_strstatus(st));
|
||||
SANE_Bool next_page =
|
||||
(SANE_STATUS_GOOD == st ?
|
||||
|
|
|
@ -87,10 +87,10 @@ typedef struct {
|
|||
typedef struct ESCL_Device {
|
||||
struct ESCL_Device *next;
|
||||
|
||||
char *model_name;
|
||||
int port_nb;
|
||||
char *model_name;
|
||||
int port_nb;
|
||||
char *ip_address;
|
||||
char *type;
|
||||
char *type;
|
||||
SANE_Bool https;
|
||||
char *unix_socket;
|
||||
} ESCL_Device;
|
||||
|
@ -181,7 +181,7 @@ enum
|
|||
ESCL_Device *escl_devices(SANE_Status *status);
|
||||
SANE_Status escl_device_add(int port_nb, const char *model_name,
|
||||
char *ip_address, char *type);
|
||||
SANE_Status escl_status(const ESCL_Device *device, int source);
|
||||
SANE_Status escl_status(const ESCL_Device *device, int source, char *jobid);
|
||||
capabilities_t *escl_capabilities(const ESCL_Device *device, SANE_Status *status);
|
||||
char *escl_newjob(capabilities_t *scanner, const ESCL_Device *device,
|
||||
SANE_Status *status);
|
||||
|
|
|
@ -185,50 +185,48 @@ find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner, int type)
|
|||
if (strcmp(name, "ColorMode") == 0) {
|
||||
const char *color = (SANE_String_Const)xmlNodeGetContent(node);
|
||||
if (type == PLATEN || strcmp(color, "BlackAndWhite1"))
|
||||
scanner->caps[type].ColorModes = char_to_array(
|
||||
scanner->caps[type].ColorModes,
|
||||
&scanner->caps[type].ColorModesSize,
|
||||
(SANE_String_Const)xmlNodeGetContent(node), 1);
|
||||
scanner->caps[type].ColorModes = char_to_array(scanner->caps[type].ColorModes, &scanner->caps[type].ColorModesSize, (SANE_String_Const)xmlNodeGetContent(node), 1);
|
||||
}
|
||||
else if (strcmp(name, "ContentType") == 0)
|
||||
scanner->caps[type].ContentTypes = char_to_array(
|
||||
scanner->caps[type].ContentTypes,
|
||||
&scanner->caps[type].ContentTypesSize,
|
||||
(SANE_String_Const)xmlNodeGetContent(node), 0);
|
||||
scanner->caps[type].ContentTypes = char_to_array(scanner->caps[type].ContentTypes, &scanner->caps[type].ContentTypesSize, (SANE_String_Const)xmlNodeGetContent(node), 0);
|
||||
else if (strcmp(name, "DocumentFormat") == 0)
|
||||
{
|
||||
int i = 0;
|
||||
int _is_jpeg = 0, _is_png = 0, _is_tiff = 0, _is_pdf = 0;
|
||||
scanner->caps[type].DocumentFormats = char_to_array(
|
||||
scanner->caps[type].DocumentFormats,
|
||||
&scanner->caps[type].DocumentFormatsSize,
|
||||
(SANE_String_Const)xmlNodeGetContent(node), 0);
|
||||
SANE_Bool have_jpeg = SANE_FALSE, have_png = SANE_FALSE, have_tiff = SANE_FALSE, have_pdf = SANE_FALSE;
|
||||
scanner->caps[type].DocumentFormats = char_to_array(scanner->caps[type].DocumentFormats, &scanner->caps[type].DocumentFormatsSize, (SANE_String_Const)xmlNodeGetContent(node), 0);
|
||||
for(; i < scanner->caps[type].DocumentFormatsSize; i++)
|
||||
{
|
||||
if (!strcmp(scanner->caps[type].DocumentFormats[i], "image/jpeg"))
|
||||
_is_jpeg = 1;
|
||||
{
|
||||
have_jpeg = SANE_TRUE;
|
||||
}
|
||||
#if(defined HAVE_LIBPNG)
|
||||
else if(!strcmp(scanner->caps[type].DocumentFormats[i], "image/png"))
|
||||
_is_png = 1;
|
||||
{
|
||||
have_png = SANE_TRUE;
|
||||
}
|
||||
#endif
|
||||
#if(defined HAVE_TIFFIO_H)
|
||||
else if(!strcmp(scanner->caps[type].DocumentFormats[i], "image/tiff"))
|
||||
_is_tiff = 1;
|
||||
else if(type == PLATEN && !strcmp(scanner->caps[type].DocumentFormats[i], "image/tiff"))
|
||||
{
|
||||
have_tiff = SANE_TRUE;
|
||||
}
|
||||
#endif
|
||||
#if(defined HAVE_POPPLER_GLIB)
|
||||
else if(!strcmp(scanner->caps[type].DocumentFormats[i], "application/pdf"))
|
||||
_is_pdf = 1;
|
||||
else if(type == PLATEN && !strcmp(scanner->caps[type].DocumentFormats[i], "application/pdf"))
|
||||
{
|
||||
have_pdf = SANE_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (_is_pdf)
|
||||
scanner->caps[type].default_format = strdup("application/pdf");
|
||||
else if (_is_tiff)
|
||||
scanner->caps[type].default_format = strdup("image/tiff");
|
||||
else if (_is_png)
|
||||
scanner->caps[type].default_format = strdup("image/png");
|
||||
else if(_is_jpeg)
|
||||
scanner->caps[type].default_format = strdup("image/jpeg");
|
||||
fprintf(stderr, "Capability : [%s]\n", scanner->caps[type].default_format);
|
||||
if (have_pdf)
|
||||
scanner->caps[type].default_format = strdup("application/pdf");
|
||||
else if (have_tiff)
|
||||
scanner->caps[type].default_format = strdup("image/tiff");
|
||||
else if (have_png)
|
||||
scanner->caps[type].default_format = strdup("image/png");
|
||||
else if (have_jpeg)
|
||||
scanner->caps[type].default_format = strdup("image/jpeg");
|
||||
}
|
||||
else if (strcmp(name, "DocumentFormatExt") == 0)
|
||||
scanner->caps[type].format_ext = 1;
|
||||
|
|
|
@ -72,12 +72,12 @@ escl_crop_surface(capabilities_t *scanner,
|
|||
y_off > 0 || real_h < scanner->caps[scanner->source].height) {
|
||||
surface_crop = (unsigned char *)malloc (sizeof (unsigned char) * real_w
|
||||
* real_h * bps);
|
||||
if(!surface_crop) {
|
||||
if(!surface_crop) {
|
||||
DBG( 1, "Escl Crop : Surface_crop Memory allocation problem\n");
|
||||
free(surface);
|
||||
surface = NULL;
|
||||
goto finish;
|
||||
}
|
||||
free(surface);
|
||||
surface = NULL;
|
||||
goto finish;
|
||||
}
|
||||
for (y = 0; y < real_h; y++)
|
||||
{
|
||||
for (x = 0; x < real_w; x++)
|
||||
|
@ -91,7 +91,7 @@ escl_crop_surface(capabilities_t *scanner,
|
|||
}
|
||||
}
|
||||
free(surface);
|
||||
surface = surface_crop;
|
||||
surface = surface_crop;
|
||||
}
|
||||
// we don't need row pointers anymore
|
||||
scanner->img_data = surface;
|
||||
|
|
|
@ -83,47 +83,81 @@ find_nodes_s(xmlNode *node)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* \fn static void print_xml_s(xmlNode *node, SANE_Status *platen_status, SANE_Status *adf_status, int source)
|
||||
* \brief Function that browses the xml file, node by node.
|
||||
* If the node 'State' is found, we are expecting to found in this node the 'Idle'
|
||||
* content (if the scanner is ready to use) and then 'status' = SANE_STATUS_GOOD.
|
||||
* Otherwise, this means that the scanner isn't ready to use.
|
||||
*/
|
||||
static void
|
||||
print_xml_s(xmlNode *node, SANE_Status *platen_status, SANE_Status* adf_status, int source)
|
||||
print_xml_job_status(xmlNode *node,
|
||||
SANE_Status *processing,
|
||||
SANE_Status *complete,
|
||||
int *image)
|
||||
{
|
||||
while (node) {
|
||||
if (node->type == XML_ELEMENT_NODE) {
|
||||
if (find_nodes_s(node)) {
|
||||
if (strcmp((const char *)node->name, "JobState") == 0) {
|
||||
const char *state = (const char *)xmlNodeGetContent(node);
|
||||
if (!strcmp(state, "Processing")) {
|
||||
*processing = SANE_STATUS_GOOD;
|
||||
}
|
||||
if (!strcmp(state, "Completed")) {
|
||||
*complete = SANE_STATUS_GOOD;
|
||||
}
|
||||
}
|
||||
else if (strcmp((const char *)node->name, "ImagesToTransfer") == 0) {
|
||||
const char *state = (const char *)xmlNodeGetContent(node);
|
||||
*image = atoi(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
print_xml_job_status(node->children, processing, complete, image);
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_xml_feeder_status(xmlNode *node,
|
||||
const char *job,
|
||||
SANE_Status *processing,
|
||||
SANE_Status *complete,
|
||||
int *image)
|
||||
{
|
||||
while (node) {
|
||||
if (node->type == XML_ELEMENT_NODE) {
|
||||
if (find_nodes_s(node)) {
|
||||
if (strcmp((const char *)node->name, "JobUri") == 0) {
|
||||
if (strstr((const char *)xmlNodeGetContent(node), job)) {
|
||||
print_xml_job_status(node, processing, complete, image);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print_xml_feeder_status(node->children, job, processing, complete, image);
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_xml_platen_status(xmlNode *node, SANE_Status *status)
|
||||
{
|
||||
while (node) {
|
||||
if (node->type == XML_ELEMENT_NODE) {
|
||||
if (find_nodes_s(node)) {
|
||||
if (strcmp((const char *)node->name, "State") == 0) {
|
||||
printf ("State\t");
|
||||
const char *state = (const char *)xmlNodeGetContent(node);
|
||||
if (!strcmp(state, "Idle")) {
|
||||
*platen_status = SANE_STATUS_GOOD;
|
||||
printf("Idle SANE_STATUS_GOOD\n");
|
||||
*status = SANE_STATUS_GOOD;
|
||||
} else if (!strcmp(state, "Processing")) {
|
||||
*platen_status = SANE_STATUS_DEVICE_BUSY;
|
||||
printf("Processing SANE_STATUS_DEVICE_BUSY\n");
|
||||
*status = SANE_STATUS_DEVICE_BUSY;
|
||||
} else {
|
||||
*platen_status = SANE_STATUS_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
else if (strcmp((const char *)node->name, "AdfState") == 0) {
|
||||
const char *state = (const char *)xmlNodeGetContent(node);
|
||||
if (!strcmp(state, "ScannerAdfLoaded") ||
|
||||
!strcmp(state, "ScannerAdfProcessing")) {
|
||||
*adf_status = SANE_STATUS_GOOD;
|
||||
} else if (!strcmp(state, "ScannerAdfJam")) {
|
||||
*adf_status = SANE_STATUS_JAMMED;
|
||||
} else if (!strcmp(state, "ScannerAdfDoorOpen")) {
|
||||
*adf_status = SANE_STATUS_COVER_OPEN;
|
||||
} else if (!strcmp(state, "ScannerAdfEmpty")) {
|
||||
*adf_status = SANE_STATUS_NO_DOCS;
|
||||
} else {
|
||||
*adf_status = SANE_STATUS_UNSUPPORTED;
|
||||
printf("%s SANE_STATUS_UNSUPPORTED\n", state);
|
||||
*status = SANE_STATUS_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print_xml_s(node->children, platen_status, adf_status, source);
|
||||
print_xml_platen_status(node->children, status);
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
@ -137,11 +171,9 @@ print_xml_s(xmlNode *node, SANE_Status *platen_status, SANE_Status* adf_status,
|
|||
* \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL)
|
||||
*/
|
||||
SANE_Status
|
||||
escl_status(const ESCL_Device *device, int source)
|
||||
escl_status(const ESCL_Device *device, int source, char *jobid)
|
||||
{
|
||||
SANE_Status status;
|
||||
SANE_Status adf_status;
|
||||
SANE_Status platen_status;
|
||||
CURL *curl_handle = NULL;
|
||||
struct idle *var = NULL;
|
||||
xmlDoc *data = NULL;
|
||||
|
@ -177,23 +209,24 @@ escl_status(const ESCL_Device *device, int source)
|
|||
goto clean;
|
||||
}
|
||||
status = SANE_STATUS_DEVICE_BUSY;
|
||||
print_xml_s(node, &platen_status, &adf_status, source);
|
||||
/* Decode Job status */
|
||||
/* Decode Job status */
|
||||
if (source == PLATEN) {
|
||||
status = platen_status;
|
||||
} else if (platen_status == SANE_STATUS_DEVICE_BUSY) {
|
||||
status = SANE_STATUS_GOOD;
|
||||
} else if (platen_status == SANE_STATUS_GOOD &&
|
||||
adf_status == SANE_STATUS_NO_DOCS) {
|
||||
status = SANE_STATUS_NO_DOCS;
|
||||
} else if (platen_status != SANE_STATUS_UNSUPPORTED) {
|
||||
status = adf_status;
|
||||
print_xml_platen_status(node, &status);
|
||||
} else {
|
||||
SANE_Status processing = SANE_STATUS_UNSUPPORTED;
|
||||
SANE_Status complete = SANE_STATUS_UNSUPPORTED;
|
||||
int image = -1;
|
||||
print_xml_feeder_status(node, jobid, &processing, &complete, &image);
|
||||
if (processing == SANE_STATUS_GOOD && image == 0 &&
|
||||
complete == SANE_STATUS_UNSUPPORTED)
|
||||
status = SANE_STATUS_EOF;
|
||||
else if (complete == SANE_STATUS_GOOD && image == -1 &&
|
||||
processing == SANE_STATUS_UNSUPPORTED)
|
||||
status = SANE_STATUS_EOF;
|
||||
else
|
||||
status = SANE_STATUS_GOOD;
|
||||
}
|
||||
else
|
||||
status = platen_status;
|
||||
|
||||
printf ("STATUS AA : %s\n", sane_strstatus(status));
|
||||
DBG (10, "STATUS : %s\n", sane_strstatus(status));
|
||||
clean:
|
||||
xmlFreeDoc(data);
|
||||
clean_data:
|
||||
|
|
Ładowanie…
Reference in New Issue