/*******************************************************************************
* profiles
******************************************************************************/
-void _kds_s2000w_option_descriptors_init_min_profile()
+SANE_Status _kds_s2000w_option_descriptors_init_min_profile()
{
max_option_count = PROFILE_MIN_MAX_OPTION_COUNT;
descriptors = malloc(sizeof(option_descriptor*) * max_option_count);
+ if (descriptors == NULL)
+ return SANE_STATUS_NO_MEM;
+
for (int i = 0; i < max_option_count; i++) {
descriptors[i] = malloc(sizeof(option_descriptor));
+ if (descriptors[i] == NULL) {
+ kds_s2000w_option_descriptors_free(descriptors);
+ descriptors = NULL;
+ return SANE_STATUS_NO_MEM;
+ }
}
descriptors[0]->config_name = OPTION_COUNT;
descriptors[10]->descriptor = _kds_s2000w_option_descriptor_feeder_group();
descriptors[11]->config_name = AUTOSTART;
descriptors[11]->descriptor = _kds_s2000w_option_descriptor_autostart();
+
+ return SANE_STATUS_GOOD;
}
-void _kds_s2000w_option_descriptors_init_230802_v1_0_36_profile()
+SANE_Status _kds_s2000w_option_descriptors_init_230802_v1_0_36_profile()
{
max_option_count = PROFILE_230802_V1_0_36_MAX_OPTION_COUNT;
descriptors = malloc(sizeof(option_descriptor*) * max_option_count);
+ if (descriptors == NULL)
+ return SANE_STATUS_NO_MEM;
+
for (int i = 0; i < max_option_count; i++) {
descriptors[i] = malloc(sizeof(option_descriptor));
+ if (descriptors[i] == NULL) {
+ kds_s2000w_option_descriptors_free(descriptors);
+ descriptors = NULL;
+ return SANE_STATUS_NO_MEM;
+ }
}
descriptors[0]->config_name = OPTION_COUNT;
descriptors[24]->descriptor = _kds_s2000w_option_descriptor_feeder_group();
descriptors[25]->config_name = AUTOSTART;
descriptors[25]->descriptor = _kds_s2000w_option_descriptor_autostart();
+
+ return SANE_STATUS_GOOD;
}
-void _kds_s2000w_option_descriptors_init_full_profile()
+SANE_Status _kds_s2000w_option_descriptors_init_full_profile()
{
max_option_count = PROFILE_FULL_MAX_OPTION_COUNT;
descriptors = malloc(sizeof(option_descriptor*) * max_option_count);
+ if (descriptors == NULL)
+ return SANE_STATUS_NO_MEM;
+
for (int i = 0; i < max_option_count; i++) {
descriptors[i] = malloc(sizeof(option_descriptor));
+ if (descriptors[i] == NULL) {
+ kds_s2000w_option_descriptors_free(descriptors);
+ descriptors = NULL;
+ return SANE_STATUS_NO_MEM;
+ }
}
descriptors[0]->config_name = OPTION_COUNT;
descriptors[46]->descriptor = _kds_s2000w_option_descriptor_document_feeder_timeout();
descriptors[47]->config_name = DOCUMENT_FEEDER_TIMEOUT_RESPONSE;
descriptors[47]->descriptor = _kds_s2000w_option_descriptor_document_feeder_timeout_response();
+
+ return SANE_STATUS_GOOD;
}
/*******************************************************************************
* public methods
******************************************************************************/
-void kds_s2000w_option_descriptors_init(uint8_t profile)
+SANE_Status kds_s2000w_option_descriptors_init(uint8_t profile)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptors_init");
switch (profile) {
case PROFILE_FULL:
- _kds_s2000w_option_descriptors_init_full_profile();
+ return _kds_s2000w_option_descriptors_init_full_profile();
break;
case PROFILE_230802_V1_0_36:
- _kds_s2000w_option_descriptors_init_230802_v1_0_36_profile();
+ return _kds_s2000w_option_descriptors_init_230802_v1_0_36_profile();
break;
default:
- _kds_s2000w_option_descriptors_init_min_profile();
+ return _kds_s2000w_option_descriptors_init_min_profile();
break;
}
+
+ return SANE_STATUS_INVAL;
}
void kds_s2000w_option_descriptors_free()