修改Windows平台判断,为Win64作准备

This commit is contained in:
gb 2022-07-18 16:56:03 +08:00
parent 8cd888301a
commit 592bd6ce31
29 changed files with 75 additions and 77 deletions

View File

@ -1,5 +1,5 @@
#include "G4Tiff.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <io.h>
#else
#include <fcntl.h>

View File

@ -3,7 +3,7 @@
//#include <boost/thread/mutex.hpp>
//#include <boost/thread/condition_variable.hpp>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#endif
#include <mutex>

View File

@ -5,7 +5,7 @@
#include "PaperSize.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
class IMat2Bmp {
public:
virtual ~IMat2Bmp() {}

View File

@ -3,7 +3,7 @@
#include <map>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#endif
#include "common_setting.h"

View File

@ -21,7 +21,7 @@ typedef struct hg_tag_SIZE
typedef CSSIZE CSSIZEL;
typedef CSSIZE* PCSSIZEL, * LPCSSIZEL;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#else
typedef CSSIZE Size;

View File

@ -1,7 +1,7 @@
#ifndef FILE_TOOLS_H
#define FILE_TOOLS_H
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <vector>
#include <io.h>
#include <fstream>

View File

@ -2,7 +2,7 @@
#include "../wrapper/hg_log.h"
#include "huagao/hgscanner_error.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
//#include "scanner_manager.h"
#else
#include <string.h>
@ -32,7 +32,7 @@ void free_memory(void* ptr)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// windows event ...
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
int __stdcall sem_init(sem_t* handle, int, int)
{
if (!handle)
@ -160,7 +160,7 @@ shared_memory::~shared_memory()
void shared_memory::init(void)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char name[40] = { 0 };
DWORD* key = (DWORD*)&key_;
HANDLE h = NULL;
@ -244,7 +244,7 @@ void shared_memory::init(void)
void shared_memory::clear(void)
{
if (obj_ != (void*)-1)
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
CloseHandle((HANDLE)obj_);
#else
{
@ -261,7 +261,7 @@ void shared_memory::clear(void)
}
char* shared_memory::get_buf(void)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char* buf = (char*)MapViewOfFile((HANDLE)obj_, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if (!buf)
buf = (char*)-1;
@ -275,14 +275,14 @@ char* shared_memory::get_buf(void)
}
void shared_memory::release_buf(void* buf)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
UnmapViewOfFile(buf);
#else
shmdt(buf);
#endif
}
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN64)
std::string shared_memory::get_proc_name_by_pid(pid_t pid)
{
char path[512] = { 0 };
@ -378,7 +378,7 @@ HANDLE_NAME tiny_file_map::open_file_for_mapping(const char* file, unsigned* byt
{
HANDLE_NAME ret = INVALID_HANDLE_NAME;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
HANDLE f = INVALID_HANDLE_VALUE;
if (create)
{
@ -442,7 +442,7 @@ HANDLE_NAME tiny_file_map::open_file_for_mapping(const char* file, unsigned* byt
}
void tiny_file_map::close_handle_name(HANDLE_NAME h)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
CloseHandle(h);
#else
::close(h);
@ -452,7 +452,7 @@ void* tiny_file_map::sys_map_api(HANDLE_NAME h, int access, unsigned int off, un
{
void* mem = nullptr;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
mem = MapViewOfFile(h, access, 0, off, size);
if (err)
{
@ -484,7 +484,7 @@ void* tiny_file_map::sys_map_api(HANDLE_NAME h, int access, unsigned int off, un
}
void tiny_file_map::sys_unmap_api(void* buf, size_t size)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
UnmapViewOfFile(buf);
#else
munmap(buf, size);
@ -495,7 +495,7 @@ int tiny_file_map::map_to_mem(unsigned int off)
{
int err = SCANNER_ERR_OUT_OF_RANGE;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
int acc = FILE_MAP_READ | FILE_MAP_WRITE;
#else
int acc = PROT_READ | PROT_WRITE;

View File

@ -5,7 +5,7 @@
// created on 2022-03-01
//
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#define sem_t HANDLE
@ -120,7 +120,7 @@ class shared_memory : public refer
char* get_buf(void);
void release_buf(void* buf);
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN64)
static std::string get_proc_name_by_pid(pid_t pid);
#endif
@ -138,7 +138,7 @@ public:
};
// buffer
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define HANDLE_NAME HANDLE
#define INVALID_HANDLE_NAME NULL
#else

View File

@ -2,7 +2,7 @@
#include "../wrapper/hg_log.h"
#include "sane/sane_option_definitions.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#include <direct.h>
#endif
@ -161,7 +161,7 @@ std::string hg_scanner::temporary_file(char* tail, char* head)
if (!tail)
tail = (char*)"";
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char me[MAX_PATH] = { 0 }, * n = NULL;
GetModuleFileNameA(NULL, me, _countof(me) - 1);
@ -902,7 +902,7 @@ int hg_scanner::setting_help(int sn, void* data)
printf("helpfile = %s\r\n",helpfile.c_str());
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
com = "";
helpfile.insert(0, hg_log::get_scanner_path());
FILE* src = fopen(helpfile.c_str(), "rb");

View File

@ -21,7 +21,7 @@
#include "StopWatch.h"
#include "PaperSize.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#else
#include <unistd.h>
#endif
@ -329,6 +329,6 @@ public:
#else
static const std::string helpfile_ ="/opt/apps/scanner-driver-huagao/doc/HuaGoScan_scanSettings_Help_manual.pdf";//帮助文档路径
#endif
#elif defined(WIN32)
#elif defined(WIN32) || defined(_WIN64)
static const std::string helpfile_ = "docs\\help_setting.pdf";
#endif

View File

@ -1,7 +1,7 @@
#include "hg_scanner_200.h"
#include "../wrapper/hg_log.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif

View File

@ -2,7 +2,7 @@
#include "../wrapper/hg_log.h"
#include "filetools.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif

View File

@ -1,7 +1,7 @@
#include "hg_scanner_300.h"
#include "../wrapper/hg_log.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif

View File

@ -1,7 +1,7 @@
#include "hg_scanner_400.h"
#include "../wrapper/hg_log.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif

View File

@ -2,7 +2,7 @@
#include "../wrapper/hg_log.h"
#include "filetools.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif

View File

@ -3,7 +3,7 @@
#include <vector>
#include <string.h>
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN64)
#include <unistd.h>
#pragma pack(push)
#pragma pack(1)
@ -47,7 +47,7 @@ typedef struct BITMAPINFOHEADER
#include "ImageMultiOutput.h"
#include "PaperSize.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#include "ocr/hanwangOCRdetect.h"
#else
@ -607,7 +607,7 @@ namespace hg_imgproc
if (img_conf_.is_autotext)
rotatetype = CImageApplyRotation::RotationType::AutoTextOrientation;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char szIniFile[MAX_PATH] = {0};
SHGetSpecialFolderPathA(NULL, szIniFile, CSIDL_WINDOWS, TRUE);
strcat(szIniFile, "\\twain_32\\HuaGoScan\\tessdata");

View File

@ -6,11 +6,9 @@
if(code == cls) \
return #cls;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "scanner_manager.h"
#endif
#ifndef WIN32
#else
void memset(void* buf, unsigned char fill, int len)
{
unsigned char* data = (unsigned char*)buf;
@ -47,7 +45,7 @@ usb_manager::~usb_manager()
run_ = false;
wait_pnp_.notify();
libusb_context* ctx = nullptr;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
ctx = context_;
libusb_quit(ctx);
#endif
@ -98,7 +96,7 @@ void usb_manager::usb_log_callback(libusb_context* ctx, libusb_log_level level,
int usb_manager::register_usb_pnp(void)
{
libusb_context* ctx = nullptr;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
ctx = context_;
#endif
int ret = libusb_hotplug_register_callback(ctx, (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT),
@ -1138,7 +1136,7 @@ unsigned int usb_io::set_timeout(unsigned int to)
to_ = to;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
if (handle_)
{
libusb_set_timeout(handle_, to_);

View File

@ -1,6 +1,6 @@
#pragma once
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include "win_usb/win_usb.h"
#else
#include <libusb-1.0/libusb.h>

View File

@ -4,7 +4,7 @@
#include <stdio.h>
#include <string>
#include <stdarg.h>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#include <direct.h>
#include <Psapi.h>
@ -183,7 +183,7 @@ extern "C"
return true;
}
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
static std::string u2a(const wchar_t* u, UINT cp = CP_ACP)
{
std::string a("");
@ -300,7 +300,7 @@ extern "C"
}
std::string format_current_thread_id(void)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
return format_ptr((void*)GetCurrentThreadId());
#else
return format_ptr((void*)pthread_self());
@ -352,7 +352,7 @@ extern "C"
{
std::string utf8("");
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
utf8 = u2a(u, CP_UTF8);
#else
#endif
@ -360,7 +360,7 @@ extern "C"
}
std::string pe_path(std::string* name)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
wchar_t path[MAX_PATH] = { 0 }, * last = NULL;
GetModuleFileNameW(NULL, path, _countof(path) - 1);
@ -396,7 +396,7 @@ extern "C"
}
unsigned long long available_memory(void)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
MEMORYSTATUSEX ms;
if (GlobalMemoryStatusEx(&ms))
@ -433,7 +433,7 @@ extern "C"
ff.pattern = module_part_name;
str_tolower(ff.pattern);
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#else
sprintf(path, "/proc/%u/map_files/", getpid());
#endif
@ -448,7 +448,7 @@ extern "C"
unsigned int get_page_size(unsigned int* map_unit)
{
unsigned int ps = 1024;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
SYSTEM_INFO si = { 0 };
GetSystemInfo(&si);
@ -526,7 +526,7 @@ extern "C"
if (home.empty())
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
std::string env("LOCALAPPDATA"), lead("");
#else
std::string env("HOME"), lead(".");
@ -622,7 +622,7 @@ extern "C"
}
#endif
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
void hg_debug_log(int level, const char* info)
{
hg_log::log(level, info);

View File

@ -8,7 +8,7 @@
#include <string>
#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define bzero(a, l) memset(a, 0, l)
#define PATH_SEPARATOR "\\"
#define DLL_EXTESION ".dll"

View File

@ -1,9 +1,9 @@
#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h"
#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h"
#include "../wrapper/hg_log.h"
#include "../hgdev/scanner_manager.h"
#include <iostream>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <fileapi.h>
#else
#include <sys/vfs.h>
@ -37,7 +37,7 @@ extern "C"
path(PATH_SEPARATOR),
scanner(g_scanner_path),
sane(hg_log::get_module_full_path((g_sane_name + DLL_EXTESION).c_str()));
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
size_t pos = g_scanner_path.rfind('\\');
if (pos++ != std::string::npos)
g_scanner_path.erase(pos);
@ -284,7 +284,7 @@ extern "C"
{
int ret = SCANNER_ERR_OK;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
ULARGE_INTEGER av = { 0 },
all = { 0 };
if (GetDiskFreeSpaceExA(path, &av, &all, NULL))
@ -330,7 +330,7 @@ extern "C"
}
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
{

View File

@ -6,7 +6,7 @@
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define bzero(b, s) memset(b, 0, s)
#endif
@ -19,7 +19,7 @@ simple_ini::~simple_ini()
std::string simple_ini::temporary_path(void)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char path[MAX_PATH] = { 0 };
if (GetTempPathA(_countof(path) - 1, path))
@ -57,7 +57,7 @@ void simple_ini::trime(char*& ptr)
int simple_ini::load(const char* local_file)
{
int ret = 0;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
file_ = local_file;
#else
values_.clear();
@ -134,7 +134,7 @@ int simple_ini::load(const char* local_file)
return ret;
}
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN64)
int simple_ini::save(const char* local_file)
{
FILE* dst = fopen(local_file, "wb");
@ -164,7 +164,7 @@ int simple_ini::save(const char* local_file)
std::string simple_ini::get(const char* sec, const char* key, const char* default_val)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
char str[MAX_PATH] = { 0 };
GetPrivateProfileStringA(sec, key, default_val, str, _countof(str), file_.c_str());
@ -183,7 +183,7 @@ std::string simple_ini::get(const char* sec, const char* key, const char* defaul
}
void simple_ini::set(const char* sec, const char* key, const char* val)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
WritePrivateProfileStringA(sec, key, val, file_.c_str());
#else
std::vector<SECKEY>::iterator it = std::find(values_.begin(), values_.end(), sec);
@ -217,7 +217,7 @@ void simple_ini::set(const char* sec, const char* key, const char* val)
}
void simple_ini::remove(const char* sec, const char* key)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#else
std::vector<SECKEY>::iterator it = std::find(values_.begin(), values_.end(), sec);
if (it == values_.end())
@ -230,7 +230,7 @@ void simple_ini::remove(const char* sec, const char* key)
}
void simple_ini::remove(const char* sec)
{
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
std::vector<SECKEY>::iterator it = std::find(values_.begin(), values_.end(), sec);
if (it != values_.end())
values_.erase(it);

View File

@ -1,6 +1,6 @@
#pragma once
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#else
#include <string.h>
@ -42,7 +42,7 @@ class simple_ini
}SECKEY;
std::vector<SECKEY> values_;
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
std::string file_;
#endif
@ -56,7 +56,7 @@ public:
public:
int load(const char* local_file);
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN64)
int save(const char* local_file);
#endif

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define bzero(b, s) memset(b, 0, s)
#endif

View File

@ -1,6 +1,6 @@
#pragma once
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#endif

View File

@ -5,7 +5,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <mutex>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#include <windows.h>
#include <direct.h>
#define pthread_t DWORD
@ -335,7 +335,7 @@ hg_sane_middleware::hg_sane_middleware(void) : opt_0_(nullptr), std_opt_(nullptr
hg_scanner_set_sane_info(g_sane_name.c_str(), sane_ver);
hg_scanner_initialize(local_utility::ui_cb, NULL);
#ifndef WIN32
#if defined(WIN32) || defined(_WIN64)
char path[512] = { 0 };
size_t pos = 0;
@ -2020,7 +2020,7 @@ extern "C" { // avoid compiler exporting name in C++ style !!!
}
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
HMODULE g_my_inst = NULL;
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
{

View File

@ -7,7 +7,7 @@
#include <algorithm>
#include <string>
#include <stdio.h>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define bzero(b, s) memset(b, 0, s)
#else
#include <iconv.h>

View File

@ -7,7 +7,7 @@
#include <algorithm>
#include <string>
#include <stdio.h>
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#define bzero(b, s) memset(b, 0, s)
#else
#include <iconv.h>

View File

@ -27,7 +27,7 @@
#include "huagao/hgscanner_error.h"
#include "sane/sane_ex.h"
#ifdef WIN32
#if defined(WIN32) || defined(_WIN64)
#ifndef HGSCANNER_EXPORT
#ifdef _DEBUG
#pragma comment(lib, "debug/scanner.lib")