From cb6d1c89436800a60976779763f64bd4a66e4e4c Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:20:29 +0800 Subject: [PATCH] Windows building. --- .gitignore | 12 ++ CMakeLists.txt | 140 +++++++++++++++++++++ cmake/zbarConfig.cmake.in | 5 + win32/config.h | 246 ++++++++++++++++++++++++++++++++++++ win32/zbar.vcxproj | 251 +++++++++++++++++++++++++++++++++++++ win32/zbar.vcxproj.filters | 159 +++++++++++++++++++++++ win32/zbar_qrcode.sln | 29 +++++ zbar/decoder.h | 3 +- zbar/image.c | 6 +- zbar/img_scanner.c | 15 ++- zbar/processor.c | 68 ++++++---- zbar/processor/lock.c | 20 +-- zbar/symbol.c | 54 ++++---- zbar/thread.h | 2 +- 14 files changed, 946 insertions(+), 64 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/zbarConfig.cmake.in create mode 100644 win32/config.h create mode 100644 win32/zbar.vcxproj create mode 100644 win32/zbar.vcxproj.filters create mode 100644 win32/zbar_qrcode.sln diff --git a/.gitignore b/.gitignore index 6fd3bd2..d8566fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ +build/ +Debug/ +Release/ +x64/ +.vs/ +.vscode/ +*.sdf +*.suo +*.vcxproj.user +*.ipch +*.opensdf + *.la *.lo *.o diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0a2dd2f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,140 @@ +project(zbar_qrcode) +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +set(CMAKE_THREAD_PREFER_PTHREAD ON) +find_package(Threads QUIET) +find_package(Iconv QUIET) + +find_file(HAVE_INTTYPES_H "inttypes.h" DOC "inttypes.h exists") +find_file(HAVE_FEATURES_H "features.h" DOC "features.h exists") +find_file(HAVE_POLL_H "poll.h" DOC "poll.h exists") +find_file(HAVE_SYS_TIME_H "sys/time.h" DOC "sys/time.h exists") + +add_library(zbar + zbar/decoder/qr_finder.c + zbar/qrcode/qrdec.c + zbar/qrcode/qrdectxt.c + zbar/qrcode/rs.c + zbar/qrcode/isaac.c + zbar/qrcode/bch15_5.c + zbar/qrcode/binarize.c + zbar/qrcode/util.c + zbar/processor/posix.c + zbar/symbol.c + zbar/image.c + zbar/video.c + zbar/img_scanner.c + zbar/scanner.c + zbar/window.c + zbar/decoder.c + zbar/refcnt.c + zbar/processor/lock.c + zbar/processor.c + zbar/convert.c + zbar/error.c + zbar/video/null.c + zbar/processor/null.c + zbar/window/null.c + + include/zbar.h + zbar/decoder/qr_finder.h + zbar/qrcode.h + zbar/qrcode/qrdec.h + zbar/qrcode/rs.h + zbar/qrcode/isaac.h + zbar/qrcode/bch15_5.h + zbar/qrcode/binarize.h + zbar/qrcode/util.h + zbar/error.h + zbar/symbol.h + zbar/image.h + zbar/processor.h + zbar/refcnt.h + zbar/timer.h + zbar/mutex.h + zbar/event.h + zbar/thread.h + zbar/window.h + zbar/video.h + zbar/img_scanner.h + zbar/decoder.h + zbar/processor/posix.h +) +target_compile_definitions(zbar + PRIVATE + ENABLE_QRCODE + ZBAR_VERSION_MAJOR=0 + ZBAR_VERSION_MINOR=23 + ZBAR_VERSION_PATCH=0 +) + +if (HAVE_INTTYPES_H) + target_compile_definitions(zbar PRIVATE HAVE_INTTYPES_H=1) +endif() +if (HAVE_FEATURES_H) + target_compile_definitions(zbar PRIVATE HAVE_FEATURES_H=1) +endif() +if (HAVE_POLL_H) + target_compile_definitions(zbar PRIVATE HAVE_POLL_H=1) +endif() +if (HAVE_SYS_TIME_H) + target_compile_definitions(zbar PRIVATE HAVE_SYS_TIME_H=1) +endif() +if(THREADS_FOUND) + target_compile_definitions(zbar PRIVATE HAVE_LIBPTHREAD=1) + target_link_libraries(zbar + PRIVATE + Threads::Threads + ) +endif() +if (ICONV_FOUND) + target_link_libraries(zbar + PRIVATE + Iconv::Iconv + ) +endif() +target_include_directories(zbar + PUBLIC + $ + $ + PRIVATE + zbar + zbar/qrcode + zbar/decoder +) + +install(TARGETS zbar EXPORT zbarTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install( + FILES include/zbar.h + DESTINATION include/zbar +) +# Package configuration +if(THREADS_FOUND) + set(find_pkg_dependencies "find_dependency(Threads)") +else() + set(find_pkg_dependencies "") +endif() +set(configPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zbar) +set(inputConfigFile "${CMAKE_CURRENT_SOURCE_DIR}/cmake/zbarConfig.cmake.in") +set(outputConfigFile "${CMAKE_CURRENT_BINARY_DIR}/zbarConfig.cmake") + configure_file(${inputConfigFile} ${outputConfigFile} @ONLY) +install(FILES ${outputConfigFile} + DESTINATION ${configPackageLocation} +) +export(EXPORT zbarTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/zbarTargets.cmake" + NAMESPACE zbar:: +) + +install(EXPORT zbarTargets + NAMESPACE zbar:: + DESTINATION ${configPackageLocation} +) diff --git a/cmake/zbarConfig.cmake.in b/cmake/zbarConfig.cmake.in new file mode 100644 index 0000000..58831f2 --- /dev/null +++ b/cmake/zbarConfig.cmake.in @@ -0,0 +1,5 @@ +include(CMakeFindDependencyMacro) + +@find_pkg_dependencies@ + +include("${CMAKE_CURRENT_LIST_DIR}/zbarTargets.cmake") diff --git a/win32/config.h b/win32/config.h new file mode 100644 index 0000000..809d5bd --- /dev/null +++ b/win32/config.h @@ -0,0 +1,246 @@ +/* manually customized for iPhone platform */ + +/* whether to build support for Code 128 symbology */ +#define ENABLE_CODE128 1 + +/* whether to build support for Code 93 symbology */ +#define ENABLE_CODE93 1 + +/* whether to build support for Code 39 symbology */ +#define ENABLE_CODE39 1 + +/* whether to build support for Codabar symbology */ +#define ENABLE_CODABAR 1 + +/* whether to build support for DataBar symbology */ +#define ENABLE_DATABAR 1 + +/* whether to build support for EAN symbologies */ +#define ENABLE_EAN 1 + +/* whether to build support for Interleaved 2 of 5 symbology */ +#define ENABLE_I25 1 + +/* whether to build support for PDF417 symbology */ +#undef ENABLE_PDF417 + +/* whether to build support for QR Code */ +#define ENABLE_QRCODE 1 + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FEATURES_H + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define to 1 if you have the header file. */ +//#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_JPEGLIB_H + +/* Define to 1 if you have the `jpeg' library (-ljpeg). */ +#undef HAVE_LIBJPEG + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#undef HAVE_LIBPTHREAD + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV2_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV_H + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_POLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SHM_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFW_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XSHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XVLIB_H + +/* Define as const if the declaration of iconv() needs const. */ +#undef ICONV_CONST + +/* Library major version */ +#define LIB_VERSION_MAJOR 0 + +/* Library minor version */ +#define LIB_VERSION_MINOR 2 + +/* Library revision */ +#define LIB_VERSION_REVISION 0 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if assertions should be disabled. */ +//#undef NDEBUG + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#define PACKAGE "zbar" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "spadix@users.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "zbar" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "zbar 0.10" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "zbar" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.10" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.10" + +/* Define to 1 if the X Window System is missing or not being used. */ +#define X_DISPLAY_MISSING 1 + +/* Program major version (before the '.') as a number */ +#define ZBAR_VERSION_MAJOR 0 + +/* Program minor version (after '.') as a number */ +#define ZBAR_VERSION_MINOR 23 + +/* Program minor version (after the second '.') as a number */ +#define ZBAR_VERSION_PATCH 0 + +//HAVE_LIBPTHREAD=1 +//CMAKE_INTDIR="Debug" + +#define PRIX32 "lX" +#define PRIx32 "lx" + +#define snprintf _snprintf + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Minimum Windows API version */ +//#undef _WIN32_WINNT + +/* used only for pthread debug attributes */ +#undef __USE_UNIX98 + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#define inline __inline +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +//#undef int32_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +//#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +//#undef uint8_t + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +//#undef uintptr_t + +#ifndef X_DISPLAY_MISSING +# define HAVE_X +#endif + diff --git a/win32/zbar.vcxproj b/win32/zbar.vcxproj new file mode 100644 index 0000000..df6f647 --- /dev/null +++ b/win32/zbar.vcxproj @@ -0,0 +1,251 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + MinSizeRel + Win32 + + + RelWithDebInfo + Win32 + + + + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760} + Win32Proj + Win32 + zbar + + + + DynamicLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + + + + + + + + <_ProjectFileVersion>10.0.20506.1 + C:\Users\Administrator\Desktop\zbar\build\Release\ + zbar.dir\Release\ + zbar + .lib + C:\Users\Administrator\Desktop\zbar\build\MinSizeRel\ + zbar.dir\MinSizeRel\ + zbar + .lib + C:\Users\Administrator\Desktop\zbar\build\RelWithDebInfo\ + zbar.dir\RelWithDebInfo\ + zbar + .lib + + + + ..\include;..\zbar;..\zbar\qrcode;..\zbar\decoder;.;%(AdditionalIncludeDirectories) + EnableFastChecks + ProgramDatabase + + + Disabled + Disabled + MultiThreadedDebugDLL + Level3 + WIN32;_WINDOWS;ENABLE_QRCODE;%(PreprocessorDefinitions) + 4996;%(DisableSpecificWarnings) + + + WIN32;_DEBUG;_WINDOWS;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions) + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(ProjectDir)/$(IntDir) + %(Filename).h + %(Filename).tlb + %(Filename)_i.c + %(Filename)_p.c + + + %(AdditionalOptions) /machine:X86 + + + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(IntDir) + + + AnySuitable + MaxSpeed + NotUsing + MultiThreadedDLL + Level3 + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="Release";%(PreprocessorDefinitions) + $(IntDir) + + + + + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions) + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(ProjectDir)/$(IntDir) + %(Filename).h + %(Filename).tlb + %(Filename)_i.c + %(Filename)_p.c + + + %(AdditionalOptions) /machine:X86 + + + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(IntDir) + + + OnlyExplicitInline + MinSpace + NotUsing + MultiThreadedDLL + Level3 + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="MinSizeRel";%(PreprocessorDefinitions) + $(IntDir) + + + + + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"MinSizeRel\";%(PreprocessorDefinitions) + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(ProjectDir)/$(IntDir) + %(Filename).h + %(Filename).tlb + %(Filename)_i.c + %(Filename)_p.c + + + %(AdditionalOptions) /machine:X86 + + + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(IntDir) + ProgramDatabase + + + OnlyExplicitInline + MaxSpeed + NotUsing + MultiThreadedDLL + Level3 + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions) + $(IntDir) + + + WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions) + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + + + C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories) + $(ProjectDir)/$(IntDir) + %(Filename).h + %(Filename).tlb + %(Filename)_i.c + %(Filename)_p.c + + + %(AdditionalOptions) /machine:X86 + + + + + + + + + + + + + true + + + + + + + + + + + + + + + $(IntDir)/zbar/video/null.c.obj + + + $(IntDir)/zbar/processor/null.c.obj + + + $(IntDir)/zbar/window/null.c.obj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/win32/zbar.vcxproj.filters b/win32/zbar.vcxproj.filters new file mode 100644 index 0000000..eeaaf33 --- /dev/null +++ b/win32/zbar.vcxproj.filters @@ -0,0 +1,159 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + + + {D9FB3D00-FC7C-3F8E-9E0B-EFE1A211E8BA} + + + {138F32C6-425A-3C3C-BAB0-E030755D908D} + + + diff --git a/win32/zbar_qrcode.sln b/win32/zbar_qrcode.sln new file mode 100644 index 0000000..3e58301 --- /dev/null +++ b/win32/zbar_qrcode.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zbar", "zbar.vcxproj", "{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + MinSizeRel|Win32 = MinSizeRel|Win32 + Release|Win32 = Release|Win32 + RelWithDebInfo|Win32 = RelWithDebInfo|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Debug|Win32.ActiveCfg = Debug|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Debug|Win32.Build.0 = Debug|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Release|Win32.ActiveCfg = Release|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Release|Win32.Build.0 = Release|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32 + {E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8D6F4E6E-8DD9-3F7B-A6D2-1CF60CFCBF4B} + EndGlobalSection +EndGlobal diff --git a/zbar/decoder.h b/zbar/decoder.h index f8db705..0a1eb4f 100644 --- a/zbar/decoder.h +++ b/zbar/decoder.h @@ -232,9 +232,10 @@ static inline unsigned decode_sortn (zbar_decoder_t *dcode, unsigned wmin = UINT_MAX; int jmin = -1, j; for(j = n - 1; j >= 0; j--) { + unsigned w; if((mask >> j) & 1) continue; - unsigned w = get_width(dcode, i0 + j * 2); + w = get_width(dcode, i0 + j * 2); if(wmin >= w) { wmin = w; jmin = j; diff --git a/zbar/image.c b/zbar/image.c index 6524517..7f2ada7 100644 --- a/zbar/image.c +++ b/zbar/image.c @@ -24,6 +24,9 @@ #include "error.h" #include "image.h" #include "refcnt.h" +#include +#include +#include zbar_image_t *zbar_image_create () { @@ -131,13 +134,14 @@ void zbar_image_set_crop (zbar_image_t *img, unsigned w, unsigned h) { + unsigned img_h; unsigned img_w = img->width; if(x > img_w) x = img_w; if(x + w > img_w) w = img_w - x; img->crop_x = x; img->crop_w = w; - unsigned img_h = img->height; + img_h = img->height; if(y > img_h) y = img_h; if(y + h > img_h) h = img_h - y; img->crop_y = y; diff --git a/zbar/img_scanner.c b/zbar/img_scanner.c index ba2031a..f4cc14d 100644 --- a/zbar/img_scanner.c +++ b/zbar/img_scanner.c @@ -657,10 +657,11 @@ int zbar_image_scanner_get_config(zbar_image_scanner_t *iscn, return zbar_decoder_get_config(iscn->dcode, sym, cfg, val); if(cfg < ZBAR_CFG_POSITION) { + int i; if(sym == ZBAR_PARTIAL) return(1); - int i = _zbar_get_symbol_hash(sym); + i = _zbar_get_symbol_hash(sym); *val = iscn->sym_configs[cfg - ZBAR_CFG_UNCERTAINTY][i]; return 0; @@ -889,6 +890,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn, zbar_scanner_t *scn = iscn->scn; unsigned w, h, cx1, cy1; int density; + char filter; + int nean = 0, naddon = 0; /* timestamp image * FIXME prefer video timestamp @@ -1057,9 +1060,9 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn, /* FIXME tmp hack to filter bad EAN results */ /* FIXME tmp hack to merge simple case EAN add-ons */ - char filter = (!iscn->enable_cache && + filter = (!iscn->enable_cache && (density == 1 || CFG(iscn, ZBAR_CFG_Y_DENSITY) == 1)); - int nean = 0, naddon = 0; + nean = 0, naddon = 0; if(syms->nsyms) { zbar_symbol_t **symp; for(symp = &syms->head; *symp; ) { @@ -1100,6 +1103,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn, } if(nean == 1 && naddon == 1 && iscn->ean_config) { + int datalen; + zbar_symbol_t *ean_sym; /* create container symbol for composite result */ zbar_symbol_t *ean = NULL, *addon = NULL; for(symp = &syms->head; *symp; ) { @@ -1120,8 +1125,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn, assert(ean); assert(addon); - int datalen = ean->datalen + addon->datalen + 1; - zbar_symbol_t *ean_sym = + datalen = ean->datalen + addon->datalen + 1; + ean_sym = _zbar_image_scanner_alloc_sym(iscn, ZBAR_COMPOSITE, datalen); ean_sym->orient = ean->orient; ean_sym->syms = _zbar_symbol_set_create(); diff --git a/zbar/processor.c b/zbar/processor.c index 9997845..a740ac6 100644 --- a/zbar/processor.c +++ b/zbar/processor.c @@ -54,14 +54,18 @@ static inline int proc_open (zbar_processor_t *proc) int _zbar_process_image (zbar_processor_t *proc, zbar_image_t *img) { + int rc; uint32_t force_fmt = proc->force_output; if(img) { + uint32_t format; + zbar_image_t *tmp; + int nsyms; if(proc->dumping) { zbar_image_write(proc->window->image, "zbar"); proc->dumping = 0; } - uint32_t format = zbar_image_get_format(img); + format = zbar_image_get_format(img); zprintf(16, "processing: %.4s(%08" PRIx32 ") %dx%d @%p\n", (char*)&format, format, zbar_image_get_width(img), zbar_image_get_height(img), @@ -70,7 +74,7 @@ int _zbar_process_image (zbar_processor_t *proc, /* FIXME locking all other interfaces while processing is conservative * but easier for now and we don't expect this to take long... */ - zbar_image_t *tmp = zbar_image_convert(img, fourcc('Y','8','0','0')); + tmp = zbar_image_convert(img, fourcc('Y','8','0','0')); if(!tmp) goto error; @@ -79,7 +83,7 @@ int _zbar_process_image (zbar_processor_t *proc, proc->syms = NULL; } zbar_image_scanner_recycle_image(proc->scanner, img); - int nsyms = zbar_scan_image(proc->scanner, tmp); + nsyms = zbar_scan_image(proc->scanner, tmp); _zbar_image_swap_symbols(img, tmp); zbar_image_destroy(tmp); @@ -128,7 +132,7 @@ int _zbar_process_image (zbar_processor_t *proc, } /* display to window if enabled */ - int rc = 0; + rc = 0; if(proc->window) { if((rc = zbar_window_draw(proc->window, img))) err_copy(proc, proc->window); @@ -198,6 +202,7 @@ static ZTHREAD proc_video_thread (void *arg) zprintf(4, "spawned video thread\n"); while(thread->started) { + zbar_image_t *img; /* wait for video stream to be active */ while(thread->started && !proc->streaming) _zbar_event_wait(&thread->notify, &proc->mutex, NULL); @@ -206,7 +211,7 @@ static ZTHREAD proc_video_thread (void *arg) /* blocking capture image from video */ _zbar_mutex_unlock(&proc->mutex); - zbar_image_t *img = zbar_video_next_image(proc->video); + img = zbar_video_next_image(proc->video); _zbar_mutex_lock(&proc->mutex); if(!img && !proc->streaming) @@ -237,6 +242,7 @@ static ZTHREAD proc_video_thread (void *arg) static ZTHREAD proc_input_thread (void *arg) { + int rc = 0; zbar_processor_t *proc = arg; zbar_thread_t *thread = &proc->input_thread; if(proc->window && proc_open(proc)) @@ -247,7 +253,7 @@ static ZTHREAD proc_input_thread (void *arg) _zbar_event_trigger(&thread->activity); zprintf(4, "spawned input thread\n"); - int rc = 0; + rc = 0; while(thread->started && rc >= 0) { _zbar_mutex_unlock(&proc->mutex); rc = _zbar_processor_input_wait(proc, &thread->notify, -1); @@ -287,6 +293,8 @@ zbar_processor_t *zbar_processor_create (int threaded) void zbar_processor_destroy (zbar_processor_t *proc) { + proc_waiter_t *w, *next; + zbar_processor_init(proc, NULL, 0); if(proc->syms) { @@ -305,7 +313,6 @@ void zbar_processor_destroy (zbar_processor_t *proc) assert(!proc->wait_tail); assert(!proc->wait_next); - proc_waiter_t *w, *next; for(w = proc->free_waiter; w; w = next) { next = w->next; _zbar_event_destroy(&w->notify); @@ -320,6 +327,9 @@ int zbar_processor_init (zbar_processor_t *proc, const char *dev, int enable_display) { + int rc = 0; + int video_threaded, input_threaded; + if(proc->video) zbar_processor_set_active(proc, 0); @@ -338,7 +348,7 @@ int zbar_processor_init (zbar_processor_t *proc, proc->window = NULL; } - int rc = 0; + rc = 0; if(proc->video) { zbar_video_destroy(proc->video); proc->video = NULL; @@ -378,7 +388,7 @@ int zbar_processor_init (zbar_processor_t *proc, } /* spawn blocking video thread */ - int video_threaded = (proc->threaded && proc->video && + video_threaded = (proc->threaded && proc->video && zbar_video_get_fd(proc->video) < 0); if(video_threaded && _zbar_thread_start(&proc->video_thread, proc_video_thread, proc, @@ -389,7 +399,7 @@ int zbar_processor_init (zbar_processor_t *proc, } /* spawn input monitor thread */ - int input_threaded = (proc->threaded && + input_threaded = (proc->threaded && (proc->window || (proc->video && !video_threaded))); if(input_threaded && @@ -460,9 +470,10 @@ void zbar_processor_set_userdata (zbar_processor_t *proc, void *zbar_processor_get_userdata (const zbar_processor_t *proc) { + void *userdata; zbar_processor_t *ncproc = (zbar_processor_t*)proc; _zbar_mutex_lock(&ncproc->mutex); - void *userdata = (void*)ncproc->userdata; + userdata = (void*)ncproc->userdata; _zbar_mutex_unlock(&ncproc->mutex); return(userdata); } @@ -472,8 +483,9 @@ int zbar_processor_set_config (zbar_processor_t *proc, zbar_config_t cfg, int val) { + int rc; proc_enter(proc); - int rc = zbar_image_scanner_set_config(proc->scanner, sym, cfg, val); + rc = zbar_image_scanner_set_config(proc->scanner, sym, cfg, val); proc_leave(proc); return(rc); } @@ -482,12 +494,13 @@ int zbar_processor_set_control (zbar_processor_t *proc, const char *control_name, int value) { - proc_enter(proc); + int rc; int value_before, value_after; + proc_enter(proc); if(_zbar_verbosity >= 4) if(zbar_video_get_control(proc->video, control_name, &value_before)==0) zprintf(0, "value of %s before a set: %d\n", control_name, value_before); - int rc = zbar_video_set_control(proc->video, control_name, value); + rc = zbar_video_set_control(proc->video, control_name, value); if(_zbar_verbosity >= 4) if(zbar_video_get_control(proc->video, control_name, &value_after)==0) zprintf(0, "value of %s after a set: %d\n", control_name, value_after); @@ -499,8 +512,9 @@ int zbar_processor_get_control (zbar_processor_t *proc, const char *control_name, int *value) { + int rc; proc_enter(proc); - int rc = zbar_video_get_control(proc->video, control_name, value); + rc = zbar_video_get_control(proc->video, control_name, value); proc_leave(proc); return(rc); } @@ -547,8 +561,9 @@ int zbar_processor_force_format (zbar_processor_t *proc, int zbar_processor_is_visible (zbar_processor_t *proc) { + int visible; proc_enter(proc); - int visible = proc->window && proc->visible; + visible = proc->window && proc->visible; proc_leave(proc); return(visible); } @@ -556,10 +571,10 @@ int zbar_processor_is_visible (zbar_processor_t *proc) int zbar_processor_set_visible (zbar_processor_t *proc, int visible) { + int rc = 0; proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); - int rc = 0; if(proc->window) { if(proc->video) rc = _zbar_processor_set_size(proc, @@ -583,9 +598,10 @@ int zbar_processor_set_visible (zbar_processor_t *proc, const zbar_symbol_set_t* zbar_processor_get_results (const zbar_processor_t *proc) { + const zbar_symbol_set_t *syms; zbar_processor_t *ncproc = (zbar_processor_t*)proc; proc_enter(ncproc); - const zbar_symbol_set_t *syms = proc->syms; + syms = proc->syms; if(syms) zbar_symbol_set_ref(syms, 1); proc_leave(ncproc); @@ -595,10 +611,11 @@ zbar_processor_get_results (const zbar_processor_t *proc) int zbar_processor_user_wait (zbar_processor_t *proc, int timeout) { + int rc = -1; + proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); - int rc = -1; if(proc->visible || proc->streaming || timeout >= 0) { zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_INPUT, @@ -620,9 +637,9 @@ int zbar_processor_user_wait (zbar_processor_t *proc, int zbar_processor_set_active (zbar_processor_t *proc, int active) { + int rc; proc_enter(proc); - int rc; if(!proc->video) { rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video input not initialized"); @@ -660,11 +677,14 @@ int zbar_processor_set_active (zbar_processor_t *proc, int zbar_process_one (zbar_processor_t *proc, int timeout) { + int streaming, rc; + zbar_timer_t timer; + proc_enter(proc); - int streaming = proc->streaming; + streaming = proc->streaming; _zbar_mutex_unlock(&proc->mutex); - int rc = 0; + rc = 0; if(!proc->video) { rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video input not initialized"); @@ -677,7 +697,6 @@ int zbar_process_one (zbar_processor_t *proc, goto done; } - zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_OUTPUT, _zbar_timer_init(&timer, timeout)); @@ -693,10 +712,11 @@ int zbar_process_one (zbar_processor_t *proc, int zbar_process_image (zbar_processor_t *proc, zbar_image_t *img) { + int rc = 0; + proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); - int rc = 0; if(img && proc->window) rc = _zbar_processor_set_size(proc, zbar_image_get_width(img), diff --git a/zbar/processor/lock.c b/zbar/processor/lock.c index 1b3766e..b88297d 100644 --- a/zbar/processor/lock.c +++ b/zbar/processor/lock.c @@ -99,6 +99,7 @@ static inline void proc_waiter_release (zbar_processor_t *proc, int _zbar_processor_lock (zbar_processor_t *proc) { + proc_waiter_t *waiter; if(!proc->lock_level) { proc->lock_owner = _zbar_thread_self(); proc->lock_level = 1; @@ -110,7 +111,7 @@ int _zbar_processor_lock (zbar_processor_t *proc) return(0); } - proc_waiter_t *waiter = proc_waiter_queue(proc); + waiter = proc_waiter_queue(proc); _zbar_event_wait(&waiter->notify, &proc->mutex, NULL); assert(proc->lock_level == 1); @@ -142,8 +143,8 @@ int _zbar_processor_unlock (zbar_processor_t *proc, void _zbar_processor_notify (zbar_processor_t *proc, unsigned events) { - proc->wait_next = NULL; proc_waiter_t *waiter; + proc->wait_next = NULL; for(waiter = proc->wait_head; waiter; waiter = waiter->next) waiter->events = ((waiter->events & ~events) | (events & EVENT_CANCELED)); @@ -159,11 +160,13 @@ static inline int proc_wait_unthreaded (zbar_processor_t *proc, proc_waiter_t *waiter, zbar_timer_t *timeout) { + int rc; int blocking = proc->streaming && zbar_video_get_fd(proc->video) < 0; _zbar_mutex_unlock(&proc->mutex); - int rc = 1; + rc = 1; while(rc > 0 && (waiter->events & EVENTS_PENDING)) { + int reltime; /* FIXME lax w/the locking (though shouldn't matter...) */ if(blocking) { zbar_image_t *img = zbar_video_next_image(proc->video); @@ -178,7 +181,7 @@ static inline int proc_wait_unthreaded (zbar_processor_t *proc, zbar_image_destroy(img); _zbar_mutex_unlock(&proc->mutex); } - int reltime = _zbar_timer_check(timeout); + reltime = _zbar_timer_check(timeout); if(blocking && (reltime < 0 || reltime > MAX_INPUT_BLOCK)) reltime = MAX_INPUT_BLOCK; rc = _zbar_processor_input_wait(proc, NULL, reltime); @@ -191,13 +194,16 @@ int _zbar_processor_wait (zbar_processor_t *proc, unsigned events, zbar_timer_t *timeout) { + int save_level; + proc_waiter_t *waiter; + int rc; + _zbar_mutex_lock(&proc->mutex); - int save_level = proc->lock_level; - proc_waiter_t *waiter = proc_waiter_queue(proc); + save_level = proc->lock_level; + waiter = proc_waiter_queue(proc); waiter->events = events & EVENTS_PENDING; _zbar_processor_unlock(proc, 1); - int rc; if(proc->threaded) rc = _zbar_event_wait(&waiter->notify, &proc->mutex, timeout); else diff --git a/zbar/symbol.c b/zbar/symbol.c index 27dbc87..33e2f90 100644 --- a/zbar/symbol.c +++ b/zbar/symbol.c @@ -100,33 +100,36 @@ const char *zbar_get_orientation_name (zbar_orientation_t orient) int _zbar_get_symbol_hash (zbar_symbol_type_t sym) { - static const signed char hash[ZBAR_CODE128 + 1] = { - [0 ... ZBAR_CODE128] = -1, + int h; + signed char hash[ZBAR_CODE128 + 1] = { 0 }; + + { + //[0 ... ZBAR_CODE128] = -1, + memset(hash, -1, sizeof(hash)); /* [ZBAR_FOO] = 0, is empty */ - [ZBAR_SQCODE] = 1, - [ZBAR_CODE128] = 2, - [ZBAR_EAN13] = 3, - [ZBAR_UPCA] = 4, - [ZBAR_EAN8] = 5, - [ZBAR_UPCE] = 6, - [ZBAR_ISBN13] = 7, - [ZBAR_ISBN10] = 8, - [ZBAR_CODE39] = 9, - [ZBAR_I25] = 10, - [ZBAR_PDF417] = 11, - [ZBAR_QRCODE] = 12, - [ZBAR_DATABAR] = 13, - [ZBAR_DATABAR_EXP] = 14, - [ZBAR_CODE93] = 15, - [ZBAR_EAN2] = 16, - [ZBAR_EAN5] = 17, - [ZBAR_COMPOSITE] = 18, - [ZBAR_CODABAR] = 19, + hash[ZBAR_SQCODE] = 1, + hash[ZBAR_CODE128] = 2, + hash[ZBAR_EAN13] = 3, + hash[ZBAR_UPCA] = 4, + hash[ZBAR_EAN8] = 5, + hash[ZBAR_UPCE] = 6, + hash[ZBAR_ISBN13] = 7, + hash[ZBAR_ISBN10] = 8, + hash[ZBAR_CODE39] = 9, + hash[ZBAR_I25] = 10, + hash[ZBAR_PDF417] = 11, + hash[ZBAR_QRCODE] = 12, + hash[ZBAR_DATABAR] = 13, + hash[ZBAR_DATABAR_EXP] = 14, + hash[ZBAR_CODE93] = 15, + hash[ZBAR_EAN2] = 16, + hash[ZBAR_EAN5] = 17, + hash[ZBAR_COMPOSITE] = 18, + hash[ZBAR_CODABAR] = 19; /* Please update NUM_SYMS accordingly */ - }; - int h; + } assert (sym >= ZBAR_PARTIAL && sym <= ZBAR_CODE128); @@ -295,6 +298,7 @@ char *zbar_symbol_xml (const zbar_symbol_t *sym, char **buf, unsigned *len) { + unsigned int mods, cfgs; unsigned int datalen, maxlen; int i, n = 0; @@ -321,10 +325,10 @@ char *zbar_symbol_xml (const zbar_symbol_t *sym, maxlen = (MAX_STATIC + strlen(type) + strlen(orient) + datalen + MAX_INT_DIGITS + 1); - unsigned int mods = sym->modifiers; + mods = sym->modifiers; if(mods) maxlen += MAX_MOD; - unsigned int cfgs = sym->configs & ~(1 << ZBAR_CFG_ENABLE); + cfgs = sym->configs & ~(1 << ZBAR_CFG_ENABLE); if(cfgs) maxlen += MAX_CFG; if(binary) diff --git a/zbar/thread.h b/zbar/thread.h index 96d6415..6d44ea5 100644 --- a/zbar/thread.h +++ b/zbar/thread.h @@ -35,7 +35,7 @@ # define HAVE_THREADS # define ZTHREAD DWORD WINAPI -typedef ZTHREAD (zbar_thread_proc_t)(void*); +typedef DWORD (WINAPI zbar_thread_proc_t)(void*); typedef DWORD zbar_thread_id_t;