Lines Matching refs:test_device
309 Test_Device *test_device = first_test_device;
311 while (test_device)
313 if (test_device == (Test_Device *) handle)
315 test_device = test_device->next;
321 cleanup_options (Test_Device * test_device)
323 DBG (2, "cleanup_options: test_device=%p\n", (void *) test_device);
325 free(test_device->val[opt_mode].s);
326 test_device->val[opt_mode].s = NULL;
328 free(test_device->val[opt_three_pass_order].s);
329 test_device->val[opt_three_pass_order].s = NULL;
331 free(test_device->val[opt_scan_source].s);
332 test_device->val[opt_scan_source].s = NULL;
334 free(test_device->val[opt_test_picture].s);
335 test_device->val[opt_test_picture].s = NULL;
337 free(test_device->val[opt_read_status_code].s);
338 test_device->val[opt_read_status_code].s = NULL;
340 free(test_device->val[opt_string].s);
341 test_device->val[opt_string].s = NULL;
343 free(test_device->val[opt_string_constraint_string_list].s);
344 test_device->val[opt_string_constraint_string_list].s = NULL;
346 free(test_device->val[opt_string_constraint_long_string_list].s);
347 test_device->val[opt_string_constraint_long_string_list].s = NULL;
349 test_device->options_initialized = SANE_FALSE;
353 init_options (Test_Device * test_device)
357 DBG (2, "init_options: test_device=%p\n", (void *) test_device);
360 od = &test_device->opt[opt_num_opts];
370 test_device->val[opt_num_opts].w = num_options;
372 test_device->loaded[opt_num_opts] = 1;
375 od = &test_device->opt[opt_mode_group];
385 test_device->val[opt_mode_group].w = 0;
388 od = &test_device->opt[opt_mode];
398 test_device->val[opt_mode].s = malloc ((size_t) od->size);
399 if (!test_device->val[opt_mode].s)
401 strcpy (test_device->val[opt_mode].s, init_mode);
404 od = &test_device->opt[opt_depth];
414 test_device->val[opt_depth].w = init_depth;
417 od = &test_device->opt[opt_hand_scanner];
432 test_device->val[opt_hand_scanner].w = init_hand_scanner;
435 od = &test_device->opt[opt_three_pass];
448 test_device->val[opt_three_pass].w = init_three_pass;
451 od = &test_device->opt[opt_three_pass_order];
465 test_device->val[opt_three_pass_order].s = malloc ((size_t) od->size);
466 if (!test_device->val[opt_three_pass_order].s)
468 strcpy (test_device->val[opt_three_pass_order].s, init_three_pass_order);
471 od = &test_device->opt[opt_resolution];
481 test_device->val[opt_resolution].w = init_resolution;
484 od = &test_device->opt[opt_scan_source];
494 test_device->val[opt_scan_source].s = malloc ((size_t) od->size);
495 if (!test_device->val[opt_scan_source].s)
497 strcpy (test_device->val[opt_scan_source].s, init_scan_source);
500 od = &test_device->opt[opt_special_group];
510 test_device->val[opt_special_group].w = 0;
513 od = &test_device->opt[opt_test_picture];
530 test_device->val[opt_test_picture].s = malloc ((size_t) od->size);
531 if (!test_device->val[opt_test_picture].s)
533 strcpy (test_device->val[opt_test_picture].s, init_test_picture);
536 od = &test_device->opt[opt_invert_endianess];
550 test_device->val[opt_invert_endianess].w = init_invert_endianess;
553 od = &test_device->opt[opt_read_limit];
564 test_device->val[opt_read_limit].w = init_read_limit;
567 od = &test_device->opt[opt_read_limit_size];
580 test_device->val[opt_read_limit_size].w = init_read_limit_size;
583 od = &test_device->opt[opt_read_delay];
593 test_device->val[opt_read_delay].w = init_read_delay;
596 od = &test_device->opt[opt_read_delay_duration];
609 test_device->val[opt_read_delay_duration].w = init_read_delay_duration;
612 od = &test_device->opt[opt_read_status_code];
625 test_device->val[opt_read_status_code].s = malloc ((size_t) od->size);
626 if (!test_device->val[opt_read_status_code].s)
628 strcpy (test_device->val[opt_read_status_code].s, init_read_status_code);
631 od = &test_device->opt[opt_ppl_loss];
643 test_device->val[opt_ppl_loss].w = init_ppl_loss;
646 od = &test_device->opt[opt_fuzzy_parameters];
657 test_device->val[opt_fuzzy_parameters].w = init_fuzzy_parameters;
660 od = &test_device->opt[opt_non_blocking];
671 test_device->val[opt_non_blocking].w = init_non_blocking;
674 od = &test_device->opt[opt_select_fd];
685 test_device->val[opt_select_fd].w = init_select_fd;
688 od = &test_device->opt[opt_enable_test_options];
700 test_device->val[opt_enable_test_options].w = init_enable_test_options;
703 od = &test_device->opt[opt_print_options];
713 test_device->val[opt_print_options].w = 0;
716 od = &test_device->opt[opt_geometry_group];
726 test_device->val[opt_geometry_group].w = 0;
729 od = &test_device->opt[opt_tl_x];
739 test_device->val[opt_tl_x].w = init_tl_x;
742 od = &test_device->opt[opt_tl_y];
752 test_device->val[opt_tl_y].w = init_tl_y;
755 od = &test_device->opt[opt_br_x];
765 test_device->val[opt_br_x].w = init_br_x;
768 od = &test_device->opt[opt_br_y];
778 test_device->val[opt_br_y].w = init_br_y;
781 od = &test_device->opt[opt_bool_group];
791 test_device->val[opt_bool_group].w = 0;
794 od = &test_device->opt[opt_bool_soft_select_soft_detect];
809 test_device->val[opt_bool_soft_select_soft_detect].w = SANE_FALSE;
812 od = &test_device->opt[opt_bool_hard_select_soft_detect];
828 test_device->val[opt_bool_hard_select_soft_detect].w = SANE_FALSE;
831 od = &test_device->opt[opt_bool_hard_select];
847 test_device->val[opt_bool_hard_select].w = SANE_FALSE;
850 od = &test_device->opt[opt_bool_soft_detect];
864 test_device->val[opt_bool_soft_detect].w = SANE_FALSE;
867 od = &test_device->opt[opt_bool_soft_select_soft_detect_emulated];
881 test_device->val[opt_bool_soft_select_soft_detect_emulated].w = SANE_FALSE;
884 od = &test_device->opt[opt_bool_soft_select_soft_detect_auto];
899 test_device->val[opt_bool_soft_select_soft_detect_auto].w = SANE_FALSE;
902 od = &test_device->opt[opt_int_group];
912 test_device->val[opt_int_group].w = 0;
915 od = &test_device->opt[opt_int];
928 test_device->val[opt_int].w = 42;
931 od = &test_device->opt[opt_int_constraint_range];
945 test_device->val[opt_int_constraint_range].w = 26;
948 od = &test_device->opt[opt_int_constraint_word_list];
961 test_device->val[opt_int_constraint_word_list].w = 42;
964 od = &test_device->opt[opt_int_array];
977 test_device->val[opt_int_array].wa = &int_array[0];
980 od = &test_device->opt[opt_int_array_constraint_range];
994 test_device->val[opt_int_array_constraint_range].wa =
998 od = &test_device->opt[opt_int_array_constraint_word_list];
1011 test_device->val[opt_int_array_constraint_word_list].wa =
1015 od = &test_device->opt[opt_int_inexact];
1028 test_device->val[opt_int_inexact].w = 67;
1033 od = &test_device->opt[opt_gamma_red];
1043 test_device->val[opt_gamma_red].wa = &gamma_red[0];
1047 od = &test_device->opt[opt_gamma_green];
1057 test_device->val[opt_gamma_green].wa = &gamma_green[0];
1061 od = &test_device->opt[opt_gamma_blue];
1071 test_device->val[opt_gamma_blue].wa = &gamma_blue[0];
1076 od = &test_device->opt[opt_gamma_all];
1086 test_device->val[opt_gamma_all].wa = &gamma_all[0];
1089 od = &test_device->opt[opt_fixed_group];
1099 test_device->val[opt_fixed_group].w = 0;
1102 od = &test_device->opt[opt_fixed];
1115 test_device->val[opt_fixed].w = SANE_FIX (42.0);
1118 od = &test_device->opt[opt_fixed_constraint_range];
1132 test_device->val[opt_fixed_constraint_range].w = SANE_FIX (41.83);
1135 od = &test_device->opt[opt_fixed_constraint_word_list];
1148 test_device->val[opt_fixed_constraint_word_list].w = SANE_FIX (42.0);
1151 od = &test_device->opt[opt_string_group];
1161 test_device->val[opt_string_group].w = 0;
1164 od = &test_device->opt[opt_string];
1176 test_device->val[opt_string].s = malloc ((size_t) od->size);
1177 if (!test_device->val[opt_string].s)
1179 strcpy (test_device->val[opt_string].s, init_string);
1182 od = &test_device->opt[opt_string_constraint_string_list];
1195 test_device->val[opt_string_constraint_string_list].s = malloc ((size_t) od->size);
1196 if (!test_device->val[opt_string_constraint_string_list].s)
1198 strcpy (test_device->val[opt_string_constraint_string_list].s,
1202 od = &test_device->opt[opt_string_constraint_long_string_list];
1215 test_device->val[opt_string_constraint_long_string_list].s =
1217 if (!test_device->val[opt_string_constraint_long_string_list].s)
1219 strcpy (test_device->val[opt_string_constraint_long_string_list].s,
1223 od = &test_device->opt[opt_button_group];
1233 test_device->val[opt_button_group].w = 0;
1236 od = &test_device->opt[opt_button];
1248 test_device->val[opt_button].w = 0;
1253 cleanup_options (test_device);
1280 cleanup_test_device (Test_Device * test_device)
1282 DBG (2, "cleanup_test_device: test_device=%p\n", (void *) test_device);
1283 if (test_device->options_initialized)
1284 cleanup_options (test_device);
1285 if (test_device->name)
1286 free (test_device->name);
1287 free (test_device);
1436 reader_process (Test_Device * test_device, SANE_Int fd)
1445 DBG (2, "(child) reader_process: test_device=%p, fd=%d\n",
1446 (void *) test_device, fd);
1448 bytes_total = (size_t) test_device->lines * (size_t) test_device->bytes_per_line;
1449 status = init_picture_buffer (test_device, &buffer, &buffer_size);
1464 if (test_device->val[opt_read_delay].w == SANE_TRUE)
1465 usleep ((useconds_t) test_device->val[opt_read_delay_duration].w);
1507 struct Test_Device *test_device = (struct Test_Device *) data;
1513 close (test_device->pipe);
1514 test_device->pipe = -1;
1525 status = reader_process (test_device, test_device->reader_fds);
1532 finish_pass (Test_Device * test_device)
1536 DBG (2, "finish_pass: test_device=%p\n", (void *) test_device);
1537 test_device->scanning = SANE_FALSE;
1538 if (test_device->pipe >= 0)
1541 close (test_device->pipe);
1543 test_device->pipe = -1;
1545 if (sanei_thread_is_valid (test_device->reader_pid))
1551 (long) test_device->reader_pid);
1552 sanei_thread_kill (test_device->reader_pid);
1553 pid = sanei_thread_waitpid (test_device->reader_pid, &status);
1565 sanei_thread_invalidate (test_device->reader_pid);
1568 if (test_device->reader_fds >= 0)
1571 close (test_device->reader_fds);
1573 test_device->reader_fds = -1;
1579 print_options (Test_Device * test_device)
1587 od = &test_device->opt[option_number];
1648 Test_Device *test_device, *previous_device;
1654 test_device = 0;
1852 test_device = calloc (sizeof (*test_device), 1);
1853 if (!test_device)
1855 test_device->sane.vendor = "Noname";
1856 test_device->sane.type = "virtual device";
1857 test_device->sane.model = "frontend-tester";
1860 test_device->name = strdup (number_string);
1861 if (!test_device->name)
1863 test_device->sane.name = test_device->name;
1865 previous_device->next = test_device;
1866 previous_device = test_device;
1868 first_test_device = test_device;
1869 sane_device_list[num] = &test_device->sane;
1870 test_device->open = SANE_FALSE;
1871 test_device->eof = SANE_FALSE;
1872 test_device->scanning = SANE_FALSE;
1873 test_device->cancelled = SANE_FALSE;
1874 test_device->options_initialized = SANE_FALSE;
1875 sanei_thread_initialize (test_device->reader_pid);
1876 test_device->pipe = -1;
1878 test_device->sane.name, test_device->sane.vendor,
1879 test_device->sane.model, test_device->sane.type);
1881 test_device->next = 0;
1889 // test_device refers to the last device we were creating, which has not
1891 free (test_device);
1895 test_device = first_test_device;
1896 while (test_device)
1898 previous_device = test_device;
1899 test_device = test_device->next;
1911 Test_Device *test_device, *previous_device;
1920 test_device = first_test_device;
1921 while (test_device)
1923 DBG (4, "sane_exit: freeing device %s\n", test_device->name);
1924 previous_device = test_device;
1925 test_device = test_device->next;
1964 Test_Device *test_device = first_test_device;
1987 for (test_device = first_test_device; test_device;
1988 test_device = test_device->next)
1990 if (strcmp (devicename, test_device->name) == 0)
1994 if (!test_device)
1999 if (test_device->open)
2004 DBG (2, "sane_open: opening device `%s', handle = %p\n", test_device->name,
2005 (void *) test_device);
2006 test_device->open = SANE_TRUE;
2007 *handle = test_device;
2009 if (!test_device->options_initialized) {
2010 status = init_options (test_device);
2013 test_device->options_initialized = SANE_TRUE;
2016 test_device->open = SANE_TRUE;
2017 test_device->scanning = SANE_FALSE;
2018 test_device->cancelled = SANE_FALSE;
2019 test_device->eof = SANE_FALSE;
2020 test_device->bytes_total = 0;
2021 test_device->pass = 0;
2022 test_device->number_of_scans = 0;
2030 Test_Device *test_device = handle;
2044 if (!test_device->open)
2049 test_device->open = SANE_FALSE;
2056 Test_Device *test_device = handle;
2073 if (!test_device->open)
2085 test_device->loaded[option] = 1;
2087 return &test_device->opt[option];
2094 Test_Device *test_device = handle;
2111 if (!test_device->open)
2116 if (test_device->scanning)
2127 if (!test_device->loaded[option])
2133 if (!SANE_OPTION_IS_ACTIVE (test_device->opt[option].cap))
2139 if (test_device->opt[option].type == SANE_TYPE_GROUP)
2148 if (!SANE_OPTION_IS_SETTABLE (test_device->opt[option].cap))
2153 if (!(test_device->opt[option].cap & SANE_CAP_AUTOMATIC))
2162 test_device->val[option].w = SANE_TRUE;
2164 "to %s\n", option, test_device->opt[option].name,
2165 test_device->val[option].w == SANE_TRUE ? "true" : "false");
2176 if (!SANE_OPTION_IS_SETTABLE (test_device->opt[option].cap))
2181 status = sanei_constrain_value (&test_device->opt[option],
2196 if (test_device->val[option].w == *(SANE_Fixed *) value)
2199 option, test_device->opt[option].name);
2202 test_device->val[option].w = *(SANE_Fixed *) value;
2205 option, test_device->opt[option].name,
2207 test_device->opt[option].unit == SANE_UNIT_MM ? "mm" : "dpi");
2211 if (test_device->val[option].w == *(SANE_Fixed *) value)
2214 option, test_device->opt[option].name);
2217 test_device->val[option].w = *(SANE_Fixed *) value;
2219 option, test_device->opt[option].name,
2227 if (test_device->val[option].w == *(SANE_Int *) value)
2230 option, test_device->opt[option].name);
2233 test_device->val[option].w = *(SANE_Int *) value;
2235 option, test_device->opt[option].name, *(SANE_Int *) value);
2238 if (test_device->val[option].w == *(SANE_Int *) value)
2241 option, test_device->opt[option].name);
2245 test_device->val[option].w = *(SANE_Int *) value;
2248 option, test_device->opt[option].name, *(SANE_Int *) value);
2251 if (test_device->val[option].w == *(SANE_Bool *) value)
2254 option, test_device->opt[option].name);
2257 test_device->val[option].w = *(SANE_Bool *) value;
2260 option, test_device->opt[option].name,
2269 if (test_device->val[option].w == *(SANE_Bool *) value)
2272 option, test_device->opt[option].name);
2275 test_device->val[option].w = *(SANE_Bool *) value;
2277 option, test_device->opt[option].name,
2281 if (test_device->val[option].w == *(SANE_Int *) value)
2284 option, test_device->opt[option].name);
2287 test_device->val[option].w = *(SANE_Int *) value;
2288 if (test_device->val[option].w == 16)
2289 test_device->opt[opt_invert_endianess].cap &= ~SANE_CAP_INACTIVE;
2291 test_device->opt[opt_invert_endianess].cap |= SANE_CAP_INACTIVE;
2296 option, test_device->opt[option].name, *(SANE_Int *) value);
2299 if (strcmp (test_device->val[option].s, value) == 0)
2302 option, test_device->opt[option].name);
2305 strcpy (test_device->val[option].s, (SANE_String) value);
2308 option, test_device->opt[option].name, (SANE_String) value);
2312 if (test_device->val[option].w == *(SANE_Int *) value)
2315 option, test_device->opt[option].name);
2318 test_device->val[option].w = *(SANE_Int *) value;
2320 option, test_device->opt[option].name, *(SANE_Int *) value);
2328 if (strcmp (test_device->val[option].s, value) == 0)
2331 option, test_device->opt[option].name);
2334 strcpy (test_device->val[option].s, (SANE_String) value);
2336 option, test_device->opt[option].name, (SANE_String) value);
2345 memcpy (test_device->val[option].wa, value,
2346 (size_t) test_device->opt[option].size);
2348 option, test_device->opt[option].name, (void *) value);
2359 option, test_device->opt[option].name);
2360 print_options (test_device);
2365 option, test_device->opt[option].name);
2368 if (strcmp (test_device->val[option].s, value) == 0)
2371 option, test_device->opt[option].name);
2374 strcpy (test_device->val[option].s, (SANE_String) value);
2377 if (strcmp (test_device->val[option].s, SANE_VALUE_SCAN_MODE_COLOR) == 0)
2379 test_device->opt[opt_three_pass].cap &= ~SANE_CAP_INACTIVE;
2380 if (test_device->val[opt_three_pass].w == SANE_TRUE)
2381 test_device->opt[opt_three_pass_order].cap
2386 test_device->opt[opt_three_pass].cap |= SANE_CAP_INACTIVE;
2387 test_device->opt[opt_three_pass_order].cap |= SANE_CAP_INACTIVE;
2390 option, test_device->opt[option].name, (SANE_String) value);
2393 if (test_device->val[option].w == *(SANE_Bool *) value)
2396 option, test_device->opt[option].name);
2399 test_device->val[option].w = *(SANE_Bool *) value;
2402 if (test_device->val[option].w == SANE_TRUE)
2403 test_device->opt[opt_three_pass_order].cap &= ~SANE_CAP_INACTIVE;
2405 test_device->opt[opt_three_pass_order].cap |= SANE_CAP_INACTIVE;
2407 option, test_device->opt[option].name,
2411 if (test_device->val[option].w == *(SANE_Bool *) value)
2414 option, test_device->opt[option].name);
2417 test_device->val[option].w = *(SANE_Bool *) value;
2420 if (test_device->val[option].w == SANE_TRUE)
2422 test_device->opt[opt_tl_x].cap |= SANE_CAP_INACTIVE;
2423 test_device->opt[opt_tl_y].cap |= SANE_CAP_INACTIVE;
2424 test_device->opt[opt_br_x].cap |= SANE_CAP_INACTIVE;
2425 test_device->opt[opt_br_y].cap |= SANE_CAP_INACTIVE;
2429 test_device->opt[opt_tl_x].cap &= ~SANE_CAP_INACTIVE;
2430 test_device->opt[opt_tl_y].cap &= ~SANE_CAP_INACTIVE;
2431 test_device->opt[opt_br_x].cap &= ~SANE_CAP_INACTIVE;
2432 test_device->opt[opt_br_y].cap &= ~SANE_CAP_INACTIVE;
2435 option, test_device->opt[option].name,
2439 if (test_device->val[option].w == *(SANE_Bool *) value)
2442 option, test_device->opt[option].name);
2445 test_device->val[option].w = *(SANE_Bool *) value;
2447 if (test_device->val[option].w == SANE_TRUE)
2448 test_device->opt[opt_read_limit_size].cap &= ~SANE_CAP_INACTIVE;
2450 test_device->opt[opt_read_limit_size].cap |= SANE_CAP_INACTIVE;
2452 option, test_device->opt[option].name,
2456 if (test_device->val[option].w == *(SANE_Bool *) value)
2459 option, test_device->opt[option].name);
2462 test_device->val[option].w = *(SANE_Bool *) value;
2464 if (test_device->val[option].w == SANE_TRUE)
2465 test_device->opt[opt_read_delay_duration].cap
2468 test_device->opt[opt_read_delay_duration].cap |=
2471 test_device->opt[option].name,
2477 if (test_device->val[option].w == *(SANE_Bool *) value)
2480 option, test_device->opt[option].name);
2483 test_device->val[option].w = *(SANE_Bool *) value;
2488 if (test_device->opt[option_number].type == SANE_TYPE_GROUP)
2490 if (test_device->val[option].w == SANE_TRUE)
2491 test_device->opt[option_number].cap &= ~SANE_CAP_INACTIVE;
2493 test_device->opt[option_number].cap |= SANE_CAP_INACTIVE;
2496 option, test_device->opt[option].name,
2523 *(SANE_Fixed *) value = test_device->val[option].w;
2526 option, test_device->opt[option].name,
2528 test_device->opt[option].unit ==
2546 *(SANE_Bool *) value = test_device->val[option].w;
2549 option, test_device->opt[option].name,
2560 strcpy (value, test_device->val[option].s);
2562 option, test_device->opt[option].name, (SANE_String) value);
2572 *(SANE_Int *) value = test_device->val[option].w;
2574 option, test_device->opt[option].name, *(SANE_Int *) value);
2583 memcpy (value, test_device->val[option].wa,
2584 (size_t) test_device->opt[option].size);
2586 option, test_device->opt[option].name, (void *) value);
2604 test_device->loaded[i] = 0;
2620 Test_Device *test_device = handle;
2638 if (!test_device->open)
2644 res = SANE_UNFIX (test_device->val[opt_resolution].w);
2645 mode = test_device->val[opt_mode].s;
2646 p = &test_device->params;
2647 p->depth = test_device->val[opt_depth].w;
2649 if (test_device->val[opt_hand_scanner].w == SANE_TRUE)
2656 test_device->lines = (SANE_Word) (res * (br_y - tl_y) / MM_PER_INCH);
2660 tl_x = SANE_UNFIX (test_device->val[opt_tl_x].w);
2661 tl_y = SANE_UNFIX (test_device->val[opt_tl_y].w);
2662 br_x = SANE_UNFIX (test_device->val[opt_br_x].w);
2663 br_y = SANE_UNFIX (test_device->val[opt_br_y].w);
2668 test_device->lines = (SANE_Word) (res * (br_y - tl_y) / MM_PER_INCH);
2669 if (test_device->lines < 1)
2670 test_device->lines = 1;
2671 p->lines = test_device->lines;
2672 if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
2673 && test_device->scanning == SANE_FALSE)
2684 if (test_device->val[opt_three_pass].w == SANE_TRUE)
2686 if (test_device->val[opt_three_pass_order].s[test_device->pass]
2689 else if (test_device->val[opt_three_pass_order].s[test_device->pass]
2694 if (test_device->pass > 1)
2707 if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
2708 && test_device->scanning == SANE_FALSE)
2721 test_device->bytes_per_line = p->bytes_per_line;
2723 p->pixels_per_line -= test_device->val[opt_ppl_loss].w;
2726 test_device->pixels_per_line = p->pixels_per_line;
2767 Test_Device *test_device = handle;
2781 if (!test_device->open)
2786 if (test_device->scanning
2787 && (test_device->val[opt_three_pass].w == SANE_FALSE
2788 && strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0))
2793 if (strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0
2794 && test_device->val[opt_three_pass].w == SANE_TRUE
2795 && test_device->pass > 2)
2801 if (test_device->pass == 0)
2803 test_device->number_of_scans++;
2804 DBG (3, "sane_start: scanning page %d\n", test_device->number_of_scans);
2806 if ((strcmp (test_device->val[opt_scan_source].s, "Automatic Document Feeder") == 0) &&
2807 (((test_device->number_of_scans) % 11) == 0))
2814 test_device->scanning = SANE_TRUE;
2815 test_device->cancelled = SANE_FALSE;
2816 test_device->eof = SANE_FALSE;
2817 test_device->bytes_total = 0;
2821 if (test_device->params.lines == 0)
2824 test_device->scanning = SANE_FALSE;
2827 if (test_device->params.pixels_per_line == 0)
2830 test_device->scanning = SANE_FALSE;
2833 if (test_device->params.bytes_per_line == 0)
2836 test_device->scanning = SANE_FALSE;
2847 test_device->pipe = pipe_descriptor[0];
2848 test_device->reader_fds = pipe_descriptor[1];
2849 test_device->reader_pid =
2850 sanei_thread_begin (reader_task, (void *) test_device);
2852 if (!sanei_thread_is_valid (test_device->reader_pid))
2861 close (test_device->reader_fds);
2862 test_device->reader_fds = -1;
2873 Test_Device *test_device = handle;
2877 size_t bytes_total = (size_t) test_device->lines * (size_t) test_device->bytes_per_line;
2898 if (strcmp (test_device->val[opt_read_status_code].s, "Default") != 0)
2900 SANE_String_Const sc = test_device->val[opt_read_status_code].s;
2927 if (test_device->val[opt_read_limit].w == SANE_TRUE
2928 && test_device->val[opt_read_limit_size].w < max_scan_length)
2930 max_scan_length = test_device->val[opt_read_limit_size].w;
2942 if (!test_device->open)
2947 if (test_device->cancelled)
2952 if (test_device->eof)
2957 if (!test_device->scanning)
2964 bytes_read = read (test_device->pipe, data, read_count);
2966 || ((size_t) bytes_read + (size_t) test_device->bytes_total >= bytes_total))
2970 status = finish_pass (test_device);
2977 test_device->eof = SANE_TRUE;
2978 if (strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0
2979 && test_device->val[opt_three_pass].w == SANE_TRUE)
2981 test_device->pass++;
2982 if (test_device->pass > 2)
2983 test_device->pass = 0;
3002 test_device->bytes_total += (size_t) bytes_read;
3005 (size_t) max_scan_length, (size_t) test_device->bytes_total);
3012 Test_Device *test_device = handle;
3025 if (!test_device->open)
3030 if (test_device->cancelled)
3035 if (!test_device->scanning)
3040 finish_pass (test_device);
3041 test_device->cancelled = SANE_TRUE;
3042 test_device->scanning = SANE_FALSE;
3043 test_device->eof = SANE_FALSE;
3044 test_device->pass = 0;
3051 Test_Device *test_device = handle;
3065 if (!test_device->open)
3070 if (!test_device->scanning)
3075 if (test_device->val[opt_non_blocking].w == SANE_TRUE)
3077 if (fcntl (test_device->pipe,
3096 Test_Device *test_device = handle;
3110 if (!test_device->open)
3115 if (!test_device->scanning)
3120 if (test_device->val[opt_select_fd].w == SANE_TRUE)
3122 *fd = test_device->pipe;