63 lines
1.7 KiB
C
63 lines
1.7 KiB
C
|
#pragma once
|
||
|
|
||
|
#include <signal.h>
|
||
|
#include <string.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <vector>
|
||
|
#include <algorithm>
|
||
|
#include <string>
|
||
|
#include <stdio.h>
|
||
|
#ifdef WIN32
|
||
|
#define bzero(b, s) memset(b, 0, s)
|
||
|
#else
|
||
|
#include <iconv.h>
|
||
|
#endif
|
||
|
#include "../sdk/hginclude/huagaoxxx_warraper_ex.h"
|
||
|
#include "sane/sane_ex.h"
|
||
|
#include "json.h"
|
||
|
|
||
|
namespace local_utility
|
||
|
{
|
||
|
void* acquire_memory(size_t bytes, const char* info);
|
||
|
void free_memory(void* m);
|
||
|
};
|
||
|
|
||
|
class sane_std_opts
|
||
|
{
|
||
|
typedef struct _sane_opt
|
||
|
{
|
||
|
SANE_Option_Descriptor* desc;
|
||
|
int opt;
|
||
|
}SANEOPT;
|
||
|
typedef struct _opt_map
|
||
|
{
|
||
|
SANEOPT known;
|
||
|
SANEOPT user;
|
||
|
}OPTMAP;
|
||
|
std::vector<OPTMAP> known_opts_;
|
||
|
int opt_num_base_;
|
||
|
int page_width_;
|
||
|
int page_height_;
|
||
|
|
||
|
SANE_Option_Descriptor* get_known_option(int opt, int* ind = nullptr);
|
||
|
SANE_Option_Descriptor* get_known_option(const char* name, int* ind = nullptr);
|
||
|
void to_known_opt_value(OPTMAP* opmap, const void* data, void* known_data);
|
||
|
void* from_known_opt_value(OPTMAP* opmap, const void* known_data, long* len);
|
||
|
|
||
|
public:
|
||
|
sane_std_opts(int opt_base);
|
||
|
~sane_std_opts();
|
||
|
|
||
|
public:
|
||
|
static json* get_opt_json(scanner_handle h, int opt); // call delete to free the returned object
|
||
|
static void* get_current_value(scanner_handle h, int opt); // call local_utility::free_memory to free the returned buffer
|
||
|
|
||
|
public:
|
||
|
void init_known_opt(int option, SANE_Option_Descriptor* desc);
|
||
|
SANE_Option_Descriptor* get_option(int option);
|
||
|
|
||
|
bool is_known_option(int opt, SANE_Option_Descriptor** user = nullptr);
|
||
|
scanner_err get_value(scanner_handle h, int opt, void* buf); // call this ONLY when is_known_option returnning true
|
||
|
scanner_err set_value(scanner_handle h, int opt, void* buf); // call this ONLY when is_known_option returnning true
|
||
|
};
|