#pragma once // For: check and load scanner configuration json // // Date: 2022-08-12 // // FileName: 0239.hsc // // Location: same parent path of scanner component, rel: ./settings // // Format: 0: short - 1.2, version of the file format // // 2: int - total length of the whole file, include this head // // 6: unsigned - checksum of content // // 10: BASE64 of the json content #include #pragma pack(push) #pragma pack(1) typedef struct _scanner_setting_file_head { unsigned char ver_main; unsigned char ver_sub; unsigned int length; // whole file length, include this head unsigned int checksum; // checksum of BASE64 content unsigned int timestamp; // time(NULL) char base64_content[0]; }SSFILEH, *LPSSFILEH; #pragma pack(pop) class base64 { char base64_ind_[128]; char base64_char_[80]; char padding_char_; bool is_valid_base64_table(const char* table); bool initialize_base64_table(const char* table); public: base64(); ~base64(); public: bool set_base64_table(const char* table = nullptr); std::string encode(const char* data, size_t bytes, unsigned int line_bytes = -1, bool need_padding = true); std::string decode(const char* data, size_t bytes); }; // return 0 for success, otherwise error code int load_scanner_setting(const char* file, std::string& jsn); int save_scanner_setting(const char* file, const std::string& jsn);