Lines Matching refs:opt

245 						const SANE_Option_Descriptor *opt,
253 check(FATAL, (opt->type == SANE_TYPE_INT ||
254 opt->type == SANE_TYPE_FIXED),
255 "type must be SANE_TYPE_INT or SANE_TYPE_FIXED (%d)", opt->type);
257 if (!SANE_OPTION_IS_SETTABLE(opt->cap)) return;
259 for (i=1; i<opt->constraint.word_list[0]; i++) {
263 val_int = opt->constraint.word_list[i];
282 if (!SANE_OPTION_IS_ACTIVE(opt->cap) ||
283 !SANE_OPTION_IS_SETTABLE(opt->cap))
292 const SANE_Option_Descriptor *opt,
300 check(FATAL, (opt->type == SANE_TYPE_STRING),
301 "type must be SANE_TYPE_STRING (%d)", opt->type);
303 if (!SANE_OPTION_IS_SETTABLE(opt->cap)) return;
305 for (i=0; opt->constraint.string_list[i] != NULL; i++) {
307 val_string = strdup(opt->constraint.string_list[i]);
310 check(WRN, (strlen(val_string) < (size_t)opt->size),
312 val_string, opt->size);
335 if (!SANE_OPTION_IS_ACTIVE(opt->cap) ||
336 !SANE_OPTION_IS_SETTABLE(opt->cap))
348 const SANE_Option_Descriptor *opt;
356 opt = sane_get_option_descriptor (device, 0);
357 check(FATAL, (opt != NULL),
359 check(INF, (opt->cap == SANE_CAP_SOFT_DETECT),
360 "invalid capabilities for option 0 (%d)", opt->cap);
361 check(ERR, (opt->type == SANE_TYPE_INT),
382 opt = sane_get_option_descriptor (device, option_num);
383 check(FATAL, (opt != NULL),
385 check(WRN, ((opt->cap & ~(SANE_CAP_SOFT_SELECT |
392 "invalid capabilities for option [%d, %s] (%x)", option_num, opt->name, opt->cap);
393 check(WRN, (opt->title != NULL),
394 "option [%d, %s] must have a title", option_num, opt->name);
395 check(WRN, (opt->desc != NULL),
396 "option [%d, %s] must have a description", option_num, opt->name);
398 if (!SANE_OPTION_IS_ACTIVE (opt->cap)) {
404 printf("checking option ""%s""\n",opt->title);
407 if (opt->type == SANE_TYPE_GROUP) {
408 check(INF, (opt->name == NULL || *opt->name == 0),
409 "option [%d, %s] has a name", option_num, opt->name);
410 check(ERR, (!SANE_OPTION_IS_SETTABLE (opt->cap)),
411 "option [%d, %s], group option is settable", option_num, opt->name);
414 check(ERR, (opt->name != NULL && *opt->name ==0),
417 check(ERR, (opt->name != NULL && *opt->name !=0),
424 if (opt->name && opt->name[0]) {
425 const char *p = opt->name;
429 option_num, opt->name);
438 option_num, opt->name);
446 switch(opt->type) {
448 check(WRN, (opt->size == sizeof(SANE_Word)),
449 "size of option %s is incorrect", opt->name);
450 optval = guards_malloc(opt->size);
451 optsize = opt->size;
452 check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE),
453 "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type);
458 check(WRN, (opt->size > 0 && (opt->size % sizeof(SANE_Word) == 0)),
459 "invalid size for option %s", opt->name);
460 optval = guards_malloc(opt->size);
461 optsize = opt->size;
462 check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE ||
463 opt->constraint_type == SANE_CONSTRAINT_RANGE ||
464 opt->constraint_type == SANE_CONSTRAINT_WORD_LIST),
465 "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type);
469 check(WRN, (opt->size >= 1),
470 "size of option [%d, %s] must be at least 1 for the NUL terminator", option_num, opt->name);
471 check(INF, (opt->unit == SANE_UNIT_NONE),
472 "unit of option [%d, %s] is not SANE_UNIT_NONE", option_num, opt->name);
473 check(WRN, (opt->constraint_type == SANE_CONSTRAINT_STRING_LIST ||
474 opt->constraint_type == SANE_CONSTRAINT_NONE),
475 "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type);
476 optval = guards_malloc(opt->size);
477 optsize = opt->size;
482 check(INF, (opt->unit == SANE_UNIT_NONE),
483 "option [%d, %s], unit is not SANE_UNIT_NONE", option_num, opt->name);
484 check(INF, (opt->size == 0),
485 "option [%d, %s], size is not 0", option_num, opt->name);
486 check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE),
487 "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type);
493 opt->type, opt->name);
513 if (SANE_OPTION_IS_GETTABLE (opt->cap)) {
515 "cannot get option [%d, %s] value, although it is active (%s)", option_num, opt->name, sane_strstatus(status));
518 "was able to get option [%d, %s] value, although it is not active", option_num, opt->name);
526 if (SANE_OPTION_IS_SETTABLE (opt->cap) && SANE_OPTION_IS_ACTIVE (opt->cap)) {
528 "cannot set option [%d, %s] value, although it is active and settable (%s)", option_num, opt->name, sane_strstatus(status));
531 "was able to set option [%d, %s] value, although it is not active or settable", option_num, opt->name);
541 if (SANE_OPTION_IS_GETTABLE (opt->cap)) {
543 "cannot get option [%d, %s] value, although it is active (%s)", option_num, opt->name, sane_strstatus(status));
546 "was able to get option [%d, %s] value, although it is not active", option_num, opt->name);
549 "when getting option [%d, %s], info was set to %x", option_num, opt->name, info);
557 if (SANE_OPTION_IS_SETTABLE (opt->cap) && SANE_OPTION_IS_ACTIVE (opt->cap)) {
559 "cannot set option [%d, %s] value, although it is active and settable (%s)", option_num, opt->name, sane_strstatus(status));
571 "was able to set option [%d, %s] value, although it is not active or settable", option_num, opt->name);
579 if (SANE_OPTION_IS_SETTABLE (opt->cap) &&
580 SANE_OPTION_IS_ACTIVE (opt->cap) &&
581 (opt->cap & SANE_CAP_AUTOMATIC)) {
583 "cannot set the option [%d, %s] automatically.", option_num, opt->name);
586 "was able to automatically set option [%d, %s], although it is not active or settable or automatically settable", option_num, opt->name);
599 check(ERR, ((opt->cap & (SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_SELECT)) !=
601 "option [%d, %s], SANE_CAP_HARD_SELECT and SANE_CAP_SOFT_SELECT are mutually exclusive", option_num, opt->name);
602 if (opt->cap & SANE_CAP_SOFT_SELECT) {
603 check(ERR, ((opt->cap & SANE_CAP_SOFT_DETECT) != 0),
604 "option [%d, %s], SANE_CAP_SOFT_DETECT must be set if SANE_CAP_SOFT_SELECT is set", option_num, opt->name);
606 if ((opt->cap & (SANE_CAP_SOFT_SELECT |
609 check(ERR, (!SANE_OPTION_IS_SETTABLE (opt->cap)),
610 "option [%d, %s], must not be settable", option_num, opt->name);
613 if (!SANE_OPTION_IS_SETTABLE (opt->cap)) {
620 if (opt->type == SANE_TYPE_STRING) {
624 optstr = guards_malloc(opt->size);
625 val_string2 = guards_malloc(opt->size);
628 strncpy(optstr, "-pOiSoN-", opt->size-1);
629 optstr[opt->size-1] = 0;
632 guards_set(optstr, opt->size);
635 guards_check(optstr, opt->size);
637 "cannot get option [%d, %s] value", option_num, opt->name);
642 guards_set(optstr, opt->size);
645 guards_check(optstr, opt->size);
647 "cannot set option [%d, %s] value", option_num, opt->name);
650 strncpy(optstr, "-pOiSoN-", opt->size-1);
651 optstr[opt->size-1] = 0;
654 guards_set(val_string2, opt->size);
657 guards_check(val_string2, opt->size);
659 "cannot get option [%d, %s] value", option_num, opt->name);
662 "sane_control_option did not copy the string parameter for option [%d, %s]", option_num, opt->name);
669 if (opt->type == SANE_TYPE_BOOL) {
676 "cannot get boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status));
688 org_v, option_num, opt->name);
695 "cannot set boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status));
708 "cannot set boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status));
718 switch(opt->type) {
726 "was able to set an invalid value for boolean option [%d, %s]", option_num, opt->name);
732 "was able to set an invalid value for boolean option [%d, %s]", option_num, opt->name);
741 v = guards_malloc(opt->size);
746 if (opt->constraint_type == SANE_CONSTRAINT_RANGE) {
747 for(i=0; i<opt->size / sizeof(SANE_Int); i++)
748 v[i] = opt->constraint.range->min - 1; /* invalid range */
750 guards_set(v, opt->size);
753 guards_check(v, opt->size);
755 "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info);
758 guards_set(v, opt->size);
761 guards_check(v, opt->size);
763 "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info);
766 for(i=0; i<opt->size / sizeof(SANE_Int); i++)
767 v[i] = opt->constraint.range->max + 1; /* invalid range */
769 guards_set(v, opt->size);
772 guards_check(v, opt->size);
774 "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info);
777 guards_set(v, opt->size);
780 guards_check(v, opt->size);
782 "incorrect return when setting a valid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info);
802 switch(opt->constraint_type) {
804 check(FATAL, (opt->constraint.word_list != NULL),
805 "no constraint list for option [%d, %s]", option_num, opt->name);
806 test_options_word_list (device, option_num, opt, can_do_recursive);
810 check(FATAL, (opt->constraint.string_list != NULL),
811 "no constraint list for option [%d, %s]", option_num, opt->name);
812 test_options_string_list (device, option_num, opt, can_do_recursive);
816 check(FATAL, (opt->constraint.range != NULL),
817 "no constraint range for option [%d, %s]", option_num, opt->name);
818 check(FATAL, (opt->constraint.range->max >= opt->constraint.range->min),
820 option_num, opt->name, opt->constraint.range->min, opt->constraint.range->max);
828 check(INF, (opt->constraint.range == NULL),
829 "option [%d, %s] has some constraint value set", option_num, opt->name);
842 opt = sane_get_option_descriptor (device, -1);
843 check(ERR, (opt == NULL),
846 opt = sane_get_option_descriptor (device, num_dev_options+1);
847 check(ERR, (opt == NULL),
850 opt = sane_get_option_descriptor (device, num_dev_options+2);
851 check(ERR, (opt == NULL),
854 opt = sane_get_option_descriptor (device, num_dev_options+50);
855 check(ERR, (opt == NULL),
862 const SANE_Option_Descriptor *opt;
874 opt = sane_get_option_descriptor (device, *option_num);
875 check(FATAL, (opt != NULL),
878 if (opt->name && strcmp(opt->name, name) == 0) {
879 return(opt);
888 const SANE_Option_Descriptor *opt)
895 check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)),
898 switch(opt->constraint_type) {
900 rc = check(ERR, (opt->constraint.word_list[0] > 0),
901 "no value in the list for option %s", opt->name);
903 val_int = opt->constraint.word_list[1];
907 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
911 rc = check(ERR, (opt->constraint.string_list[0] != NULL),
912 "no value in the list for option %s", opt->name);
914 val_string = strdup(opt->constraint.string_list[0]);
919 "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status));
924 val_int = opt->constraint.range->min;
928 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
939 const SANE_Option_Descriptor *opt)
947 check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)),
950 switch(opt->constraint_type) {
952 rc = check(ERR, (opt->constraint.word_list[0] > 0),
953 "no value in the list for option %s", opt->name);
955 val_int = opt->constraint.word_list[opt->constraint.word_list[0]];
959 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
963 rc = check(ERR, (opt->constraint.string_list[0] != NULL),
964 "no value in the list for option %s", opt->name);
966 for (i=1; opt->constraint.string_list[i] != NULL; i++);
967 val_string = strdup(opt->constraint.string_list[i-1]);
972 "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status));
977 val_int = opt->constraint.range->max;
981 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
991 const SANE_Option_Descriptor *opt)
999 check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)),
1002 switch(opt->constraint_type) {
1004 rc = check(ERR, (opt->constraint.word_list[0] > 0),
1005 "no value in the list for option %s", opt->name);
1007 i=1+(rand() % opt->constraint.word_list[0]);
1008 val_int = opt->constraint.word_list[i];
1012 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
1016 rc = check(ERR, (opt->constraint.string_list[0] != NULL),
1017 "no value in the list for option %s", opt->name);
1019 for (i=0; opt->constraint.string_list[i] != NULL; i++);
1021 val_string = strdup(opt->constraint.string_list[0]);
1026 "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status));
1031 i = opt->constraint.range->max - opt->constraint.range->min;
1033 val_int = opt->constraint.range->min + i;
1037 "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status));
1050 const SANE_Option_Descriptor *opt;
1056 opt = get_optdesc_by_name(device, option_name, &optnum);
1057 if (opt) {
1059 optval = guards_malloc(opt->size);
1064 switch(opt->type) {
1129 const SANE_Option_Descriptor *opt;
1147 opt = get_optdesc_by_name(device, SANE_NAME_SCAN_TL_X, &option_num);
1148 if (opt) set_min_value(device, option_num, opt);
1150 opt = get_optdesc_by_name(device, SANE_NAME_SCAN_TL_Y, &option_num);
1151 if (opt) set_min_value(device, option_num, opt);
1153 opt = get_optdesc_by_name(device, SANE_NAME_SCAN_BR_X, &option_num);
1154 if (opt) set_max_value(device, option_num, opt);
1156 opt = get_optdesc_by_name(device, SANE_NAME_SCAN_BR_Y, &option_num);
1157 if (opt) set_max_value(device, option_num, opt);