#include "kds_s2000w_option_descriptors.h"
#include "kds_s2000w_debug.h"
+#define FULL_PROFILE_MAX_OPTION_COUNT 47
+
option_descriptor** descriptors = NULL;
+uint8_t max_option_count = 0;
SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
{
void _kds_s2000w_option_descriptors_init_full_profile()
{
- descriptors = malloc(sizeof(option_descriptor*) * MAX_OPTION_COUNT);
- for (int i = 0; i < MAX_OPTION_COUNT; i++) {
+ max_option_count = FULL_PROFILE_MAX_OPTION_COUNT;
+
+ descriptors = malloc(sizeof(option_descriptor*) * max_option_count);
+ for (int i = 0; i < max_option_count; i++) {
descriptors[i] = malloc(sizeof(option_descriptor));
}
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors");
- for (int i = 0; i < MAX_OPTION_COUNT; i++) {
+ for (int i = 0; i < max_option_count; i++) {
if (descriptors[i]->descriptor.constraint_type == SANE_CONSTRAINT_STRING_LIST) {
free((void*) descriptors[i]->descriptor.constraint.string_list);
descriptors[i]->descriptor.constraint.string_list = NULL;
descriptors = NULL;
}
+uint8_t kds_s2000w_option_descriptors_get_max_option_count()
+{
+ return max_option_count;
+}
+
option_descriptor* kds_s2000w_option_descriptor_full_get_by_number(uint32_t number)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_full_get_by_number");
- if (number >= MAX_OPTION_COUNT)
+ if (number >= max_option_count)
return NULL;
return descriptors[number];
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_option_get_descriptor");
- if (number >= MAX_OPTION_COUNT)
+ if (number >= max_option_count)
return NULL;
return &descriptors[number]->descriptor;
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_get_by_name");
- for (int i = 0; i < MAX_OPTION_COUNT; i++) {
+ for (int i = 0; i < max_option_count; i++) {
if (strcmp(descriptors[i]->descriptor.name, name) == 0)
return &descriptors[i]->descriptor;
}
#include <stdint.h>
#include <sane/sane.h>
-#define MAX_OPTION_COUNT 47
#define OPTION_COUNT "OptionCount"
#define STANDARD_GROUP_NUMBER 1
void kds_s2000w_option_descriptors_init(uint8_t profile);
void kds_s2000w_option_descriptors_free();
+uint8_t kds_s2000w_option_descriptors_get_max_option_count();
option_descriptor* kds_s2000w_option_descriptor_full_get_by_number(uint32_t number);
SANE_Option_Descriptor* kds_s2000w_option_descriptors_get_by_number(uint32_t number);
SANE_Option_Descriptor* kds_s2000w_option_descriptors_get_by_name(const char* name);
#include "../src/kds_s2000w_net.h"
#include "../src/kds_s2000w_handler.h"
-#define MAX_OPTION_COUNT 47
+#define FULL_PROFILE_MAX_OPTION_COUNT 47
void sane_kds_s2000w_net_control_get_option_zero_test(void** state)
{
sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL);
- assert_int_equal(value, MAX_OPTION_COUNT);
+ assert_int_equal(value, FULL_PROFILE_MAX_OPTION_COUNT);
kds_s2000w_handler_free(h);
h = NULL;
#include "kds_s2000w_client_mock.h"
#include "../src/kds_s2000w_option_descriptors.h"
-#define MAX_OPTION_COUNT 47
-
int setup(void** state)
{
kds_s2000w_option_descriptors_init(0);
void kds_s2000w_option_get_descriptor_over_max_options_test()
{
- SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(MAX_OPTION_COUNT);
+ uint8_t max_option_count = kds_s2000w_option_descriptors_get_max_option_count();
+
+ SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get_by_number(max_option_count);
assert_null(option);
}
void kds_s2000w_option_full_get_descriptor_over_max_options_test()
{
- option_descriptor* option = kds_s2000w_option_descriptor_full_get_by_number(MAX_OPTION_COUNT);
+ uint8_t max_option_count = kds_s2000w_option_descriptors_get_max_option_count();
+
+ option_descriptor* option = kds_s2000w_option_descriptor_full_get_by_number(max_option_count);
assert_null(option);
}
\ No newline at end of file