From cf7edfa5227c608c1d0cc066172f73f7a1c83aeb Mon Sep 17 00:00:00 2001 From: spadix Date: Fri, 17 Apr 2009 22:26:38 +0000 Subject: [PATCH] * fixup some perl distribution details * project name change: everything "zebra" becomes "zbar" * remove old logo --- ChangeLog | 5 +- HACKING | 8 +- Makefile.am | 26 +- NEWS | 2 +- README | 32 +- TODO | 12 +- configure.ac | 36 +- debian/changelog | 37 - debian/compat | 1 - debian/control | 121 --- debian/copyright | 518 ------------- debian/libzebra-dev.install | 14 - debian/libzebra3.install | 1 - debian/libzebragtk-dev.install | 5 - debian/libzebragtk0.install | 1 - debian/libzebraqt-dev.install | 5 - debian/libzebraqt0.install | 1 - debian/python-zebrapygtk.install | 1 - debian/rules | 71 -- debian/zebra-tools.install | 4 - doc/Makefile.am.inc | 12 +- doc/api/footer.html | 2 +- doc/doxygen.conf.in | 4 +- doc/manual.xml | 15 +- doc/ref/commonoptions.xml | 2 - doc/ref/{zebracam.xml => zbarcam.xml} | 24 +- doc/ref/{zebraimg.xml => zbarimg.xml} | 24 +- examples/paginate.pl | 18 +- examples/processor.pl | 4 +- examples/processor.py | 6 +- examples/scan_image.c | 30 +- examples/scan_image.cpp | 6 +- examples/scan_image.pl | 6 +- examples/scan_image.py | 6 +- gtk/Makefile.am.inc | 22 +- gtk/{zebragtk.c => zbargtk.c} | 478 ++++++------ gtk/{zebragtkprivate.h => zbargtkprivate.h} | 62 +- gtk/{zebramarshal.list => zbarmarshal.list} | 0 include/Makefile.am.inc | 16 +- include/{zebra.h => zbar.h} | 720 +++++++++--------- include/{zebra => zbar}/Decoder.h | 98 +-- include/{zebra => zbar}/Exception.h | 48 +- include/{zebra => zbar}/Image.h | 112 +-- include/{zebra => zbar}/ImageScanner.h | 56 +- include/{zebra => zbar}/Processor.h | 94 +-- include/{zebra/QZebra.h => zbar/QZBar.h} | 40 +- .../QZebraImage.h => zbar/QZBarImage.h} | 26 +- include/{zebra => zbar}/Scanner.h | 78 +- include/{zebra => zbar}/Symbol.h | 70 +- include/{zebra => zbar}/Video.h | 78 +- include/{zebra => zbar}/Window.h | 62 +- include/{zebra/zebragtk.h => zbar/zbargtk.h} | 122 +-- perl/Changes | 5 +- perl/MANIFEST | 16 +- perl/Makefile.PL | 24 +- perl/README | 23 +- perl/{Zebra.pm => ZBar.pm} | 55 +- perl/ZBar.xs | 712 +++++++++++++++++ perl/{Zebra => ZBar}/Image.pod | 32 +- perl/{Zebra => ZBar}/ImageScanner.pod | 30 +- perl/{Zebra => ZBar}/Processor.pod | 34 +- perl/{Zebra => ZBar}/Symbol.pod | 24 +- perl/Zebra.xs | 712 ----------------- perl/examples/paginate.pl | 71 ++ perl/examples/processor.pl | 34 + perl/examples/scan_image.pl | 37 + perl/inc/Devel/CheckLib.pm | 350 +++++++++ perl/t/Decoder.t | 22 +- perl/t/Image.t | 16 +- perl/t/Processor.t | 16 +- perl/t/Scanner.t | 6 +- perl/t/{Zebra.t => ZBar.t} | 10 +- perl/t/pod-coverage.t | 12 + perl/t/pod.t | 12 + perl/typemap | 26 +- plugin/Makefile.am.inc | 8 +- plugin/plugin.c | 12 +- pygtk/Makefile.am.inc | 30 +- ...zebrapygtk.override => zbarpygtk.override} | 8 +- .../{zebrapygtkmodule.c => zbarpygtkmodule.c} | 24 +- python/Makefile.am.inc | 14 +- python/decoder.c | 115 +-- python/enum.c | 85 ++- python/exception.c | 67 +- python/image.c | 197 ++--- python/imagescanner.c | 67 +- python/processor.c | 121 +-- python/scanner.c | 83 +- python/symbol.c | 75 +- python/test/{test_zebra.py => test_zbar.py} | 100 +-- python/zbarmodule.c | 193 +++++ python/zbarmodule.h | 141 ++++ python/zebramodule.c | 170 ----- python/zebramodule.h | 118 --- qt/Makefile.am.inc | 22 +- qt/{QZebra.cpp => QZBar.cpp} | 60 +- qt/{QZebraThread.cpp => QZBarThread.cpp} | 38 +- qt/{QZebraThread.h => QZBarThread.h} | 30 +- test/Makefile.am.inc | 16 +- test/dbg_scan.cpp | 42 +- test/pdf417_encode.h | 12 +- test/scan_video.c | 12 +- test/test_convert.c | 24 +- test/test_cpp.cpp | 18 +- test/test_decode.c | 38 +- test/test_gtk.c | 66 +- test/test_images.c | 28 +- test/test_images.h | 14 +- test/test_jpeg.c | 42 +- test/test_perl.pl | 18 +- test/test_proc.c | 50 +- test/test_pygtk.py | 62 +- test/test_qt.cpp | 40 +- test/test_video.c | 96 +-- test/test_window.c | 48 +- zebra-gtk.pc.in => zbar-gtk.pc.in | 8 +- zebra-qt.pc.in => zbar-qt.pc.in | 8 +- zebra.pc.in => zbar.pc.in | 6 +- zebra.spec.in => zbar.spec.in | 141 ++-- zbar/Makefile.am.inc | 62 ++ {zebra => zbar}/config.c | 64 +- {zebra => zbar}/convert.c | 302 ++++---- {zebra => zbar}/debug.h | 12 +- {zebra => zbar}/decoder.c | 182 ++--- {zebra => zbar}/decoder.h | 38 +- {zebra => zbar}/decoder/code128.c | 68 +- {zebra => zbar}/decoder/code128.h | 14 +- {zebra => zbar}/decoder/code39.c | 56 +- {zebra => zbar}/decoder/code39.h | 14 +- {zebra => zbar}/decoder/ean.c | 194 ++--- {zebra => zbar}/decoder/ean.h | 38 +- {zebra => zbar}/decoder/i25.c | 58 +- {zebra => zbar}/decoder/i25.h | 14 +- {zebra => zbar}/decoder/pdf417.c | 44 +- {zebra => zbar}/decoder/pdf417.h | 14 +- {zebra => zbar}/decoder/pdf417_hash.h | 12 +- {zebra => zbar}/error.c | 66 +- {zebra => zbar}/error.h | 44 +- {zebra => zbar}/image.c | 88 +-- {zebra => zbar}/image.h | 54 +- {zebra => zbar}/img_scanner.c | 158 ++-- {zebra => zbar}/jpeg.c | 46 +- zbar/logo.c | 32 + {zebra => zbar}/processor.c | 264 +++---- {zebra => zbar}/processor.h | 42 +- {zebra => zbar}/scanner.c | 138 ++-- {zebra => zbar}/symbol.c | 72 +- {zebra => zbar}/symbol.h | 24 +- {zebra => zbar}/video.c | 138 ++-- {zebra => zbar}/video.h | 50 +- {zebra => zbar}/video/null.c | 18 +- {zebra => zbar}/video/v4l1.c | 90 +-- {zebra => zbar}/video/v4l2.c | 92 +-- {zebra => zbar}/window.c | 85 +-- {zebra => zbar}/window.h | 51 +- zbar/window/null.c | 87 +++ {zebra => zbar}/window/x.c | 96 +-- {zebra => zbar}/window/ximage.c | 48 +- {zebra => zbar}/window/xv.c | 48 +- zbarcam/Makefile.am.inc | 5 + zebracam/zebracam.c => zbarcam/zbarcam.c | 76 +- zbarimg/Makefile.am.inc | 6 + zebraimg/zebraimg.cpp => zbarimg/zbarimg.cpp | 26 +- zebra/Makefile.am.inc | 62 -- zebra/logo.c | 386 ---------- zebra/window/null.c | 87 --- zebracam/Makefile.am.inc | 5 - zebraimg/Makefile.am.inc | 6 - 168 files changed, 5697 insertions(+), 6067 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/libzebra-dev.install delete mode 100644 debian/libzebra3.install delete mode 100644 debian/libzebragtk-dev.install delete mode 100644 debian/libzebragtk0.install delete mode 100644 debian/libzebraqt-dev.install delete mode 100644 debian/libzebraqt0.install delete mode 100644 debian/python-zebrapygtk.install delete mode 100755 debian/rules delete mode 100644 debian/zebra-tools.install rename doc/ref/{zebracam.xml => zbarcam.xml} (86%) rename doc/ref/{zebraimg.xml => zbarimg.xml} (87%) rename gtk/{zebragtk.c => zbargtk.c} (52%) rename gtk/{zebragtkprivate.h => zbargtkprivate.h} (58%) rename gtk/{zebramarshal.list => zbarmarshal.list} (100%) rename include/{zebra.h => zbar.h} (52%) rename include/{zebra => zbar}/Decoder.h (56%) rename include/{zebra => zbar}/Exception.h (79%) rename include/{zebra => zbar}/Image.h (71%) rename include/{zebra => zbar}/ImageScanner.h (57%) rename include/{zebra => zbar}/Processor.h (65%) rename include/{zebra/QZebra.h => zbar/QZBar.h} (81%) rename include/{zebra/QZebraImage.h => zbar/QZBarImage.h} (73%) rename include/{zebra => zbar}/Scanner.h (58%) rename include/{zebra => zbar}/Symbol.h (75%) rename include/{zebra => zbar}/Video.h (61%) rename include/{zebra => zbar}/Window.h (63%) rename include/{zebra/zebragtk.h => zbar/zbargtk.h} (56%) rename perl/{Zebra.pm => ZBar.pm} (64%) create mode 100644 perl/ZBar.xs rename perl/{Zebra => ZBar}/Image.pod (75%) rename perl/{Zebra => ZBar}/ImageScanner.pod (67%) rename perl/{Zebra => ZBar}/Processor.pod (77%) rename perl/{Zebra => ZBar}/Symbol.pod (79%) delete mode 100644 perl/Zebra.xs create mode 100755 perl/examples/paginate.pl create mode 100755 perl/examples/processor.pl create mode 100755 perl/examples/scan_image.pl create mode 100644 perl/inc/Devel/CheckLib.pm rename perl/t/{Zebra.t => ZBar.t} (52%) create mode 100644 perl/t/pod-coverage.t create mode 100644 perl/t/pod.t rename pygtk/{zebrapygtk.override => zbarpygtk.override} (58%) rename pygtk/{zebrapygtkmodule.c => zbarpygtkmodule.c} (60%) rename python/test/{test_zebra.py => test_zbar.py} (75%) create mode 100644 python/zbarmodule.c create mode 100644 python/zbarmodule.h delete mode 100644 python/zebramodule.c delete mode 100644 python/zebramodule.h rename qt/{QZebra.cpp => QZBar.cpp} (73%) rename qt/{QZebraThread.cpp => QZBarThread.cpp} (84%) rename qt/{QZebraThread.h => QZBarThread.h} (85%) rename zebra-gtk.pc.in => zbar-gtk.pc.in (60%) rename zebra-qt.pc.in => zbar-qt.pc.in (60%) rename zebra.pc.in => zbar.pc.in (70%) rename zebra.spec.in => zbar.spec.in (51%) create mode 100644 zbar/Makefile.am.inc rename {zebra => zbar}/config.c (71%) rename {zebra => zbar}/convert.c (77%) rename {zebra => zbar}/debug.h (87%) rename {zebra => zbar}/decoder.c (55%) rename {zebra => zbar}/decoder.h (82%) rename {zebra => zbar}/decoder/code128.c (89%) rename {zebra => zbar}/decoder/code128.h (76%) rename {zebra => zbar}/decoder/code39.c (86%) rename {zebra => zbar}/decoder/code39.h (77%) rename {zebra => zbar}/decoder/ean.c (77%) rename {zebra => zbar}/decoder/ean.h (66%) rename {zebra => zbar}/decoder/i25.c (80%) rename {zebra => zbar}/decoder/i25.h (77%) rename {zebra => zbar}/decoder/pdf417.c (81%) rename {zebra => zbar}/decoder/pdf417.h (76%) rename {zebra => zbar}/decoder/pdf417_hash.h (98%) rename {zebra => zbar}/error.c (70%) rename {zebra => zbar}/error.h (83%) rename {zebra => zbar}/image.c (59%) rename {zebra => zbar}/image.h (71%) rename {zebra => zbar}/img_scanner.c (68%) rename {zebra => zbar}/jpeg.c (82%) create mode 100644 zbar/logo.c rename {zebra => zbar}/processor.c (70%) rename {zebra => zbar}/processor.h (81%) rename {zebra => zbar}/scanner.c (61%) rename {zebra => zbar}/symbol.c (60%) rename {zebra => zbar}/symbol.h (72%) rename {zebra => zbar}/video.c (64%) rename {zebra => zbar}/video.h (72%) rename {zebra => zbar}/video/null.c (64%) rename {zebra => zbar}/video/v4l1.c (83%) rename {zebra => zbar}/video/v4l2.c (85%) rename {zebra => zbar}/window.c (52%) rename {zebra => zbar}/window.h (72%) create mode 100644 zbar/window/null.c rename {zebra => zbar}/window/x.c (75%) rename {zebra => zbar}/window/ximage.c (83%) rename {zebra => zbar}/window/xv.c (87%) create mode 100644 zbarcam/Makefile.am.inc rename zebracam/zebracam.c => zbarcam/zbarcam.c (75%) create mode 100644 zbarimg/Makefile.am.inc rename zebraimg/zebraimg.cpp => zbarimg/zbarimg.cpp (93%) delete mode 100644 zebra/Makefile.am.inc delete mode 100644 zebra/logo.c delete mode 100644 zebra/window/null.c delete mode 100644 zebracam/Makefile.am.inc delete mode 100644 zebraimg/Makefile.am.inc diff --git a/ChangeLog b/ChangeLog index ff0aee23..faf3d68d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -current: +version 0.7: + * fixup some perl distribution details + * project name change: everything "zebra" becomes "zbar" + * remove old logo * add first pass python bindings! * fix perl mortality bug * add new cfg constants to perl diff --git a/HACKING b/HACKING index 78595660..dc5566b7 100644 --- a/HACKING +++ b/HACKING @@ -1,8 +1,8 @@ -if you're hacking at zebra, PLEASE send patches against the latest SVN! -if you haven't already, get zebra from SVN by running: +if you're hacking at ZBar, PLEASE send patches against the latest SVN! +if you haven't already, get ZBar from SVN by running: - svn co https://zebra.svn.sourceforge.net/svnroot/zebra/trunk zebra - cd zebra + svn co https://zbar.svn.sourceforge.net/svnroot/zbar/trunk zbar + cd zbar autoreconf --install this will generate configure and all that other foo you usually get with diff --git a/Makefile.am b/Makefile.am index cc55d511..65b5b3f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,31 +12,31 @@ BUILT_SOURCES = EXTRA_DIST = pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = zebra.pc +pkgconfig_DATA = zbar.pc dist_doc_DATA = COPYING.LIB HACKING INSTALL NEWS README TODO include $(srcdir)/include/Makefile.am.inc -include $(srcdir)/zebra/Makefile.am.inc +include $(srcdir)/zbar/Makefile.am.inc if HAVE_MAGICK -include $(srcdir)/zebraimg/Makefile.am.inc +include $(srcdir)/zbarimg/Makefile.am.inc endif if HAVE_VIDEO -include $(srcdir)/zebracam/Makefile.am.inc +include $(srcdir)/zbarcam/Makefile.am.inc endif if HAVE_PYTHON include $(srcdir)/python/Makefile.am.inc endif if HAVE_GTK include $(srcdir)/gtk/Makefile.am.inc -pkgconfig_DATA += zebra-gtk.pc +pkgconfig_DATA += zbar-gtk.pc if HAVE_PYTHON include $(srcdir)/pygtk/Makefile.am.inc endif endif if HAVE_QT include $(srcdir)/qt/Makefile.am.inc -pkgconfig_DATA += zebra-qt.pc +pkgconfig_DATA += zbar-qt.pc endif if HAVE_NPAPI include $(srcdir)/plugin/Makefile.am.inc @@ -45,11 +45,13 @@ include $(srcdir)/test/Makefile.am.inc include $(srcdir)/doc/Makefile.am.inc EXTRA_DIST += examples/upcrpc.pl examples/upcrpc.py examples/paginate.pl \ - zebra.spec.in zebra.spec + zbar.spec.in zbar.spec EXTRA_DIST += perl/MANIFEST perl/README perl/Changes perl/COPYING.LIB \ - perl/Makefile.PL perl/typemap perl/Zebra.xs perl/ppport.h \ - perl/Zebra.pm perl/Zebra/Image.pod perl/Zebra/ImageScanner.pod \ - perl/Zebra/Processor.pod perl/Zebra/Symbol.pod \ - perl/t/Decoder.t perl/t/Image.t perl/t/Processor.t perl/t/Scanner.t \ - perl/t/Zebra.t perl/t/barcode.png + perl/Makefile.PL perl/typemap perl/ZBar.xs perl/ppport.h \ + perl/ZBar.pm perl/inc/Devel/CheckLib.pm perl/ZBar/Image.pod + perl/ZBar/ImageScanner.pod perl/ZBar/Processor.pod perl/ZBar/Symbol.pod \ + perl/examples/paginate.pl perl/examples/processor.pl \ + perl/examples/scan_image.pl \ + perl/t/barcode.png perl/t/ZBar.t perl/t/Decoder.t perl/t/Image.t \ + perl/t/Processor.t perl/t/Scanner.t perl/t/pod.t perl/t/pod-coverage.t diff --git a/NEWS b/NEWS index 9c4d4fe8..3ee6dbb2 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Zebra Barcode Reader +ZBar Barcode Reader version 0.6 (2009-02-28): This release fixes many bugs and adds several improvements suggested diff --git a/README b/README index 96407393..382bd86d 100644 --- a/README +++ b/README @@ -1,18 +1,16 @@ -ZEBRA BARCODE READER +ZBAR BAR CODE READER ==================== -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN/UPC, Code 128, Code -39 and Interleaved 2 of 5. Included with the library are basic -applications for decoding captured bar code images and using a video -device (eg, webcam) as a bar code scanner. The flexible, layered -architecture features a fast, streaming interface with a minimal -memory footprint. +The ZBar Bar Code Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN/UPC, Code 128, Code 39 and +Interleaved 2 of 5. Included with the library are basic applications +for decoding captured bar code images and using a video device (eg, +webcam) as a bar code scanner. The flexible, layered architecture +features a fast, streaming interface with a minimal memory footprint. -Check the zebra library home page for the latest release, mailing -lists, etc. - http://zebra.sourceforge.net/ +Check the zbar home page for the latest release, mailing lists, etc. + http://zbar.sourceforge.net/ License information can be found in 'COPYING.LIB'. @@ -25,7 +23,7 @@ See 'INSTALL' for generic configuration and build instructions. The scanner/decoder library itself only requires a few standard library functions which should be avilable almost anywhere. -The zebracam program uses the video4linux API (v4l1 or v4l2) to access +The zbarcam program uses the video4linux API (v4l1 or v4l2) to access the video device. This interface is part of the linux kernel, a 2.6 kernel is recommended for full support. More information is available at @@ -36,7 +34,7 @@ installed pkg-config if you need any of the remaining components. pkg-config may be obtained from http://pkg-config.freedesktop.org/ -The zebraimg program uses ImageMagick to read image files in many +The zbarimg program uses ImageMagick to read image files in many different formats. You will need at least ImageMagick version 6.2.6 and the Magick++ development interface to ImageMagick if you want to scan image files. ImageMagick may be obtained from @@ -76,7 +74,7 @@ RUNNING ======= 'make install' will install the library and application programs. Run -'zebracam' to start the video scanner. use 'zebraimg barcode.jpg' to +'zbarcam' to start the video scanner. use 'zbarimg barcode.jpg' to decode a saved image file. Check the manual to find specific options for each program. @@ -85,9 +83,9 @@ REPORTING BUGS ============== Bugs can be reported on the sourceforge project page - http://www.sourceforge.net/projects/zebra/ + http://www.sourceforge.net/projects/zbar/ -Please include the zebra version number and a detailed description of +Please include the ZBar version number and a detailed description of the problem. You'll probably have better luck if you're also familiar with the concepts from: http://www.catb.org/~esr/faqs/smart-questions.html diff --git a/TODO b/TODO index 1c47e9eb..4bb7f54a 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,8 @@ general: * example using SANE to scan symbol(s) wrappers: - * build API docs for zebragtk, zebrapygtk - * is zebragtk/QZebra BGR4 alpha swapped? + * build API docs for zbargtk, zbarpygtk + * is zbargtk/QZBar BGR4 alpha swapped? * widget config APIs * drag-and-drop for widgets (configurable...) * Perl build support integration? @@ -68,7 +68,7 @@ window: * decoded result(?) * stats -zebracam/zebraimg: - * zebraimg multi-frame duplicate suppression - * stats/fps at zebracam exit - * decode hook (program/script)? (also zebraimg?) +zbarcam/zbarimg: + * zbarimg multi-frame duplicate suppression + * stats/fps at zbarcam exit + * decode hook (program/script)? (also zbarimg?) diff --git a/configure.ac b/configure.ac index a788da2c..55fdff27 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.61]) -AC_INIT([zebra], [0.6], [spadix@users.sourceforge.net]) +AC_INIT([zbar], [0.6], [spadix@users.sourceforge.net]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(config) AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign subdir-objects std-options dist-bzip2]) AC_CONFIG_HEADERS([include/config.h]) -AC_CONFIG_SRCDIR(zebra/scanner.c) +AC_CONFIG_SRCDIR(zbar/scanner.c) LT_PREREQ([2.2]) LT_INIT([dlopen win32-dll]) @@ -20,18 +20,18 @@ dnl - If any interfaces have been added since the last public release, dnl then increment age. dnl - If any interfaces have been removed since the last public release, dnl then set age to 0. -AC_SUBST([LIB_VERSION], [6:0:3]) +AC_SUBST([LIB_VERSION], [0:0:0]) AC_SUBST([RELDATE], [2009-02-28]) dnl widget libraries use their own versioning. dnl NB pygtk wrapper is *unversioned* AC_SUBST([ZGTK_LIB_VERSION], [0:0:0]) -AC_SUBST([ZQT_LIB_VERSION], [1:0:1]) +AC_SUBST([ZQT_LIB_VERSION], [0:0:0]) -AC_DEFINE_UNQUOTED([ZEBRA_VERSION_MAJOR], +AC_DEFINE_UNQUOTED([ZBAR_VERSION_MAJOR], [[`echo "$PACKAGE_VERSION" | sed -e 's/\..*$//'`]], [Program major version (before the '.') as a number]) -AC_DEFINE_UNQUOTED([ZEBRA_VERSION_MINOR], +AC_DEFINE_UNQUOTED([ZBAR_VERSION_MINOR], [[`echo "$PACKAGE_VERSION" | sed -e 's/^[^.]*\.\([^.]*\)$/\1/'`]], [Program minor version (after '.') as a number]) @@ -56,7 +56,7 @@ AC_ARG_ENABLE([codes], [], [enable_codes="ean,code39,code128,i25"]) dnl pdf417 -AC_DEFUN([ZEBRA_CHK_CODE], [ +AC_DEFUN([ZBAR_CHK_CODE], [ AC_MSG_CHECKING([whether to build $2]) enable_$1="no" AH_TEMPLATE([ENABLE_]translit($1, a-z, A-Z), @@ -71,11 +71,11 @@ AC_DEFUN([ZEBRA_CHK_CODE], [ AC_MSG_RESULT([$enable_$1]) ])dnl -ZEBRA_CHK_CODE([ean], [EAN symbologies]) -ZEBRA_CHK_CODE([code128], [Code 128 symbology]) -ZEBRA_CHK_CODE([code39], [Code 39 symbology]) -ZEBRA_CHK_CODE([pdf417], [PDF417 symbology]) -ZEBRA_CHK_CODE([i25], [Interleaved 2 of 5 symbology]) +ZBAR_CHK_CODE([ean], [EAN symbologies]) +ZBAR_CHK_CODE([code128], [Code 128 symbology]) +ZBAR_CHK_CODE([code39], [Code 39 symbology]) +ZBAR_CHK_CODE([pdf417], [PDF417 symbology]) +ZBAR_CHK_CODE([i25], [Interleaved 2 of 5 symbology]) dnl libraries @@ -378,10 +378,10 @@ AC_CONFIG_COMMANDS([doc/reldate.xml], AC_CONFIG_FILES([ Makefile -zebra.pc -zebra-gtk.pc -zebra-qt.pc -zebra.spec +zbar.pc +zbar-gtk.pc +zbar-qt.pc +zbar.spec doc/doxygen.conf ]) AC_OUTPUT @@ -395,13 +395,13 @@ echo "X --with-x=$with_x" echo "pthreads --enable-pthread=$enable_pthread" echo "v4l --enable-video=$enable_video" AS_IF([test "x$enable_video" != "xyes"], - [echo " => zebracam video scanner will *NOT* be built"]) + [echo " => zbarcam video scanner will *NOT* be built"]) echo "jpeg --with-jpeg=$with_jpeg" AS_IF([test "x$with_jpeg" != "xyes"], [echo " => JPEG image conversions will *NOT* be supported"]) echo "Magick++ --with-imagemagick=$with_imagemagick" AS_IF([test "x$with_imagemagick" != "xyes"], - [echo " => the zebraimg file scanner will *NOT* be built"]) + [echo " => the zbarimg file scanner will *NOT* be built"]) echo "Python --with-python=$with_python" echo "GTK+ --with-gtk=$with_gtk" AS_IF([test "x$with_gtk" != "xyes"], diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index a875afdd..00000000 --- a/debian/changelog +++ /dev/null @@ -1,37 +0,0 @@ -zebra (0.5-2) unstable; urgency=low - - * update libmagick version (bug #2070164) - * fix missing zebrapygtk dependency on libzebragtk (bug #2070164) - * also removed debian directory from releases (bug #2070164) - - -- Jeff Brown Sun, 24 July 2008 16:00:00 -0500 - -zebra (0.5-1) unstable; urgency=low - - * update to release 0.5 - * change source package name to zebra - * update binary name for new soname - * add binary packages for new widgets - * fixes for multi-package build - * remove autoreconf and documentation rebuild, along w/associated depends - - -- Jeff Brown Fri, 25 July 2008 21:00:00 -0500 - -zebra (0.4-1) unstable; urgency=low - - * update to release 0.4 - - -- Jeff Brown Fri, 30 May 2008 09:00:00 -0500 - -zebra (0.2-1) unstable; urgency=low - - * Added libsdl dependency - * automake1.10 is now required - - -- Vít Hrachový Thu, 17 May 2007 9:20:45 +0200 - -zebra (0.1-1) unstable; urgency=low - - * Initial release - - -- Vít Hrachový Wed, 11 Apr 2007 21:15:45 +0200 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011e..00000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/control b/debian/control deleted file mode 100644 index 5bc3001e..00000000 --- a/debian/control +++ /dev/null @@ -1,121 +0,0 @@ -Source: zebra -Section: libs -Priority: optional -Maintainer: Vít Hrachový -Homepage: http://zebra.sourceforge.net -Build-Depends: debhelper (>= 7), pkg-config, libx11-dev, python-dev (>= 2.3), libgtk2.0-dev, python-gtk2-dev, libqt4-dev, libmagick++9-dev -Standards-Version: 3.8.0 - -Package: libzebra3 -Section: libs -Architecture: any -Depends: ${shlibs:Depends} -Description: bar code scanning and decoding library - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains the shared library. - -Package: libzebra-dev -Section: libdevel -Architecture: any -Depends: libzebra3 (= ${binary:Version}) -Conflicts: libzebra-dev -Description: bar code library extra development files - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains header files and additional libraries used for - developing applications that read bar codes with this library. - -Package: libzebragtk0 -Section: libs -Architecture: any -Depends: libzebra3 (= ${binary:Version}), libgtk2.0-0 -Description: bar code reader GTK widget - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains a bar code scanning widget for use with GUI - applications based on GTK+-2.0. - -Package: libzebragtk-dev -Section: libdevel -Architecture: any -Depends: libzebragtk0 (= ${binary:Version}), libgtk2.0-dev -Description: bar code reader GTK widget extra development files - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains header files and additional libraries used for - developing GUI applications based on GTK+-2.0 that include a bar code - scanning widget. - -Package: python-zebrapygtk -Section: libs -Architecture: any -Depends: libzebragtk0 (= ${binary:Version}), python (>= 2.3), python-gtk2 -Description: bar code reader PyGTK widget - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains a bar code scanning widget for use in GUI - applications based on PyGTK. - -Package: libzebraqt0 -Section: libs -Architecture: any -Depends: libzebra3 (= ${binary:Version}), libqt4-0 -Description: bar code reader Qt widget - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains a bar code scanning widget for use with GUI - applications based on Qt4. - -Package: libzebraqt-dev -Section: libdevel -Architecture: any -Depends: libzebraqt0 (= ${binary:Version}), libqt4-dev -Description: bar code reader Qt widget extra development files - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package contains header files and additional libraries used for - developing GUI applications based on Qt4 that include a bar code - scanning widget. - -Package: zebra-tools -Section: graphics -Architecture: any -Depends: libzebra3 (= ${binary:Version}), ${shlibs:Depends}, libmagick10 -Description: utilities for reading bar codes from a webcam or image files - Zebra is a library for scanning and decoding bar codes from various - sources such as video streams, image files or raw intensity sensors. - It supports EAN, UPC, Code 128, Code 39 and Interleaved 2 of 5. The - flexible, layered architecture features a fast, streaming interface - with a minimal memory footprint. - . - This package provides basic applications for reading bar codes from a - video device or from captured images of bar codes. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index d6f769b0..00000000 --- a/debian/copyright +++ /dev/null @@ -1,518 +0,0 @@ -This package was debianized by Vít Hrachový on -Wed, 11 Apr 2007 21:15:45 +0200. - -It was downloaded from Sourceforge.net - -Upstream Author: Jeff Brown - -Copyright: 2006-2008 Jeff Brown - -License: - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - -The Debian packaging is (C) 2007, Vít Hrachový and -is licensed under the GPL, see `/usr/share/common-licenses/GPL'. - diff --git a/debian/libzebra-dev.install b/debian/libzebra-dev.install deleted file mode 100644 index 0d548f55..00000000 --- a/debian/libzebra-dev.install +++ /dev/null @@ -1,14 +0,0 @@ -usr/include/zebra.h -usr/include/zebra/Exception.h -usr/include/zebra/Symbol.h -usr/include/zebra/Image.h -usr/include/zebra/Decoder.h -usr/include/zebra/Scanner.h -usr/include/zebra/ImageScanner.h -usr/include/zebra/Video.h -usr/include/zebra/Window.h -usr/include/zebra/Processor.h -usr/lib/libzebra.la -usr/lib/libzebra.a -usr/lib/libzebra.so -usr/lib/pkgconfig/zebra.pc diff --git a/debian/libzebra3.install b/debian/libzebra3.install deleted file mode 100644 index 7e7ade69..00000000 --- a/debian/libzebra3.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/libzebra.so.* diff --git a/debian/libzebragtk-dev.install b/debian/libzebragtk-dev.install deleted file mode 100644 index 8080f6f6..00000000 --- a/debian/libzebragtk-dev.install +++ /dev/null @@ -1,5 +0,0 @@ -usr/include/zebra/zebragtk.h -usr/lib/libzebragtk.la -usr/lib/libzebragtk.a -usr/lib/libzebragtk.so -usr/lib/pkgconfig/zebra-gtk.pc diff --git a/debian/libzebragtk0.install b/debian/libzebragtk0.install deleted file mode 100644 index 160ac44e..00000000 --- a/debian/libzebragtk0.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/libzebragtk.so.* diff --git a/debian/libzebraqt-dev.install b/debian/libzebraqt-dev.install deleted file mode 100644 index 6d487940..00000000 --- a/debian/libzebraqt-dev.install +++ /dev/null @@ -1,5 +0,0 @@ -usr/include/zebra/QZebra*.h -usr/lib/libzebraqt.la -usr/lib/libzebraqt.a -usr/lib/libzebraqt.so -usr/lib/pkgconfig/zebra-qt.pc diff --git a/debian/libzebraqt0.install b/debian/libzebraqt0.install deleted file mode 100644 index 77cf98f6..00000000 --- a/debian/libzebraqt0.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/libzebraqt.so.* diff --git a/debian/python-zebrapygtk.install b/debian/python-zebrapygtk.install deleted file mode 100644 index 607c0659..00000000 --- a/debian/python-zebrapygtk.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/python* diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 0b16b668..00000000 --- a/debian/rules +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -# export DH_VERBOSE=1 - - -CFLAGS = -Wall -g - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -config.status: configure - dh_testdir - dh_auto_configure - -build: build-stamp -build-stamp: config.status - dh_testdir - dh_auto_build - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - dh_auto_clean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs - dh_auto_install - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs ChangeLog - dh_installdocs - dh_installexamples - dh_installmenu - dh_installman - dh_install --fail-missing -Xzebrapygtk.la - dh_link - dh_strip - dh_compress - dh_fixperms - dh_makeshlibs - dh_installdeb - dh_shlibdeps -- --ignore-missing-info - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install diff --git a/debian/zebra-tools.install b/debian/zebra-tools.install deleted file mode 100644 index 57c574e4..00000000 --- a/debian/zebra-tools.install +++ /dev/null @@ -1,4 +0,0 @@ -usr/bin/zebraimg -usr/bin/zebracam -usr/share/man/man1/*.1 -usr/share/doc/zebra/* diff --git a/doc/Makefile.am.inc b/doc/Makefile.am.inc index 5e83e2a0..fea5f369 100644 --- a/doc/Makefile.am.inc +++ b/doc/Makefile.am.inc @@ -1,22 +1,22 @@ # documentation sources DOCSOURCES = doc/manual.xml doc/version.xml doc/reldate.xml \ - doc/ref/zebraimg.xml doc/ref/zebracam.xml doc/ref/commonoptions.xml + doc/ref/zbarimg.xml doc/ref/zbarcam.xml doc/ref/commonoptions.xml # man page targets to distribute and install dist_man_MANS = if HAVE_MAGICK -dist_man_MANS += doc/man/zebraimg.1 +dist_man_MANS += doc/man/zbarimg.1 endif if HAVE_VIDEO -dist_man_MANS += doc/man/zebracam.1 +dist_man_MANS += doc/man/zbarcam.1 endif # witness to man page build (many-to-many workaround) man_stamp = doc/man/man.stamp # TBD add manual content -#dist_doc_DATA = doc/zebra.pdf doc/zebra.html +#dist_doc_DATA = doc/zbar.pdf doc/zbar.html # distribute all documentation related files to avoid end-user rebuilds EXTRA_DIST += $(DOCSOURCES) $(man_stamp) @@ -27,8 +27,8 @@ docs: $(dist_man_MANS) #dist_doc_DATA doc_path = --searchpath $(abs_builddir)/doc -m $(abs_srcdir)/doc/style.xsl -#pdf: doc/zebra-manual.pdf -#doc/zebra-manual.pdf: $(DOCSOURCES) +#pdf: doc/zbar-manual.pdf +#doc/zbar-manual.pdf: $(DOCSOURCES) # $(XMLTO) $(XMLTOFLAGS) -o doc pdf $< html-local: doc/html/index.html diff --git a/doc/api/footer.html b/doc/api/footer.html index cf93d9da..d9529a35 100644 --- a/doc/api/footer.html +++ b/doc/api/footer.html @@ -9,7 +9,7 @@
spadix@users.sourceforge.net
-

Copyright 2008 (c) Jeff Brown - All Rights Reserved.

+

Copyright 2008-2009 (c) Jeff Brown - All Rights Reserved.

Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

diff --git a/doc/doxygen.conf.in b/doc/doxygen.conf.in index 546d433f..c7a23902 100644 --- a/doc/doxygen.conf.in +++ b/doc/doxygen.conf.in @@ -1,9 +1,9 @@ -PROJECT_NAME = "Zebra Barcode Reader Library" +PROJECT_NAME = "ZBar Bar Code Reader Library" PROJECT_NUMBER = "version @VERSION@" INPUT = @top_srcdir@/include RECURSIVE = YES -EXCLUDE = @top_srcdir@/include/zebra/zebragtk.h +EXCLUDE = @top_srcdir@/include/zbar/zbargtk.h EXCLUDE_PATTERNS = */.svn/* STRIP_FROM_PATH = @top_srcdir@ diff --git a/doc/manual.xml b/doc/manual.xml index 3c4edea4..076ca239 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -7,14 +7,14 @@ - - + + ]> - Zebra Barcode Reader + ZBar Barcode Reader - zebra-&version; + zbar-&version; &date; @@ -31,7 +31,6 @@ Jeff Brown All Rights Reserved - @@ -41,10 +40,10 @@ - Zebra Barcode Reader - Command Reference + ZBar Barcode Reader - Command Reference - &refzebracam; - &refzebraimg; + &refzbarcam; + &refzbarimg; diff --git a/doc/ref/commonoptions.xml b/doc/ref/commonoptions.xml index 53543cad..15665f28 100644 --- a/doc/ref/commonoptions.xml +++ b/doc/ref/commonoptions.xml @@ -111,7 +111,5 @@ - - diff --git a/doc/ref/zebracam.xml b/doc/ref/zbarcam.xml similarity index 86% rename from doc/ref/zebracam.xml rename to doc/ref/zbarcam.xml index 1eaf8945..a0be0140 100644 --- a/doc/ref/zebracam.xml +++ b/doc/ref/zbarcam.xml @@ -1,13 +1,13 @@ - - zebracam + zbarcam 1 - zebracam + zbarcam scan and decode bar codes from a video device @@ -15,7 +15,7 @@ - zebracam + zbarcam @@ -37,7 +37,7 @@ - zebracam + zbarcam @@ -49,7 +49,7 @@ Description - zebracam scans a video4linux video source + zbarcam scans a video4linux video source (eg, a webcam) for bar codes and prints any decoded data to the standard output. The video stream is also displayed to the screen. @@ -100,7 +100,7 @@ Stream results using an XML output format. This format wraps the raw data from the symbol with information about the scan in an easy to parse format. The latest - schema is available from . + schema is available from . @@ -126,7 +126,7 @@ resulting data through a script that searches for each code in a database and does something useful with them: - zebracam /dev/video1 | upcrpc.py + zbarcam /dev/video1 | upcrpc.py The upcrpc.py example script included in the examples/ subdirectory of the distribution @@ -138,21 +138,21 @@ Interleaved 2 of 5 codes to prevent confusion with other symbologies or background noise: - zebracam + zbarcam Scan only for Code 39, without using the preview window - maybe for a fixed installation. To enable only Code 39, first all symbologies are disabled, then Code 39 is re-enabled: - zebracam + zbarcam See Also - - + + diff --git a/doc/ref/zebraimg.xml b/doc/ref/zbarimg.xml similarity index 87% rename from doc/ref/zebraimg.xml rename to doc/ref/zbarimg.xml index dae26027..b3e5616e 100644 --- a/doc/ref/zebraimg.xml +++ b/doc/ref/zbarimg.xml @@ -1,13 +1,13 @@ - - zebraimg + zbarimg 1 - zebraimg + zbarimg scan and decode bar codes from image file(s) @@ -15,7 +15,7 @@ - zebraimg + zbarimg See Also - - + + diff --git a/examples/paginate.pl b/examples/paginate.pl index 24262087..68ffe505 100755 --- a/examples/paginate.pl +++ b/examples/paginate.pl @@ -2,29 +2,29 @@ #------------------------------------------------------------------------ # Copyright 2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ use warnings; use strict; -use Barcode::Zebra; +use Barcode::ZBar; use Image::Magick; warn("no input files specified?\n") if(!@ARGV); @@ -33,7 +33,7 @@ my $out = undef; # barcode scanner -my $scanner = Barcode::Zebra::ImageScanner->new(); +my $scanner = Barcode::ZBar::ImageScanner->new(); foreach my $file (@ARGV) { print "scanning from \"$file\"\n"; @@ -42,8 +42,8 @@ warn($err) if($err); foreach my $page (@$imseq) { - # convert ImageMagick page to Zebra image - my $zimg = Barcode::Zebra::Image->new(); + # convert ImageMagick page to ZBar image + my $zimg = Barcode::ZBar::Image->new(); $zimg->set_format('Y800'); $zimg->set_size($page->Get(qw(columns rows))); $zimg->set_data($page->Clone()->ImageToBlob(magick => 'GRAY', depth => 8)); diff --git a/examples/processor.pl b/examples/processor.pl index ef1f2011..e14a4a3c 100755 --- a/examples/processor.pl +++ b/examples/processor.pl @@ -1,10 +1,10 @@ #!/usr/bin/env perl use warnings; use strict; -require Barcode::Zebra; +require Barcode::ZBar; # create a Processor -my $proc = Barcode::Zebra::Processor->new(); +my $proc = Barcode::ZBar::Processor->new(); # configure the Processor $proc->parse_config("enable"); diff --git a/examples/processor.py b/examples/processor.py index 8d86a84e..e5651642 100755 --- a/examples/processor.py +++ b/examples/processor.py @@ -1,9 +1,9 @@ #!/usr/bin/python from sys import argv -import zebra +import zbar # create a Processor -proc = zebra.Processor() +proc = zbar.Processor() # configure the Processor proc.parse_config('enable') @@ -31,5 +31,5 @@ def my_handler(proc, image, closure): proc.active = True try: proc.user_wait() -except zebra.WindowClosed, e: +except zbar.WindowClosed, e: pass diff --git a/examples/scan_image.c b/examples/scan_image.c index b8b81c11..2ce4a68a 100644 --- a/examples/scan_image.c +++ b/examples/scan_image.c @@ -1,9 +1,9 @@ #include #include #include -#include +#include -zebra_image_scanner_t *scanner = NULL; +zbar_image_scanner_t *scanner = NULL; /* to complete a runnable example, this abbreviated implementation of * get_data() will use libpng to read an image file. refer to libpng @@ -53,10 +53,10 @@ int main (int argc, char **argv) if(argc < 2) return(1); /* create a reader */ - scanner = zebra_image_scanner_create(); + scanner = zbar_image_scanner_create(); /* configure the reader */ - zebra_image_scanner_set_config(scanner, 0, ZEBRA_CFG_ENABLE, 1); + zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1); /* obtain image data */ int width = 0, height = 0; @@ -64,26 +64,26 @@ int main (int argc, char **argv) get_data(argv[1], &width, &height, &raw); /* wrap image data */ - zebra_image_t *image = zebra_image_create(); - zebra_image_set_format(image, *(int*)"Y800"); - zebra_image_set_size(image, width, height); - zebra_image_set_data(image, raw, width * height, zebra_image_free_data); + zbar_image_t *image = zbar_image_create(); + zbar_image_set_format(image, *(int*)"Y800"); + zbar_image_set_size(image, width, height); + zbar_image_set_data(image, raw, width * height, zbar_image_free_data); /* scan the image for barcodes */ - int n = zebra_scan_image(scanner, image); + int n = zbar_scan_image(scanner, image); /* extract results */ - const zebra_symbol_t *symbol = zebra_image_first_symbol(image); - for(; symbol; symbol = zebra_symbol_next(symbol)) { + const zbar_symbol_t *symbol = zbar_image_first_symbol(image); + for(; symbol; symbol = zbar_symbol_next(symbol)) { /* do something useful with results */ - zebra_symbol_type_t typ = zebra_symbol_get_type(symbol); - const char *data = zebra_symbol_get_data(symbol); + zbar_symbol_type_t typ = zbar_symbol_get_type(symbol); + const char *data = zbar_symbol_get_data(symbol); printf("decoded %s symbol \"%s\"\n", - zebra_get_symbol_name(typ), data); + zbar_get_symbol_name(typ), data); } /* clean up */ - zebra_image_destroy(image); + zbar_image_destroy(image); return(0); } diff --git a/examples/scan_image.cpp b/examples/scan_image.cpp index 8edf06bd..18a65a32 100644 --- a/examples/scan_image.cpp +++ b/examples/scan_image.cpp @@ -1,9 +1,9 @@ #include #include -#include +#include using namespace std; -using namespace zebra; +using namespace zbar; int main (int argc, char **argv) { @@ -13,7 +13,7 @@ int main (int argc, char **argv) ImageScanner scanner; // configure the reader - scanner.set_config(ZEBRA_NONE, ZEBRA_CFG_ENABLE, 1); + scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); // obtain image data Magick::Image magick(argv[1]); // read an image file diff --git a/examples/scan_image.pl b/examples/scan_image.pl index 93185e5b..3734d19e 100755 --- a/examples/scan_image.pl +++ b/examples/scan_image.pl @@ -2,12 +2,12 @@ use warnings; use strict; require Image::Magick; -require Barcode::Zebra; +require Barcode::ZBar; $ARGV[0] || die; # create a reader -my $scanner = Barcode::Zebra::ImageScanner->new(); +my $scanner = Barcode::ZBar::ImageScanner->new(); # configure the reader $scanner->parse_config("enable"); @@ -18,7 +18,7 @@ my $raw = $magick->ImageToBlob(magick => 'GRAY'); # wrap image data -my $image = Barcode::Zebra::Image->new(); +my $image = Barcode::ZBar::Image->new(); $image->set_format('Y800'); $image->set_size($magick->Get(qw(columns rows))); $image->set_data($raw); diff --git a/examples/scan_image.py b/examples/scan_image.py index ec584adc..2a80759d 100755 --- a/examples/scan_image.py +++ b/examples/scan_image.py @@ -1,12 +1,12 @@ #!/usr/bin/python from sys import argv -import zebra +import zbar import Image if len(argv) < 2: exit(1) # create a reader -scanner = zebra.ImageScanner() +scanner = zbar.ImageScanner() # configure the reader scanner.parse_config('enable') @@ -17,7 +17,7 @@ raw = pil.tostring() # wrap image data -image = zebra.Image(width, height, 'Y800', raw) +image = zbar.Image(width, height, 'Y800', raw) # scan the image for barcodes scanner.scan(image) diff --git a/gtk/Makefile.am.inc b/gtk/Makefile.am.inc index 2bc511e0..cf5132d4 100644 --- a/gtk/Makefile.am.inc +++ b/gtk/Makefile.am.inc @@ -1,18 +1,18 @@ -lib_LTLIBRARIES += gtk/libzebragtk.la -gtk_libzebragtk_la_CPPFLAGS = -Igtk $(GTK_CFLAGS) $(AM_CPPFLAGS) -gtk_libzebragtk_la_LDFLAGS = -version-info $(ZGTK_LIB_VERSION) \ - -export-symbols-regex "^zebra_gtk_.*" $(AM_LDFLAGS) -gtk_libzebragtk_la_LIBADD = $(GTK_LIBS) zebra/libzebra.la $(AM_LIBADD) +lib_LTLIBRARIES += gtk/libzbargtk.la +gtk_libzbargtk_la_CPPFLAGS = -Igtk $(GTK_CFLAGS) $(AM_CPPFLAGS) +gtk_libzbargtk_la_LDFLAGS = -version-info $(ZGTK_LIB_VERSION) \ + -export-symbols-regex "^zbar_gtk_.*" $(AM_LDFLAGS) +gtk_libzbargtk_la_LIBADD = $(GTK_LIBS) zbar/libzbar.la $(AM_LIBADD) -gtk_libzebragtk_la_SOURCES = gtk/zebragtk.c gtk/zebragtkprivate.h \ - gtk/zebramarshal.c gtk/zebramarshal.h -BUILT_SOURCES += gtk/zebramarshal.c gtk/zebramarshal.h -EXTRA_DIST += gtk/zebramarshal.list +gtk_libzbargtk_la_SOURCES = gtk/zbargtk.c gtk/zbargtkprivate.h \ + gtk/zbarmarshal.c gtk/zbarmarshal.h +BUILT_SOURCES += gtk/zbarmarshal.c gtk/zbarmarshal.h +EXTRA_DIST += gtk/zbarmarshal.list %.h: %.list - $(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zebra_marshal \ + $(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zbar_marshal \ --header $^ > $@ %.c: %.list - $(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zebra_marshal \ + $(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zbar_marshal \ --body $^ > $@ diff --git a/gtk/zebragtk.c b/gtk/zbargtk.c similarity index 52% rename from gtk/zebragtk.c rename to gtk/zbargtk.c index 75418d42..67dc842b 100644 --- a/gtk/zebragtk.c +++ b/gtk/zbargtk.c @@ -1,32 +1,32 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include -#include -#include "zebragtkprivate.h" -#include "zebramarshal.h" +#include +#include "zbargtkprivate.h" +#include "zbarmarshal.h" #ifndef G_PARAM_STATIC_STRINGS # define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) @@ -53,27 +53,27 @@ enum { PROP_VIDEO_OPENED, }; -static guint zebra_gtk_signals[LAST_SIGNAL] = { 0 }; +static guint zbar_gtk_signals[LAST_SIGNAL] = { 0 }; -static gpointer zebra_gtk_parent_class = NULL; +static gpointer zbar_gtk_parent_class = NULL; /* FIXME what todo w/errors? OOM? */ /* FIXME signal failure notifications to main gui thread */ -void zebra_gtk_release_pixbuf (zebra_image_t *img) +void zbar_gtk_release_pixbuf (zbar_image_t *img) { - GdkPixbuf *pixbuf = zebra_image_get_userdata(img); + GdkPixbuf *pixbuf = zbar_image_get_userdata(img); g_assert(GDK_IS_PIXBUF(pixbuf)); /* remove reference */ - zebra_image_set_userdata(img, NULL); + zbar_image_set_userdata(img, NULL); /* release reference to associated pixbuf and it's data */ g_object_unref(pixbuf); } -gboolean zebra_gtk_image_from_pixbuf (zebra_image_t *zimg, - GdkPixbuf *pixbuf) +gboolean zbar_gtk_image_from_pixbuf (zbar_image_t *zimg, + GdkPixbuf *pixbuf) { /* apparently should always be packed RGB? */ GdkColorspace colorspace = gdk_pixbuf_get_colorspace(pixbuf); @@ -102,7 +102,7 @@ gboolean zebra_gtk_image_from_pixbuf (zebra_image_t *zimg, nchannels, bps); return(FALSE); } - zebra_image_set_format(zimg, type); + zbar_image_set_format(zimg, type); /* FIXME we don't deal w/bpl... * this will cause problems w/unpadded pixbufs :| @@ -117,15 +117,15 @@ gboolean zebra_gtk_image_from_pixbuf (zebra_image_t *zimg, unsigned height = gdk_pixbuf_get_height(pixbuf); /* FIXME this isn't correct either */ unsigned long datalen = width * height * nchannels; - zebra_image_set_size(zimg, width, height); + zbar_image_set_size(zimg, width, height); - /* when the zebra image is released, the pixbuf will be + /* when the zbar image is released, the pixbuf will be * automatically be released */ - zebra_image_set_userdata(zimg, pixbuf); - zebra_image_set_data(zimg, gdk_pixbuf_get_pixels(pixbuf), datalen, - zebra_gtk_release_pixbuf); -#ifdef DEBUG_ZEBRAGTK + zbar_image_set_userdata(zimg, pixbuf); + zbar_image_set_data(zimg, gdk_pixbuf_get_pixels(pixbuf), datalen, + zbar_gtk_release_pixbuf); +#ifdef DEBUG_ZBARGTK g_message("colorspace=%d nchannels=%d bps=%d type=%.4s(%08lx)\n" "\tpitch=%d width=%d height=%d datalen=0x%lx\n", colorspace, nchannels, bps, (char*)&type, type, @@ -134,47 +134,47 @@ gboolean zebra_gtk_image_from_pixbuf (zebra_image_t *zimg, return(TRUE); } -static inline gboolean zebra_gtk_video_open (ZebraGtk *self, - const char *video_device) +static inline gboolean zbar_gtk_video_open (ZBarGtk *self, + const char *video_device) { - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); gboolean video_opened = FALSE; gdk_threads_enter(); - zebra->req_width = DEFAULT_WIDTH; - zebra->req_height = DEFAULT_HEIGHT; + zbar->req_width = DEFAULT_WIDTH; + zbar->req_height = DEFAULT_HEIGHT; gtk_widget_queue_resize(GTK_WIDGET(self)); - zebra->video_opened = FALSE; - if(zebra->thread) + zbar->video_opened = FALSE; + if(zbar->thread) g_object_notify(G_OBJECT(self), "video-opened"); - if(zebra->window) { + if(zbar->window) { /* ensure old video doesn't have image ref * (FIXME handle video destroyed w/images outstanding) */ - zebra_window_draw(zebra->window, NULL); + zbar_window_draw(zbar->window, NULL); gtk_widget_queue_draw(GTK_WIDGET(self)); } gdk_threads_leave(); - if(zebra->video) { - zebra_video_destroy(zebra->video); - zebra->video = NULL; + if(zbar->video) { + zbar_video_destroy(zbar->video); + zbar->video = NULL; } - if(video_device && video_device[0] && zebra->thread) { + if(video_device && video_device[0] && zbar->thread) { /* create video * FIXME video should support re-open */ - zebra->video = zebra_video_create(); - g_assert(zebra->video); + zbar->video = zbar_video_create(); + g_assert(zbar->video); - if(zebra_video_open(zebra->video, video_device)) { - zebra_video_error_spew(zebra->video, 0); - zebra_video_destroy(zebra->video); - zebra->video = NULL; + if(zbar_video_open(zbar->video, video_device)) { + zbar_video_error_spew(zbar->video, 0); + zbar_video_destroy(zbar->video); + zbar->video = NULL; /* FIXME error propagation */ return(FALSE); } @@ -184,16 +184,16 @@ static inline gboolean zebra_gtk_video_open (ZebraGtk *self, */ gdk_threads_enter(); - video_opened = !zebra_negotiate_format(zebra->video, zebra->window); + video_opened = !zbar_negotiate_format(zbar->video, zbar->window); if(video_opened) { - zebra->req_width = zebra_video_get_width(zebra->video); - zebra->req_height = zebra_video_get_height(zebra->video); + zbar->req_width = zbar_video_get_width(zbar->video); + zbar->req_height = zbar_video_get_height(zbar->video); } gtk_widget_queue_resize(GTK_WIDGET(self)); - zebra->video_opened = video_opened; - if(zebra->thread) + zbar->video_opened = video_opened; + if(zbar->thread) g_object_notify(G_OBJECT(self), "video-opened"); gdk_threads_leave(); @@ -201,45 +201,45 @@ static inline gboolean zebra_gtk_video_open (ZebraGtk *self, return(video_opened); } -static inline int zebra_gtk_process_image (ZebraGtk *self, - zebra_image_t *image) +static inline int zbar_gtk_process_image (ZBarGtk *self, + zbar_image_t *image) { - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); if(!image) return(-1); - int rc = zebra_scan_image(zebra->scanner, image); + int rc = zbar_scan_image(zbar->scanner, image); if(rc < 0) return(rc); gdk_threads_enter(); - if(rc && zebra->thread) { + if(rc && zbar->thread) { /* update decode results */ - const zebra_symbol_t *sym; - for(sym = zebra_image_first_symbol(image); + const zbar_symbol_t *sym; + for(sym = zbar_image_first_symbol(image); sym; - sym = zebra_symbol_next(sym)) - if(!zebra_symbol_get_count(sym)) { - zebra_symbol_type_t type = zebra_symbol_get_type(sym); - const char *data = zebra_symbol_get_data(sym); - g_signal_emit(self, zebra_gtk_signals[DECODED], 0, + sym = zbar_symbol_next(sym)) + if(!zbar_symbol_get_count(sym)) { + zbar_symbol_type_t type = zbar_symbol_get_type(sym); + const char *data = zbar_symbol_get_data(sym); + g_signal_emit(self, zbar_gtk_signals[DECODED], 0, type, data); /* FIXME skip this when unconnected? */ - gchar *text = g_strconcat(zebra_get_symbol_name(type), - zebra_get_addon_name(type), + gchar *text = g_strconcat(zbar_get_symbol_name(type), + zbar_get_addon_name(type), ":", data, NULL); - g_signal_emit(self, zebra_gtk_signals[DECODED_TEXT], 0, text); + g_signal_emit(self, zbar_gtk_signals[DECODED_TEXT], 0, text); g_free(text); } } - if(zebra->window) { - rc = zebra_window_draw(zebra->window, image); + if(zbar->window) { + rc = zbar_window_draw(zbar->window, image); gtk_widget_queue_draw(GTK_WIDGET(self)); } else @@ -248,18 +248,18 @@ static inline int zebra_gtk_process_image (ZebraGtk *self, return(rc); } -static void *zebra_gtk_processing_thread (void *arg) +static void *zbar_gtk_processing_thread (void *arg) { - ZebraGtk *self = ZEBRA_GTK(arg); + ZBarGtk *self = ZBAR_GTK(arg); if(!self->_private) return(NULL); - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); - g_object_ref(zebra); - g_assert(zebra->queue); - g_async_queue_ref(zebra->queue); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); + g_object_ref(zbar); + g_assert(zbar->queue); + g_async_queue_ref(zbar->queue); - zebra->scanner = zebra_image_scanner_create(); - g_assert(zebra->scanner); + zbar->scanner = zbar_image_scanner_create(); + g_assert(zbar->scanner); /* thread side enabled state */ gboolean video_enabled = FALSE; @@ -267,7 +267,7 @@ static void *zebra_gtk_processing_thread (void *arg) while(TRUE) { if(!msg) - msg = g_async_queue_pop(zebra->queue); + msg = g_async_queue_pop(zbar->queue); g_assert(G_IS_VALUE(msg)); GType type = G_VALUE_TYPE(msg); @@ -287,17 +287,17 @@ static void *zebra_gtk_processing_thread (void *arg) else if(type == G_TYPE_STRING) { /* open new video device */ const char *video_device = g_value_get_string(msg); - video_enabled = zebra_gtk_video_open(self, video_device); + video_enabled = zbar_gtk_video_open(self, video_device); } else if(type == GDK_TYPE_PIXBUF) { /* scan provided image and broadcast results */ - zebra_image_t *image = zebra_image_create(); + zbar_image_t *image = zbar_image_create(); GdkPixbuf *pixbuf = GDK_PIXBUF(g_value_dup_object(msg)); - if(zebra_gtk_image_from_pixbuf(image, pixbuf)) - zebra_gtk_process_image(self, image); + if(zbar_gtk_image_from_pixbuf(image, pixbuf)) + zbar_gtk_process_image(self, image); else g_object_unref(pixbuf); - zebra_image_destroy(image); + zbar_image_destroy(image); } else { gchar *dbg = g_strdup_value_contents(msg); @@ -311,52 +311,52 @@ static void *zebra_gtk_processing_thread (void *arg) if(video_enabled) { /* release reference to any previous pixbuf */ - zebra_window_draw(zebra->window, NULL); + zbar_window_draw(zbar->window, NULL); - if(zebra_video_enable(zebra->video, 1)) { - zebra_video_error_spew(zebra->video, 0); + if(zbar_video_enable(zbar->video, 1)) { + zbar_video_error_spew(zbar->video, 0); video_enabled = FALSE; continue; } - zebra_image_scanner_enable_cache(zebra->scanner, 1); + zbar_image_scanner_enable_cache(zbar->scanner, 1); while(video_enabled && - !(msg = g_async_queue_try_pop(zebra->queue))) { - zebra_image_t *image = zebra_video_next_image(zebra->video); - if(zebra_gtk_process_image(self, image) < 0) + !(msg = g_async_queue_try_pop(zbar->queue))) { + zbar_image_t *image = zbar_video_next_image(zbar->video); + if(zbar_gtk_process_image(self, image) < 0) video_enabled = FALSE; if(image) - zebra_image_destroy(image); + zbar_image_destroy(image); } - zebra_image_scanner_enable_cache(zebra->scanner, 0); - if(zebra_video_enable(zebra->video, 0)) { - zebra_video_error_spew(zebra->video, 0); + zbar_image_scanner_enable_cache(zbar->scanner, 0); + if(zbar_video_enable(zbar->video, 0)) { + zbar_video_error_spew(zbar->video, 0); video_enabled = FALSE; } /* release video image and revert to logo */ - if(zebra->window) { - zebra_window_draw(zebra->window, NULL); + if(zbar->window) { + zbar_window_draw(zbar->window, NULL); gtk_widget_queue_draw(GTK_WIDGET(self)); } if(!video_enabled) /* must have been an error while streaming */ - zebra_gtk_video_open(self, NULL); + zbar_gtk_video_open(self, NULL); } } - if(zebra->window) - zebra_window_draw(zebra->window, NULL); - g_object_unref(zebra); + if(zbar->window) + zbar_window_draw(zbar->window, NULL); + g_object_unref(zbar); return(NULL); } -static void zebra_gtk_realize (GtkWidget *widget) +static void zbar_gtk_realize (GtkWidget *widget) { - ZebraGtk *self = ZEBRA_GTK(widget); + ZBarGtk *self = ZBAR_GTK(widget); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); GTK_WIDGET_UNSET_FLAGS(widget, GTK_DOUBLE_BUFFERED); GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); @@ -377,36 +377,36 @@ static void zebra_gtk_realize (GtkWidget *widget) gdk_window_set_user_data(widget->window, widget); gdk_window_set_back_pixmap(widget->window, NULL, TRUE); - /* attach zebra_window to underlying X window */ - if(zebra_window_attach(zebra->window, + /* attach zbar_window to underlying X window */ + if(zbar_window_attach(zbar->window, gdk_x11_drawable_get_xdisplay(widget->window), gdk_x11_drawable_get_xid(widget->window))) - zebra_window_error_spew(zebra->window, 0); + zbar_window_error_spew(zbar->window, 0); } -static inline GValue *zebra_gtk_new_value (GType type) +static inline GValue *zbar_gtk_new_value (GType type) { return(g_value_init(g_malloc0(sizeof(GValue)), type)); } -static void zebra_gtk_unrealize (GtkWidget *widget) +static void zbar_gtk_unrealize (GtkWidget *widget) { if(GTK_WIDGET_MAPPED(widget)) gtk_widget_unmap(widget); - ZebraGtk *self = ZEBRA_GTK(widget); + ZBarGtk *self = ZBAR_GTK(widget); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); - if(zebra->video_enabled) { - zebra->video_enabled = FALSE; - GValue *msg = zebra_gtk_new_value(G_TYPE_INT); + if(zbar->video_enabled) { + zbar->video_enabled = FALSE; + GValue *msg = zbar_gtk_new_value(G_TYPE_INT); g_value_set_int(msg, 0); - g_async_queue_push(zebra->queue, msg); + g_async_queue_push(zbar->queue, msg); } - zebra_window_attach(zebra->window, NULL, 0); + zbar_window_attach(zbar->window, NULL, 0); GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED); @@ -415,101 +415,101 @@ static void zebra_gtk_unrealize (GtkWidget *widget) widget->window = NULL; } -static void zebra_gtk_size_request (GtkWidget *widget, - GtkRequisition *requisition) +static void zbar_gtk_size_request (GtkWidget *widget, + GtkRequisition *requisition) { - ZebraGtk *self = ZEBRA_GTK(widget); + ZBarGtk *self = ZBAR_GTK(widget); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); /* use native video size (max) if available, * arbitrary defaults otherwise. * video attributes maintained under main gui thread lock */ - requisition->width = zebra->req_width; - requisition->height = zebra->req_height; + requisition->width = zbar->req_width; + requisition->height = zbar->req_height; } -static void zebra_gtk_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) +static void zbar_gtk_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { - ZebraGtk *self = ZEBRA_GTK(widget); + ZBarGtk *self = ZBAR_GTK(widget); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); - (*GTK_WIDGET_CLASS(zebra_gtk_parent_class)->size_allocate) + (*GTK_WIDGET_CLASS(zbar_gtk_parent_class)->size_allocate) (widget, allocation); - if(zebra->window) - zebra_window_resize(zebra->window, + if(zbar->window) + zbar_window_resize(zbar->window, allocation->width, allocation->height); } -static gboolean zebra_gtk_expose (GtkWidget *widget, - GdkEventExpose *event) +static gboolean zbar_gtk_expose (GtkWidget *widget, + GdkEventExpose *event) { - ZebraGtk *self = ZEBRA_GTK(widget); + ZBarGtk *self = ZBAR_GTK(widget); if(!self->_private) return(FALSE); - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); if(GTK_WIDGET_VISIBLE(widget) && GTK_WIDGET_MAPPED(widget) && - zebra_window_redraw(zebra->window)) + zbar_window_redraw(zbar->window)) return(TRUE); return(FALSE); } -void zebra_gtk_scan_image (ZebraGtk *self, - GdkPixbuf *img) +void zbar_gtk_scan_image (ZBarGtk *self, + GdkPixbuf *img) { if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); g_object_ref(G_OBJECT(img)); /* queue for scanning by the processor thread */ - GValue *msg = zebra_gtk_new_value(GDK_TYPE_PIXBUF); + GValue *msg = zbar_gtk_new_value(GDK_TYPE_PIXBUF); /* this grabs a new reference to the image, * eventually released by the processor thread */ g_value_set_object(msg, img); - g_async_queue_push(zebra->queue, msg); + g_async_queue_push(zbar->queue, msg); } -const char *zebra_gtk_get_video_device (ZebraGtk *self) +const char *zbar_gtk_get_video_device (ZBarGtk *self) { if(!self->_private) return(NULL); - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); - if(zebra->video_device) - return(zebra->video_device); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); + if(zbar->video_device) + return(zbar->video_device); else return(""); } -void zebra_gtk_set_video_device (ZebraGtk *self, - const char *video_device) +void zbar_gtk_set_video_device (ZBarGtk *self, + const char *video_device) { if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); - g_free((void*)zebra->video_device); - zebra->video_device = g_strdup(video_device); - zebra->video_enabled = video_device && video_device[0]; + g_free((void*)zbar->video_device); + zbar->video_device = g_strdup(video_device); + zbar->video_enabled = video_device && video_device[0]; /* push another copy to processor thread */ - GValue *msg = zebra_gtk_new_value(G_TYPE_STRING); + GValue *msg = zbar_gtk_new_value(G_TYPE_STRING); if(video_device) g_value_set_string(msg, video_device); else g_value_set_static_string(msg, ""); - g_async_queue_push(zebra->queue, msg); + g_async_queue_push(zbar->queue, msg); g_object_freeze_notify(G_OBJECT(self)); g_object_notify(G_OBJECT(self), "video-device"); @@ -517,180 +517,180 @@ void zebra_gtk_set_video_device (ZebraGtk *self, g_object_thaw_notify(G_OBJECT(self)); } -gboolean zebra_gtk_get_video_enabled (ZebraGtk *self) +gboolean zbar_gtk_get_video_enabled (ZBarGtk *self) { if(!self->_private) return(FALSE); - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); - return(zebra->video_enabled); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); + return(zbar->video_enabled); } -void zebra_gtk_set_video_enabled (ZebraGtk *self, - gboolean video_enabled) +void zbar_gtk_set_video_enabled (ZBarGtk *self, + gboolean video_enabled) { if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); video_enabled = (video_enabled != FALSE); - if(zebra->video_enabled != video_enabled) { - zebra->video_enabled = video_enabled; + if(zbar->video_enabled != video_enabled) { + zbar->video_enabled = video_enabled; /* push state change to processor thread */ - GValue *msg = zebra_gtk_new_value(G_TYPE_INT); - g_value_set_int(msg, zebra->video_enabled); - g_async_queue_push(zebra->queue, msg); + GValue *msg = zbar_gtk_new_value(G_TYPE_INT); + g_value_set_int(msg, zbar->video_enabled); + g_async_queue_push(zbar->queue, msg); g_object_notify(G_OBJECT(self), "video-enabled"); } } -gboolean zebra_gtk_get_video_opened (ZebraGtk *self) +gboolean zbar_gtk_get_video_opened (ZBarGtk *self) { if(!self->_private) return(FALSE); - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); - return(zebra->video_opened); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); + return(zbar->video_opened); } -static void zebra_gtk_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +static void zbar_gtk_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - ZebraGtk *self = ZEBRA_GTK(object); + ZBarGtk *self = ZBAR_GTK(object); switch(prop_id) { case PROP_VIDEO_DEVICE: - zebra_gtk_set_video_device(self, g_value_get_string(value)); + zbar_gtk_set_video_device(self, g_value_get_string(value)); break; case PROP_VIDEO_ENABLED: - zebra_gtk_set_video_enabled(self, g_value_get_boolean(value)); + zbar_gtk_set_video_enabled(self, g_value_get_boolean(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } } -static void zebra_gtk_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +static void zbar_gtk_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - ZebraGtk *self = ZEBRA_GTK(object); + ZBarGtk *self = ZBAR_GTK(object); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); switch(prop_id) { case PROP_VIDEO_DEVICE: - if(zebra->video_device) - g_value_set_string(value, zebra->video_device); + if(zbar->video_device) + g_value_set_string(value, zbar->video_device); else g_value_set_static_string(value, ""); break; case PROP_VIDEO_ENABLED: - g_value_set_boolean(value, zebra->video_enabled); + g_value_set_boolean(value, zbar->video_enabled); break; case PROP_VIDEO_OPENED: - g_value_set_boolean(value, zebra->video_opened); + g_value_set_boolean(value, zbar->video_opened); default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } } -static void zebra_gtk_init (ZebraGtk *self) +static void zbar_gtk_init (ZBarGtk *self) { - ZebraGtkPrivate *zebra = g_object_new(ZEBRA_TYPE_GTK_PRIVATE, NULL); - self->_private = (void*)zebra; + ZBarGtkPrivate *zbar = g_object_new(ZBAR_TYPE_GTK_PRIVATE, NULL); + self->_private = (void*)zbar; - zebra->window = zebra_window_create(); - g_assert(zebra->window); + zbar->window = zbar_window_create(); + g_assert(zbar->window); - zebra->req_width = DEFAULT_WIDTH; - zebra->req_height = DEFAULT_HEIGHT; + zbar->req_width = DEFAULT_WIDTH; + zbar->req_height = DEFAULT_HEIGHT; /* spawn a thread to handle decoding and video */ - zebra->queue = g_async_queue_new(); - zebra->thread = g_thread_create(zebra_gtk_processing_thread, self, + zbar->queue = g_async_queue_new(); + zbar->thread = g_thread_create(zbar_gtk_processing_thread, self, FALSE, NULL); - g_assert(zebra->thread); + g_assert(zbar->thread); } -static void zebra_gtk_dispose (GObject *object) +static void zbar_gtk_dispose (GObject *object) { - ZebraGtk *self = ZEBRA_GTK(object); + ZBarGtk *self = ZBAR_GTK(object); if(!self->_private) return; - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(self->_private); + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private); self->_private = NULL; - g_free((void*)zebra->video_device); - zebra->video_device = NULL; + g_free((void*)zbar->video_device); + zbar->video_device = NULL; /* signal processor thread to exit */ - GValue *msg = zebra_gtk_new_value(G_TYPE_INT); + GValue *msg = zbar_gtk_new_value(G_TYPE_INT); g_value_set_int(msg, -1); - g_async_queue_push(zebra->queue, msg); - zebra->thread = NULL; + g_async_queue_push(zbar->queue, msg); + zbar->thread = NULL; /* there are no external references which might call other APIs */ - g_async_queue_unref(zebra->queue); + g_async_queue_unref(zbar->queue); - g_object_unref(G_OBJECT(zebra)); + g_object_unref(G_OBJECT(zbar)); } -static void zebra_gtk_private_finalize (GObject *object) +static void zbar_gtk_private_finalize (GObject *object) { - ZebraGtkPrivate *zebra = ZEBRA_GTK_PRIVATE(object); - if(zebra->window) { - zebra_window_destroy(zebra->window); - zebra->window = NULL; + ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(object); + if(zbar->window) { + zbar_window_destroy(zbar->window); + zbar->window = NULL; } - if(zebra->scanner) { - zebra_image_scanner_destroy(zebra->scanner); - zebra->scanner = NULL; + if(zbar->scanner) { + zbar_image_scanner_destroy(zbar->scanner); + zbar->scanner = NULL; } - if(zebra->video) { - zebra_video_destroy(zebra->video); - zebra->video = NULL; + if(zbar->video) { + zbar_video_destroy(zbar->video); + zbar->video = NULL; } - g_async_queue_unref(zebra->queue); - zebra->queue = NULL; + g_async_queue_unref(zbar->queue); + zbar->queue = NULL; } -static void zebra_gtk_class_init (ZebraGtkClass *klass) +static void zbar_gtk_class_init (ZBarGtkClass *klass) { - zebra_gtk_parent_class = g_type_class_peek_parent(klass); + zbar_gtk_parent_class = g_type_class_peek_parent(klass); GObjectClass *object_class = G_OBJECT_CLASS(klass); - object_class->dispose = zebra_gtk_dispose; - object_class->set_property = zebra_gtk_set_property; - object_class->get_property = zebra_gtk_get_property; + object_class->dispose = zbar_gtk_dispose; + object_class->set_property = zbar_gtk_set_property; + object_class->get_property = zbar_gtk_get_property; GtkWidgetClass *widget_class = (GtkWidgetClass*)klass; - widget_class->realize = zebra_gtk_realize; - widget_class->unrealize = zebra_gtk_unrealize; - widget_class->size_request = zebra_gtk_size_request; - widget_class->size_allocate = zebra_gtk_size_allocate; - widget_class->expose_event = zebra_gtk_expose; + widget_class->realize = zbar_gtk_realize; + widget_class->unrealize = zbar_gtk_unrealize; + widget_class->size_request = zbar_gtk_size_request; + widget_class->size_allocate = zbar_gtk_size_allocate; + widget_class->expose_event = zbar_gtk_expose; widget_class->unmap = NULL; - zebra_gtk_signals[DECODED] = + zbar_gtk_signals[DECODED] = g_signal_new("decoded", G_TYPE_FROM_CLASS(object_class), G_SIGNAL_RUN_CLEANUP, - G_STRUCT_OFFSET(ZebraGtkClass, decoded), + G_STRUCT_OFFSET(ZBarGtkClass, decoded), NULL, NULL, - zebra_marshal_VOID__INT_STRING, + zbar_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - zebra_gtk_signals[DECODED_TEXT] = + zbar_gtk_signals[DECODED_TEXT] = g_signal_new("decoded-text", G_TYPE_FROM_CLASS(object_class), G_SIGNAL_RUN_CLEANUP, - G_STRUCT_OFFSET(ZebraGtkClass, decoded_text), + G_STRUCT_OFFSET(ZBarGtkClass, decoded_text), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, @@ -718,50 +718,50 @@ static void zebra_gtk_class_init (ZebraGtkClass *klass) g_object_class_install_property(object_class, PROP_VIDEO_OPENED, p); } -GType zebra_gtk_get_type () +GType zbar_gtk_get_type () { static GType type = 0; if(!type) { static const GTypeInfo info = { - sizeof(ZebraGtkClass), + sizeof(ZBarGtkClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc)zebra_gtk_class_init, + (GClassInitFunc)zbar_gtk_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof(ZebraGtk), + sizeof(ZBarGtk), 0, - (GInstanceInitFunc)zebra_gtk_init, + (GInstanceInitFunc)zbar_gtk_init, }; - type = g_type_register_static(GTK_TYPE_WIDGET, "ZebraGtk", &info, 0); + type = g_type_register_static(GTK_TYPE_WIDGET, "ZBarGtk", &info, 0); } return(type); } -static void zebra_gtk_private_class_init (ZebraGtkPrivateClass *klass) +static void zbar_gtk_private_class_init (ZBarGtkPrivateClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - object_class->finalize = zebra_gtk_private_finalize; + object_class->finalize = zbar_gtk_private_finalize; } -static GType zebra_gtk_private_get_type () +static GType zbar_gtk_private_get_type () { static GType type = 0; if(!type) { static const GTypeInfo info = { - sizeof(ZebraGtkPrivateClass), + sizeof(ZBarGtkPrivateClass), NULL, NULL, - (GClassInitFunc)zebra_gtk_private_class_init, + (GClassInitFunc)zbar_gtk_private_class_init, NULL, NULL, - sizeof(ZebraGtkPrivate), + sizeof(ZBarGtkPrivate), }; - type = g_type_register_static(G_TYPE_OBJECT, "ZebraGtkPrivate", + type = g_type_register_static(G_TYPE_OBJECT, "ZBarGtkPrivate", &info, 0); } return(type); } -GtkWidget *zebra_gtk_new () +GtkWidget *zbar_gtk_new () { - return(GTK_WIDGET(g_object_new(ZEBRA_TYPE_GTK, NULL))); + return(GTK_WIDGET(g_object_new(ZBAR_TYPE_GTK, NULL))); } diff --git a/gtk/zebragtkprivate.h b/gtk/zbargtkprivate.h similarity index 58% rename from gtk/zebragtkprivate.h rename to gtk/zbargtkprivate.h index 2375d814..7832e765 100644 --- a/gtk/zebragtkprivate.h +++ b/gtk/zbargtkprivate.h @@ -1,51 +1,51 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ -#ifndef __ZEBRA_GTK_PRIVATE_H__ -#define __ZEBRA_GTK_PRIVATE_H__ +#ifndef __ZBAR_GTK_PRIVATE_H__ +#define __ZBAR_GTK_PRIVATE_H__ #include #include #include -#include +#include G_BEGIN_DECLS -#define ZEBRA_TYPE_GTK_PRIVATE (zebra_gtk_private_get_type()) -#define ZEBRA_GTK_PRIVATE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), ZEBRA_TYPE_GTK_PRIVATE, ZebraGtkPrivate)) -#define ZEBRA_GTK_PRIVATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), ZEBRA_TYPE_GTK_PRIVATE, ZebraGtkPrivateClass)) -#define ZEBRA_IS_GTK_PRIVATE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZEBRA_TYPE_GTK_PRIVATE)) -#define ZEBRA_IS_GTK_PRIVATE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), ZEBRA_TYPE_GTK_PRIVATE)) -#define ZEBRA_GTK_PRIVATE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), ZEBRA_TYPE_GTK_PRIVATE, ZebraGtkPrivateClass)) - - -/* zebra widget processor thread shared/private data */ -typedef struct _ZebraGtkPrivate +#define ZBAR_TYPE_GTK_PRIVATE (zbar_gtk_private_get_type()) +#define ZBAR_GTK_PRIVATE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivate)) +#define ZBAR_GTK_PRIVATE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivateClass)) +#define ZBAR_IS_GTK_PRIVATE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZBAR_TYPE_GTK_PRIVATE)) +#define ZBAR_IS_GTK_PRIVATE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), ZBAR_TYPE_GTK_PRIVATE)) +#define ZBAR_GTK_PRIVATE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivateClass)) + + +/* zbar widget processor thread shared/private data */ +typedef struct _ZBarGtkPrivate { GObject object; @@ -77,23 +77,23 @@ typedef struct _ZebraGtkPrivate * processor thread only calls draw() and negotiate_format(). * protected by main gui lock (and internal lock) */ - zebra_window_t *window; + zbar_window_t *window; /* video and scanner are owned by the processor thread */ - zebra_video_t *video; - zebra_image_scanner_t *scanner; + zbar_video_t *video; + zbar_image_scanner_t *scanner; -} ZebraGtkPrivate; +} ZBarGtkPrivate; -typedef struct _ZebraGtkPrivateClass +typedef struct _ZBarGtkPrivateClass { GObjectClass parent_class; -} ZebraGtkPrivateClass; +} ZBarGtkPrivateClass; -static GType zebra_gtk_private_get_type() G_GNUC_CONST; +static GType zbar_gtk_private_get_type() G_GNUC_CONST; G_END_DECLS diff --git a/gtk/zebramarshal.list b/gtk/zbarmarshal.list similarity index 100% rename from gtk/zebramarshal.list rename to gtk/zbarmarshal.list diff --git a/include/Makefile.am.inc b/include/Makefile.am.inc index 3efa39cc..a782b296 100644 --- a/include/Makefile.am.inc +++ b/include/Makefile.am.inc @@ -1,13 +1,13 @@ -zincludedir = $(includedir)/zebra -include_HEADERS = include/zebra.h -zinclude_HEADERS = include/zebra/Scanner.h include/zebra/Decoder.h \ - include/zebra/Exception.h include/zebra/Symbol.h include/zebra/Image.h \ - include/zebra/ImageScanner.h include/zebra/Video.h include/zebra/Window.h \ - include/zebra/Processor.h +zincludedir = $(includedir)/zbar +include_HEADERS = include/zbar.h +zinclude_HEADERS = include/zbar/Scanner.h include/zbar/Decoder.h \ + include/zbar/Exception.h include/zbar/Symbol.h include/zbar/Image.h \ + include/zbar/ImageScanner.h include/zbar/Video.h include/zbar/Window.h \ + include/zbar/Processor.h if HAVE_GTK -zinclude_HEADERS += include/zebra/zebragtk.h +zinclude_HEADERS += include/zbar/zbargtk.h endif if HAVE_QT -zinclude_HEADERS += include/zebra/QZebra.h include/zebra/QZebraImage.h +zinclude_HEADERS += include/zbar/QZBar.h include/zbar/QZBarImage.h endif diff --git a/include/zebra.h b/include/zbar.h similarity index 52% rename from include/zebra.h rename to include/zbar.h index bbd5eafe..7bb9572f 100644 --- a/include/zebra.h +++ b/include/zbar.h @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ -#ifndef _ZEBRA_H_ -#define _ZEBRA_H_ +#ifndef _ZBAR_H_ +#define _ZBAR_H_ /** @file - * Zebra Barcode Reader Library C API definition + * ZBar Barcode Reader C API definition */ /** @mainpage @@ -38,37 +38,37 @@ * package for a specific toolkit: * - the "GTK+ 2.x widget" may be used with GTK GUI applications. a * Python wrapper is included for PyGtk - * - the @ref zebra::QZebra "Qt4 widget" may be used with Qt GUI + * - the @ref zbar::QZBar "Qt4 widget" may be used with Qt GUI * applications * - the Processor interface (in @ref c-processor "C" or @ref - * zebra::Processor "C++") adds a scanning window to an application + * zbar::Processor "C++") adds a scanning window to an application * with no GUI. * * @section mid-level Intermediate Interfaces * * building blocks used to construct high-level interfaces: * - the ImageScanner (in @ref c-imagescanner "C" or @ref - * zebra::ImageScanner "C++") looks for barcodes in a library defined + * zbar::ImageScanner "C++") looks for barcodes in a library defined * image object * - the Window abstraction (in @ref c-window "C" or @ref - * zebra::Window "C++") sinks library images, displaying them on the + * zbar::Window "C++") sinks library images, displaying them on the * platform display - * - the Video abstraction (in @ref c-video "C" or @ref zebra::Video + * - the Video abstraction (in @ref c-video "C" or @ref zbar::Video * "C++") sources library images from a video device * * @section low-level Low-Level Interfaces * * direct interaction with barcode scanning and decoding: - * - the Scanner (in @ref c-scanner "C" or @ref zebra::Scanner "C++") + * - the Scanner (in @ref c-scanner "C" or @ref zbar::Scanner "C++") * looks for barcodes in a linear intensity sample stream - * - the Decoder (in @ref c-decoder "C" or @ref zebra::Decoder "C++") + * - the Decoder (in @ref c-decoder "C" or @ref zbar::Decoder "C++") * extracts barcodes from a stream of bar and space widths */ #ifdef __cplusplus /** C++ namespace for library interfaces */ -namespace zebra { +namespace zbar { extern "C" { #endif @@ -77,95 +77,95 @@ namespace zebra { /*@{*/ /** "color" of element: bar or space. */ -typedef enum zebra_color_e { - ZEBRA_SPACE = 0, /**< light area or space between bars */ - ZEBRA_BAR = 1, /**< dark area or colored bar segment */ -} zebra_color_t; +typedef enum zbar_color_e { + ZBAR_SPACE = 0, /**< light area or space between bars */ + ZBAR_BAR = 1, /**< dark area or colored bar segment */ +} zbar_color_t; /** decoded symbol type. */ -typedef enum zebra_symbol_type_e { - ZEBRA_NONE = 0, /**< no symbol decoded */ - ZEBRA_PARTIAL = 1, /**< intermediate status */ - ZEBRA_EAN8 = 8, /**< EAN-8 */ - ZEBRA_UPCE = 9, /**< UPC-E */ - ZEBRA_ISBN10 = 10, /**< ISBN-10 (from EAN-13). @since 0.4 */ - ZEBRA_UPCA = 12, /**< UPC-A */ - ZEBRA_EAN13 = 13, /**< EAN-13 */ - ZEBRA_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */ - ZEBRA_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */ - ZEBRA_CODE39 = 39, /**< Code 39. @since 0.4 */ - ZEBRA_PDF417 = 57, /**< PDF417. @since 0.6 */ - ZEBRA_CODE128 = 128, /**< Code 128 */ - ZEBRA_SYMBOL = 0x00ff, /**< mask for base symbol type */ - ZEBRA_ADDON2 = 0x0200, /**< 2-digit add-on flag */ - ZEBRA_ADDON5 = 0x0500, /**< 5-digit add-on flag */ - ZEBRA_ADDON = 0x0700, /**< add-on flag mask */ -} zebra_symbol_type_t; +typedef enum zbar_symbol_type_e { + ZBAR_NONE = 0, /**< no symbol decoded */ + ZBAR_PARTIAL = 1, /**< intermediate status */ + ZBAR_EAN8 = 8, /**< EAN-8 */ + ZBAR_UPCE = 9, /**< UPC-E */ + ZBAR_ISBN10 = 10, /**< ISBN-10 (from EAN-13). @since 0.4 */ + ZBAR_UPCA = 12, /**< UPC-A */ + ZBAR_EAN13 = 13, /**< EAN-13 */ + ZBAR_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */ + ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */ + ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */ + ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */ + ZBAR_CODE128 = 128, /**< Code 128 */ + ZBAR_SYMBOL = 0x00ff, /**< mask for base symbol type */ + ZBAR_ADDON2 = 0x0200, /**< 2-digit add-on flag */ + ZBAR_ADDON5 = 0x0500, /**< 5-digit add-on flag */ + ZBAR_ADDON = 0x0700, /**< add-on flag mask */ +} zbar_symbol_type_t; /** error codes. */ -typedef enum zebra_error_e { - ZEBRA_OK = 0, /**< no error */ - ZEBRA_ERR_NOMEM, /**< out of memory */ - ZEBRA_ERR_INTERNAL, /**< internal library error */ - ZEBRA_ERR_UNSUPPORTED, /**< unsupported request */ - ZEBRA_ERR_INVALID, /**< invalid request */ - ZEBRA_ERR_SYSTEM, /**< system error */ - ZEBRA_ERR_LOCKING, /**< locking error */ - ZEBRA_ERR_BUSY, /**< all resources busy */ - ZEBRA_ERR_XDISPLAY, /**< X11 display error */ - ZEBRA_ERR_XPROTO, /**< X11 protocol error */ - ZEBRA_ERR_CLOSED, /**< output window is closed */ - ZEBRA_ERR_NUM /**< number of error codes */ -} zebra_error_t; +typedef enum zbar_error_e { + ZBAR_OK = 0, /**< no error */ + ZBAR_ERR_NOMEM, /**< out of memory */ + ZBAR_ERR_INTERNAL, /**< internal library error */ + ZBAR_ERR_UNSUPPORTED, /**< unsupported request */ + ZBAR_ERR_INVALID, /**< invalid request */ + ZBAR_ERR_SYSTEM, /**< system error */ + ZBAR_ERR_LOCKING, /**< locking error */ + ZBAR_ERR_BUSY, /**< all resources busy */ + ZBAR_ERR_XDISPLAY, /**< X11 display error */ + ZBAR_ERR_XPROTO, /**< X11 protocol error */ + ZBAR_ERR_CLOSED, /**< output window is closed */ + ZBAR_ERR_NUM /**< number of error codes */ +} zbar_error_t; /** decoder configuration options. * @since 0.4 */ -typedef enum zebra_config_e { - ZEBRA_CFG_ENABLE = 0, /**< enable symbology/feature */ - ZEBRA_CFG_ADD_CHECK, /**< enable check digit when optional */ - ZEBRA_CFG_EMIT_CHECK, /**< return check digit when present */ - ZEBRA_CFG_ASCII, /**< enable full ASCII character set */ - ZEBRA_CFG_NUM, /**< number of boolean configs */ +typedef enum zbar_config_e { + ZBAR_CFG_ENABLE = 0, /**< enable symbology/feature */ + ZBAR_CFG_ADD_CHECK, /**< enable check digit when optional */ + ZBAR_CFG_EMIT_CHECK, /**< return check digit when present */ + ZBAR_CFG_ASCII, /**< enable full ASCII character set */ + ZBAR_CFG_NUM, /**< number of boolean configs */ - ZEBRA_CFG_MIN_LEN = 0x20, /**< minimum data length for valid decode */ - ZEBRA_CFG_MAX_LEN, /**< maximum data length for valid decode */ + ZBAR_CFG_MIN_LEN = 0x20, /**< minimum data length for valid decode */ + ZBAR_CFG_MAX_LEN, /**< maximum data length for valid decode */ - ZEBRA_CFG_X_DENSITY = 0x100,/**< image scanner vertical scan density */ - ZEBRA_CFG_Y_DENSITY, /**< image scanner horizontal scan density */ -} zebra_config_t; + ZBAR_CFG_X_DENSITY = 0x100, /**< image scanner vertical scan density */ + ZBAR_CFG_Y_DENSITY, /**< image scanner horizontal scan density */ +} zbar_config_t; /** retrieve runtime library version information. * @param major set to the running major version (unless NULL) * @param minor set to the running minor version (unless NULL) * @returns 0 */ -extern int zebra_version(unsigned *major, - unsigned *minor); +extern int zbar_version(unsigned *major, + unsigned *minor); /** set global library debug level. * @param verbosity desired debug level. higher values create more spew */ -extern void zebra_set_verbosity(int verbosity); +extern void zbar_set_verbosity(int verbosity); /** increase global library debug level. * eg, for -vvvv */ -extern void zebra_increase_verbosity(); +extern void zbar_increase_verbosity(); /** retrieve string name for symbol encoding. * @param sym symbol type encoding * @returns the static string name for the specified symbol type, * or "UNKNOWN" if the encoding is not recognized */ -extern const char *zebra_get_symbol_name(zebra_symbol_type_t sym); +extern const char *zbar_get_symbol_name(zbar_symbol_type_t sym); /** retrieve string name for addon encoding. * @param sym symbol type encoding * @returns static string name for any addon, or the empty string * if no addons were decoded */ -extern const char *zebra_get_addon_name(zebra_symbol_type_t sym); +extern const char *zbar_get_addon_name(zbar_symbol_type_t sym); /** parse a configuration string of the form "[symbology.]config[=value]". * the config must match one of the recognized names. @@ -175,17 +175,17 @@ extern const char *zebra_get_addon_name(zebra_symbol_type_t sym); * @returns 0 if the config is parsed successfully, 1 otherwise * @since 0.4 */ -extern int zebra_parse_config(const char *config_string, - zebra_symbol_type_t *symbology, - zebra_config_t *config, - int *value); +extern int zbar_parse_config(const char *config_string, + zbar_symbol_type_t *symbology, + zbar_config_t *config, + int *value); /** @internal type unsafe error API (don't use) */ -extern int _zebra_error_spew(const void *object, - int verbosity); -extern const char *_zebra_error_string(const void *object, - int verbosity); -extern zebra_error_t _zebra_get_error_code(const void *object); +extern int _zbar_error_spew(const void *object, + int verbosity); +extern const char *_zbar_error_string(const void *object, + int verbosity); +extern zbar_error_t _zbar_get_error_code(const void *object); /*@}*/ @@ -197,19 +197,19 @@ extern zebra_error_t _zebra_get_error_code(const void *object); */ /*@{*/ -struct zebra_symbol_s; +struct zbar_symbol_s; /** opaque decoded symbol object. */ -typedef struct zebra_symbol_s zebra_symbol_t; +typedef struct zbar_symbol_s zbar_symbol_t; /** retrieve type of decoded symbol. * @returns the symbol type */ -extern zebra_symbol_type_t zebra_symbol_get_type(const zebra_symbol_t *symbol); +extern zbar_symbol_type_t zbar_symbol_get_type(const zbar_symbol_t *symbol); /** retrieve ASCII data decoded from symbol. * @returns the data string */ -extern const char *zebra_symbol_get_data(const zebra_symbol_t *symbol); +extern const char *zbar_symbol_get_data(const zbar_symbol_t *symbol); /** retrieve current cache count. when the cache is enabled for the * image_scanner this provides inter-frame reliability and redundancy @@ -218,7 +218,7 @@ extern const char *zebra_symbol_get_data(const zebra_symbol_t *symbol); * @returns 0 if symbol is newly verified. * @returns > 0 for duplicate symbols */ -extern int zebra_symbol_get_count(const zebra_symbol_t *symbol); +extern int zbar_symbol_get_count(const zbar_symbol_t *symbol); /** retrieve the number of points in the location polygon. the * location polygon defines the image area that the symbol was @@ -227,32 +227,32 @@ extern int zebra_symbol_get_count(const zebra_symbol_t *symbol); * @note this is currently not a polygon, but the scan locations * where the symbol was decoded */ -extern unsigned zebra_symbol_get_loc_size(const zebra_symbol_t *symbol); +extern unsigned zbar_symbol_get_loc_size(const zbar_symbol_t *symbol); /** retrieve location polygon x-coordinates. * points are specified by 0-based index. * @returns the x-coordinate for a point in the location polygon. * @returns -1 if index is out of range */ -extern int zebra_symbol_get_loc_x(const zebra_symbol_t *symbol, - unsigned index); +extern int zbar_symbol_get_loc_x(const zbar_symbol_t *symbol, + unsigned index); /** retrieve location polygon y-coordinates. * points are specified by 0-based index. * @returns the y-coordinate for a point in the location polygon. * @returns -1 if index is out of range */ -extern int zebra_symbol_get_loc_y(const zebra_symbol_t *symbol, - unsigned index); +extern int zbar_symbol_get_loc_y(const zbar_symbol_t *symbol, + unsigned index); /** iterate the result set. * @returns the next result symbol, or * @returns NULL when no more results are available */ -extern const zebra_symbol_t *zebra_symbol_next(const zebra_symbol_t *symbol); +extern const zbar_symbol_t *zbar_symbol_next(const zbar_symbol_t *symbol); /** print XML symbol element representation to user result buffer. - * @see http://zebra.sourceforge.net/2008/barcode.xsd for the schema. + * @see http://zbar.sourceforge.net/2008/barcode.xsd for the schema. * @param symbol is the symbol to print * @param buffer is the inout result pointer, it will be reallocated * with a larger size if necessary. @@ -260,9 +260,9 @@ extern const zebra_symbol_t *zebra_symbol_next(const zebra_symbol_t *symbol); * @returns the buffer pointer * @since 0.6 */ -extern char *zebra_symbol_xml(const zebra_symbol_t *symbol, - char **buffer, - unsigned *buflen); +extern char *zbar_symbol_xml(const zbar_symbol_t *symbol, + char **buffer, + unsigned *buflen); /*@}*/ @@ -273,27 +273,27 @@ extern char *zebra_symbol_xml(const zebra_symbol_t *symbol, */ /*@{*/ -struct zebra_image_s; +struct zbar_image_s; /** opaque image object. */ -typedef struct zebra_image_s zebra_image_t; +typedef struct zbar_image_s zbar_image_t; /** cleanup handler callback function. * called to free sample data when an image is destroyed. */ -typedef void (zebra_image_cleanup_handler_t)(zebra_image_t *image); +typedef void (zbar_image_cleanup_handler_t)(zbar_image_t *image); /** data handler callback function. * called when decoded symbol results are available for an image */ -typedef void (zebra_image_data_handler_t)(zebra_image_t *image, - const void *userdata); +typedef void (zbar_image_data_handler_t)(zbar_image_t *image, + const void *userdata); /** new image constructor. * @returns a new image object with uninitialized data and format. - * this image should be destroyed (using zebra_image_destroy()) as + * this image should be destroyed (using zbar_image_destroy()) as * soon as the application is finished with it */ -extern zebra_image_t *zebra_image_create(); +extern zbar_image_t *zbar_image_create(); /** image destructor. all images created by or returned to the * application should be destroyed using this function. when an image @@ -304,17 +304,17 @@ extern zebra_image_t *zebra_image_create(); * is still using them. if necessary, use the cleanup handler hook * to keep track of image data buffers */ -extern void zebra_image_destroy(zebra_image_t *image); +extern void zbar_image_destroy(zbar_image_t *image); /** image reference count manipulation. * increment the reference count when you store a new reference to the * image. decrement when the reference is no longer used. do not * refer to the image any longer once the count is decremented. - * zebra_image_ref(image, -1) is the same as zebra_image_destroy(image) + * zbar_image_ref(image, -1) is the same as zbar_image_destroy(image) * @since 0.5 */ -extern void zebra_image_ref(zebra_image_t *image, - int refs); +extern void zbar_image_ref(zbar_image_t *image, + int refs); /** image format conversion. refer to the documentation for supported * image formats @@ -324,8 +324,8 @@ extern void zebra_image_ref(zebra_image_t *image, * @note the converted image size may be rounded (up) due to format * constraints */ -extern zebra_image_t *zebra_image_convert(const zebra_image_t *image, - unsigned long format); +extern zbar_image_t *zbar_image_convert(const zbar_image_t *image, + unsigned long format); /** image format conversion with crop/pad. * if the requested size is larger than the image, the last row/column @@ -335,97 +335,97 @@ extern zebra_image_t *zebra_image_convert(const zebra_image_t *image, * @returns a @em new image with the sample data from the original * image converted to the requested format and size. * @note the image is @em not scaled - * @see zebra_image_convert() + * @see zbar_image_convert() * @since 0.4 */ -extern zebra_image_t *zebra_image_convert_resize(const zebra_image_t *image, - unsigned long format, - unsigned width, - unsigned height); +extern zbar_image_t *zbar_image_convert_resize(const zbar_image_t *image, + unsigned long format, + unsigned width, + unsigned height); /** retrieve the image format. * @returns the fourcc describing the format of the image sample data */ -extern unsigned long zebra_image_get_format(const zebra_image_t *image); +extern unsigned long zbar_image_get_format(const zbar_image_t *image); /** retrieve a "sequence" (page/frame) number associated with this image. * @since 0.6 */ -extern unsigned zebra_image_get_sequence(const zebra_image_t *image); +extern unsigned zbar_image_get_sequence(const zbar_image_t *image); /** retrieve the width of the image. * @returns the width in sample columns */ -extern unsigned zebra_image_get_width(const zebra_image_t *image); +extern unsigned zbar_image_get_width(const zbar_image_t *image); /** retrieve the height of the image. * @returns the height in sample rows */ -extern unsigned zebra_image_get_height(const zebra_image_t *image); +extern unsigned zbar_image_get_height(const zbar_image_t *image); /** return the image sample data. the returned data buffer is only - * valid until zebra_image_destroy() is called + * valid until zbar_image_destroy() is called */ -extern const void *zebra_image_get_data(const zebra_image_t *image); +extern const void *zbar_image_get_data(const zbar_image_t *image); /** return the size of image data. * @since 0.6 */ -unsigned long zebra_image_get_data_length(const zebra_image_t *img); +unsigned long zbar_image_get_data_length(const zbar_image_t *img); /** image_scanner decode result iterator. * @returns the first decoded symbol result for an image * or NULL if no results are available */ -extern const zebra_symbol_t* -zebra_image_first_symbol(const zebra_image_t *image); +extern const zbar_symbol_t* +zbar_image_first_symbol(const zbar_image_t *image); /** specify the fourcc image format code for image sample data. * refer to the documentation for supported formats. * @note this does not convert the data! - * (see zebra_image_convert() for that) + * (see zbar_image_convert() for that) */ -extern void zebra_image_set_format(zebra_image_t *image, - unsigned long format); +extern void zbar_image_set_format(zbar_image_t *image, + unsigned long format); /** associate a "sequence" (page/frame) number with this image. * @since 0.6 */ -extern void zebra_image_set_sequence(zebra_image_t *image, - unsigned sequence_num); +extern void zbar_image_set_sequence(zbar_image_t *image, + unsigned sequence_num); /** specify the pixel size of the image. * @note this does not affect the data! */ -extern void zebra_image_set_size(zebra_image_t *image, - unsigned width, - unsigned height); +extern void zbar_image_set_size(zbar_image_t *image, + unsigned width, + unsigned height); /** specify image sample data. when image data is no longer needed by * the library the specific data cleanup handler will be called * (unless NULL) * @note application image data will not be modified by the library */ -extern void zebra_image_set_data(zebra_image_t *image, - const void *data, - unsigned long data_byte_length, - zebra_image_cleanup_handler_t *cleanup_hndlr); +extern void zbar_image_set_data(zbar_image_t *image, + const void *data, + unsigned long data_byte_length, + zbar_image_cleanup_handler_t *cleanup_hndlr); /** built-in cleanup handler. * passes the image data buffer to free() */ -extern void zebra_image_free_data(zebra_image_t *image); +extern void zbar_image_free_data(zbar_image_t *image); /** associate user specified data value with an image. * @since 0.5 */ -extern void zebra_image_set_userdata(zebra_image_t *image, - void *userdata); +extern void zbar_image_set_userdata(zbar_image_t *image, + void *userdata); /** return user specified data value associated with the image. * @since 0.5 */ -extern void *zebra_image_get_userdata(const zebra_image_t *image); +extern void *zbar_image_get_userdata(const zbar_image_t *image); /** dump raw image data to a file for debug. * the data will be prefixed with a 16 byte header consisting of: @@ -450,13 +450,13 @@ extern void *zebra_image_get_userdata(const zebra_image_t *image); * XXXX is the format fourcc * @returns 0 on success or a system error code on failure */ -extern int zebra_image_write(const zebra_image_t *image, - const char *filebase); +extern int zbar_image_write(const zbar_image_t *image, + const char *filebase); -/** read back an image in the format written by zebra_image_write() +/** read back an image in the format written by zbar_image_write() * @note TBD */ -extern zebra_image_t *zebra_image_read(char *filename); +extern zbar_image_t *zbar_image_read(char *filename); /*@}*/ @@ -469,44 +469,44 @@ extern zebra_image_t *zebra_image_read(char *filename); */ /*@{*/ -struct zebra_processor_s; +struct zbar_processor_s; /** opaque standalone processor object. */ -typedef struct zebra_processor_s zebra_processor_t; +typedef struct zbar_processor_s zbar_processor_t; /** constructor. * if threaded is set and threading is available the processor * will spawn threads where appropriate to avoid blocking and * improve responsiveness */ -extern zebra_processor_t *zebra_processor_create(int threaded); +extern zbar_processor_t *zbar_processor_create(int threaded); /** destructor. cleans up all resources associated with the processor */ -extern void zebra_processor_destroy(zebra_processor_t *processor); +extern void zbar_processor_destroy(zbar_processor_t *processor); /** (re)initialization. * opens a video input device and/or prepares to display output */ -extern int zebra_processor_init(zebra_processor_t *processor, - const char *video_device, - int enable_display); +extern int zbar_processor_init(zbar_processor_t *processor, + const char *video_device, + int enable_display); /** request a preferred size for the video image from the device. * the request may be adjusted or completely ignored by the driver. - * @note must be called before zebra_processor_init() + * @note must be called before zbar_processor_init() * @since 0.6 */ -extern int zebra_processor_request_size(zebra_processor_t *processor, - unsigned width, - unsigned height); +extern int zbar_processor_request_size(zbar_processor_t *processor, + unsigned width, + unsigned height); /** request a preferred video driver interface version for * debug/testing. - * @note must be called before zebra_processor_init() + * @note must be called before zbar_processor_init() * @since 0.6 */ -extern int zebra_processor_request_interface(zebra_processor_t *processor, - int version); +extern int zbar_processor_request_interface(zbar_processor_t *processor, + int version); /** request a preferred video I/O mode for debug/testing. You will * get errors if the driver does not support the specified mode. @@ -516,18 +516,18 @@ extern int zebra_processor_request_interface(zebra_processor_t *processor, 2 = force memory mapped I/O using mmap() 3 = force USERPTR I/O (v4l2 only) @endverbatim - * @note must be called before zebra_processor_init() + * @note must be called before zbar_processor_init() * @since 0.7 */ -extern int zebra_processor_request_iomode(zebra_processor_t *video, - int iomode); +extern int zbar_processor_request_iomode(zbar_processor_t *video, + int iomode); /** force specific input and output formats for debug/testing. - * @note must be called before zebra_processor_init() + * @note must be called before zbar_processor_init() */ -extern int zebra_processor_force_format(zebra_processor_t *processor, - unsigned long input_format, - unsigned long output_format); +extern int zbar_processor_force_format(zbar_processor_t *processor, + unsigned long input_format, + unsigned long output_format); /** setup result handler callback. * the specified function will be called by the processor whenever @@ -535,86 +535,86 @@ extern int zebra_processor_force_format(zebra_processor_t *processor, * pass a NULL value to disable callbacks. * @param processor the object on which to set the handler. * @param handler the function to call when new results are available. - * @param userdata is set as with zebra_processor_set_userdata(). + * @param userdata is set as with zbar_processor_set_userdata(). * @returns the previously registered handler */ -extern zebra_image_data_handler_t* -zebra_processor_set_data_handler(zebra_processor_t *processor, - zebra_image_data_handler_t *handler, - const void *userdata); +extern zbar_image_data_handler_t* +zbar_processor_set_data_handler(zbar_processor_t *processor, + zbar_image_data_handler_t *handler, + const void *userdata); /** associate user specified data value with the processor. * @since 0.6 */ -extern void zebra_processor_set_userdata(zebra_processor_t *processor, - void *userdata); +extern void zbar_processor_set_userdata(zbar_processor_t *processor, + void *userdata); /** return user specified data value associated with the processor. * @since 0.6 */ -extern void *zebra_processor_get_userdata(const zebra_processor_t *processor); +extern void *zbar_processor_get_userdata(const zbar_processor_t *processor); /** set config for indicated symbology (0 for all) to specified value. * @returns 0 for success, non-0 for failure (config does not apply to * specified symbology, or value out of range) - * @see zebra_decoder_set_config() + * @see zbar_decoder_set_config() * @since 0.4 */ -extern int zebra_processor_set_config(zebra_processor_t *processor, - zebra_symbol_type_t symbology, - zebra_config_t config, - int value); +extern int zbar_processor_set_config(zbar_processor_t *processor, + zbar_symbol_type_t symbology, + zbar_config_t config, + int value); -/** parse configuration string using zebra_parse_config() - * and apply to processor using zebra_processor_set_config(). +/** parse configuration string using zbar_parse_config() + * and apply to processor using zbar_processor_set_config(). * @returns 0 for success, non-0 for failure - * @see zebra_parse_config() - * @see zebra_processor_set_config() + * @see zbar_parse_config() + * @see zbar_processor_set_config() * @since 0.4 */ -static inline int zebra_processor_parse_config (zebra_processor_t *processor, - const char *config_string) +static inline int zbar_processor_parse_config (zbar_processor_t *processor, + const char *config_string) { - zebra_symbol_type_t sym; - zebra_config_t cfg; + zbar_symbol_type_t sym; + zbar_config_t cfg; int val; - return(zebra_parse_config(config_string, &sym, &cfg, &val) || - zebra_processor_set_config(processor, sym, cfg, val)); + return(zbar_parse_config(config_string, &sym, &cfg, &val) || + zbar_processor_set_config(processor, sym, cfg, val)); } /** retrieve the current state of the ouput window. * @returns 1 if the output window is currently displayed, 0 if not. * @returns -1 if an error occurs */ -extern int zebra_processor_is_visible(zebra_processor_t *processor); +extern int zbar_processor_is_visible(zbar_processor_t *processor); /** show or hide the display window owned by the library. * the size will be adjusted to the input size */ -extern int zebra_processor_set_visible(zebra_processor_t *processor, - int visible); +extern int zbar_processor_set_visible(zbar_processor_t *processor, + int visible); /** control the processor in free running video mode. * only works if video input is initialized. if threading is in use, * scanning will occur in the background, otherwise this is only - * useful wrapping calls to zebra_processor_user_wait(). if the + * useful wrapping calls to zbar_processor_user_wait(). if the * library output window is visible, video display will be enabled. */ -extern int zebra_processor_set_active(zebra_processor_t *processor, - int active); +extern int zbar_processor_set_active(zbar_processor_t *processor, + int active); /** wait for input to the display window from the user * (via mouse or keyboard). * @returns >0 when input is received, 0 if timeout ms expired * with no input or -1 in case of an error */ -extern int zebra_processor_user_wait(zebra_processor_t *processor, - int timeout); +extern int zbar_processor_user_wait(zbar_processor_t *processor, + int timeout); /** process from the video stream until a result is available, * or the timeout (in milliseconds) expires. * specify a timeout of -1 to scan indefinitely - * (zebra_processor_set_active() may still be used to abort the scan + * (zbar_processor_set_active() may still be used to abort the scan * from another thread). * if the library window is visible, video display will be enabled. * @note that multiple results may still be returned (despite the @@ -623,40 +623,40 @@ extern int zebra_processor_user_wait(zebra_processor_t *processor, * 0 if no symbols were found (ie, the timeout expired) * or -1 if an error occurs */ -extern int zebra_process_one(zebra_processor_t *processor, - int timeout); +extern int zbar_process_one(zbar_processor_t *processor, + int timeout); /** process the provided image for barcodes. * if the library window is visible, the image will be displayed. * @returns >0 if symbols were successfully decoded, * 0 if no symbols were found or -1 if an error occurs */ -extern int zebra_process_image(zebra_processor_t *processor, - zebra_image_t *image); +extern int zbar_process_image(zbar_processor_t *processor, + zbar_image_t *image); /** display detail for last processor error to stderr. * @returns a non-zero value suitable for passing to exit() */ static inline int -zebra_processor_error_spew (const zebra_processor_t *processor, - int verbosity) +zbar_processor_error_spew (const zbar_processor_t *processor, + int verbosity) { - return(_zebra_error_spew(processor, verbosity)); + return(_zbar_error_spew(processor, verbosity)); } /** retrieve the detail string for the last processor error. */ static inline const char* -zebra_processor_error_string (const zebra_processor_t *processor, - int verbosity) +zbar_processor_error_string (const zbar_processor_t *processor, + int verbosity) { - return(_zebra_error_string(processor, verbosity)); + return(_zbar_error_string(processor, verbosity)); } /** retrieve the type code for the last processor error. */ -static inline zebra_error_t -zebra_processor_get_error_code (const zebra_processor_t *processor) +static inline zbar_error_t +zbar_processor_get_error_code (const zbar_processor_t *processor) { - return(_zebra_get_error_code(processor)); + return(_zbar_get_error_code(processor)); } /*@}*/ @@ -669,15 +669,15 @@ zebra_processor_get_error_code (const zebra_processor_t *processor) */ /*@{*/ -struct zebra_video_s; +struct zbar_video_s; /** opaque video object. */ -typedef struct zebra_video_s zebra_video_t; +typedef struct zbar_video_s zbar_video_t; /** constructor. */ -extern zebra_video_t *zebra_video_create(); +extern zbar_video_t *zbar_video_create(); /** destructor. */ -extern void zebra_video_destroy(zebra_video_t *video); +extern void zbar_video_destroy(zbar_video_t *video); /** open and probe a video device. * the device specified by platform specific unique name @@ -685,8 +685,8 @@ extern void zebra_video_destroy(zebra_video_t *video); * DirectShow DevicePath property in windows). * @returns 0 if successful or -1 if an error occurs */ -extern int zebra_video_open(zebra_video_t *video, - const char *device); +extern int zbar_video_open(zbar_video_t *video, + const char *device); /** retrieve file descriptor associated with open *nix video device * useful for using select()/poll() to tell when new images are @@ -694,7 +694,7 @@ extern int zebra_video_open(zebra_video_t *video, * @returns the file descriptor or -1 if the video device is not open * or the driver only supports v4l1 */ -extern int zebra_video_get_fd(const zebra_video_t *video); +extern int zbar_video_get_fd(const zbar_video_t *video); /** request a preferred size for the video image from the device. * the request may be adjusted or completely ignored by the driver. @@ -702,16 +702,16 @@ extern int zebra_video_get_fd(const zebra_video_t *video); * initialized * @since 0.6 */ -extern int zebra_video_request_size(zebra_video_t *video, - unsigned width, - unsigned height); +extern int zbar_video_request_size(zbar_video_t *video, + unsigned width, + unsigned height); /** request a preferred driver interface version for debug/testing. - * @note must be called before zebra_video_open() + * @note must be called before zbar_video_open() * @since 0.6 */ -extern int zebra_video_request_interface(zebra_video_t *video, - int version); +extern int zbar_video_request_interface(zbar_video_t *video, + int version); /** request a preferred I/O mode for debug/testing. You will get * errors if the driver does not support the specified mode. @@ -721,62 +721,62 @@ extern int zebra_video_request_interface(zebra_video_t *video, 2 = force memory mapped I/O using mmap() 3 = force USERPTR I/O (v4l2 only) @endverbatim - * @note must be called before zebra_video_open() + * @note must be called before zbar_video_open() * @since 0.7 */ -extern int zebra_video_request_iomode(zebra_video_t *video, - int iomode); +extern int zbar_video_request_iomode(zbar_video_t *video, + int iomode); /** retrieve current output image width. * @returns the width or 0 if the video device is not open */ -extern int zebra_video_get_width(const zebra_video_t *video); +extern int zbar_video_get_width(const zbar_video_t *video); /** retrieve current output image height. * @returns the height or 0 if the video device is not open */ -extern int zebra_video_get_height(const zebra_video_t *video); +extern int zbar_video_get_height(const zbar_video_t *video); /** initialize video using a specific format for debug. - * use zebra_negotiate_format() to automatically select and initialize + * use zbar_negotiate_format() to automatically select and initialize * the best available format */ -extern int zebra_video_init(zebra_video_t *video, - unsigned long format); +extern int zbar_video_init(zbar_video_t *video, + unsigned long format); /** start/stop video capture. * all buffered images are retired when capture is disabled. * @returns 0 if successful or -1 if an error occurs */ -extern int zebra_video_enable(zebra_video_t *video, - int enable); +extern int zbar_video_enable(zbar_video_t *video, + int enable); /** retrieve next captured image. blocks until an image is available. * @returns NULL if video is not enabled or an error occurs */ -extern zebra_image_t *zebra_video_next_image(zebra_video_t *video); +extern zbar_image_t *zbar_video_next_image(zbar_video_t *video); /** display detail for last video error to stderr. * @returns a non-zero value suitable for passing to exit() */ -static inline int zebra_video_error_spew (const zebra_video_t *video, - int verbosity) +static inline int zbar_video_error_spew (const zbar_video_t *video, + int verbosity) { - return(_zebra_error_spew(video, verbosity)); + return(_zbar_error_spew(video, verbosity)); } /** retrieve the detail string for the last video error. */ -static inline const char *zebra_video_error_string (const zebra_video_t *video, - int verbosity) +static inline const char *zbar_video_error_string (const zbar_video_t *video, + int verbosity) { - return(_zebra_error_string(video, verbosity)); + return(_zbar_error_string(video, verbosity)); } /** retrieve the type code for the last video error. */ -static inline zebra_error_t -zebra_video_get_error_code (const zebra_video_t *video) +static inline zbar_error_t +zbar_video_get_error_code (const zbar_video_t *video) { - return(_zebra_get_error_code(video)); + return(_zbar_get_error_code(video)); } /*@}*/ @@ -789,15 +789,15 @@ zebra_video_get_error_code (const zebra_video_t *video) */ /*@{*/ -struct zebra_window_s; +struct zbar_window_s; /** opaque window object. */ -typedef struct zebra_window_s zebra_window_t; +typedef struct zbar_window_s zbar_window_t; /** constructor. */ -extern zebra_window_t *zebra_window_create(); +extern zbar_window_t *zbar_window_create(); /** destructor. */ -extern void zebra_window_destroy(zebra_window_t *window); +extern void zbar_window_destroy(zbar_window_t *window); /** associate reader with an existing platform window. * This can be any "Drawable" for X Windows or a "HWND" for windows. @@ -805,9 +805,9 @@ extern void zebra_window_destroy(zebra_window_t *window); * pass NULL to detach from the resource, further input will be * ignored */ -extern int zebra_window_attach(zebra_window_t *window, - void *x11_display_w32_hwnd, - unsigned long x11_drawable); +extern int zbar_window_attach(zbar_window_t *window, + void *x11_display_w32_hwnd, + unsigned long x11_drawable); /** control content level of the reader overlay. * the overlay displays graphical data for informational or debug @@ -818,46 +818,46 @@ extern int zebra_window_attach(zebra_window_t *window, 2 = also track and display input frame rate @endverbatim */ -extern void zebra_window_set_overlay(zebra_window_t *window, - int level); +extern void zbar_window_set_overlay(zbar_window_t *window, + int level); /** draw a new image into the output window. */ -extern int zebra_window_draw(zebra_window_t *window, - zebra_image_t *image); +extern int zbar_window_draw(zbar_window_t *window, + zbar_image_t *image); /** redraw the last image (exposure handler). */ -extern int zebra_window_redraw(zebra_window_t *window); +extern int zbar_window_redraw(zbar_window_t *window); /** resize the image window (reconfigure handler). * this does @em not update the contents of the window * @since 0.3, changed in 0.4 to not redraw window */ -extern int zebra_window_resize(zebra_window_t *window, - unsigned width, - unsigned height); +extern int zbar_window_resize(zbar_window_t *window, + unsigned width, + unsigned height); /** display detail for last window error to stderr. * @returns a non-zero value suitable for passing to exit() */ -static inline int zebra_window_error_spew (const zebra_window_t *window, - int verbosity) +static inline int zbar_window_error_spew (const zbar_window_t *window, + int verbosity) { - return(_zebra_error_spew(window, verbosity)); + return(_zbar_error_spew(window, verbosity)); } /** retrieve the detail string for the last window error. */ static inline const char* -zebra_window_error_string (const zebra_window_t *window, - int verbosity) +zbar_window_error_string (const zbar_window_t *window, + int verbosity) { - return(_zebra_error_string(window, verbosity)); + return(_zbar_error_string(window, verbosity)); } /** retrieve the type code for the last window error. */ -static inline zebra_error_t -zebra_window_get_error_code (const zebra_window_t *window) +static inline zbar_error_t +zbar_window_get_error_code (const zbar_window_t *window) { - return(_zebra_get_error_code(window)); + return(_zbar_get_error_code(window)); } @@ -867,8 +867,8 @@ zebra_window_get_error_code (const zebra_window_t *window) * barcode scanning. if a format conversion is necessary, it will * heuristically attempt to minimize the cost of the conversion */ -extern int zebra_negotiate_format(zebra_video_t *video, - zebra_window_t *window); +extern int zbar_negotiate_format(zbar_video_t *video, + zbar_window_t *window); /*@}*/ @@ -880,15 +880,15 @@ extern int zebra_negotiate_format(zebra_video_t *video, */ /*@{*/ -struct zebra_image_scanner_s; +struct zbar_image_scanner_s; /** opaque image scanner object. */ -typedef struct zebra_image_scanner_s zebra_image_scanner_t; +typedef struct zbar_image_scanner_s zbar_image_scanner_t; /** constructor. */ -extern zebra_image_scanner_t *zebra_image_scanner_create(); +extern zbar_image_scanner_t *zbar_image_scanner_create(); /** destructor. */ -extern void zebra_image_scanner_destroy(zebra_image_scanner_t *scanner); +extern void zbar_image_scanner_destroy(zbar_image_scanner_t *scanner); /** setup result handler callback. * the specified function will be called by the scanner whenever @@ -896,39 +896,39 @@ extern void zebra_image_scanner_destroy(zebra_image_scanner_t *scanner); * pass a NULL value to disable callbacks. * @returns the previously registered handler */ -extern zebra_image_data_handler_t* -zebra_image_scanner_set_data_handler(zebra_image_scanner_t *scanner, - zebra_image_data_handler_t *handler, - const void *userdata); +extern zbar_image_data_handler_t* +zbar_image_scanner_set_data_handler(zbar_image_scanner_t *scanner, + zbar_image_data_handler_t *handler, + const void *userdata); /** set config for indicated symbology (0 for all) to specified value. * @returns 0 for success, non-0 for failure (config does not apply to * specified symbology, or value out of range) - * @see zebra_decoder_set_config() + * @see zbar_decoder_set_config() * @since 0.4 */ -extern int zebra_image_scanner_set_config(zebra_image_scanner_t *scanner, - zebra_symbol_type_t symbology, - zebra_config_t config, - int value); +extern int zbar_image_scanner_set_config(zbar_image_scanner_t *scanner, + zbar_symbol_type_t symbology, + zbar_config_t config, + int value); -/** parse configuration string using zebra_parse_config() - * and apply to image scanner using zebra_image_scanner_set_config(). +/** parse configuration string using zbar_parse_config() + * and apply to image scanner using zbar_image_scanner_set_config(). * @returns 0 for success, non-0 for failure - * @see zebra_parse_config() - * @see zebra_image_scanner_set_config() + * @see zbar_parse_config() + * @see zbar_image_scanner_set_config() * @since 0.4 */ static inline int -zebra_image_scanner_parse_config (zebra_image_scanner_t *scanner, - const char *config_string) +zbar_image_scanner_parse_config (zbar_image_scanner_t *scanner, + const char *config_string) { - zebra_symbol_type_t sym; - zebra_config_t cfg; + zbar_symbol_type_t sym; + zbar_config_t cfg; int val; - return(zebra_parse_config(config_string, &sym, &cfg, &val) || - zebra_image_scanner_set_config(scanner, sym, cfg, val)); + return(zbar_parse_config(config_string, &sym, &cfg, &val) || + zbar_image_scanner_set_config(scanner, sym, cfg, val)); } /** enable or disable the inter-image result cache (default disabled). @@ -937,15 +937,15 @@ zebra_image_scanner_parse_config (zebra_image_scanner_t *scanner, * consistency checking and hysteresis to the results. * this interface also clears the cache */ -extern void zebra_image_scanner_enable_cache(zebra_image_scanner_t *scanner, - int enable); +extern void zbar_image_scanner_enable_cache(zbar_image_scanner_t *scanner, + int enable); /** scan for symbols in provided image. * @returns >0 if symbols were successfully decoded from the image, * 0 if no symbols were found or -1 if an error occurs */ -extern int zebra_scan_image(zebra_image_scanner_t *scanner, - zebra_image_t *image); +extern int zbar_scan_image(zbar_image_scanner_t *scanner, + zbar_image_t *image); /*@}*/ @@ -957,104 +957,104 @@ extern int zebra_scan_image(zebra_image_scanner_t *scanner, */ /*@{*/ -struct zebra_decoder_s; +struct zbar_decoder_s; /** opaque decoder object. */ -typedef struct zebra_decoder_s zebra_decoder_t; +typedef struct zbar_decoder_s zbar_decoder_t; /** decoder data handler callback function. * called by decoder when new data has just been decoded */ -typedef void (zebra_decoder_handler_t)(zebra_decoder_t *decoder); +typedef void (zbar_decoder_handler_t)(zbar_decoder_t *decoder); /** constructor. */ -extern zebra_decoder_t *zebra_decoder_create(); +extern zbar_decoder_t *zbar_decoder_create(); /** destructor. */ -extern void zebra_decoder_destroy(zebra_decoder_t *decoder); +extern void zbar_decoder_destroy(zbar_decoder_t *decoder); /** set config for indicated symbology (0 for all) to specified value. * @returns 0 for success, non-0 for failure (config does not apply to * specified symbology, or value out of range) * @since 0.4 */ -extern int zebra_decoder_set_config(zebra_decoder_t *decoder, - zebra_symbol_type_t symbology, - zebra_config_t config, - int value); +extern int zbar_decoder_set_config(zbar_decoder_t *decoder, + zbar_symbol_type_t symbology, + zbar_config_t config, + int value); -/** parse configuration string using zebra_parse_config() - * and apply to decoder using zebra_decoder_set_config(). +/** parse configuration string using zbar_parse_config() + * and apply to decoder using zbar_decoder_set_config(). * @returns 0 for success, non-0 for failure - * @see zebra_parse_config() - * @see zebra_decoder_set_config() + * @see zbar_parse_config() + * @see zbar_decoder_set_config() * @since 0.4 */ -static inline int zebra_decoder_parse_config (zebra_decoder_t *decoder, - const char *config_string) +static inline int zbar_decoder_parse_config (zbar_decoder_t *decoder, + const char *config_string) { - zebra_symbol_type_t sym; - zebra_config_t cfg; + zbar_symbol_type_t sym; + zbar_config_t cfg; int val; - return(zebra_parse_config(config_string, &sym, &cfg, &val) || - zebra_decoder_set_config(decoder, sym, cfg, val)); + return(zbar_parse_config(config_string, &sym, &cfg, &val) || + zbar_decoder_set_config(decoder, sym, cfg, val)); } /** clear all decoder state. * any partial symbols are flushed */ -extern void zebra_decoder_reset(zebra_decoder_t *decoder); +extern void zbar_decoder_reset(zbar_decoder_t *decoder); /** mark start of a new scan pass. - * clears any intra-symbol state and resets color to ::ZEBRA_SPACE. + * clears any intra-symbol state and resets color to ::ZBAR_SPACE. * any partially decoded symbol state is retained */ -extern void zebra_decoder_new_scan(zebra_decoder_t *decoder); +extern void zbar_decoder_new_scan(zbar_decoder_t *decoder); /** process next bar/space width from input stream. * the width is in arbitrary relative units. first value of a scan - * is ::ZEBRA_SPACE width, alternating from there. + * is ::ZBAR_SPACE width, alternating from there. * @returns appropriate symbol type if width completes * decode of a symbol (data is available for retrieval) - * @returns ::ZEBRA_PARTIAL as a hint if part of a symbol was decoded - * @returns ::ZEBRA_NONE (0) if no new symbol data is available + * @returns ::ZBAR_PARTIAL as a hint if part of a symbol was decoded + * @returns ::ZBAR_NONE (0) if no new symbol data is available */ -extern zebra_symbol_type_t zebra_decode_width(zebra_decoder_t *decoder, - unsigned width); +extern zbar_symbol_type_t zbar_decode_width(zbar_decoder_t *decoder, + unsigned width); /** retrieve color of @em next element passed to - * zebra_decode_width(). */ -extern zebra_color_t zebra_decoder_get_color(const zebra_decoder_t *decoder); + * zbar_decode_width(). */ +extern zbar_color_t zbar_decoder_get_color(const zbar_decoder_t *decoder); /** retrieve last decoded data in ASCII format. * @returns the data string or NULL if no new data available. * the returned data buffer is owned by library, contents are only - * valid between non-0 return from zebra_decode_width and next library + * valid between non-0 return from zbar_decode_width and next library * call */ -extern const char *zebra_decoder_get_data(const zebra_decoder_t *decoder); +extern const char *zbar_decoder_get_data(const zbar_decoder_t *decoder); /** retrieve last decoded symbol type. - * @returns the type or ::ZEBRA_NONE if no new data available + * @returns the type or ::ZBAR_NONE if no new data available */ -extern zebra_symbol_type_t -zebra_decoder_get_type(const zebra_decoder_t *decoder); +extern zbar_symbol_type_t +zbar_decoder_get_type(const zbar_decoder_t *decoder); /** setup data handler callback. * the registered function will be called by the decoder - * just before zebra_decode_width() returns a non-zero value. + * just before zbar_decode_width() returns a non-zero value. * pass a NULL value to disable callbacks. * @returns the previously registered handler */ -extern zebra_decoder_handler_t* -zebra_decoder_set_handler(zebra_decoder_t *decoder, - zebra_decoder_handler_t *handler); +extern zbar_decoder_handler_t* +zbar_decoder_set_handler(zbar_decoder_t *decoder, + zbar_decoder_handler_t *handler); /** associate user specified data value with the decoder. */ -extern void zebra_decoder_set_userdata(zebra_decoder_t *decoder, - void *userdata); +extern void zbar_decoder_set_userdata(zbar_decoder_t *decoder, + void *userdata); /** return user specified data value associated with the decoder. */ -extern void *zebra_decoder_get_userdata(const zebra_decoder_t *decoder); +extern void *zbar_decoder_get_userdata(const zbar_decoder_t *decoder); /*@}*/ @@ -1067,55 +1067,55 @@ extern void *zebra_decoder_get_userdata(const zebra_decoder_t *decoder); */ /*@{*/ -struct zebra_scanner_s; +struct zbar_scanner_s; /** opaque scanner object. */ -typedef struct zebra_scanner_s zebra_scanner_t; +typedef struct zbar_scanner_s zbar_scanner_t; /** constructor. * if decoder is non-NULL it will be attached to scanner * and called automatically at each new edge - * current color is initialized to ::ZEBRA_SPACE + * current color is initialized to ::ZBAR_SPACE * (so an initial BAR->SPACE transition may be discarded) */ -extern zebra_scanner_t *zebra_scanner_create(zebra_decoder_t *decoder); +extern zbar_scanner_t *zbar_scanner_create(zbar_decoder_t *decoder); /** destructor. */ -extern void zebra_scanner_destroy(zebra_scanner_t *scanner); +extern void zbar_scanner_destroy(zbar_scanner_t *scanner); /** clear all scanner state. * also resets an associated decoder */ -extern zebra_symbol_type_t zebra_scanner_reset(zebra_scanner_t *scanner); +extern zbar_symbol_type_t zbar_scanner_reset(zbar_scanner_t *scanner); -/** mark start of a new scan pass. resets color to ::ZEBRA_SPACE. +/** mark start of a new scan pass. resets color to ::ZBAR_SPACE. * also updates an associated decoder. * @returns any decode results flushed from the pipeline * @note when not using callback handlers, the return value should - * be checked the same as zebra_scan_y() + * be checked the same as zbar_scan_y() */ -extern zebra_symbol_type_t zebra_scanner_new_scan(zebra_scanner_t *scanner); +extern zbar_symbol_type_t zbar_scanner_new_scan(zbar_scanner_t *scanner); /** process next sample intensity value. * intensity (y) is in arbitrary relative units. - * @returns result of zebra_decode_width() if a decoder is attached, - * otherwise @returns (::ZEBRA_PARTIAL) when new edge is detected - * or 0 (::ZEBRA_NONE) if no new edge is detected + * @returns result of zbar_decode_width() if a decoder is attached, + * otherwise @returns (::ZBAR_PARTIAL) when new edge is detected + * or 0 (::ZBAR_NONE) if no new edge is detected */ -extern zebra_symbol_type_t zebra_scan_y(zebra_scanner_t *scanner, - int y); +extern zbar_symbol_type_t zbar_scan_y(zbar_scanner_t *scanner, + int y); /** process next sample from RGB (or BGR) triple. */ -static inline zebra_symbol_type_t zebra_scan_rgb24 (zebra_scanner_t *scanner, +static inline zbar_symbol_type_t zbar_scan_rgb24 (zbar_scanner_t *scanner, unsigned char *rgb) { - return(zebra_scan_y(scanner, rgb[0] + rgb[1] + rgb[2])); + return(zbar_scan_y(scanner, rgb[0] + rgb[1] + rgb[2])); } /** retrieve last scanned width. */ -extern unsigned zebra_scanner_get_width(const zebra_scanner_t *scanner); +extern unsigned zbar_scanner_get_width(const zbar_scanner_t *scanner); /** retrieve last scanned color. */ -extern zebra_color_t zebra_scanner_get_color(const zebra_scanner_t *scanner); +extern zbar_color_t zbar_scanner_get_color(const zbar_scanner_t *scanner); /*@}*/ @@ -1123,15 +1123,15 @@ extern zebra_color_t zebra_scanner_get_color(const zebra_scanner_t *scanner); } } -# include "zebra/Exception.h" -# include "zebra/Decoder.h" -# include "zebra/Scanner.h" -# include "zebra/Symbol.h" -# include "zebra/Image.h" -# include "zebra/ImageScanner.h" -# include "zebra/Video.h" -# include "zebra/Window.h" -# include "zebra/Processor.h" +# include "zbar/Exception.h" +# include "zbar/Decoder.h" +# include "zbar/Scanner.h" +# include "zbar/Symbol.h" +# include "zbar/Image.h" +# include "zbar/ImageScanner.h" +# include "zbar/Video.h" +# include "zbar/Window.h" +# include "zbar/Processor.h" #endif #endif diff --git a/include/zebra/Decoder.h b/include/zbar/Decoder.h similarity index 56% rename from include/zebra/Decoder.h rename to include/zbar/Decoder.h index 65b60d66..2c5ce788 100644 --- a/include/zebra/Decoder.h +++ b/include/zbar/Decoder.h @@ -1,38 +1,38 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_DECODER_H_ -#define _ZEBRA_DECODER_H_ +#ifndef _ZBAR_DECODER_H_ +#define _ZBAR_DECODER_H_ /// @file /// Decoder C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Decoder.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Decoder.h" #endif #include -namespace zebra { +namespace zbar { /// low-level bar width stream decoder interface. /// identifies symbols and extracts encoded data @@ -55,126 +55,126 @@ class Decoder { Decoder () : _handler(NULL) { - _decoder = zebra_decoder_create(); + _decoder = zbar_decoder_create(); } ~Decoder () { - zebra_decoder_destroy(_decoder); + zbar_decoder_destroy(_decoder); } /// clear all decoder state. - /// see zebra_decoder_reset() + /// see zbar_decoder_reset() void reset () { - zebra_decoder_reset(_decoder); + zbar_decoder_reset(_decoder); } /// mark start of a new scan pass. - /// see zebra_decoder_new_scan() + /// see zbar_decoder_new_scan() void new_scan () { - zebra_decoder_new_scan(_decoder); + zbar_decoder_new_scan(_decoder); } /// process next bar/space width from input stream. - /// see zebra_decode_width() - zebra_symbol_type_t decode_width (unsigned width) + /// see zbar_decode_width() + zbar_symbol_type_t decode_width (unsigned width) { - return(zebra_decode_width(_decoder, width)); + return(zbar_decode_width(_decoder, width)); } /// process next bar/space width from input stream. - /// see zebra_decode_width() + /// see zbar_decode_width() Decoder& operator<< (unsigned width) { - zebra_decode_width(_decoder, width); + zbar_decode_width(_decoder, width); return(*this); } /// retrieve color of @em next element passed to Decoder. - /// see zebra_decoder_get_color() - zebra_color_t get_color () const + /// see zbar_decoder_get_color() + zbar_color_t get_color () const { - return(zebra_decoder_get_color(_decoder)); + return(zbar_decoder_get_color(_decoder)); } /// retrieve last decoded symbol type. - /// see zebra_decoder_get_type() - zebra_symbol_type_t get_type () const + /// see zbar_decoder_get_type() + zbar_symbol_type_t get_type () const { - return(zebra_decoder_get_type(_decoder)); + return(zbar_decoder_get_type(_decoder)); } /// retrieve string name of last decoded symbol type. - /// see zebra_get_symbol_name() + /// see zbar_get_symbol_name() const char *get_symbol_name () const { - return(zebra_get_symbol_name(zebra_decoder_get_type(_decoder))); + return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder))); } /// retrieve string name for last decode addon. - /// see zebra_get_addon_name() + /// see zbar_get_addon_name() const char *get_addon_name () const { - return(zebra_get_addon_name(zebra_decoder_get_type(_decoder))); + return(zbar_get_addon_name(zbar_decoder_get_type(_decoder))); } /// retrieve last decoded data in ASCII format as a char array. - /// see zebra_decoder_get_data() + /// see zbar_decoder_get_data() const char *get_data_chars() const { - return(zebra_decoder_get_data(_decoder)); + return(zbar_decoder_get_data(_decoder)); } /// retrieve last decoded data in ASCII format as a std::string. - /// see zebra_decoder_get_data() + /// see zbar_decoder_get_data() const std::string get_data_string() const { - return(zebra_decoder_get_data(_decoder)); + return(zbar_decoder_get_data(_decoder)); } /// retrieve last decoded data in ASCII format as a std::string. - /// see zebra_decoder_get_data() + /// see zbar_decoder_get_data() const std::string get_data() const { - return(zebra_decoder_get_data(_decoder)); + return(zbar_decoder_get_data(_decoder)); } /// setup callback to handle result data. void set_handler (Handler &handler) { _handler = &handler; - zebra_decoder_set_handler(_decoder, _cb); - zebra_decoder_set_userdata(_decoder, this); + zbar_decoder_set_handler(_decoder, _cb); + zbar_decoder_set_userdata(_decoder, this); } /// set config for indicated symbology (0 for all) to specified value. - /// @see zebra_decoder_set_config() + /// @see zbar_decoder_set_config() /// @since 0.4 - int set_config (zebra_symbol_type_t symbology, - zebra_config_t config, + int set_config (zbar_symbol_type_t symbology, + zbar_config_t config, int value) { - return(zebra_decoder_set_config(_decoder, symbology, config, value)); + return(zbar_decoder_set_config(_decoder, symbology, config, value)); } /// set config parsed from configuration string. - /// @see zebra_decoder_parse_config() + /// @see zbar_decoder_parse_config() /// @since 0.4 int set_config (std::string cfgstr) { - return(zebra_decoder_parse_config(_decoder, cfgstr.c_str())); + return(zbar_decoder_parse_config(_decoder, cfgstr.c_str())); } private: friend class Scanner; - zebra_decoder_t *_decoder; + zbar_decoder_t *_decoder; Handler *_handler; - static void _cb (zebra_decoder_t *cdcode) + static void _cb (zbar_decoder_t *cdcode) { - Decoder *dcode = (Decoder*)zebra_decoder_get_userdata(cdcode); + Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode); if(dcode && dcode->_handler) dcode->_handler->decode_callback(*dcode); } diff --git a/include/zebra/Exception.h b/include/zbar/Exception.h similarity index 79% rename from include/zebra/Exception.h rename to include/zbar/Exception.h index c18c2bdc..236622f6 100644 --- a/include/zebra/Exception.h +++ b/include/zbar/Exception.h @@ -1,39 +1,39 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_EXCEPTION_H_ -#define _ZEBRA_EXCEPTION_H_ +#ifndef _ZBAR_EXCEPTION_H_ +#define _ZBAR_EXCEPTION_H_ /// @file /// C++ Exception definitions -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Exception.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Exception.h" #endif #include #include -namespace zebra { +namespace zbar { /// base class for exceptions defined by this API. class Exception : public std::exception { @@ -51,8 +51,8 @@ class Exception : public std::exception { virtual const char* what () const throw() { if(!_obj) - return("zebra library unspecified generic error"); - return(_zebra_error_string(_obj, 0)); + return("zbar library unspecified generic error"); + return(_zbar_error_string(_obj, 0)); } private: @@ -156,26 +156,26 @@ class FormatError : public Exception { /// extract error information and create exception. static inline std::exception throw_exception (const void *obj) { - switch(_zebra_get_error_code(obj)) { - case ZEBRA_ERR_NOMEM: + switch(_zbar_get_error_code(obj)) { + case ZBAR_ERR_NOMEM: throw std::bad_alloc(); - case ZEBRA_ERR_INTERNAL: + case ZBAR_ERR_INTERNAL: throw InternalError(obj); - case ZEBRA_ERR_UNSUPPORTED: + case ZBAR_ERR_UNSUPPORTED: throw UnsupportedError(obj); - case ZEBRA_ERR_INVALID: + case ZBAR_ERR_INVALID: throw InvalidError(obj); - case ZEBRA_ERR_SYSTEM: + case ZBAR_ERR_SYSTEM: throw SystemError(obj); - case ZEBRA_ERR_LOCKING: + case ZBAR_ERR_LOCKING: throw LockingError(obj); - case ZEBRA_ERR_BUSY: + case ZBAR_ERR_BUSY: throw BusyError(obj); - case ZEBRA_ERR_XDISPLAY: + case ZBAR_ERR_XDISPLAY: throw XDisplayError(obj); - case ZEBRA_ERR_XPROTO: + case ZBAR_ERR_XPROTO: throw XProtoError(obj); - case ZEBRA_ERR_CLOSED: + case ZBAR_ERR_CLOSED: throw ClosedError(obj); default: throw Exception(obj); diff --git a/include/zebra/Image.h b/include/zbar/Image.h similarity index 71% rename from include/zebra/Image.h rename to include/zbar/Image.h index c20dc929..387cb277 100644 --- a/include/zebra/Image.h +++ b/include/zbar/Image.h @@ -1,33 +1,33 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_IMAGE_H_ -#define _ZEBRA_IMAGE_H_ +#ifndef _ZBAR_IMAGE_H_ +#define _ZBAR_IMAGE_H_ /// @file /// Image C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Image.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Image.h" #endif #include @@ -35,7 +35,7 @@ #include "Symbol.h" #include "Exception.h" -namespace zebra { +namespace zbar { class Video; @@ -56,17 +56,17 @@ class Image { virtual void image_callback(Image &image) = 0; /// cast this handler to the C handler - operator zebra_image_data_handler_t* () const + operator zbar_image_data_handler_t* () const { return(_cb); } private: - static void _cb (zebra_image_t *zimg, + static void _cb (zbar_image_t *zimg, const void *userdata) { if(userdata) { - Image *image = (Image*)zebra_image_get_userdata(zimg); + Image *image = (Image*)zbar_image_get_userdata(zimg); ((Handler*)userdata)->image_callback(*image); } } @@ -81,7 +81,7 @@ class Image { SymbolIterator (const Image *img = NULL) { if(img) { - const zebra_symbol_t *zsym = zebra_image_first_symbol(*img); + const zbar_symbol_t *zsym = zbar_image_first_symbol(*img); _sym.init(zsym); } } @@ -94,9 +94,9 @@ class Image { /// advance iterator to next Symbol. SymbolIterator& operator++ () { - const zebra_symbol_t *zsym = _sym; + const zbar_symbol_t *zsym = _sym; if(zsym) { - zsym = zebra_symbol_next(zsym); + zsym = zbar_symbol_next(zsym); _sym.init(zsym); } return(*this); @@ -138,9 +138,9 @@ class Image { const std::string& format = "", const void *data = NULL, unsigned long length = 0) - : _img(zebra_image_create()) + : _img(zbar_image_create()) { - zebra_image_set_userdata(_img, this); + zbar_image_set_userdata(_img, this); if(width && height) set_size(width, height); if(format.length()) @@ -151,37 +151,37 @@ class Image { ~Image () { - zebra_image_ref(_img, -1); + zbar_image_ref(_img, -1); } /// cast to C image object - operator const zebra_image_t* () const + operator const zbar_image_t* () const { return(_img); } /// cast to C image object - operator zebra_image_t* () + operator zbar_image_t* () { return(_img); } /// retrieve the image format. - /// see zebra_image_get_format() + /// see zbar_image_get_format() unsigned long get_format () const { - return(zebra_image_get_format(_img)); + return(zbar_image_get_format(_img)); } /// specify the fourcc image format code for image sample data. - /// see zebra_image_set_format() + /// see zbar_image_set_format() void set_format (unsigned long format) { - zebra_image_set_format(_img, format); + zbar_image_set_format(_img, format); } /// specify the fourcc image format code for image sample data. - /// see zebra_image_set_format() + /// see zbar_image_set_format() void set_format (const std::string& format) { if(format.length() != 4) @@ -190,90 +190,90 @@ class Image { ((format[1] & 0xff) << 8) | ((format[2] & 0xff) << 16) | ((format[3] & 0xff) << 24)); - zebra_image_set_format(_img, fourcc); + zbar_image_set_format(_img, fourcc); } /// retrieve a "sequence" (page/frame) number associated with this /// image. - /// see zebra_image_get_sequence() + /// see zbar_image_get_sequence() /// @since 0.6 unsigned get_sequence () const { - return(zebra_image_get_sequence(_img)); + return(zbar_image_get_sequence(_img)); } /// associate a "sequence" (page/frame) number with this image. - /// see zebra_image_set_sequence() + /// see zbar_image_set_sequence() /// @since 0.6 void set_sequence (unsigned sequence_num) { - zebra_image_set_sequence(_img, sequence_num); + zbar_image_set_sequence(_img, sequence_num); } /// retrieve the width of the image. - /// see zebra_image_get_width() + /// see zbar_image_get_width() unsigned get_width () const { - return(zebra_image_get_width(_img)); + return(zbar_image_get_width(_img)); } /// retrieve the height of the image. - /// see zebra_image_get_height() + /// see zbar_image_get_height() unsigned get_height () const { - return(zebra_image_get_height(_img)); + return(zbar_image_get_height(_img)); } /// specify the pixel size of the image. - /// see zebra_image_set_size() + /// see zbar_image_set_size() void set_size (unsigned width, unsigned height) { - zebra_image_set_size(_img, width, height); + zbar_image_set_size(_img, width, height); } /// return the image sample data. - /// see zebra_image_get_data() + /// see zbar_image_get_data() const void *get_data () const { - return(zebra_image_get_data(_img)); + return(zbar_image_get_data(_img)); } /// return the size of the image sample data. - /// see zebra_image_get_data_length() + /// see zbar_image_get_data_length() /// @since 0.6 unsigned long get_data_length () const { - return(zebra_image_get_data_length(_img)); + return(zbar_image_get_data_length(_img)); } /// specify image sample data. - /// see zebra_image_set_data() + /// see zbar_image_set_data() void set_data (const void *data, unsigned long length) { - zebra_image_set_data(_img, data, length, _cleanup); + zbar_image_set_data(_img, data, length, _cleanup); } /// image format conversion. - /// see zebra_image_convert() + /// see zbar_image_convert() Image convert (unsigned long format) const { - zebra_image_t *img = zebra_image_convert(_img, format); + zbar_image_t *img = zbar_image_convert(_img, format); if(img) return(Image(img)); throw FormatError(); } /// image format conversion with crop/pad. - /// see zebra_image_convert_resize() + /// see zbar_image_convert_resize() /// @since 0.4 Image convert (unsigned long format, unsigned width, unsigned height) const { - zebra_image_t *img = - zebra_image_convert_resize(_img, format, width, height); + zbar_image_t *img = + zbar_image_convert_resize(_img, format, width, height); if(img) return(Image(img)); throw FormatError(); @@ -295,27 +295,27 @@ class Image { /// constructor. /// @internal - /// create a new Image from a zebra_image_t C object - Image (zebra_image_t *src, + /// create a new Image from a zbar_image_t C object + Image (zbar_image_t *src, int refs = 0) : _img(src) { if(refs) - zebra_image_ref(_img, refs); - zebra_image_set_userdata(_img, this); + zbar_image_ref(_img, refs); + zbar_image_set_userdata(_img, this); } /// default data cleanup (noop) /// @internal - static void _cleanup (zebra_image_t *img) + static void _cleanup (zbar_image_t *img) { // by default nothing is cleaned assert(img); - assert(zebra_image_get_userdata(img)); + assert(zbar_image_get_userdata(img)); } private: - zebra_image_t *_img; + zbar_image_t *_img; SymbolIterator _sym_iter_end; }; diff --git a/include/zebra/ImageScanner.h b/include/zbar/ImageScanner.h similarity index 57% rename from include/zebra/ImageScanner.h rename to include/zbar/ImageScanner.h index 7370fce7..a401d2ef 100644 --- a/include/zebra/ImageScanner.h +++ b/include/zbar/ImageScanner.h @@ -1,38 +1,38 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_IMAGE_SCANNER_H_ -#define _ZEBRA_IMAGE_SCANNER_H_ +#ifndef _ZBAR_IMAGE_SCANNER_H_ +#define _ZBAR_IMAGE_SCANNER_H_ /// @file /// Image Scanner C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/ImageScanner.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/ImageScanner.h" #endif #include "Image.h" -namespace zebra { +namespace zbar { /// mid-level image scanner interface. /// reads barcodes from a 2-D Image @@ -40,21 +40,21 @@ namespace zebra { class ImageScanner { public: /// constructor. - ImageScanner (zebra_image_scanner_t *scanner = NULL) + ImageScanner (zbar_image_scanner_t *scanner = NULL) { if(scanner) _scanner = scanner; else - _scanner = zebra_image_scanner_create(); + _scanner = zbar_image_scanner_create(); } ~ImageScanner () { - zebra_image_scanner_destroy(_scanner); + zbar_image_scanner_destroy(_scanner); } /// cast to C image_scanner object - operator zebra_image_scanner_t* () const + operator zbar_image_scanner_t* () const { return(_scanner); } @@ -62,44 +62,44 @@ class ImageScanner { /// setup result handler callback. void set_handler (Image::Handler &handler) { - zebra_image_scanner_set_data_handler(_scanner, handler, &handler); + zbar_image_scanner_set_data_handler(_scanner, handler, &handler); } /// set config for indicated symbology (0 for all) to specified value. - /// @see zebra_image_scanner_set_config() + /// @see zbar_image_scanner_set_config() /// @since 0.4 - int set_config (zebra_symbol_type_t symbology, - zebra_config_t config, + int set_config (zbar_symbol_type_t symbology, + zbar_config_t config, int value) { - return(zebra_image_scanner_set_config(_scanner, symbology, + return(zbar_image_scanner_set_config(_scanner, symbology, config, value)); } /// set config parsed from configuration string. - /// @see zebra_image_scanner_parse_config() + /// @see zbar_image_scanner_parse_config() /// @since 0.4 int set_config (std::string cfgstr) { - return(zebra_image_scanner_parse_config(_scanner, cfgstr.c_str())); + return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str())); } /// enable or disable the inter-image result cache. - /// see zebra_image_scanner_enable_cache() + /// see zbar_image_scanner_enable_cache() void enable_cache (bool enable = true) { - zebra_image_scanner_enable_cache(_scanner, enable); + zbar_image_scanner_enable_cache(_scanner, enable); } /// scan for symbols in provided image. - /// see zebra_scan_image() + /// see zbar_scan_image() int scan (Image& image) { - return(zebra_scan_image(_scanner, image)); + return(zbar_scan_image(_scanner, image)); } /// scan for symbols in provided image. - /// see zebra_scan_image() + /// see zbar_scan_image() ImageScanner& operator<< (Image& image) { scan(image); @@ -107,7 +107,7 @@ class ImageScanner { } private: - zebra_image_scanner_t *_scanner; + zbar_image_scanner_t *_scanner; }; } diff --git a/include/zebra/Processor.h b/include/zbar/Processor.h similarity index 65% rename from include/zebra/Processor.h rename to include/zbar/Processor.h index b66d9399..d89f9c77 100644 --- a/include/zebra/Processor.h +++ b/include/zbar/Processor.h @@ -1,39 +1,39 @@ //------------------------------------------------------------------------ // Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_PROCESSOR_H_ -#define _ZEBRA_PROCESSOR_H_ +#ifndef _ZBAR_PROCESSOR_H_ +#define _ZBAR_PROCESSOR_H_ /// @file /// Processor C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Processor.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Processor.h" #endif #include "Exception.h" #include "Image.h" -namespace zebra { +namespace zbar { /// high-level self-contained image processor. /// processes video and images for barcodes, optionally displaying @@ -49,7 +49,7 @@ class Processor { const char *video_device = "", bool enable_display = true) { - _processor = zebra_processor_create(threaded); + _processor = zbar_processor_create(threaded); if(!_processor) throw std::bad_alloc(); init(video_device, enable_display); @@ -57,104 +57,104 @@ class Processor { ~Processor () { - zebra_processor_destroy(_processor); + zbar_processor_destroy(_processor); } /// cast to C processor object. - operator zebra_processor_t* () + operator zbar_processor_t* () { return(_processor); } /// opens a video input device and/or prepares to display output. - /// see zebra_processor_init() + /// see zbar_processor_init() void init (const char *video_device = "", bool enable_display = true) { - if(zebra_processor_init(_processor, video_device, enable_display)) + if(zbar_processor_init(_processor, video_device, enable_display)) throw_exception(_processor); } /// setup result handler callback. - /// see zebra_processor_set_data_handler() + /// see zbar_processor_set_data_handler() void set_handler (Image::Handler& handler) { - zebra_processor_set_data_handler(_processor, handler, &handler); + zbar_processor_set_data_handler(_processor, handler, &handler); } /// set config for indicated symbology (0 for all) to specified value. - /// @see zebra_processor_set_config() + /// @see zbar_processor_set_config() /// @since 0.4 - int set_config (zebra_symbol_type_t symbology, - zebra_config_t config, + int set_config (zbar_symbol_type_t symbology, + zbar_config_t config, int value) { - return(zebra_processor_set_config(_processor, symbology, + return(zbar_processor_set_config(_processor, symbology, config, value)); } /// set config parsed from configuration string. - /// @see zebra_processor_parse_config() + /// @see zbar_processor_parse_config() /// @since 0.4 int set_config (std::string cfgstr) { - return(zebra_processor_parse_config(_processor, cfgstr.c_str())); + return(zbar_processor_parse_config(_processor, cfgstr.c_str())); } /// retrieve the current state of the ouput window. - /// see zebra_processor_is_visible() + /// see zbar_processor_is_visible() bool is_visible () { - int rc = zebra_processor_is_visible(_processor); + int rc = zbar_processor_is_visible(_processor); if(rc < 0) throw_exception(_processor); return(rc != 0); } /// show or hide the display window owned by the library. - /// see zebra_processor_set_visible() + /// see zbar_processor_set_visible() void set_visible (bool visible = true) { - if(zebra_processor_set_visible(_processor, visible) < 0) + if(zbar_processor_set_visible(_processor, visible) < 0) throw_exception(_processor); } /// control the processor in free running video mode. - /// see zebra_processor_set_active() + /// see zbar_processor_set_active() void set_active (bool active = true) { - if(zebra_processor_set_active(_processor, active) < 0) + if(zbar_processor_set_active(_processor, active) < 0) throw_exception(_processor); } /// wait for input to the display window from the user. - /// see zebra_processor_user_wait() + /// see zbar_processor_user_wait() int user_wait (int timeout = FOREVER) { - int rc = zebra_processor_user_wait(_processor, timeout); + int rc = zbar_processor_user_wait(_processor, timeout); if(rc < 0) throw_exception(_processor); return(rc); } /// process from the video stream until a result is available. - /// see zebra_process_one() + /// see zbar_process_one() void process_one (int timeout = FOREVER) { - if(zebra_process_one(_processor, timeout) < 0) + if(zbar_process_one(_processor, timeout) < 0) throw_exception(_processor); } /// process the provided image for barcodes. - /// see zebra_process_image() + /// see zbar_process_image() void process_image (Image& image) { - if(zebra_process_image(_processor, image) < 0) + if(zbar_process_image(_processor, image) < 0) throw_exception(_processor); } /// process the provided image for barcodes. - /// see zebra_process_image() + /// see zbar_process_image() Processor& operator<< (Image& image) { process_image(image); @@ -162,53 +162,53 @@ class Processor { } /// force specific input and output formats for debug/testing. - /// see zebra_processor_force_format() + /// see zbar_processor_force_format() void force_format (unsigned long input_format, unsigned long output_format) { - if(zebra_processor_force_format(_processor, input_format, + if(zbar_processor_force_format(_processor, input_format, output_format)) throw_exception(_processor); } /// force specific input and output formats for debug/testing. - /// see zebra_processor_force_format() + /// see zbar_processor_force_format() void force_format (std::string& input_format, std::string& output_format) { unsigned long ifourcc = *(unsigned long*)input_format.c_str(); unsigned long ofourcc = *(unsigned long*)output_format.c_str(); - if(zebra_processor_force_format(_processor, ifourcc, ofourcc)) + if(zbar_processor_force_format(_processor, ifourcc, ofourcc)) throw_exception(_processor); } /// request a preferred size for the video image from the device. - /// see zebra_processor_request_size() + /// see zbar_processor_request_size() /// @since 0.6 void request_size (int width, int height) { - zebra_processor_request_size(_processor, width, height); + zbar_processor_request_size(_processor, width, height); } /// request a preferred driver interface version for debug/testing. - /// see zebra_processor_request_interface() + /// see zbar_processor_request_interface() /// @since 0.6 void request_interface (int version) { - zebra_processor_request_interface(_processor, version); + zbar_processor_request_interface(_processor, version); } /// request a preferred I/O mode for debug/testing. - /// see zebra_processor_request_iomode() + /// see zbar_processor_request_iomode() /// @since 0.7 void request_iomode (int iomode) { - if(zebra_processor_request_iomode(_processor, iomode)) + if(zbar_processor_request_iomode(_processor, iomode)) throw_exception(_processor); } private: - zebra_processor_t *_processor; + zbar_processor_t *_processor; }; } diff --git a/include/zebra/QZebra.h b/include/zbar/QZBar.h similarity index 81% rename from include/zebra/QZebra.h rename to include/zbar/QZBar.h index 2d7a86af..db6d51da 100644 --- a/include/zebra/QZebra.h +++ b/include/zbar/QZBar.h @@ -1,52 +1,52 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _QZEBRA_H_ -#define _QZEBRA_H_ +#ifndef _QZBAR_H_ +#define _QZBAR_H_ /// @file /// Barcode Reader Qt4 Widget #include -namespace zebra { +namespace zbar { -class QZebraThread; +class QZBarThread; /// barcode reader Qt4 widget. /// embeds a barcode reader directly into a Qt4 based GUI. the widget -/// can process barcodes from a video source (using the QZebra::videoDevice -/// and QZebra::videoEnabled properties) or from individual QImages -/// supplied to the QZebra::scanImage() slot +/// can process barcodes from a video source (using the QZBar::videoDevice +/// and QZBar::videoEnabled properties) or from individual QImages +/// supplied to the QZBar::scanImage() slot /// @since 1.5 -class QZebra : public QWidget +class QZBar : public QWidget { Q_OBJECT /// the currently opened video device. /// /// setting a new device opens it and automatically sets - /// QZebra::videoEnabled + /// QZBar::videoEnabled /// /// @see videoDevice(), setVideoDevice() Q_PROPERTY(QString videoDevice @@ -66,7 +66,7 @@ class QZebra : public QWidget /// video device opened state. /// - /// (re)setting QZebra::videoDevice should eventually cause it + /// (re)setting QZBar::videoDevice should eventually cause it /// to be opened or closed. any errors while streaming/scanning /// will also cause the device to be closed /// @@ -78,9 +78,9 @@ class QZebra : public QWidget public: /// constructs a barcode reader widget with the given @a parent - QZebra(QWidget *parent = NULL); + QZBar(QWidget *parent = NULL); - ~QZebra(); + ~QZBar(); /// retrieve the currently opened video device. /// @returns the current video device or the empty string if no @@ -124,7 +124,7 @@ public Q_SLOTS: Q_SIGNALS: /// emitted when when a video device is opened or closed. /// - /// (re)setting QZebra::videoDevice should eventually cause it + /// (re)setting QZBar::videoDevice should eventually cause it /// to be opened or closed. any errors while streaming/scanning /// will also cause the device to be closed void videoOpened(bool videoOpened); @@ -155,7 +155,7 @@ protected Q_SLOTS: /// @} private: - QZebraThread *thread; + QZBarThread *thread; QString _videoDevice; bool _videoEnabled; }; diff --git a/include/zebra/QZebraImage.h b/include/zbar/QZBarImage.h similarity index 73% rename from include/zebra/QZebraImage.h rename to include/zbar/QZBarImage.h index 92dcbe15..ce984012 100644 --- a/include/zebra/QZebraImage.h +++ b/include/zbar/QZBarImage.h @@ -1,46 +1,46 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _QZEBRAIMAGE_H_ -#define _QZEBRAIMAGE_H_ +#ifndef _QZBARIMAGE_H_ +#define _QZBARIMAGE_H_ /// @file /// QImage to Image type conversion wrapper #include -#include +#include -namespace zebra { +namespace zbar { /// wrap a QImage and convert into a format suitable for scanning. -class QZebraImage +class QZBarImage : public Image { public: - /// construct a zebra library image based on an existing QImage. + /// construct a zbar library image based on an existing QImage. - QZebraImage (const QImage &qimg) + QZBarImage (const QImage &qimg) : qimg(qimg) { QImage::Format fmt = qimg.format(); diff --git a/include/zebra/Scanner.h b/include/zbar/Scanner.h similarity index 58% rename from include/zebra/Scanner.h rename to include/zbar/Scanner.h index 51340dfa..3191f587 100644 --- a/include/zebra/Scanner.h +++ b/include/zbar/Scanner.h @@ -1,38 +1,38 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_SCANNER_H_ -#define _ZEBRA_SCANNER_H_ +#ifndef _ZBAR_SCANNER_H_ +#define _ZBAR_SCANNER_H_ /// @file /// Scanner C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Scanner.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Scanner.h" #endif #include -namespace zebra { +namespace zbar { /// low-level linear intensity sample stream scanner interface. /// identifies "bar" edges and measures width between them. @@ -46,7 +46,7 @@ class Scanner { /// be passed scan results automatically Scanner (Decoder& decoder) { - _scanner = zebra_scanner_create(decoder._decoder); + _scanner = zbar_scanner_create(decoder._decoder); } /// constructor. @@ -54,98 +54,98 @@ class Scanner { /// be passed scan results automatically Scanner (Decoder* decoder = NULL) { - zebra_decoder_t *zdcode = NULL; + zbar_decoder_t *zdcode = NULL; if(decoder) zdcode = decoder->_decoder; - _scanner = zebra_scanner_create(zdcode); + _scanner = zbar_scanner_create(zdcode); } ~Scanner () { - zebra_scanner_destroy(_scanner); + zbar_scanner_destroy(_scanner); } /// clear all scanner state. - /// see zebra_scanner_reset() + /// see zbar_scanner_reset() void reset () { - zebra_scanner_reset(_scanner); + zbar_scanner_reset(_scanner); } /// mark start of a new scan pass. - /// see zebra_scanner_new_scan() + /// see zbar_scanner_new_scan() void new_scan () { - zebra_scanner_new_scan(_scanner); + zbar_scanner_new_scan(_scanner); } /// process next sample intensity value. - /// see zebra_scan_y() - zebra_symbol_type_t scan_y (int y) + /// see zbar_scan_y() + zbar_symbol_type_t scan_y (int y) { - _type = zebra_scan_y(_scanner, y); + _type = zbar_scan_y(_scanner, y); return(_type); } /// process next sample intensity value. - /// see zebra_scan_y() + /// see zbar_scan_y() Scanner& operator<< (int y) { - _type = zebra_scan_y(_scanner, y); + _type = zbar_scan_y(_scanner, y); return(*this); } /// process next sample from RGB (or BGR) triple. - /// see zebra_scan_rgb24() - zebra_symbol_type_t scan_rgb24 (unsigned char *rgb) + /// see zbar_scan_rgb24() + zbar_symbol_type_t scan_rgb24 (unsigned char *rgb) { - _type = zebra_scan_rgb24(_scanner, rgb); + _type = zbar_scan_rgb24(_scanner, rgb); return(_type); } /// process next sample from RGB (or BGR) triple. - /// see zebra_scan_rgb24() + /// see zbar_scan_rgb24() Scanner& operator<< (unsigned char *rgb) { - _type = zebra_scan_rgb24(_scanner, rgb); + _type = zbar_scan_rgb24(_scanner, rgb); return(*this); } /// retrieve last scanned width. - /// see zebra_scanner_get_width() + /// see zbar_scanner_get_width() unsigned get_width () const { - return(zebra_scanner_get_width(_scanner)); + return(zbar_scanner_get_width(_scanner)); } /// retrieve last scanned color. - /// see zebra_scanner_get_color() - zebra_color_t get_color () const + /// see zbar_scanner_get_color() + zbar_color_t get_color () const { - return(zebra_scanner_get_color(_scanner)); + return(zbar_scanner_get_color(_scanner)); } /// retrieve last scan result. - zebra_symbol_type_t get_type () const + zbar_symbol_type_t get_type () const { return(_type); } /// cast to C scanner - operator zebra_scanner_t* () const + operator zbar_scanner_t* () const { return(_scanner); } /// retrieve C scanner - const zebra_scanner_t *get_c_scanner () const + const zbar_scanner_t *get_c_scanner () const { return(_scanner); } private: - zebra_scanner_t *_scanner; - zebra_symbol_type_t _type; + zbar_scanner_t *_scanner; + zbar_symbol_type_t _type; }; } diff --git a/include/zebra/Symbol.h b/include/zbar/Symbol.h similarity index 75% rename from include/zebra/Symbol.h rename to include/zbar/Symbol.h index 6d56fd47..a04fc618 100644 --- a/include/zebra/Symbol.h +++ b/include/zbar/Symbol.h @@ -1,39 +1,39 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_SYMBOL_H_ -#define _ZEBRA_SYMBOL_H_ +#ifndef _ZBAR_SYMBOL_H_ +#define _ZBAR_SYMBOL_H_ /// @file /// Symbol C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Symbol.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Symbol.h" #endif #include #include -namespace zebra { +namespace zbar { /// decoded barcode symbol result object. stores type, data, and /// image location of decoded symbol @@ -69,7 +69,7 @@ class Symbol { _index(index) { if(!sym || - (unsigned)_index >= zebra_symbol_get_loc_size(*_sym)) + (unsigned)_index >= zbar_symbol_get_loc_size(*_sym)) _index = -1; } @@ -83,8 +83,8 @@ class Symbol { PointIterator& operator++ () { if(_index >= 0) { - _pt.x = zebra_symbol_get_loc_x(*_sym, ++_index); - _pt.y = zebra_symbol_get_loc_y(*_sym, _index); + _pt.x = zbar_symbol_get_loc_x(*_sym, ++_index); + _pt.y = zbar_symbol_get_loc_y(*_sym, _index); if(_pt.x < 0 || _pt.y < 0) _index = -1; } @@ -119,7 +119,7 @@ class Symbol { }; /// constructor. - Symbol (const zebra_symbol_t *sym = NULL) + Symbol (const zbar_symbol_t *sym = NULL) : _xmlbuf(NULL), _xmllen(0) { @@ -132,23 +132,23 @@ class Symbol { } /// initialize Symbol from C symbol object. - void init (const zebra_symbol_t *sym) + void init (const zbar_symbol_t *sym) { _sym = sym; if(sym) { - _type = zebra_symbol_get_type(sym); - _data = zebra_symbol_get_data(sym); - _count = zebra_symbol_get_count(sym); + _type = zbar_symbol_get_type(sym); + _data = zbar_symbol_get_data(sym); + _count = zbar_symbol_get_count(sym); } else { - _type = ZEBRA_NONE; + _type = ZBAR_NONE; _data = ""; _count = -1; } } /// cast to C symbol. - operator const zebra_symbol_t* () const + operator const zbar_symbol_t* () const { return(_sym); } @@ -166,7 +166,7 @@ class Symbol { } /// retrieve type of decoded symbol. - zebra_symbol_type_t get_type () const + zbar_symbol_type_t get_type () const { return(_type); } @@ -174,13 +174,13 @@ class Symbol { /// retrieve the string name of the symbol type. const std::string get_type_name () const { - return(zebra_get_symbol_name(_type)); + return(zbar_get_symbol_name(_type)); } /// retrieve the string name for any addon. const std::string get_addon_name () const { - return(zebra_get_addon_name(_type)); + return(zbar_get_addon_name(_type)); } /// retrieve ASCII data decoded from symbol. @@ -190,7 +190,7 @@ class Symbol { } /// retrieve inter-frame coherency count. - /// see zebra_symbol_get_count() + /// see zbar_symbol_get_count() /// @since 1.5 int get_count () const { @@ -210,33 +210,33 @@ class Symbol { return(_point_iter_end); } - /// see zebra_symbol_get_loc_size(). + /// see zbar_symbol_get_loc_size(). int get_location_size () const { - return(zebra_symbol_get_loc_size(_sym)); + return(zbar_symbol_get_loc_size(_sym)); } - /// see zebra_symbol_get_loc_x(). + /// see zbar_symbol_get_loc_x(). int get_location_x (unsigned index) const { - return(zebra_symbol_get_loc_x(_sym, index)); + return(zbar_symbol_get_loc_x(_sym, index)); } - /// see zebra_symbol_get_loc_y(). + /// see zbar_symbol_get_loc_y(). int get_location_y (unsigned index) const { - return(zebra_symbol_get_loc_y(_sym, index)); + return(zbar_symbol_get_loc_y(_sym, index)); } - /// see zebra_symbol_xml(). + /// see zbar_symbol_xml(). const std::string xml () const { - return(zebra_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen)); + return(zbar_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen)); } private: - const zebra_symbol_t *_sym; - zebra_symbol_type_t _type; + const zbar_symbol_t *_sym; + zbar_symbol_type_t _type; std::string _data; int _count; PointIterator _point_iter_end; diff --git a/include/zebra/Video.h b/include/zbar/Video.h similarity index 61% rename from include/zebra/Video.h rename to include/zbar/Video.h index 8e41fdc8..2787d86b 100644 --- a/include/zebra/Video.h +++ b/include/zbar/Video.h @@ -1,38 +1,38 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_VIDEO_H_ -#define _ZEBRA_VIDEO_H_ +#ifndef _ZBAR_VIDEO_H_ +#define _ZBAR_VIDEO_H_ /// @file /// Video Input C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Video.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Video.h" #endif #include "Image.h" -namespace zebra { +namespace zbar { /// mid-level video source abstraction. /// captures images from a video device @@ -40,28 +40,28 @@ namespace zebra { class Video { public: /// constructor. - Video (zebra_video_t *video = NULL) + Video (zbar_video_t *video = NULL) { if(video) _video = video; else - _video = zebra_video_create(); + _video = zbar_video_create(); } /// constructor. Video (std::string& device) { - _video = zebra_video_create(); + _video = zbar_video_create(); open(device); } ~Video () { - zebra_video_destroy(_video); + zbar_video_destroy(_video); } /// cast to C video object. - operator zebra_video_t* () const + operator zbar_video_t* () const { return(_video); } @@ -69,100 +69,100 @@ class Video { /// open and probe a video device. void open (std::string& device) { - if(zebra_video_open(_video, device.c_str())) + if(zbar_video_open(_video, device.c_str())) throw_exception(_video); } /// close video device if open. void close () { - if(zebra_video_open(_video, NULL)) + if(zbar_video_open(_video, NULL)) throw_exception(_video); } /// initialize video using a specific format for debug. - /// see zebra_video_init() + /// see zbar_video_init() void init (unsigned long fourcc) { - if(zebra_video_init(_video, fourcc)) + if(zbar_video_init(_video, fourcc)) throw_exception(_video); } /// initialize video using a specific format for debug. - /// see zebra_video_init() + /// see zbar_video_init() void init (std::string& format) { unsigned int fourcc = *(unsigned int*)format.c_str(); - if(zebra_video_init(_video, fourcc)) + if(zbar_video_init(_video, fourcc)) throw_exception(_video); } /// retrieve file descriptor associated with open *nix video device. - /// see zebra_video_get_fd() + /// see zbar_video_get_fd() int get_fd () { - return(zebra_video_get_fd(_video)); + return(zbar_video_get_fd(_video)); } /// retrieve current output image width. - /// see zebra_video_get_width() + /// see zbar_video_get_width() int get_width () { - return(zebra_video_get_width(_video)); + return(zbar_video_get_width(_video)); } /// retrieve current output image height. - /// see zebra_video_get_height() + /// see zbar_video_get_height() int get_height () { - return(zebra_video_get_height(_video)); + return(zbar_video_get_height(_video)); } /// start/stop video capture. - /// see zebra_video_enable() + /// see zbar_video_enable() void enable (bool enable = true) { - if(zebra_video_enable(_video, enable)) + if(zbar_video_enable(_video, enable)) throw_exception(_video); } /// retrieve next captured image. - /// see zebra_video_next_image() + /// see zbar_video_next_image() Image next_image () { - zebra_image_t *img = zebra_video_next_image(_video); + zbar_image_t *img = zbar_video_next_image(_video); if(!img) throw_exception(_video); return(Image(img)); } /// request a preferred size for the video image from the device. - /// see zebra_video_request_size() + /// see zbar_video_request_size() /// @since 0.6 void request_size (int width, int height) { - zebra_video_request_size(_video, width, height); + zbar_video_request_size(_video, width, height); } /// request a preferred driver interface version for debug/testing. - /// see zebra_video_request_interface() + /// see zbar_video_request_interface() /// @since 0.6 void request_interface (int version) { - zebra_video_request_interface(_video, version); + zbar_video_request_interface(_video, version); } /// request a preferred I/O mode for debug/testing. - /// see zebra_video_request_iomode() + /// see zbar_video_request_iomode() /// @since 0.7 void request_iomode (int iomode) { - if(zebra_video_request_iomode(_video, iomode)) + if(zbar_video_request_iomode(_video, iomode)) throw_exception(_video); } private: - zebra_video_t *_video; + zbar_video_t *_video; }; } diff --git a/include/zebra/Window.h b/include/zbar/Window.h similarity index 63% rename from include/zebra/Window.h rename to include/zbar/Window.h index f34861fc..8cba07ec 100644 --- a/include/zebra/Window.h +++ b/include/zbar/Window.h @@ -1,38 +1,38 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _ZEBRA_WINDOW_H_ -#define _ZEBRA_WINDOW_H_ +#ifndef _ZBAR_WINDOW_H_ +#define _ZBAR_WINDOW_H_ /// @file /// Output Window C++ wrapper -#ifndef _ZEBRA_H_ -# error "include zebra.h in your application, **not** zebra/Window.h" +#ifndef _ZBAR_H_ +# error "include zbar.h in your application, **not** zbar/Window.h" #endif #include "Image.h" -namespace zebra { +namespace zbar { /// mid-level output window abstraction. /// displays images to user-specified platform specific output window @@ -40,91 +40,91 @@ namespace zebra { class Window { public: /// constructor. - Window (zebra_window_t *window = NULL) + Window (zbar_window_t *window = NULL) { if(window) _window = window; else - _window = zebra_window_create(); + _window = zbar_window_create(); } /// constructor. Window (void *x11_display_w32_hwnd, unsigned long x11_drawable) { - _window = zebra_window_create(); + _window = zbar_window_create(); attach(x11_display_w32_hwnd, x11_drawable); } ~Window () { - zebra_window_destroy(_window); + zbar_window_destroy(_window); } /// cast to C window object. - operator zebra_window_t* () const + operator zbar_window_t* () const { return(_window); } /// associate reader with an existing platform window. - /// see zebra_window_attach() + /// see zbar_window_attach() void attach (void *x11_display_w32_hwnd, unsigned long x11_drawable = 0) { - if(zebra_window_attach(_window, + if(zbar_window_attach(_window, x11_display_w32_hwnd, x11_drawable) < 0) throw_exception(_window); } /// control content level of the reader overlay. - /// see zebra_window_set_overlay() + /// see zbar_window_set_overlay() void set_overlay (int level) { - zebra_window_set_overlay(_window, level); + zbar_window_set_overlay(_window, level); } /// draw a new image into the output window. - /// see zebra_window_draw() + /// see zbar_window_draw() void draw (Image& image) { - if(zebra_window_draw(_window, image) < 0) + if(zbar_window_draw(_window, image) < 0) throw_exception(_window); } /// clear the image from the output window. - /// see zebra_window_draw() + /// see zbar_window_draw() void clear () { - if(zebra_window_draw(_window, NULL) < 0) + if(zbar_window_draw(_window, NULL) < 0) throw_exception(_window); } /// redraw the last image. - /// zebra_window_redraw() + /// zbar_window_redraw() void redraw () { - if(zebra_window_redraw(_window) < 0) + if(zbar_window_redraw(_window) < 0) throw_exception(_window); } /// resize the image window. - /// zebra_window_resize() + /// zbar_window_resize() void resize (unsigned width, unsigned height) { - if(zebra_window_resize(_window, width, height) < 0) + if(zbar_window_resize(_window, width, height) < 0) throw_exception(_window); } private: - zebra_window_t *_window; + zbar_window_t *_window; }; /// select a compatible format between video input and output window. -/// see zebra_negotiate_format() +/// see zbar_negotiate_format() static inline void negotiate_format (Video& video, Window& window) { - if(zebra_negotiate_format(video, window) < 0) + if(zbar_negotiate_format(video, window) < 0) throw_exception(video); } diff --git a/include/zebra/zebragtk.h b/include/zbar/zbargtk.h similarity index 56% rename from include/zebra/zebragtk.h rename to include/zbar/zbargtk.h index 9b3351d4..5d4ddc00 100644 --- a/include/zebra/zebragtk.h +++ b/include/zbar/zbargtk.h @@ -1,36 +1,36 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ -#ifndef __ZEBRA_GTK_H__ -#define __ZEBRA_GTK_H__ +#ifndef __ZBAR_GTK_H__ +#define __ZBAR_GTK_H__ -/** SECTION:ZebraGtk +/** SECTION:ZBarGtk * @short_description: barcode reader GTK+ 2.x widget - * @include: zebra/zebragtk.h + * @include: zbar/zbargtk.h * * embeds a barcode reader directly into a GTK+ based GUI. the widget * can process barcodes from a video source (using the - * #ZebraGtk:video-device and #ZebraGtk:video-enabled properties) or - * from individual GdkPixbufs supplied to zebra_gtk_scan_image() + * #ZBarGtk:video-device and #ZBarGtk:video-enabled properties) or + * from individual GdkPixbufs supplied to zbar_gtk_scan_image() * * Since: 1.5 */ @@ -39,43 +39,43 @@ #include #include -#include +#include G_BEGIN_DECLS -#define ZEBRA_TYPE_GTK (zebra_gtk_get_type()) -#define ZEBRA_GTK(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), ZEBRA_TYPE_GTK, ZebraGtk)) -#define ZEBRA_GTK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), ZEBRA_TYPE_GTK, ZebraGtkClass)) -#define ZEBRA_IS_GTK(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZEBRA_TYPE_GTK)) -#define ZEBRA_IS_GTK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), ZEBRA_TYPE_GTK)) -#define ZEBRA_GTK_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), ZEBRA_TYPE_GTK, ZebraGtkClass)) - -typedef struct _ZebraGtk ZebraGtk; -typedef struct _ZebraGtkClass ZebraGtkClass; - -struct _ZebraGtk { +#define ZBAR_TYPE_GTK (zbar_gtk_get_type()) +#define ZBAR_GTK(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), ZBAR_TYPE_GTK, ZBarGtk)) +#define ZBAR_GTK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), ZBAR_TYPE_GTK, ZBarGtkClass)) +#define ZBAR_IS_GTK(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZBAR_TYPE_GTK)) +#define ZBAR_IS_GTK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), ZBAR_TYPE_GTK)) +#define ZBAR_GTK_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), ZBAR_TYPE_GTK, ZBarGtkClass)) + +typedef struct _ZBarGtk ZBarGtk; +typedef struct _ZBarGtkClass ZBarGtkClass; + +struct _ZBarGtk { GtkWidget widget; gpointer *_private; /* properties */ /** - * ZebraGtk:video-device: + * ZBarGtk:video-device: * * the currently set video device. * * setting a new device opens it and automatically sets - * #ZebraGtk:video-enabled. set the empty string ("") or NULL to + * #ZBarGtk:video-enabled. set the empty string ("") or NULL to * close. */ /** - * ZebraGtk:video-enabled: + * ZBarGtk:video-enabled: * * video device streaming state. * @@ -83,37 +83,37 @@ struct _ZebraGtk { */ /** - * ZebraGtk:video-opened: + * ZBarGtk:video-opened: * * video device opened state. * - * (re)setting #ZebraGtk:video-device should eventually cause it + * (re)setting #ZBarGtk:video-device should eventually cause it * to be opened or closed. any errors while streaming/scanning * will also cause the device to be closed */ }; -struct _ZebraGtkClass { +struct _ZBarGtkClass { GtkWidgetClass parent_class; /* signals */ /** - * ZebraGtk::decoded: + * ZBarGtk::decoded: * @widget: the object that received the signal - * @symbol_type: the type of symbol decoded (a zebra_symbol_type_t) + * @symbol_type: the type of symbol decoded (a zbar_symbol_type_t) * @data: the data decoded from the symbol * * emitted when a barcode is decoded from an image. * the symbol type and contained data are provided as separate * parameters */ - void (*decoded) (ZebraGtk *zebra, - zebra_symbol_type_t symbol_type, + void (*decoded) (ZBarGtk *zbar, + zbar_symbol_type_t symbol_type, const char *data); /** - * ZebraGtk::decoded-text: + * ZBarGtk::decoded-text: * @widget: the object that received the signal * @text: the decoded data prefixed by the string name of the * symbol type (separated by a colon) @@ -122,41 +122,41 @@ struct _ZebraGtkClass { * the symbol type name is prefixed to the data, separated by a * colon */ - void (*decoded_text) (ZebraGtk *zebra, + void (*decoded_text) (ZBarGtk *zbar, const char *text); /** - * ZebraGtk::scan-image: + * ZBarGtk::scan-image: * @widget: the object that received the signal * @image: the image to scan for barcodes */ - void (*scan_image) (ZebraGtk *zebra, + void (*scan_image) (ZBarGtk *zbar, GdkPixbuf *image); }; -GType zebra_gtk_get_type() G_GNUC_CONST; +GType zbar_gtk_get_type() G_GNUC_CONST; /** - * zebra_gtk_new: + * zbar_gtk_new: * create a new barcode reader widget instance. * initially has no associated video device or image. * - * Returns: a new #ZebraGtk widget instance + * Returns: a new #ZBarGtk widget instance */ -GtkWidget *zebra_gtk_new(); +GtkWidget *zbar_gtk_new(); /** - * zebra_gtk_scan_image: + * zbar_gtk_scan_image: * */ -void zebra_gtk_scan_image(ZebraGtk *zebra, - GdkPixbuf *image); +void zbar_gtk_scan_image(ZBarGtk *zbar, + GdkPixbuf *image); /** retrieve the currently opened video device. * * Returns: the current video device or NULL if no device is opened */ -const char *zebra_gtk_get_video_device(ZebraGtk *zebra); +const char *zbar_gtk_get_video_device(ZBarGtk *zbar); /** open a new video device. * @@ -166,39 +166,39 @@ const char *zebra_gtk_get_video_device(ZebraGtk *zebra); * @note since opening a device may take some time, this call will * return immediately and the device will be opened asynchronously */ -void zebra_gtk_set_video_device(ZebraGtk *zebra, - const char *video_device); +void zbar_gtk_set_video_device(ZBarGtk *zbar, + const char *video_device); /** retrieve the current video enabled state. * * Returns: true if video scanning is currently enabled, false otherwise */ -gboolean zebra_gtk_get_video_enabled(ZebraGtk *zebra); +gboolean zbar_gtk_get_video_enabled(ZBarGtk *zbar); /** enable/disable video scanning. * @video_enabled: true to enable video scanning, false to disable * * has no effect unless a video device is opened */ -void zebra_gtk_set_video_enabled(ZebraGtk *zebra, - gboolean video_enabled); +void zbar_gtk_set_video_enabled(ZBarGtk *zbar, + gboolean video_enabled); /** retrieve the current video opened state. * * Returns: true if video device is currently opened, false otherwise */ -gboolean zebra_gtk_get_video_opened(ZebraGtk *zebra); +gboolean zbar_gtk_get_video_opened(ZBarGtk *zbar); /** - * utility function to populate a zebra_image_t from a GdkPixbuf. - * @image: the zebra library image destination to populate + * utility function to populate a zbar_image_t from a GdkPixbuf. + * @image: the zbar library image destination to populate * @pixbuf: the GdkPixbuf source * * Returns: TRUE if successful or FALSE if the conversion could not be * performed for some reason */ -gboolean zebra_gtk_image_from_pixbuf(zebra_image_t *image, - GdkPixbuf *pixbuf); +gboolean zbar_gtk_image_from_pixbuf(zbar_image_t *image, + GdkPixbuf *pixbuf); G_END_DECLS diff --git a/perl/Changes b/perl/Changes index 618612ac..2bba2b3d 100644 --- a/perl/Changes +++ b/perl/Changes @@ -1,4 +1,7 @@ -Revision history for Perl extension Barcode::Zebra. +Revision history for Perl extension Barcode::ZBar. + +0.02 2009-04-16 spadix + * project name change: package becomes Barcode::ZBar 0.01 2009-02-28 spadix * add Barcode:: namespace prefix diff --git a/perl/MANIFEST b/perl/MANIFEST index 8146a675..77ed362b 100644 --- a/perl/MANIFEST +++ b/perl/MANIFEST @@ -4,16 +4,18 @@ Changes COPYING.LIB Makefile.PL typemap -Zebra.xs +ZBar.xs ppport.h -Zebra.pm -Zebra/Image.pod -Zebra/ImageScanner.pod -Zebra/Processor.pod -Zebra/Symbol.pod +ZBar.pm +ZBar/Image.pod +ZBar/ImageScanner.pod +ZBar/Processor.pod +ZBar/Symbol.pod t/barcode.png t/Decoder.t t/Image.t t/Processor.t t/Scanner.t -t/Zebra.t +t/ZBar.t +t/pod.t +t/pod-coverage.t diff --git a/perl/Makefile.PL b/perl/Makefile.PL index 5ed763d4..db237982 100644 --- a/perl/Makefile.PL +++ b/perl/Makefile.PL @@ -1,10 +1,26 @@ use 5.006; use ExtUtils::MakeMaker; +use lib qw(inc); +use Devel::CheckLib; + +check_lib_or_exit( + lib => 'zbar', + header => 'zbar.h', + LIBS => join(' ', map({ /^LIBS=(.*)/; $1 } grep(/^LIBS=/, @ARGV))), + INC => join(' ', map({ /^INC=(.*)/; $1 } grep(/^INC=/, @ARGV))), +); + WriteMakefile( - NAME => 'Barcode::Zebra', - VERSION_FROM => "Zebra.pm", - ABSTRACT_FROM => "Zebra.pm", + NAME => 'Barcode::ZBar', + VERSION_FROM => "ZBar.pm", + ABSTRACT_FROM => "ZBar.pm", AUTHOR => 'Jeff Brown ', - LIBS => ['-lzebra'], + LICENSE => 'lgpl', + LIBS => ['-lzbar'], + META_MERGE => { + build_requires => { + 'Test::More' => 0, + } + }, ); diff --git a/perl/README b/perl/README index d8735655..1824af51 100644 --- a/perl/README +++ b/perl/README @@ -1,15 +1,14 @@ -Barcode::Zebra Perl module -========================== +Barcode::ZBar Perl module +========================= -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. These are the Perl bindings for the -library. +The ZBar Bar Code Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. These are the Perl bindings for the library. -Check the zebra library home page for the latest release, mailing +Check the ZBar project home page for the latest release, mailing lists, etc. - http://zebra.sourceforge.net/ + http://zbar.sourceforge.net/ INSTALLATION @@ -24,10 +23,10 @@ To install this module type the following: DEPENDENCIES -This module requires the Zebra Barcode Reader library, which may be -obtained from: +This module requires the ZBar Bar Code Reader, which may be obtained +from: - http://zebra.sourceforge.net/ + http://zbar.sourceforge.net/ COPYRIGHT AND LICENCE diff --git a/perl/Zebra.pm b/perl/ZBar.pm similarity index 64% rename from perl/Zebra.pm rename to perl/ZBar.pm index 4a28b18b..8e0a902d 100644 --- a/perl/Zebra.pm +++ b/perl/ZBar.pm @@ -1,26 +1,26 @@ #------------------------------------------------------------------------ # Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ -package Barcode::Zebra; +package Barcode::ZBar; use 5.006; use strict; @@ -32,12 +32,12 @@ our @ISA = qw(Exporter); our @EXPORT_OK = qw(SPACE BAR version increase_verbosity set_verbosity); -our $VERSION = '0.1'; +our $VERSION = '0.02'; require XSLoader; -XSLoader::load('Barcode::Zebra', $VERSION); +XSLoader::load('Barcode::ZBar', $VERSION); -package Barcode::Zebra::Error; +package Barcode::ZBar::Error; use overload '""' => sub { return($_[0]->error_string()) }; @@ -47,22 +47,22 @@ __END__ =head1 NAME -Barcode::Zebra - Perl interface to the Zebra Barcode Reader Library +Barcode::ZBar - Perl interface to the ZBar Barcode Reader =head1 SYNOPSIS setup: - use Barcode::Zebra; + use Barcode::ZBar; - my $reader = Barcode::Zebra::Processor->new(); + my $reader = Barcode::ZBar::Processor->new(); $reader->init(); $reader->set_data_handler(\&my_handler); scan an image: - my $image = Barcode::Zebra::Image->new(); + my $image = Barcode::ZBar::Image->new(); $image->set_format('422P'); $image->set_size(114, 80); $image->set_data($raw_bits); @@ -84,10 +84,10 @@ collect results: =head1 DESCRIPTION -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. +The ZBar Bar Code Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. These are the bindings for interacting directly with the library from Perl. @@ -101,7 +101,7 @@ Perl. =item version() -Returns the version of the zebra library as "I.I". +Returns the version of the zbar library as "I.I". =item increase_verbosity() @@ -112,6 +112,13 @@ Increases global library debug by one level. Sets global library debug to the indicated level. Higher numbers give more verbosity. +=item parse_config(I) + +Parse a decoder configuration setting into a list containing the +symbology constant, config constant, and value to set. See the +documentation for C/C for available configuration +options. + =back =head2 Constants @@ -133,13 +140,13 @@ Dark area or colored bar segment. =head1 SEE ALSO -Barcode::Zebra::Processor, Barcode::Zebra::ImageScanner, -Barcode::Zebra::Image, Barcode::Zebra::Symbol, -Barcode::Zebra::Scanner, Barcode::Zebra::Decoder +Barcode::ZBar::Processor, Barcode::ZBar::ImageScanner, +Barcode::ZBar::Image, Barcode::ZBar::Symbol, +Barcode::ZBar::Scanner, Barcode::ZBar::Decoder -zebraimg(1), zebracam(1) +zbarimg(1), zbarcam(1) -http://zebra.sf.net +http://zbar.sf.net =head1 AUTHOR @@ -151,7 +158,7 @@ Jeff Brown, Espadix@users.sourceforge.netE Copyright 2008-2009 (c) Jeff Brown Espadix@users.sourceforge.netE -The Zebra Barcode Library is free software; you can redistribute it +The ZBar Bar Code Reader is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/perl/ZBar.xs b/perl/ZBar.xs new file mode 100644 index 00000000..65f8f976 --- /dev/null +++ b/perl/ZBar.xs @@ -0,0 +1,712 @@ +//------------------------------------------------------------------------ +// Copyright 2008-2009 (c) Jeff Brown +// +// This file is part of the ZBar Bar Code Reader. +// +// The ZBar Bar Code Reader is free software; you can redistribute it +// and/or modify it under the terms of the GNU Lesser Public License as +// published by the Free Software Foundation; either version 2.1 of +// the License, or (at your option) any later version. +// +// The ZBar Bar Code Reader is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser Public License for more details. +// +// You should have received a copy of the GNU Lesser Public License +// along with the ZBar Bar Code Reader; if not, write to the Free +// Software Foundation, Inc., 51 Franklin St, Fifth Floor, +// Boston, MA 02110-1301 USA +// +// http://sourceforge.net/projects/zbar +//------------------------------------------------------------------------ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include "ppport.h" + +#include + +typedef zbar_symbol_t *Barcode__ZBar__Symbol; +typedef zbar_image_t *Barcode__ZBar__Image; +typedef zbar_processor_t *Barcode__ZBar__Processor; +typedef zbar_video_t *Barcode__ZBar__Video; +typedef zbar_window_t *Barcode__ZBar__Window; +typedef zbar_image_scanner_t *Barcode__ZBar__ImageScanner; +typedef zbar_decoder_t *Barcode__ZBar__Decoder; +typedef zbar_scanner_t *Barcode__ZBar__Scanner; +typedef void *Barcode__ZBar__Error; + +typedef unsigned long fourcc_t; +typedef int timeout_t; +typedef int config_error; + +typedef struct handler_wrapper_s { + SV *instance; + SV *handler; + SV *closure; +} handler_wrapper_t; + + +static AV *LOOKUP_zbar_color_t = NULL; +static AV *LOOKUP_zbar_symbol_type_t = NULL; +static AV *LOOKUP_zbar_error_t = NULL; +static AV *LOOKUP_zbar_config_t = NULL; + +#define CONSTANT(typ, prefix, sym, name) \ + do { \ + SV *c = newSViv(ZBAR_ ## prefix ## sym); \ + sv_setpv(c, name); \ + SvIOK_on(c); \ + newCONSTSUB(stash, #sym, c); \ + av_store(LOOKUP_zbar_ ## typ ## _t, \ + ZBAR_ ## prefix ## sym, \ + SvREFCNT_inc(c)); \ + } while(0) + +#define LOOKUP_ENUM(typ, val) \ + lookup_enum(LOOKUP_zbar_ ## typ ## _t, val) + +static inline SV *lookup_enum (AV *lookup, int val) +{ + SV **tmp = av_fetch(lookup, val, 0); + return((tmp) ? *tmp : sv_newmortal()); +} + +static inline void check_error (int rc, void *obj) +{ + if(rc < 0) { + sv_setref_pv(get_sv("@", TRUE), "Barcode::ZBar::Error", obj); + croak(NULL); + } +} + +static void image_cleanup_handler (zbar_image_t *image) +{ + SV *data = zbar_image_get_userdata(image); + if(!data) + /* FIXME this is internal error */ + return; + + /* release reference to cleanup data */ + SvREFCNT_dec(data); +} + +static inline int set_handler (handler_wrapper_t **wrapp, + SV *instance, + SV *handler, + SV *closure) +{ + handler_wrapper_t *wrap = *wrapp; + if(!handler || !SvOK(handler)) { + if(wrap) { + if(wrap->instance) SvREFCNT_dec(wrap->instance); + if(wrap->handler) SvREFCNT_dec(wrap->handler); + if(wrap->closure) SvREFCNT_dec(wrap->closure); + wrap->instance = wrap->handler = wrap->closure = NULL; + } + return(0); + } + + if(!wrap) { + Newxz(wrap, 1, handler_wrapper_t); + wrap->instance = newSVsv(instance); + wrap->closure = newSV(0); + *wrapp = wrap; + } + + if(wrap->handler) + SvSetSV(wrap->handler, handler); + else + wrap->handler = newSVsv(handler); + + if(!closure || !SvOK(closure)) + SvSetSV(wrap->closure, &PL_sv_undef); + else + SvSetSV(wrap->closure, closure); + return(1); +} + +static inline void activate_handler (handler_wrapper_t *wrap, + SV *param) +{ + dSP; + if(!wrap) + /* FIXME this is internal error */ + return; + + ENTER; + SAVETMPS; + + PUSHMARK(SP); + EXTEND(SP, 2); + PUSHs(sv_mortalcopy(wrap->instance)); + if(param) + PUSHs(param); + PUSHs(sv_mortalcopy(wrap->closure)); + PUTBACK; + + call_sv(wrap->handler, G_DISCARD); + + FREETMPS; + LEAVE; +} + +static void processor_handler (zbar_image_t *image, + const void *userdata) +{ + SV *img; + zbar_image_ref(image, 1); + img = sv_setref_pv(newSV(0), "Barcode::ZBar::Image", image); + activate_handler((void*)userdata, img); + SvREFCNT_dec(img); +} + +static void decoder_handler (zbar_decoder_t *decoder) +{ + activate_handler(zbar_decoder_get_userdata(decoder), NULL); +} + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar PREFIX = zbar_ + +PROTOTYPES: ENABLE + +BOOT: + { + HV *stash = gv_stashpv("Barcode::ZBar", TRUE); + + LOOKUP_zbar_color_t = newAV(); + CONSTANT(color, , SPACE, "SPACE"); + CONSTANT(color, , BAR, "BAR"); + } + +SV * +zbar_version() + PREINIT: + unsigned major; + unsigned minor; + CODE: + zbar_version(&major, &minor); + RETVAL = newSVpvf("%u.%u", major, minor); + OUTPUT: + RETVAL + +void +zbar_increase_verbosity() + +void +zbar_set_verbosity(verbosity) + int verbosity + +SV * +parse_config(config_string) + const char * config_string + PREINIT: + zbar_symbol_type_t sym; + zbar_config_t cfg; + int val; + PPCODE: + if(zbar_parse_config(config_string, &sym, &cfg, &val)) + croak("invalid configuration setting: %s", config_string); + EXTEND(SP, 3); + PUSHs(LOOKUP_ENUM(symbol_type, sym)); + PUSHs(LOOKUP_ENUM(config, cfg)); + mPUSHi(val); + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Error PREFIX = zbar_ + +BOOT: + { + HV *stash = gv_stashpv("Barcode::ZBar::Error", TRUE); + + LOOKUP_zbar_error_t = newAV(); + CONSTANT(error, ERR_, NOMEM, "out of memory"); + CONSTANT(error, ERR_, INTERNAL, "internal library error"); + CONSTANT(error, ERR_, UNSUPPORTED, "unsupported request"); + CONSTANT(error, ERR_, INVALID, "invalid request"); + CONSTANT(error, ERR_, SYSTEM, "system error"); + CONSTANT(error, ERR_, LOCKING, "locking error"); + CONSTANT(error, ERR_, BUSY, "all resources busy"); + CONSTANT(error, ERR_, XDISPLAY, "X11 display error"); + CONSTANT(error, ERR_, XPROTO, "X11 protocol error"); + CONSTANT(error, ERR_, CLOSED, "output window is closed"); + } + +zbar_error_t +get_error_code(err) + Barcode::ZBar::Error err + CODE: + RETVAL = _zbar_get_error_code(err); + OUTPUT: + RETVAL + +const char * +error_string(err) + Barcode::ZBar::Error err + CODE: + RETVAL = _zbar_error_string(err, 1); + OUTPUT: + RETVAL + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Config PREFIX = zbar_config_ + +BOOT: + { + HV *stash = gv_stashpv("Barcode::ZBar::Config", TRUE); + + LOOKUP_zbar_config_t = newAV(); + CONSTANT(config, CFG_, ENABLE, "enable"); + CONSTANT(config, CFG_, ADD_CHECK, "add-check"); + CONSTANT(config, CFG_, EMIT_CHECK, "emit-check"); + CONSTANT(config, CFG_, ASCII, "ascii"); + CONSTANT(config, CFG_, MIN_LEN, "min-length"); + CONSTANT(config, CFG_, MAX_LEN, "max-length"); + CONSTANT(config, CFG_, X_DENSITY, "x-density"); + CONSTANT(config, CFG_, Y_DENSITY, "y-density"); + } + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Symbol PREFIX = zbar_symbol_ + +BOOT: + { + HV *stash = gv_stashpv("Barcode::ZBar::Symbol", TRUE); + + LOOKUP_zbar_symbol_type_t = newAV(); + CONSTANT(symbol_type, , NONE, "None"); + CONSTANT(symbol_type, , PARTIAL, "Partial"); + CONSTANT(symbol_type, , EAN8, zbar_get_symbol_name(ZBAR_EAN8)); + CONSTANT(symbol_type, , UPCE, zbar_get_symbol_name(ZBAR_UPCE)); + CONSTANT(symbol_type, , ISBN10, zbar_get_symbol_name(ZBAR_ISBN10)); + CONSTANT(symbol_type, , UPCA, zbar_get_symbol_name(ZBAR_UPCA)); + CONSTANT(symbol_type, , EAN13, zbar_get_symbol_name(ZBAR_EAN13)); + CONSTANT(symbol_type, , ISBN13, zbar_get_symbol_name(ZBAR_ISBN13)); + CONSTANT(symbol_type, , I25, zbar_get_symbol_name(ZBAR_I25)); + CONSTANT(symbol_type, , CODE39, zbar_get_symbol_name(ZBAR_CODE39)); + CONSTANT(symbol_type, , PDF417, zbar_get_symbol_name(ZBAR_PDF417)); + CONSTANT(symbol_type, , CODE128, zbar_get_symbol_name(ZBAR_CODE128)); + } + +zbar_symbol_type_t +zbar_symbol_get_type(symbol) + Barcode::ZBar::Symbol symbol + +const char * +zbar_symbol_get_data(symbol) + Barcode::ZBar::Symbol symbol + +int +zbar_symbol_get_count(symbol) + Barcode::ZBar::Symbol symbol + +SV * +zbar_symbol_get_loc(symbol) + Barcode::ZBar::Symbol symbol + PREINIT: + unsigned i, size; + PPCODE: + size = zbar_symbol_get_loc_size(symbol); + EXTEND(SP, size); + for(i = 0; i < size; i++) { + AV *pt = (AV*)sv_2mortal((SV*)newAV()); + PUSHs(newRV((SV*)pt)); + av_push(pt, newSVuv(zbar_symbol_get_loc_x(symbol, i))); + av_push(pt, newSVuv(zbar_symbol_get_loc_y(symbol, i))); + } + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Image PREFIX = zbar_image_ + +Barcode::ZBar::Image +new(package) + char * package + CODE: + RETVAL = zbar_image_create(); + OUTPUT: + RETVAL + +void +DESTROY(image) + Barcode::ZBar::Image image + CODE: + zbar_image_destroy(image); + +Barcode::ZBar::Image +zbar_image_convert(image, format) + Barcode::ZBar::Image image + fourcc_t format + +Barcode::ZBar::Image +zbar_image_convert_resize(image, format, width, height) + Barcode::ZBar::Image image + fourcc_t format + unsigned width + unsigned height + +fourcc_t +zbar_image_get_format(image) + Barcode::ZBar::Image image + +unsigned +zbar_image_get_sequence(image) + Barcode::ZBar::Image image + +void +get_size(image) + Barcode::ZBar::Image image + PPCODE: + EXTEND(SP, 2); + mPUSHu(zbar_image_get_width(image)); + mPUSHu(zbar_image_get_height(image)); + +SV * +zbar_image_get_data(image) + Barcode::ZBar::Image image + CODE: + RETVAL = newSVpvn(zbar_image_get_data(image), + zbar_image_get_data_length(image)); + OUTPUT: + RETVAL + +SV * +get_symbols(image) + Barcode::ZBar::Image image + PREINIT: + const zbar_symbol_t *sym; + PPCODE: + sym = zbar_image_first_symbol(image); + for(; sym; sym = zbar_symbol_next(sym)) + XPUSHs(sv_setref_pv(sv_newmortal(), "Barcode::ZBar::Symbol", + (void*)sym)); + +void +zbar_image_set_format(image, format) + Barcode::ZBar::Image image + fourcc_t format + +void +zbar_image_set_sequence(image, seq_num) + Barcode::ZBar::Image image + unsigned seq_num + +void +zbar_image_set_size(image, width, height) + Barcode::ZBar::Image image + unsigned width + unsigned height + +void +zbar_image_set_data(image, data) + Barcode::ZBar::Image image + SV * data + PREINIT: + SV *old; + CODE: + if(!data || !SvOK(data)) { + zbar_image_set_data(image, NULL, 0, NULL); + zbar_image_set_userdata(image, NULL); + } + else if(SvPOK(data)) { + /* FIXME is this copy of data or new ref to same data? + * not sure this is correct: + * need to retain a reference to image data, + * but do not really want to copy it...maybe an RV? + */ + SV *copy = newSVsv(data); + STRLEN len; + void *raw = SvPV(copy, len); + zbar_image_set_data(image, raw, len, image_cleanup_handler); + zbar_image_set_userdata(image, copy); + } + else + croak("image data must be binary string"); + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Processor PREFIX = zbar_processor_ + +Barcode::ZBar::Processor +new(package, threaded=0) + char * package + bool threaded + CODE: + RETVAL = zbar_processor_create(threaded); + OUTPUT: + RETVAL + +void +DESTROY(processor) + Barcode::ZBar::Processor processor + CODE: + zbar_processor_destroy(processor); + +void +zbar_processor_init(processor, video_device="/dev/video0", enable_display=1) + Barcode::ZBar::Processor processor + const char * video_device + bool enable_display + CODE: + check_error(zbar_processor_init(processor, video_device, enable_display), + processor); + +void +zbar_processor_request_size(processor, width, height) + Barcode::ZBar::Processor processor + unsigned width + unsigned height + CODE: + check_error(zbar_processor_request_size(processor, width, height), + processor); + +void +zbar_processor_force_format(processor, input_format=0, output_format=0) + Barcode::ZBar::Processor processor + fourcc_t input_format + fourcc_t output_format + CODE: + check_error(zbar_processor_force_format(processor, input_format, output_format), + processor); + +void +zbar_processor_set_config(processor, symbology, config, value=1) + Barcode::ZBar::Processor processor + zbar_symbol_type_t symbology + zbar_config_t config + int value + +config_error +zbar_processor_parse_config(processor, config_string) + Barcode::ZBar::Processor processor + const char *config_string + +bool +zbar_processor_is_visible(processor) + Barcode::ZBar::Processor processor + CODE: + check_error((RETVAL = zbar_processor_is_visible(processor)), + processor); + OUTPUT: + RETVAL + +void +zbar_processor_set_visible(processor, visible=1) + Barcode::ZBar::Processor processor + bool visible + CODE: + check_error(zbar_processor_set_visible(processor, visible), + processor); + +void +zbar_processor_set_active(processor, active=1) + Barcode::ZBar::Processor processor + bool active + CODE: + check_error(zbar_processor_set_active(processor, active), + processor); + +int +zbar_processor_user_wait(processor, timeout=-1) + Barcode::ZBar::Processor processor + timeout_t timeout + CODE: + check_error((RETVAL = zbar_processor_user_wait(processor, timeout)), + processor); + OUTPUT: + RETVAL + +int +process_one(processor, timeout=-1) + Barcode::ZBar::Processor processor + timeout_t timeout + CODE: + check_error((RETVAL = zbar_process_one(processor, timeout)), + processor); + OUTPUT: + RETVAL + +int +process_image(processor, image) + Barcode::ZBar::Processor processor + Barcode::ZBar::Image image + CODE: + check_error((RETVAL = zbar_process_image(processor, image)), + processor); + OUTPUT: + RETVAL + +void +zbar_processor_set_data_handler(processor, handler = 0, closure = 0) + Barcode::ZBar::Processor processor + SV * handler + SV * closure + PREINIT: + handler_wrapper_t *wrap; + zbar_image_data_handler_t *callback = NULL; + CODE: + wrap = zbar_processor_get_userdata(processor); + if(set_handler(&wrap, ST(0), handler, closure)) + callback = processor_handler; + zbar_processor_set_data_handler(processor, callback, wrap); + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::ImageScanner PREFIX = zbar_image_scanner_ + +Barcode::ZBar::ImageScanner +new(package) + char * package + CODE: + RETVAL = zbar_image_scanner_create(); + OUTPUT: + RETVAL + +void +DESTROY(scanner) + Barcode::ZBar::ImageScanner scanner + CODE: + zbar_image_scanner_destroy(scanner); + +void +zbar_image_scanner_set_config(scanner, symbology, config, value=1) + Barcode::ZBar::ImageScanner scanner + zbar_symbol_type_t symbology + zbar_config_t config + int value + +config_error +zbar_image_scanner_parse_config(scanner, config_string) + Barcode::ZBar::ImageScanner scanner + const char *config_string + +void +zbar_image_scanner_enable_cache(scanner, enable) + Barcode::ZBar::ImageScanner scanner + int enable + +int +scan_image(scanner, image) + Barcode::ZBar::ImageScanner scanner + Barcode::ZBar::Image image + CODE: + RETVAL = zbar_scan_image(scanner, image); + OUTPUT: + RETVAL + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Decoder PREFIX = zbar_decoder_ + +Barcode::ZBar::Decoder +new(package) + char * package + CODE: + RETVAL = zbar_decoder_create(); + OUTPUT: + RETVAL + +void +DESTROY(decoder) + Barcode::ZBar::Decoder decoder + CODE: + /* FIXME cleanup handler wrapper */ + zbar_decoder_destroy(decoder); + +void +zbar_decoder_set_config(decoder, symbology, config, value=1) + Barcode::ZBar::Decoder decoder + zbar_symbol_type_t symbology + zbar_config_t config + int value + +config_error +zbar_decoder_parse_config(decoder, config_string) + Barcode::ZBar::Decoder decoder + const char *config_string + +void +zbar_decoder_reset(decoder) + Barcode::ZBar::Decoder decoder + +void +zbar_decoder_new_scan(decoder) + Barcode::ZBar::Decoder decoder + +zbar_symbol_type_t +decode_width(decoder, width) + Barcode::ZBar::Decoder decoder + unsigned width + CODE: + RETVAL = zbar_decode_width(decoder, width); + OUTPUT: + RETVAL + +zbar_color_t +zbar_decoder_get_color(decoder) + Barcode::ZBar::Decoder decoder + +const char * +zbar_decoder_get_data(decoder) + Barcode::ZBar::Decoder decoder + +zbar_symbol_type_t +zbar_decoder_get_type(decoder) + Barcode::ZBar::Decoder decoder + +void +zbar_decoder_set_handler(decoder, handler = 0, closure = 0) + Barcode::ZBar::Decoder decoder + SV * handler + SV * closure + PREINIT: + handler_wrapper_t *wrap; + CODE: + wrap = zbar_decoder_get_userdata(decoder); + zbar_decoder_set_handler(decoder, NULL); + if(set_handler(&wrap, ST(0), handler, closure)) { + zbar_decoder_set_userdata(decoder, wrap); + zbar_decoder_set_handler(decoder, decoder_handler); + } + + +MODULE = Barcode::ZBar PACKAGE = Barcode::ZBar::Scanner PREFIX = zbar_scanner_ + +Barcode::ZBar::Scanner +new(package, decoder = 0) + char * package + Barcode::ZBar::Decoder decoder + CODE: + RETVAL = zbar_scanner_create(decoder); + OUTPUT: + RETVAL + +void +DESTROY(scanner) + Barcode::ZBar::Scanner scanner + CODE: + zbar_scanner_destroy(scanner); + +zbar_symbol_type_t +zbar_scanner_reset(scanner) + Barcode::ZBar::Scanner scanner + +zbar_symbol_type_t +zbar_scanner_new_scan(scanner) + Barcode::ZBar::Scanner scanner + +zbar_color_t +zbar_scanner_get_color(scanner) + Barcode::ZBar::Scanner scanner + +unsigned +zbar_scanner_get_width(scanner) + Barcode::ZBar::Scanner scanner + +zbar_symbol_type_t +scan_y(scanner, y) + Barcode::ZBar::Scanner scanner + int y + CODE: + RETVAL = zbar_scan_y(scanner, y); + OUTPUT: + RETVAL diff --git a/perl/Zebra/Image.pod b/perl/ZBar/Image.pod similarity index 75% rename from perl/Zebra/Image.pod rename to perl/ZBar/Image.pod index f3322f1b..6b3fc31b 100644 --- a/perl/Zebra/Image.pod +++ b/perl/ZBar/Image.pod @@ -1,37 +1,37 @@ #------------------------------------------------------------------------ # Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ =pod =head1 NAME -Barcode::Zebra::Image - image object to scan for bar codes +Barcode::ZBar::Image - image object to scan for bar codes =head1 SYNOPSIS - use Barcode::Zebra; + use Barcode::ZBar; - my $image = Barcode::Zebra::Image->new(); + my $image = Barcode::ZBar::Image->new(); $image->set_format('422P'); $image->set_size(114, 80); $image->set_data($raw_bits); @@ -40,7 +40,7 @@ Barcode::Zebra::Image - image object to scan for bar codes =head1 DESCRIPTION -Barcode::Zebra::Image is used to pass images to the bar code scanner. +Barcode::ZBar::Image is used to pass images to the bar code scanner. It wraps raw image data with the meta-data required to interpret it (size, pixel format, etc) @@ -76,7 +76,7 @@ Examples: =item new() -Create a new Barcode::Zebra::Image object. The size, pixel format and +Create a new Barcode::ZBar::Image object. The size, pixel format and data must be defined before the object may be used. =item get_format() @@ -105,12 +105,12 @@ Return/specify the raw image data as a binary string. =item get_symbols() -Return a list of scanned Barcode::Zebra::Symbol results attached to +Return a list of scanned Barcode::ZBar::Symbol results attached to this image. =item convert(I) -Return a new Barcode::Zebra::Image object converted to the indicated +Return a new Barcode::ZBar::Image object converted to the indicated fourcc format. Returns C if the conversion is not supported. Conversion complexity ranges from CPU intensive to trivial depending on the formats involved. Note that only a few conversions retain @@ -120,11 +120,11 @@ color information. =head1 SEE ALSO -Barcode::Zebra, Barcode::Zebra::Image, Barcode::Zebra::Symbol +Barcode::ZBar, Barcode::ZBar::Image, Barcode::ZBar::Symbol -zebraimg(1), zebracam(1) +zbarimg(1), zbarcam(1) -http://zebra.sf.net +http://zbar.sf.net =head1 AUTHOR @@ -134,7 +134,7 @@ Jeff Brown, Espadix@users.sourceforge.netE Copyright 2008-2009 (c) Jeff Brown Espadix@users.sourceforge.netE -The Zebra Barcode Library is free software; you can redistribute it +The ZBar Bar Code Reader is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/perl/Zebra/ImageScanner.pod b/perl/ZBar/ImageScanner.pod similarity index 67% rename from perl/Zebra/ImageScanner.pod rename to perl/ZBar/ImageScanner.pod index e557d4a5..db199822 100644 --- a/perl/Zebra/ImageScanner.pod +++ b/perl/ZBar/ImageScanner.pod @@ -1,44 +1,44 @@ #------------------------------------------------------------------------ # Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ =pod =head1 NAME -Barcode::Zebra::ImageScanner - scan images for bar codes +Barcode::ZBar::ImageScanner - scan images for bar codes =head1 SYNOPSIS - use Barcode::Zebra; + use Barcode::ZBar; - my $scanner = Barcode::Zebra::ImageScanner->new(); + my $scanner = Barcode::ZBar::ImageScanner->new(); $scanner->parse_config('i25.disable'); $scanner->scan_image($image); =head1 DESCRIPTION -A Barcode::Zebra::ImageScanner is used to scan for bar codes in a -Barcode::Zebra::Image. +A Barcode::ZBar::ImageScanner is used to scan for bar codes in a +Barcode::ZBar::Image. =head1 REFERENCE @@ -52,7 +52,7 @@ Create a new bar code image scanner instance. =item scan_image([I]) -Scan a Barcode::Zebra::Image for bar codes. +Scan a Barcode::ZBar::Image for bar codes. =item enable_cache([I]) @@ -61,15 +61,15 @@ Enable the inter-image result consistency cache. =item parse_config(I) Apply a decoder configuration setting. See the documentation for -C/C for available configuration options. +C/C for available configuration options. =back =head1 SEE ALSO -Barcode::Zebra, Barcode::Zebra::Image, zebraimg(1), zebracam(1) +Barcode::ZBar, Barcode::ZBar::Image, zbarimg(1), zbarcam(1) -http://zebra.sf.net +http://zbar.sf.net =head1 AUTHOR @@ -79,7 +79,7 @@ Jeff Brown, Espadix@users.sourceforge.netE Copyright 2008-2009 (c) Jeff Brown Espadix@users.sourceforge.netE -The Zebra Barcode Library is free software; you can redistribute it +The ZBar Bar Code Reader is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/perl/Zebra/Processor.pod b/perl/ZBar/Processor.pod similarity index 77% rename from perl/Zebra/Processor.pod rename to perl/ZBar/Processor.pod index 5d70bc03..0db7b74f 100644 --- a/perl/Zebra/Processor.pod +++ b/perl/ZBar/Processor.pod @@ -1,39 +1,39 @@ #------------------------------------------------------------------------ # Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ =pod =head1 NAME -Barcode::Zebra::Processor - self-contained bar code reader +Barcode::ZBar::Processor - self-contained bar code reader =head1 SYNOPSIS setup: - use Barcode::Zebra; + use Barcode::ZBar; - my $reader = Barcode::Zebra::Processor->new(); + my $reader = Barcode::ZBar::Processor->new(); $reader->init("/dev/video1", 1); $reader->parse_config('code39.disable'); $reader->set_data_handler(\&my_handler); @@ -50,13 +50,13 @@ scan from video: =head1 DESCRIPTION -A Barcode::Zebra::Processor may be used to quickly create stand-alone +A Barcode::ZBar::Processor may be used to quickly create stand-alone bar code scanning applications. It has interfaces to scan images or video and to optionally display a video/image preview to a window. This interface is not well suited for integration with an existing GUI, as the library manages the optional preview window and any user -interaction. Use a Barcode::Zebra::ImageScanner or Investigate the +interaction. Use a Barcode::ZBar::ImageScanner or Investigate the avilable widget interfaces for GUI applications. =head1 REFERENCE @@ -77,7 +77,7 @@ Open a video input device and/or prepare to display output. Setup a callback to process results whenever new results are available from the video stream or a static image. The specified callable will -be invoked with the associated Barcode::Zebra::Processor object and +be invoked with the associated Barcode::ZBar::Processor object and I as arguments. Closure may be achieved either using standard Perl closure or by manually passing a scalar via I. @@ -103,12 +103,12 @@ multiple results may still be returned. =item process_image([I]) -Scan a Barcode::Zebra::Image for bar codes. +Scan a Barcode::ZBar::Image for bar codes. =item parse_config(I) Apply a decoder configuration setting. See the documentation for -C/C for available configuration options. +C/C for available configuration options. =item request_size(I, I) @@ -120,11 +120,11 @@ called before C =head1 SEE ALSO -Barcode::Zebra, Barcode::Zebra::Image, Barcode::Zebra::ImageScanner +Barcode::ZBar, Barcode::ZBar::Image, Barcode::ZBar::ImageScanner -zebraimg(1), zebracam(1) +zbarimg(1), zbarcam(1) -http://zebra.sf.net +http://zbar.sf.net =head1 AUTHOR @@ -134,7 +134,7 @@ Jeff Brown, Espadix@users.sourceforge.netE Copyright 2008-2009 (c) Jeff Brown Espadix@users.sourceforge.netE -The Zebra Barcode Library is free software; you can redistribute it +The ZBar Bar Code Reader is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/perl/Zebra/Symbol.pod b/perl/ZBar/Symbol.pod similarity index 79% rename from perl/Zebra/Symbol.pod rename to perl/ZBar/Symbol.pod index 4bef64aa..c8f9192b 100644 --- a/perl/Zebra/Symbol.pod +++ b/perl/ZBar/Symbol.pod @@ -1,31 +1,31 @@ #------------------------------------------------------------------------ # Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ =pod =head1 NAME -Barcode::Zebra::Symbol - bar code scan result object +Barcode::ZBar::Symbol - bar code scan result object =head1 SYNOPSIS @@ -38,7 +38,7 @@ Barcode::Zebra::Symbol - bar code scan result object =head1 DESCRIPTION -Barcode::Zebra::Symbol objects are constant results returned for each +Barcode::ZBar::Symbol objects are constant results returned for each bar code scanned from images or video. This object wraps the raw symbol data with additional information about the decode (symbology, confidence, location, etc) @@ -62,7 +62,7 @@ data. Current cache count of the symbol. This integer value provides inter-scan reliability and redundancy information if enabled at the -Barcode::Zebra::ImageScanner. +Barcode::ZBar::ImageScanner. =over 2 @@ -115,11 +115,11 @@ Bar code type "symbology" constants: =head1 SEE ALSO -Barcode::Zebra, Barcode::Zebra::Image +Barcode::ZBar, Barcode::ZBar::Image -zebraimg(1), zebracam(1) +zbarimg(1), zbarcam(1) -http://zebra.sf.net +http://zbar.sf.net =head1 AUTHOR @@ -129,7 +129,7 @@ Jeff Brown, Espadix@users.sourceforge.netE Copyright 2008-2009 (c) Jeff Brown Espadix@users.sourceforge.netE -The Zebra Barcode Library is free software; you can redistribute it +The ZBar Bar Code Reader is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/perl/Zebra.xs b/perl/Zebra.xs deleted file mode 100644 index 0f3b7b89..00000000 --- a/perl/Zebra.xs +++ /dev/null @@ -1,712 +0,0 @@ -//------------------------------------------------------------------------ -// Copyright 2008-2009 (c) Jeff Brown -// -// This file is part of the Zebra Barcode Library. -// -// The Zebra Barcode Library is free software; you can redistribute it -// and/or modify it under the terms of the GNU Lesser Public License as -// published by the Free Software Foundation; either version 2.1 of -// the License, or (at your option) any later version. -// -// The Zebra Barcode Library is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser Public License for more details. -// -// You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin St, Fifth Floor, -// Boston, MA 02110-1301 USA -// -// http://sourceforge.net/projects/zebra -//------------------------------------------------------------------------ -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include "ppport.h" - -#include - -typedef zebra_symbol_t *Barcode__Zebra__Symbol; -typedef zebra_image_t *Barcode__Zebra__Image; -typedef zebra_processor_t *Barcode__Zebra__Processor; -typedef zebra_video_t *Barcode__Zebra__Video; -typedef zebra_window_t *Barcode__Zebra__Window; -typedef zebra_image_scanner_t *Barcode__Zebra__ImageScanner; -typedef zebra_decoder_t *Barcode__Zebra__Decoder; -typedef zebra_scanner_t *Barcode__Zebra__Scanner; -typedef void *Barcode__Zebra__Error; - -typedef unsigned long fourcc_t; -typedef int timeout_t; -typedef int config_error; - -typedef struct handler_wrapper_s { - SV *instance; - SV *handler; - SV *closure; -} handler_wrapper_t; - - -static AV *LOOKUP_zebra_color_t = NULL; -static AV *LOOKUP_zebra_symbol_type_t = NULL; -static AV *LOOKUP_zebra_error_t = NULL; -static AV *LOOKUP_zebra_config_t = NULL; - -#define CONSTANT(typ, prefix, sym, name) \ - do { \ - SV *c = newSViv(ZEBRA_ ## prefix ## sym); \ - sv_setpv(c, name); \ - SvIOK_on(c); \ - newCONSTSUB(stash, #sym, c); \ - av_store(LOOKUP_zebra_ ## typ ## _t, \ - ZEBRA_ ## prefix ## sym, \ - SvREFCNT_inc(c)); \ - } while(0) - -#define LOOKUP_ENUM(typ, val) \ - lookup_enum(LOOKUP_zebra_ ## typ ## _t, val) - -static inline SV *lookup_enum (AV *lookup, int val) -{ - SV **tmp = av_fetch(lookup, val, 0); - return((tmp) ? *tmp : sv_newmortal()); -} - -static inline void check_error (int rc, void *obj) -{ - if(rc < 0) { - sv_setref_pv(get_sv("@", TRUE), "Barcode::Zebra::Error", obj); - croak(NULL); - } -} - -static void image_cleanup_handler (zebra_image_t *image) -{ - SV *data = zebra_image_get_userdata(image); - if(!data) - /* FIXME this is internal error */ - return; - - /* release reference to cleanup data */ - SvREFCNT_dec(data); -} - -static inline int set_handler (handler_wrapper_t **wrapp, - SV *instance, - SV *handler, - SV *closure) -{ - handler_wrapper_t *wrap = *wrapp; - if(!handler || !SvOK(handler)) { - if(wrap) { - if(wrap->instance) SvREFCNT_dec(wrap->instance); - if(wrap->handler) SvREFCNT_dec(wrap->handler); - if(wrap->closure) SvREFCNT_dec(wrap->closure); - wrap->instance = wrap->handler = wrap->closure = NULL; - } - return(0); - } - - if(!wrap) { - Newxz(wrap, 1, handler_wrapper_t); - wrap->instance = newSVsv(instance); - wrap->closure = newSV(0); - *wrapp = wrap; - } - - if(wrap->handler) - SvSetSV(wrap->handler, handler); - else - wrap->handler = newSVsv(handler); - - if(!closure || !SvOK(closure)) - SvSetSV(wrap->closure, &PL_sv_undef); - else - SvSetSV(wrap->closure, closure); - return(1); -} - -static inline void activate_handler (handler_wrapper_t *wrap, - SV *param) -{ - dSP; - if(!wrap) - /* FIXME this is internal error */ - return; - - ENTER; - SAVETMPS; - - PUSHMARK(SP); - EXTEND(SP, 2); - PUSHs(sv_mortalcopy(wrap->instance)); - if(param) - PUSHs(param); - PUSHs(sv_mortalcopy(wrap->closure)); - PUTBACK; - - call_sv(wrap->handler, G_DISCARD); - - FREETMPS; - LEAVE; -} - -static void processor_handler (zebra_image_t *image, - const void *userdata) -{ - SV *img; - zebra_image_ref(image, 1); - img = sv_setref_pv(newSV(0), "Barcode::Zebra::Image", image); - activate_handler((void*)userdata, img); - SvREFCNT_dec(img); -} - -static void decoder_handler (zebra_decoder_t *decoder) -{ - activate_handler(zebra_decoder_get_userdata(decoder), NULL); -} - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra PREFIX = zebra_ - -PROTOTYPES: ENABLE - -BOOT: - { - HV *stash = gv_stashpv("Barcode::Zebra", TRUE); - - LOOKUP_zebra_color_t = newAV(); - CONSTANT(color, , SPACE, "SPACE"); - CONSTANT(color, , BAR, "BAR"); - } - -SV * -zebra_version() - PREINIT: - unsigned major; - unsigned minor; - CODE: - zebra_version(&major, &minor); - RETVAL = newSVpvf("%u.%u", major, minor); - OUTPUT: - RETVAL - -void -zebra_increase_verbosity() - -void -zebra_set_verbosity(verbosity) - int verbosity - -SV * -parse_config(config_string) - const char * config_string - PREINIT: - zebra_symbol_type_t sym; - zebra_config_t cfg; - int val; - PPCODE: - if(zebra_parse_config(config_string, &sym, &cfg, &val)) - croak("invalid configuration setting: %s", config_string); - EXTEND(SP, 3); - PUSHs(LOOKUP_ENUM(symbol_type, sym)); - PUSHs(LOOKUP_ENUM(config, cfg)); - mPUSHi(val); - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Error PREFIX = zebra_ - -BOOT: - { - HV *stash = gv_stashpv("Barcode::Zebra::Error", TRUE); - - LOOKUP_zebra_error_t = newAV(); - CONSTANT(error, ERR_, NOMEM, "out of memory"); - CONSTANT(error, ERR_, INTERNAL, "internal library error"); - CONSTANT(error, ERR_, UNSUPPORTED, "unsupported request"); - CONSTANT(error, ERR_, INVALID, "invalid request"); - CONSTANT(error, ERR_, SYSTEM, "system error"); - CONSTANT(error, ERR_, LOCKING, "locking error"); - CONSTANT(error, ERR_, BUSY, "all resources busy"); - CONSTANT(error, ERR_, XDISPLAY, "X11 display error"); - CONSTANT(error, ERR_, XPROTO, "X11 protocol error"); - CONSTANT(error, ERR_, CLOSED, "output window is closed"); - } - -zebra_error_t -get_error_code(err) - Barcode::Zebra::Error err - CODE: - RETVAL = _zebra_get_error_code(err); - OUTPUT: - RETVAL - -const char * -error_string(err) - Barcode::Zebra::Error err - CODE: - RETVAL = _zebra_error_string(err, 1); - OUTPUT: - RETVAL - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Config PREFIX = zebra_config_ - -BOOT: - { - HV *stash = gv_stashpv("Barcode::Zebra::Config", TRUE); - - LOOKUP_zebra_config_t = newAV(); - CONSTANT(config, CFG_, ENABLE, "enable"); - CONSTANT(config, CFG_, ADD_CHECK, "add-check"); - CONSTANT(config, CFG_, EMIT_CHECK, "emit-check"); - CONSTANT(config, CFG_, ASCII, "ascii"); - CONSTANT(config, CFG_, MIN_LEN, "min-length"); - CONSTANT(config, CFG_, MAX_LEN, "max-length"); - CONSTANT(config, CFG_, X_DENSITY, "x-density"); - CONSTANT(config, CFG_, Y_DENSITY, "y-density"); - } - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Symbol PREFIX = zebra_symbol_ - -BOOT: - { - HV *stash = gv_stashpv("Barcode::Zebra::Symbol", TRUE); - - LOOKUP_zebra_symbol_type_t = newAV(); - CONSTANT(symbol_type, , NONE, "None"); - CONSTANT(symbol_type, , PARTIAL, "Partial"); - CONSTANT(symbol_type, , EAN8, zebra_get_symbol_name(ZEBRA_EAN8)); - CONSTANT(symbol_type, , UPCE, zebra_get_symbol_name(ZEBRA_UPCE)); - CONSTANT(symbol_type, , ISBN10, zebra_get_symbol_name(ZEBRA_ISBN10)); - CONSTANT(symbol_type, , UPCA, zebra_get_symbol_name(ZEBRA_UPCA)); - CONSTANT(symbol_type, , EAN13, zebra_get_symbol_name(ZEBRA_EAN13)); - CONSTANT(symbol_type, , ISBN13, zebra_get_symbol_name(ZEBRA_ISBN13)); - CONSTANT(symbol_type, , I25, zebra_get_symbol_name(ZEBRA_I25)); - CONSTANT(symbol_type, , CODE39, zebra_get_symbol_name(ZEBRA_CODE39)); - CONSTANT(symbol_type, , PDF417, zebra_get_symbol_name(ZEBRA_PDF417)); - CONSTANT(symbol_type, , CODE128, zebra_get_symbol_name(ZEBRA_CODE128)); - } - -zebra_symbol_type_t -zebra_symbol_get_type(symbol) - Barcode::Zebra::Symbol symbol - -const char * -zebra_symbol_get_data(symbol) - Barcode::Zebra::Symbol symbol - -int -zebra_symbol_get_count(symbol) - Barcode::Zebra::Symbol symbol - -SV * -zebra_symbol_get_loc(symbol) - Barcode::Zebra::Symbol symbol - PREINIT: - unsigned i, size; - PPCODE: - size = zebra_symbol_get_loc_size(symbol); - EXTEND(SP, size); - for(i = 0; i < size; i++) { - AV *pt = (AV*)sv_2mortal((SV*)newAV()); - PUSHs(newRV((SV*)pt)); - av_push(pt, newSVuv(zebra_symbol_get_loc_x(symbol, i))); - av_push(pt, newSVuv(zebra_symbol_get_loc_y(symbol, i))); - } - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Image PREFIX = zebra_image_ - -Barcode::Zebra::Image -new(package) - char * package - CODE: - RETVAL = zebra_image_create(); - OUTPUT: - RETVAL - -void -DESTROY(image) - Barcode::Zebra::Image image - CODE: - zebra_image_destroy(image); - -Barcode::Zebra::Image -zebra_image_convert(image, format) - Barcode::Zebra::Image image - fourcc_t format - -Barcode::Zebra::Image -zebra_image_convert_resize(image, format, width, height) - Barcode::Zebra::Image image - fourcc_t format - unsigned width - unsigned height - -fourcc_t -zebra_image_get_format(image) - Barcode::Zebra::Image image - -unsigned -zebra_image_get_sequence(image) - Barcode::Zebra::Image image - -void -get_size(image) - Barcode::Zebra::Image image - PPCODE: - EXTEND(SP, 2); - mPUSHu(zebra_image_get_width(image)); - mPUSHu(zebra_image_get_height(image)); - -SV * -zebra_image_get_data(image) - Barcode::Zebra::Image image - CODE: - RETVAL = newSVpvn(zebra_image_get_data(image), - zebra_image_get_data_length(image)); - OUTPUT: - RETVAL - -SV * -get_symbols(image) - Barcode::Zebra::Image image - PREINIT: - const zebra_symbol_t *sym; - PPCODE: - sym = zebra_image_first_symbol(image); - for(; sym; sym = zebra_symbol_next(sym)) - XPUSHs(sv_setref_pv(sv_newmortal(), "Barcode::Zebra::Symbol", - (void*)sym)); - -void -zebra_image_set_format(image, format) - Barcode::Zebra::Image image - fourcc_t format - -void -zebra_image_set_sequence(image, seq_num) - Barcode::Zebra::Image image - unsigned seq_num - -void -zebra_image_set_size(image, width, height) - Barcode::Zebra::Image image - unsigned width - unsigned height - -void -zebra_image_set_data(image, data) - Barcode::Zebra::Image image - SV * data - PREINIT: - SV *old; - CODE: - if(!data || !SvOK(data)) { - zebra_image_set_data(image, NULL, 0, NULL); - zebra_image_set_userdata(image, NULL); - } - else if(SvPOK(data)) { - /* FIXME is this copy of data or new ref to same data? - * not sure this is correct: - * need to retain a reference to image data, - * but do not really want to copy it...maybe an RV? - */ - SV *copy = newSVsv(data); - STRLEN len; - void *raw = SvPV(copy, len); - zebra_image_set_data(image, raw, len, image_cleanup_handler); - zebra_image_set_userdata(image, copy); - } - else - croak("image data must be binary string"); - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Processor PREFIX = zebra_processor_ - -Barcode::Zebra::Processor -new(package, threaded=0) - char * package - bool threaded - CODE: - RETVAL = zebra_processor_create(threaded); - OUTPUT: - RETVAL - -void -DESTROY(processor) - Barcode::Zebra::Processor processor - CODE: - zebra_processor_destroy(processor); - -void -zebra_processor_init(processor, video_device="/dev/video0", enable_display=1) - Barcode::Zebra::Processor processor - const char * video_device - bool enable_display - CODE: - check_error(zebra_processor_init(processor, video_device, enable_display), - processor); - -void -zebra_processor_request_size(processor, width, height) - Barcode::Zebra::Processor processor - unsigned width - unsigned height - CODE: - check_error(zebra_processor_request_size(processor, width, height), - processor); - -void -zebra_processor_force_format(processor, input_format=0, output_format=0) - Barcode::Zebra::Processor processor - fourcc_t input_format - fourcc_t output_format - CODE: - check_error(zebra_processor_force_format(processor, input_format, output_format), - processor); - -void -zebra_processor_set_config(processor, symbology, config, value=1) - Barcode::Zebra::Processor processor - zebra_symbol_type_t symbology - zebra_config_t config - int value - -config_error -zebra_processor_parse_config(processor, config_string) - Barcode::Zebra::Processor processor - const char *config_string - -bool -zebra_processor_is_visible(processor) - Barcode::Zebra::Processor processor - CODE: - check_error((RETVAL = zebra_processor_is_visible(processor)), - processor); - OUTPUT: - RETVAL - -void -zebra_processor_set_visible(processor, visible=1) - Barcode::Zebra::Processor processor - bool visible - CODE: - check_error(zebra_processor_set_visible(processor, visible), - processor); - -void -zebra_processor_set_active(processor, active=1) - Barcode::Zebra::Processor processor - bool active - CODE: - check_error(zebra_processor_set_active(processor, active), - processor); - -int -zebra_processor_user_wait(processor, timeout=-1) - Barcode::Zebra::Processor processor - timeout_t timeout - CODE: - check_error((RETVAL = zebra_processor_user_wait(processor, timeout)), - processor); - OUTPUT: - RETVAL - -int -process_one(processor, timeout=-1) - Barcode::Zebra::Processor processor - timeout_t timeout - CODE: - check_error((RETVAL = zebra_process_one(processor, timeout)), - processor); - OUTPUT: - RETVAL - -int -process_image(processor, image) - Barcode::Zebra::Processor processor - Barcode::Zebra::Image image - CODE: - check_error((RETVAL = zebra_process_image(processor, image)), - processor); - OUTPUT: - RETVAL - -void -zebra_processor_set_data_handler(processor, handler = 0, closure = 0) - Barcode::Zebra::Processor processor - SV * handler - SV * closure - PREINIT: - handler_wrapper_t *wrap; - zebra_image_data_handler_t *callback = NULL; - CODE: - wrap = zebra_processor_get_userdata(processor); - if(set_handler(&wrap, ST(0), handler, closure)) - callback = processor_handler; - zebra_processor_set_data_handler(processor, callback, wrap); - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::ImageScanner PREFIX = zebra_image_scanner_ - -Barcode::Zebra::ImageScanner -new(package) - char * package - CODE: - RETVAL = zebra_image_scanner_create(); - OUTPUT: - RETVAL - -void -DESTROY(scanner) - Barcode::Zebra::ImageScanner scanner - CODE: - zebra_image_scanner_destroy(scanner); - -void -zebra_image_scanner_set_config(scanner, symbology, config, value=1) - Barcode::Zebra::ImageScanner scanner - zebra_symbol_type_t symbology - zebra_config_t config - int value - -config_error -zebra_image_scanner_parse_config(scanner, config_string) - Barcode::Zebra::ImageScanner scanner - const char *config_string - -void -zebra_image_scanner_enable_cache(scanner, enable) - Barcode::Zebra::ImageScanner scanner - int enable - -int -scan_image(scanner, image) - Barcode::Zebra::ImageScanner scanner - Barcode::Zebra::Image image - CODE: - RETVAL = zebra_scan_image(scanner, image); - OUTPUT: - RETVAL - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Decoder PREFIX = zebra_decoder_ - -Barcode::Zebra::Decoder -new(package) - char * package - CODE: - RETVAL = zebra_decoder_create(); - OUTPUT: - RETVAL - -void -DESTROY(decoder) - Barcode::Zebra::Decoder decoder - CODE: - /* FIXME cleanup handler wrapper */ - zebra_decoder_destroy(decoder); - -void -zebra_decoder_set_config(decoder, symbology, config, value=1) - Barcode::Zebra::Decoder decoder - zebra_symbol_type_t symbology - zebra_config_t config - int value - -config_error -zebra_decoder_parse_config(decoder, config_string) - Barcode::Zebra::Decoder decoder - const char *config_string - -void -zebra_decoder_reset(decoder) - Barcode::Zebra::Decoder decoder - -void -zebra_decoder_new_scan(decoder) - Barcode::Zebra::Decoder decoder - -zebra_symbol_type_t -decode_width(decoder, width) - Barcode::Zebra::Decoder decoder - unsigned width - CODE: - RETVAL = zebra_decode_width(decoder, width); - OUTPUT: - RETVAL - -zebra_color_t -zebra_decoder_get_color(decoder) - Barcode::Zebra::Decoder decoder - -const char * -zebra_decoder_get_data(decoder) - Barcode::Zebra::Decoder decoder - -zebra_symbol_type_t -zebra_decoder_get_type(decoder) - Barcode::Zebra::Decoder decoder - -void -zebra_decoder_set_handler(decoder, handler = 0, closure = 0) - Barcode::Zebra::Decoder decoder - SV * handler - SV * closure - PREINIT: - handler_wrapper_t *wrap; - CODE: - wrap = zebra_decoder_get_userdata(decoder); - zebra_decoder_set_handler(decoder, NULL); - if(set_handler(&wrap, ST(0), handler, closure)) { - zebra_decoder_set_userdata(decoder, wrap); - zebra_decoder_set_handler(decoder, decoder_handler); - } - - -MODULE = Barcode::Zebra PACKAGE = Barcode::Zebra::Scanner PREFIX = zebra_scanner_ - -Barcode::Zebra::Scanner -new(package, decoder = 0) - char * package - Barcode::Zebra::Decoder decoder - CODE: - RETVAL = zebra_scanner_create(decoder); - OUTPUT: - RETVAL - -void -DESTROY(scanner) - Barcode::Zebra::Scanner scanner - CODE: - zebra_scanner_destroy(scanner); - -zebra_symbol_type_t -zebra_scanner_reset(scanner) - Barcode::Zebra::Scanner scanner - -zebra_symbol_type_t -zebra_scanner_new_scan(scanner) - Barcode::Zebra::Scanner scanner - -zebra_color_t -zebra_scanner_get_color(scanner) - Barcode::Zebra::Scanner scanner - -unsigned -zebra_scanner_get_width(scanner) - Barcode::Zebra::Scanner scanner - -zebra_symbol_type_t -scan_y(scanner, y) - Barcode::Zebra::Scanner scanner - int y - CODE: - RETVAL = zebra_scan_y(scanner, y); - OUTPUT: - RETVAL diff --git a/perl/examples/paginate.pl b/perl/examples/paginate.pl new file mode 100755 index 00000000..68ffe505 --- /dev/null +++ b/perl/examples/paginate.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl +#------------------------------------------------------------------------ +# Copyright 2009 (c) Jeff Brown +# +# This file is part of the ZBar Bar Code Reader. +# +# The ZBar Bar Code Reader is free software; you can redistribute it +# and/or modify it under the terms of the GNU Lesser Public License as +# published by the Free Software Foundation; either version 2.1 of +# the License, or (at your option) any later version. +# +# The ZBar Bar Code Reader is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser Public License for more details. +# +# You should have received a copy of the GNU Lesser Public License +# along with the ZBar Bar Code Reader; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# http://sourceforge.net/projects/zbar +#------------------------------------------------------------------------ +use warnings; +use strict; + +use Barcode::ZBar; +use Image::Magick; + +warn("no input files specified?\n") if(!@ARGV); + +# running output document +my $out = undef; + +# barcode scanner +my $scanner = Barcode::ZBar::ImageScanner->new(); + +foreach my $file (@ARGV) { + print "scanning from \"$file\"\n"; + my $imseq = Image::Magick->new(); + my $err = $imseq->Read($file); + warn($err) if($err); + + foreach my $page (@$imseq) { + # convert ImageMagick page to ZBar image + my $zimg = Barcode::ZBar::Image->new(); + $zimg->set_format('Y800'); + $zimg->set_size($page->Get(qw(columns rows))); + $zimg->set_data($page->Clone()->ImageToBlob(magick => 'GRAY', depth => 8)); + + # scan for barcodes + if($scanner->scan_image($zimg)) { + # write out previous document + $out->write() if($out); + + # use first symbol found to name next image (FIXME sanitize) + my $data = ($zimg->get_symbols())[0]->get_data(); + my $idx = $page->Get('scene') + 1; + print "splitting $data from page $idx\n"; + + # create new output document + $out = Image::Magick->new(filename => $data); + } + + # append this page to current output + push(@$out, $page) if($out); + } + + # write out final document + $out->write() if($out); +} diff --git a/perl/examples/processor.pl b/perl/examples/processor.pl new file mode 100755 index 00000000..e14a4a3c --- /dev/null +++ b/perl/examples/processor.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +use warnings; +use strict; +require Barcode::ZBar; + +# create a Processor +my $proc = Barcode::ZBar::Processor->new(); + +# configure the Processor +$proc->parse_config("enable"); + +# initialize the Processor +$proc->init($ARGV[0] || '/dev/video0'); + +# setup a callback +sub my_handler { + my ($proc, $image, $closure) = @_; + + # extract results + foreach my $symbol ($image->get_symbols()) { + # do something useful with results + print('decoded ' . $symbol->get_type() . + ' symbol "' . $symbol->get_data() . "\"\n") + if(!$symbol->get_count()); + } +} +$proc->set_data_handler(\&my_handler); + +# enable the preview window +$proc->set_visible(); + +# initiate scanning +$proc->set_active(); +$proc->user_wait(); diff --git a/perl/examples/scan_image.pl b/perl/examples/scan_image.pl new file mode 100755 index 00000000..3734d19e --- /dev/null +++ b/perl/examples/scan_image.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl +use warnings; +use strict; +require Image::Magick; +require Barcode::ZBar; + +$ARGV[0] || die; + +# create a reader +my $scanner = Barcode::ZBar::ImageScanner->new(); + +# configure the reader +$scanner->parse_config("enable"); + +# obtain image data +my $magick = Image::Magick->new(); +$magick->Read($ARGV[0]) && die; +my $raw = $magick->ImageToBlob(magick => 'GRAY'); + +# wrap image data +my $image = Barcode::ZBar::Image->new(); +$image->set_format('Y800'); +$image->set_size($magick->Get(qw(columns rows))); +$image->set_data($raw); + +# scan the image for barcodes +my $n = $scanner->scan_image($image); + +# extract results +foreach my $symbol ($image->get_symbols()) { + # do something useful with results + print('decoded ' . $symbol->get_type() . + ' symbol "' . $symbol->get_data() . "\"\n"); +} + +# clean up +undef($image); diff --git a/perl/inc/Devel/CheckLib.pm b/perl/inc/Devel/CheckLib.pm new file mode 100644 index 00000000..d7167f43 --- /dev/null +++ b/perl/inc/Devel/CheckLib.pm @@ -0,0 +1,350 @@ +# $Id: CheckLib.pm,v 1.22 2008/03/12 19:52:50 drhyde Exp $ + +package Devel::CheckLib; + +use strict; +use vars qw($VERSION @ISA @EXPORT); +$VERSION = '0.5'; +use Config; + +use File::Spec; +use File::Temp; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(assert_lib check_lib_or_exit); + +# localising prevents the warningness leaking out of this module +local $^W = 1; # use warnings is a 5.6-ism + +_findcc(); # bomb out early if there's no compiler + +=head1 NAME + +Devel::CheckLib - check that a library is available + +=head1 DESCRIPTION + +Devel::CheckLib is a perl module that checks whether a particular C +library and its headers are available. + +=head1 SYNOPSIS + + # in a Makefile.PL or Build.PL + use lib qw(inc); + use Devel::CheckLib; + + check_lib_or_exit( lib => 'jpeg', header => 'jpeglib.h' ); + check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] ); + + # or prompt for path to library and then do this: + check_lib_or_exit( lib => 'jpeg', libpath => $additional_path ); + +=head1 HOW IT WORKS + +You pass named parameters to a function, describing to it how to build +and link to the libraries. + +It works by trying to compile this: + + int main(void) { return 0; } + +and linking it to the specified libraries. If something pops out the end +which looks executable, then we know that it worked. That tiny program is +built once for each library that you specify, and (without linking) once +for each header file. + +=head1 FUNCTIONS + +All of these take the same named parameters and are exported by default. +To avoid exporting them, C. + +=head2 assert_lib + +This takes several named parameters, all of which are optional, and dies +with an error message if any of the libraries listed can +not be found. B: dying in a Makefile.PL or Build.PL may provoke +a 'FAIL' report from CPAN Testers' automated smoke testers. Use +C instead. + +The named parameters are: + +=over + +=item lib + +Must be either a string with the name of a single +library or a reference to an array of strings of library names. Depending +on the compiler found, library names will be fed to the compiler either as +C<-l> arguments or as C<.lib> file names. (E.g. C<-ljpeg> or C) + +=item libpath + +a string or an array of strings +representing additional paths to search for libraries. + +=item LIBS + +a C-style space-seperated list of +libraries (each preceded by '-l') and directories (preceded by '-L'). + +=back + +And libraries are no use without header files, so ... + +=over + +=item header + +Must be either a string with the name of a single +header file or a reference to an array of strings of header file names. + +=item incpath + +a string or an array of strings +representing additional paths to search for headers. + +=item INC + +a C-style space-seperated list of +incpaths, each preceded by '-I'. + +=back + +=head2 check_lib_or_exit + +This behaves exactly the same as C except that instead of +dieing, it warns (with exactly the same error message) and exits. +This is intended for use in Makefile.PL / Build.PL +when you might want to prompt the user for various paths and +things before checking that what they've told you is sane. + +If any library or header is missing, it exits with an exit value of 0 to avoid +causing a CPAN Testers 'FAIL' report. CPAN Testers should ignore this +result -- which is what you want if an external library dependency is not +available. + +=cut + +sub check_lib_or_exit { + eval 'assert_lib(@_)'; + if($@) { + warn $@; + exit; + } +} + +sub assert_lib { + my %args = @_; + my (@libs, @libpaths, @headers, @incpaths); + + # FIXME: these four just SCREAM "refactor" at me + @libs = (ref($args{lib}) ? @{$args{lib}} : $args{lib}) + if $args{lib}; + @libpaths = (ref($args{libpath}) ? @{$args{libpath}} : $args{libpath}) + if $args{libpath}; + @headers = (ref($args{header}) ? @{$args{header}} : $args{header}) + if $args{header}; + @incpaths = (ref($args{incpath}) ? @{$args{incpath}} : $args{incpath}) + if $args{incpath}; + + # work-a-like for Makefile.PL's LIBS and INC arguments + if(defined($args{LIBS})) { + foreach my $arg (split(/\s+/, $args{LIBS})) { + die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-l/i); + push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2); + } + } + if(defined($args{INC})) { + foreach my $arg (split(/\s+/, $args{INC})) { + die("INC argument badly-formed: $arg\n") unless($arg =~ /^-I/); + push @incpaths, substr($arg, 2); + } + } + + my @cc = _findcc(); + my @missing; + + # first figure out which headers we can't find ... + for my $header (@headers) { + my($ch, $cfile) = File::Temp::tempfile( + 'assertlibXXXXXXXX', SUFFIX => '.c' + ); + print $ch qq{#include <$header>\nint main(void) { return 0; }\n}; + close($ch); + my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe}; + my @sys_cmd; + # FIXME: re-factor - almost identical code later when linking + if ( $Config{cc} eq 'cl' ) { # Microsoft compiler + require Win32; + @sys_cmd = (@cc, $cfile, "/Fe$exefile", (map { '/I'.Win32::GetShortPathName($_) } @incpaths)); + } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland + @sys_cmd = (@cc, (map { "-I$_" } @incpaths), "-o$exefile", $cfile); + } else { # Unix-ish + # gcc, Sun, AIX (gcc, cc) + @sys_cmd = (@cc, $cfile, (map { "-I$_" } @incpaths), "-o", "$exefile"); + } + warn "# @sys_cmd\n" if $args{debug}; + my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd); + push @missing, $header if $rv != 0 || ! -x $exefile; + _cleanup_exe($exefile); + unlink $cfile; + } + + # now do each library in turn with no headers + my($ch, $cfile) = File::Temp::tempfile( + 'assertlibXXXXXXXX', SUFFIX => '.c' + ); + print $ch "int main(void) { return 0; }\n"; + close($ch); + for my $lib ( @libs ) { + my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe}; + my @sys_cmd; + if ( $Config{cc} eq 'cl' ) { # Microsoft compiler + require Win32; + my @libpath = map { + q{/libpath:} . Win32::GetShortPathName($_) + } @libpaths; + @sys_cmd = (@cc, $cfile, "${lib}.lib", "/Fe$exefile", + "/link", @libpath + ); + } elsif($Config{cc} eq 'CC/DECC') { # VMS + } elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland + my @libpath = map { "-L$_" } @libpaths; + @sys_cmd = (@cc, "-o$exefile", "-l$lib", @libpath, $cfile); + } else { # Unix-ish + # gcc, Sun, AIX (gcc, cc) + my @libpath = map { "-L$_" } @libpaths; + @sys_cmd = (@cc, $cfile, "-o", "$exefile", "-l$lib", @libpath); + } + warn "# @sys_cmd\n" if $args{debug}; + my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd); + push @missing, $lib if $rv != 0 || ! -x $exefile; + _cleanup_exe($exefile); + } + unlink $cfile; + + my $miss_string = join( q{, }, map { qq{'$_'} } @missing ); + die("Can't link/include $miss_string\n") if @missing; +} + +sub _cleanup_exe { + my ($exefile) = @_; + my $ofile = $exefile; + $ofile =~ s/$Config{_exe}$/$Config{_o}/; + unlink $exefile if -f $exefile; + unlink $ofile if -f $ofile; + unlink "$exefile\.manifest" if -f "$exefile\.manifest"; + return +} + +sub _findcc { + my @paths = split(/$Config{path_sep}/, $ENV{PATH}); + my @cc = split(/\s+/, $Config{cc}); + return @cc if -x $cc[0]; + foreach my $path (@paths) { + my $compiler = File::Spec->catfile($path, $cc[0]) . $Config{_exe}; + return ($compiler, @cc[1 .. $#cc]) if -x $compiler; + } + die("Couldn't find your C compiler\n"); +} + +# code substantially borrowed from IPC::Run3 +sub _quiet_system { + my (@cmd) = @_; + + # save handles + local *STDOUT_SAVE; + local *STDERR_SAVE; + open STDOUT_SAVE, ">&STDOUT" or die "CheckLib: $! saving STDOUT"; + open STDERR_SAVE, ">&STDERR" or die "CheckLib: $! saving STDERR"; + + # redirect to nowhere + local *DEV_NULL; + open DEV_NULL, ">" . File::Spec->devnull + or die "CheckLib: $! opening handle to null device"; + open STDOUT, ">&" . fileno DEV_NULL + or die "CheckLib: $! redirecting STDOUT to null handle"; + open STDERR, ">&" . fileno DEV_NULL + or die "CheckLib: $! redirecting STDERR to null handle"; + + # run system command + my $rv = system(@cmd); + + # restore handles + open STDOUT, ">&" . fileno STDOUT_SAVE + or die "CheckLib: $! restoring STDOUT handle"; + open STDERR, ">&" . fileno STDERR_SAVE + or die "CheckLib: $! restoring STDERR handle"; + + return $rv; +} + +=head1 PLATFORMS SUPPORTED + +You must have a C compiler installed. We check for C<$Config{cc}>, +both literally as it is in Config.pm and also in the $PATH. + +It has been tested with varying degrees on rigourousness on: + +=over + +=item gcc (on Linux, *BSD, Mac OS X, Solaris, Cygwin) + +=item Sun's compiler tools on Solaris + +=item IBM's tools on AIX + +=item Microsoft's tools on Windows + +=item MinGW on Windows (with Strawberry Perl) + +=item Borland's tools on Windows + +=back + +=head1 WARNINGS, BUGS and FEEDBACK + +This is a very early release intended primarily for feedback from +people who have discussed it. The interface may change and it has +not been adequately tested. + +Feedback is most welcome, including constructive criticism. +Bug reports should be made using L or by email. + +When submitting a bug report, please include the output from running: + + perl -V + perl -MDevel::CheckLib -e0 + +=head1 SEE ALSO + +L + +L + +=head1 AUTHORS + +David Cantrell Edavid@cantrell.org.ukE + +David Golden Edagolden@cpan.orgE + +Thanks to the cpan-testers-discuss mailing list for prompting us to write it +in the first place; + +to Chris Williams for help with Borland support. + +=head1 COPYRIGHT and LICENCE + +Copyright 2007 David Cantrell. Portions copyright 2007 David Golden. + +This module is free-as-in-speech software, and may be used, distributed, +and modified under the same conditions as perl itself. + +=head1 CONSPIRACY + +This module is also free-as-in-mason software. + +=cut + +1; diff --git a/perl/t/Decoder.t b/perl/t/Decoder.t index cd91c460..2938d8de 100755 --- a/perl/t/Decoder.t +++ b/perl/t/Decoder.t @@ -7,12 +7,12 @@ use Test::More tests => 13; ######################### -BEGIN { use_ok('Barcode::Zebra') } +BEGIN { use_ok('Barcode::ZBar') } ######################### -my $decoder = Barcode::Zebra::Decoder->new(); -isa_ok($decoder, 'Barcode::Zebra::Decoder', 'decoder'); +my $decoder = Barcode::ZBar::Decoder->new(); +isa_ok($decoder, 'Barcode::ZBar::Decoder', 'decoder'); $decoder->parse_config('enable'); @@ -24,7 +24,7 @@ can_ok($decoder, qw(set_config parse_config reset new_scan decode_width ######################### my $sym = $decoder->decode_width(5); -is($sym, Barcode::Zebra::Symbol::NONE, 'enum/enum compare'); +is($sym, Barcode::ZBar::Symbol::NONE, 'enum/enum compare'); ######################### @@ -46,7 +46,7 @@ $decoder->set_handler(sub { my $type = $_[0]->get_type(); $handler_type = $type - if(!$handler_type or $type > Barcode::Zebra::Symbol::PARTIAL); + if(!$handler_type or $type > Barcode::ZBar::Symbol::PARTIAL); ${$_[1]} += 1 }, \$explicit_closure); @@ -54,7 +54,7 @@ $decoder->set_handler(sub { ######################### $decoder->reset(); -is($decoder->get_color(), Barcode::Zebra::SPACE, 'reset color'); +is($decoder->get_color(), Barcode::ZBar::SPACE, 'reset color'); ######################### @@ -63,11 +63,11 @@ my $encoded = foreach my $width (split(/ */, $encoded)) { my $tmp = $decoder->decode_width($width); - if($tmp > Barcode::Zebra::Symbol::PARTIAL) { - $sym = ($sym == Barcode::Zebra::Symbol::NONE) ? $tmp : -1; + if($tmp > Barcode::ZBar::Symbol::PARTIAL) { + $sym = ($sym == Barcode::ZBar::Symbol::NONE) ? $tmp : -1; } } -is($sym, Barcode::Zebra::Symbol::EAN13, 'EAN-13 type'); +is($sym, Barcode::ZBar::Symbol::EAN13, 'EAN-13 type'); ######################### @@ -75,11 +75,11 @@ is($decoder->get_data(), '6268964977804', 'EAN-13 data'); ######################### -is($decoder->get_color(), Barcode::Zebra::BAR, 'post-scan color'); +is($decoder->get_color(), Barcode::ZBar::BAR, 'post-scan color'); ######################### -is($handler_type, Barcode::Zebra::Symbol::EAN13, 'handler type'); +is($handler_type, Barcode::ZBar::Symbol::EAN13, 'handler type'); ######################### diff --git a/perl/t/Image.t b/perl/t/Image.t index 7ff08f57..86f5ceba 100755 --- a/perl/t/Image.t +++ b/perl/t/Image.t @@ -7,19 +7,19 @@ use Test::More tests => 16; ######################### -BEGIN { use_ok('Barcode::Zebra') } +BEGIN { use_ok('Barcode::ZBar') } -Barcode::Zebra::set_verbosity(16); +Barcode::ZBar::set_verbosity(16); ######################### -my $image = Barcode::Zebra::Image->new(); -isa_ok($image, 'Barcode::Zebra::Image', 'image'); +my $image = Barcode::ZBar::Image->new(); +isa_ok($image, 'Barcode::ZBar::Image', 'image'); ######################### -my $scanner = Barcode::Zebra::ImageScanner->new(); -isa_ok($scanner, 'Barcode::Zebra::ImageScanner', 'image scanner'); +my $scanner = Barcode::ZBar::ImageScanner->new(); +isa_ok($scanner, 'Barcode::ZBar::ImageScanner', 'image scanner'); ######################### @@ -77,7 +77,7 @@ SKIP: { ######################### my $sym = $symbols[0]; - isa_ok($sym, 'Barcode::Zebra::Symbol', 'symbol'); + isa_ok($sym, 'Barcode::ZBar::Symbol', 'symbol'); ######################### @@ -85,7 +85,7 @@ SKIP: { ######################### - is($sym->get_type(), Barcode::Zebra::Symbol::EAN13, 'result type'); + is($sym->get_type(), Barcode::ZBar::Symbol::EAN13, 'result type'); ######################### diff --git a/perl/t/Processor.t b/perl/t/Processor.t index 2aa88f4b..12e0c128 100755 --- a/perl/t/Processor.t +++ b/perl/t/Processor.t @@ -7,14 +7,14 @@ use Test::More tests => 19; ######################### -BEGIN { use_ok('Barcode::Zebra') } +BEGIN { use_ok('Barcode::ZBar') } -Barcode::Zebra::set_verbosity(32); +Barcode::ZBar::set_verbosity(32); ######################### -my $proc = Barcode::Zebra::Processor->new(); -isa_ok($proc, 'Barcode::Zebra::Processor', 'processor'); +my $proc = Barcode::ZBar::Processor->new(); +isa_ok($proc, 'Barcode::ZBar::Processor', 'processor'); ######################### @@ -41,7 +41,7 @@ $proc->set_data_handler(sub { ######################### my $image = $_[1]; - isa_ok($image, 'Barcode::Zebra::Image', 'image'); + isa_ok($image, 'Barcode::ZBar::Image', 'image'); ######################### @@ -51,11 +51,11 @@ $proc->set_data_handler(sub { ######################### my $sym = $symbols[0]; - isa_ok($sym, 'Barcode::Zebra::Symbol', 'symbol'); + isa_ok($sym, 'Barcode::ZBar::Symbol', 'symbol'); ######################### - is($sym->get_type(), Barcode::Zebra::Symbol::EAN13, 'result type'); + is($sym->get_type(), Barcode::ZBar::Symbol::EAN13, 'result type'); ######################### @@ -94,7 +94,7 @@ SKIP: { my $im = Image::Magick->new(); my $err = $im->Read('t/barcode.png'); die($err) if($err); - my $image = Barcode::Zebra::Image->new(); + my $image = Barcode::ZBar::Image->new(); $image->set_format('422P'); $image->set_size($im->Get(qw(columns rows))); $image->set_data($im->ImageToBlob( diff --git a/perl/t/Scanner.t b/perl/t/Scanner.t index 23834e09..99b8942d 100755 --- a/perl/t/Scanner.t +++ b/perl/t/Scanner.t @@ -7,12 +7,12 @@ use Test::More tests => 3; ######################### -BEGIN { use_ok('Barcode::Zebra') } +BEGIN { use_ok('Barcode::ZBar') } ######################### -my $scanner = Barcode::Zebra::Scanner->new(); -isa_ok($scanner, 'Barcode::Zebra::Scanner', 'scanner'); +my $scanner = Barcode::ZBar::Scanner->new(); +isa_ok($scanner, 'Barcode::ZBar::Scanner', 'scanner'); ######################### diff --git a/perl/t/Zebra.t b/perl/t/ZBar.t similarity index 52% rename from perl/t/Zebra.t rename to perl/t/ZBar.t index a970a371..f9a7e8e6 100755 --- a/perl/t/Zebra.t +++ b/perl/t/ZBar.t @@ -1,5 +1,5 @@ # Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl Zebra.t' +# `make test'. After `make install' it should work as `perl ZBar.t' use warnings; use strict; @@ -7,16 +7,16 @@ use Test::More tests => 3; ######################### -BEGIN { use_ok('Barcode::Zebra') } +BEGIN { use_ok('Barcode::ZBar') } ######################### -like(Barcode::Zebra::version(), qr<\d.\d>, 'version'); +like(Barcode::ZBar::version(), qr<\d.\d>, 'version'); ######################### -Barcode::Zebra::set_verbosity(16); -Barcode::Zebra::increase_verbosity(); +Barcode::ZBar::set_verbosity(16); +Barcode::ZBar::increase_verbosity(); pass('verbosity'); ######################### diff --git a/perl/t/pod-coverage.t b/perl/t/pod-coverage.t new file mode 100644 index 00000000..97c2df8f --- /dev/null +++ b/perl/t/pod-coverage.t @@ -0,0 +1,12 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl pod.t' + +use warnings; +use strict; +use Test::More; + +eval "use Test::Pod::Coverage"; +plan skip_all => "Test::Pod::Coverage required for testing pod coverage" + if $@; + +all_pod_coverage_ok(); diff --git a/perl/t/pod.t b/perl/t/pod.t new file mode 100644 index 00000000..a83ee7de --- /dev/null +++ b/perl/t/pod.t @@ -0,0 +1,12 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl pod.t' + +use warnings; +use strict; +use Test::More; + +eval { use Test::Pod 1.00 }; +plan skip_all => "Test::Pod 1.00 required for testing POD" + if $@; + +all_pod_files_ok(); diff --git a/perl/typemap b/perl/typemap index 5ff79ddc..4cad035a 100644 --- a/perl/typemap +++ b/perl/typemap @@ -1,19 +1,19 @@ # objects -Barcode::Zebra::Error T_PTROBJ -Barcode::Zebra::Symbol T_PTROBJ -Barcode::Zebra::Image T_PTROBJ -Barcode::Zebra::Processor T_PTROBJ -Barcode::Zebra::Video T_PTROBJ -Barcode::Zebra::Window T_PTROBJ -Barcode::Zebra::ImageScanner T_PTROBJ -Barcode::Zebra::Decoder T_PTROBJ -Barcode::Zebra::Scanner T_PTROBJ +Barcode::ZBar::Error T_PTROBJ +Barcode::ZBar::Symbol T_PTROBJ +Barcode::ZBar::Image T_PTROBJ +Barcode::ZBar::Processor T_PTROBJ +Barcode::ZBar::Video T_PTROBJ +Barcode::ZBar::Window T_PTROBJ +Barcode::ZBar::ImageScanner T_PTROBJ +Barcode::ZBar::Decoder T_PTROBJ +Barcode::ZBar::Scanner T_PTROBJ # enums -zebra_color_t T_ENUM -zebra_error_t T_ENUM -zebra_symbol_type_t T_ENUM -zebra_config_t T_ENUM +zbar_color_t T_ENUM +zbar_error_t T_ENUM +zbar_symbol_type_t T_ENUM +zbar_config_t T_ENUM # special scalars fourcc_t T_FOURCC diff --git a/plugin/Makefile.am.inc b/plugin/Makefile.am.inc index 763af24b..c1d44256 100644 --- a/plugin/Makefile.am.inc +++ b/plugin/Makefile.am.inc @@ -1,5 +1,5 @@ -lib_LTLIBRARIES += plugin/libzebraplugin.la -plugin_libzebraplugin_la_SOURCES = \ +lib_LTLIBRARIES += plugin/libzbarplugin.la +plugin_libzbarplugin_la_SOURCES = \ plugin/plugin.c -plugin_libzebraplugin_la_CPPFLAGS = $(MOZILLA_CFLAGS) $(AM_CPPFLAGS) -plugin_libzebraplugin_la_LDFLAGS = $(MOZILLA_LIBS) $(AM_LDFLAGS) +plugin_libzbarplugin_la_CPPFLAGS = $(MOZILLA_CFLAGS) $(AM_CPPFLAGS) +plugin_libzbarplugin_la_LDFLAGS = $(MOZILLA_LIBS) $(AM_LDFLAGS) diff --git a/plugin/plugin.c b/plugin/plugin.c index 25597147..5fbd512e 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007 (c) Jeff Brown + * Copyright 2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include diff --git a/pygtk/Makefile.am.inc b/pygtk/Makefile.am.inc index a5663da5..fba1adcd 100644 --- a/pygtk/Makefile.am.inc +++ b/pygtk/Makefile.am.inc @@ -1,19 +1,21 @@ -pyexec_LTLIBRARIES += pygtk/zebrapygtk.la -pygtk_zebrapygtk_la_CPPFLAGS = \ +pyexec_LTLIBRARIES += pygtk/zbarpygtk.la +pygtk_zbarpygtk_la_CPPFLAGS = \ $(GTK_CFLAGS) $(PYTHON_CFLAGS) $(PYGTK_CFLAGS) $(AM_CPPFLAGS) -pygtk_zebrapygtk_la_LDFLAGS = -shared -module -avoid-version -export-dynamic \ - -export-symbols-regex initzebrapygtk -pygtk_zebrapygtk_la_LIBADD = \ - $(PYTHON_LIBS) $(PYGTK_LIBS) gtk/libzebragtk.la $(AM_LIBADD) +pygtk_zbarpygtk_la_LDFLAGS = -shared -module -avoid-version -export-dynamic \ + -export-symbols-regex initzbarpygtk +pygtk_zbarpygtk_la_LIBADD = \ + $(PYTHON_LIBS) $(PYGTK_LIBS) gtk/libzbargtk.la $(AM_LIBADD) -pygtk_zebrapygtk_la_SOURCES = pygtk/zebrapygtkmodule.c pygtk/zebrapygtk.c -BUILT_SOURCES += pygtk/zebrapygtk.c pygtk/zebrapygtk.defs -EXTRA_DIST += pygtk/zebrapygtk.override pygtk/zebrapygtk.c pygtk/zebrapygtk.defs +pygtk_zbarpygtk_la_SOURCES = pygtk/zbarpygtkmodule.c pygtk/zbarpygtk.c +BUILT_SOURCES += pygtk/zbarpygtk.c pygtk/zbarpygtk.defs +EXTRA_DIST += pygtk/zbarpygtk.override pygtk/zbarpygtk.c pygtk/zbarpygtk.defs -pygtk/zebrapygtk.defs: include/zebra/zebragtk.h - $(PYTHON) $(PYGTK_H2DEF) $< > $@ +# FIXME ugly hack to fixup new name... now non-standard? +pygtk/zbarpygtk.defs: include/zbar/zbargtk.h + $(PYTHON) $(PYGTK_H2DEF) $< | \ + $(SED) -e 's/Z_TYPE_BAR_/ZBAR_TYPE_/' > $@ -pygtk/%.c: pygtk/%.defs $(srcdir)/pygtk/zebrapygtk.override - $(PYGTK_CODEGEN) --prefix zebrapygtk \ +pygtk/%.c: pygtk/%.defs $(srcdir)/pygtk/zbarpygtk.override + $(PYGTK_CODEGEN) --prefix zbarpygtk \ --register $(PYGTK_DEFS)/gdk-types.defs \ - --override $(srcdir)/pygtk/zebrapygtk.override $< > $@ + --override $(srcdir)/pygtk/zbarpygtk.override $< > $@ diff --git a/pygtk/zebrapygtk.override b/pygtk/zbarpygtk.override similarity index 58% rename from pygtk/zebrapygtk.override rename to pygtk/zbarpygtk.override index 3aea00bd..a66ceb98 100644 --- a/pygtk/zebrapygtk.override +++ b/pygtk/zbarpygtk.override @@ -2,19 +2,19 @@ headers #include #include -#include +#include %% -modulename zebrapygtk +modulename zbarpygtk %% import gtk.Widget as PyGtkWidget_Type import gtk.gdk.Pixbuf as PyGdkPixbuf_Type %% ignore-type - ZebraGtkError + ZBarGtkError %% ignore-glob *_get_type %% ignore - zebra_gtk_image_from_pixbuf # until base library wrappers are in place + zbar_gtk_image_from_pixbuf # until base library wrappers are in place %% diff --git a/pygtk/zebrapygtkmodule.c b/pygtk/zbarpygtkmodule.c similarity index 60% rename from pygtk/zebrapygtkmodule.c rename to pygtk/zbarpygtkmodule.c index 64008ad5..581d362e 100644 --- a/pygtk/zebrapygtkmodule.c +++ b/pygtk/zbarpygtkmodule.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ /* avoid "multiple definition" darwin link errors @@ -28,19 +28,19 @@ #include -void zebrapygtk_register_classes(PyObject*); -extern PyMethodDef zebrapygtk_functions[]; +void zbarpygtk_register_classes(PyObject*); +extern PyMethodDef zbarpygtk_functions[]; DL_EXPORT(void) -initzebrapygtk(void) +initzbarpygtk(void) { init_pygobject(); - PyObject *mod = Py_InitModule("zebrapygtk", zebrapygtk_functions); + PyObject *mod = Py_InitModule("zbarpygtk", zbarpygtk_functions); PyObject *dict = PyModule_GetDict(mod); - zebrapygtk_register_classes(dict); + zbarpygtk_register_classes(dict); if(PyErr_Occurred()) - Py_FatalError("unable to initialise module zebrapygtk"); + Py_FatalError("unable to initialise module zbarpygtk"); } diff --git a/python/Makefile.am.inc b/python/Makefile.am.inc index 3cf848e7..f2839d4a 100644 --- a/python/Makefile.am.inc +++ b/python/Makefile.am.inc @@ -1,9 +1,11 @@ -pyexec_LTLIBRARIES += python/zebra.la -python_zebra_la_CPPFLAGS = $(PYTHON_CFLAGS) $(AM_CPPFLAGS) -python_zebra_la_LDFLAGS = -shared -module -avoid-version -export-dynamic \ - -export-symbols-regex initzebra -python_zebra_la_LIBADD = $(PYTHON_LIBS) zebra/libzebra.la $(AM_LIBADD) +pyexec_LTLIBRARIES += python/zbar.la +python_zbar_la_CPPFLAGS = $(PYTHON_CFLAGS) $(AM_CPPFLAGS) +python_zbar_la_LDFLAGS = -shared -module -avoid-version -export-dynamic \ + -export-symbols-regex initzbar +python_zbar_la_LIBADD = $(PYTHON_LIBS) zbar/libzbar.la $(AM_LIBADD) -python_zebra_la_SOURCES = python/zebramodule.c python/zebramodule.h \ +python_zbar_la_SOURCES = python/zbarmodule.c python/zbarmodule.h \ python/enum.c python/exception.c python/symbol.c python/image.c \ python/processor.c python/imagescanner.c python/decoder.c python/scanner.c + +EXTRA_DIST += python/test/barcode.png python/test/test_zbar.py diff --git a/python/decoder.c b/python/decoder.c index 53ff92f4..81b82e60 100644 --- a/python/decoder.c +++ b/python/decoder.c @@ -1,11 +1,34 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char decoder_doc[] = PyDoc_STR( "low level decode of measured bar/space widths.\n" "\n" "FIXME."); -static zebraDecoder* +static zbarDecoder* decoder_new (PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -14,12 +37,12 @@ decoder_new (PyTypeObject *type, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebraDecoder *self = (zebraDecoder*)type->tp_alloc(type, 0); + zbarDecoder *self = (zbarDecoder*)type->tp_alloc(type, 0); if(!self) return(NULL); - self->zdcode = zebra_decoder_create(); - zebra_decoder_set_userdata(self->zdcode, self); + self->zdcode = zbar_decoder_create(); + zbar_decoder_set_userdata(self->zdcode, self); if(!self->zdcode) { Py_DECREF(self); return(NULL); @@ -29,7 +52,7 @@ decoder_new (PyTypeObject *type, } static int -decoder_traverse (zebraDecoder *self, +decoder_traverse (zbarDecoder *self, visitproc visit, void *arg) { @@ -39,52 +62,52 @@ decoder_traverse (zebraDecoder *self, } static int -decoder_clear (zebraDecoder *self) +decoder_clear (zbarDecoder *self) { - zebra_decoder_set_handler(self->zdcode, NULL); - zebra_decoder_set_userdata(self->zdcode, NULL); + zbar_decoder_set_handler(self->zdcode, NULL); + zbar_decoder_set_userdata(self->zdcode, NULL); Py_CLEAR(self->handler); Py_CLEAR(self->args); return(0); } static void -decoder_dealloc (zebraDecoder *self) +decoder_dealloc (zbarDecoder *self) { decoder_clear(self); - zebra_decoder_destroy(self->zdcode); + zbar_decoder_destroy(self->zdcode); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } -static zebraEnumItem* -decoder_get_color (zebraDecoder *self, +static zbarEnumItem* +decoder_get_color (zbarDecoder *self, void *closure) { - zebra_color_t zcol = zebra_decoder_get_color(self->zdcode); - assert(zcol == ZEBRA_BAR || zcol == ZEBRA_SPACE); - zebraEnumItem *color = color_enum[zcol]; + zbar_color_t zcol = zbar_decoder_get_color(self->zdcode); + assert(zcol == ZBAR_BAR || zcol == ZBAR_SPACE); + zbarEnumItem *color = color_enum[zcol]; Py_INCREF((PyObject*)color); return(color); } -static zebraEnumItem* -decoder_get_type (zebraDecoder *self, +static zbarEnumItem* +decoder_get_type (zbarDecoder *self, void *closure) { - zebra_symbol_type_t sym = zebra_decoder_get_type(self->zdcode); - if(sym == ZEBRA_NONE) { + zbar_symbol_type_t sym = zbar_decoder_get_type(self->zdcode); + if(sym == ZBAR_NONE) { /* hardcode most common case */ Py_INCREF((PyObject*)symbol_NONE); return(symbol_NONE); } - return(zebraSymbol_LookupEnum(sym)); + return(zbarSymbol_LookupEnum(sym)); } static PyObject* -decoder_get_data (zebraDecoder *self, +decoder_get_data (zbarDecoder *self, void *closure) { - return(PyString_FromString(zebra_decoder_get_data(self->zdcode))); + return(PyString_FromString(zbar_decoder_get_data(self->zdcode))); } static PyGetSetDef decoder_getset[] = { @@ -95,19 +118,19 @@ static PyGetSetDef decoder_getset[] = { }; static PyObject* -decoder_set_config (zebraDecoder *self, +decoder_set_config (zbarDecoder *self, PyObject *args, PyObject *kwds) { - zebra_symbol_type_t sym = ZEBRA_NONE; - zebra_config_t cfg = ZEBRA_CFG_ENABLE; + zbar_symbol_type_t sym = ZBAR_NONE; + zbar_config_t cfg = ZBAR_CFG_ENABLE; int val = 1; static char *kwlist[] = { "symbology", "config", "value", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwlist, &sym, &cfg, &val)) return(NULL); - if(zebra_decoder_set_config(self->zdcode, sym, cfg, val)) { + if(zbar_decoder_set_config(self->zdcode, sym, cfg, val)) { PyErr_SetString(PyExc_ValueError, "invalid configuration setting"); return(NULL); } @@ -115,7 +138,7 @@ decoder_set_config (zebraDecoder *self, } static PyObject* -decoder_parse_config (zebraDecoder *self, +decoder_parse_config (zbarDecoder *self, PyObject *args, PyObject *kwds) { @@ -124,7 +147,7 @@ decoder_parse_config (zebraDecoder *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &cfg)) return(NULL); - if(zebra_decoder_parse_config(self->zdcode, cfg)) { + if(zbar_decoder_parse_config(self->zdcode, cfg)) { PyErr_Format(PyExc_ValueError, "invalid configuration setting: %s", cfg); return(NULL); @@ -133,7 +156,7 @@ decoder_parse_config (zebraDecoder *self, } static PyObject* -decoder_reset (zebraDecoder *self, +decoder_reset (zbarDecoder *self, PyObject *args, PyObject *kwds) { @@ -141,12 +164,12 @@ decoder_reset (zebraDecoder *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebra_decoder_reset(self->zdcode); + zbar_decoder_reset(self->zdcode); Py_RETURN_NONE; } static PyObject* -decoder_new_scan (zebraDecoder *self, +decoder_new_scan (zbarDecoder *self, PyObject *args, PyObject *kwds) { @@ -154,15 +177,15 @@ decoder_new_scan (zebraDecoder *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebra_decoder_new_scan(self->zdcode); + zbar_decoder_new_scan(self->zdcode); Py_RETURN_NONE; } void -decode_handler (zebra_decoder_t *zdcode) +decode_handler (zbar_decoder_t *zdcode) { assert(zdcode); - zebraDecoder *self = zebra_decoder_get_userdata(zdcode); + zbarDecoder *self = zbar_decoder_get_userdata(zdcode); assert(self); assert(self->zdcode == zdcode); assert(self->handler); @@ -172,7 +195,7 @@ decode_handler (zebra_decoder_t *zdcode) } static PyObject* -decoder_set_handler (zebraDecoder *self, +decoder_set_handler (zbarDecoder *self, PyObject *args, PyObject *kwds) { @@ -204,17 +227,17 @@ decoder_set_handler (zebraDecoder *self, Py_INCREF(handler); self->handler = handler; - zebra_decoder_set_handler(self->zdcode, decode_handler); + zbar_decoder_set_handler(self->zdcode, decode_handler); } else { self->handler = self->args = NULL; - zebra_decoder_set_handler(self->zdcode, NULL); + zbar_decoder_set_handler(self->zdcode, NULL); } Py_RETURN_NONE; } -static zebraEnumItem* -decoder_decode_width (zebraDecoder *self, +static zbarEnumItem* +decoder_decode_width (zbarDecoder *self, PyObject *args, PyObject *kwds) { @@ -223,16 +246,16 @@ decoder_decode_width (zebraDecoder *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "I", kwlist, &width)) return(NULL); - zebra_symbol_type_t sym = zebra_decode_width(self->zdcode, width); + zbar_symbol_type_t sym = zbar_decode_width(self->zdcode, width); if(PyErr_Occurred()) /* propagate errors during callback */ return(NULL); - if(sym == ZEBRA_NONE) { + if(sym == ZBAR_NONE) { /* hardcode most common case */ Py_INCREF((PyObject*)symbol_NONE); return(symbol_NONE); } - return(zebraSymbol_LookupEnum(sym)); + return(zbarSymbol_LookupEnum(sym)); } static PyMethodDef decoder_methods[] = { @@ -251,11 +274,11 @@ static PyMethodDef decoder_methods[] = { { NULL, }, }; -PyTypeObject zebraDecoder_Type = { +PyTypeObject zbarDecoder_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Decoder", + .tp_name = "zbar.Decoder", .tp_doc = decoder_doc, - .tp_basicsize = sizeof(zebraDecoder), + .tp_basicsize = sizeof(zbarDecoder), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)decoder_new, diff --git a/python/enum.c b/python/enum.c index 640961b0..8a515325 100644 --- a/python/enum.c +++ b/python/enum.c @@ -1,11 +1,34 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char enumitem_doc[] = PyDoc_STR( "simple enumeration item.\n" "\n" "associates an int value with a name for printing."); -static zebraEnumItem* +static zbarEnumItem* enumitem_new (PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -16,7 +39,7 @@ enumitem_new (PyTypeObject *type, if(!PyArg_ParseTupleAndKeywords(args, kwds, "iS", kwlist, &val, &name)) return(NULL); - zebraEnumItem *self = (zebraEnumItem*)type->tp_alloc(type, 0); + zbarEnumItem *self = (zbarEnumItem*)type->tp_alloc(type, 0); if(!self) return(NULL); @@ -26,21 +49,21 @@ enumitem_new (PyTypeObject *type, } static void -enumitem_dealloc (zebraEnumItem *self) +enumitem_dealloc (zbarEnumItem *self) { Py_CLEAR(self->name); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } static PyObject* -enumitem_str (zebraEnumItem *self) +enumitem_str (zbarEnumItem *self) { Py_INCREF(self->name); return(self->name); } static int -enumitem_print (zebraEnumItem *self, +enumitem_print (zbarEnumItem *self, FILE *fp, int flags) { @@ -48,7 +71,7 @@ enumitem_print (zebraEnumItem *self, } static PyObject* -enumitem_repr (zebraEnumItem *self) +enumitem_repr (zbarEnumItem *self) { PyObject *name = PyObject_Repr(self->name); if(!name) @@ -62,11 +85,11 @@ enumitem_repr (zebraEnumItem *self) return((PyObject*)repr); } -PyTypeObject zebraEnumItem_Type = { +PyTypeObject zbarEnumItem_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.EnumItem", + .tp_name = "zbar.EnumItem", .tp_doc = enumitem_doc, - .tp_basicsize = sizeof(zebraEnumItem), + .tp_basicsize = sizeof(zbarEnumItem), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_new = (newfunc)enumitem_new, .tp_dealloc = (destructor)enumitem_dealloc, @@ -76,13 +99,13 @@ PyTypeObject zebraEnumItem_Type = { }; -zebraEnumItem* -zebraEnumItem_New (PyObject *byname, - PyObject *byvalue, - int val, - const char *name) +zbarEnumItem* +zbarEnumItem_New (PyObject *byname, + PyObject *byvalue, + int val, + const char *name) { - zebraEnumItem *self = PyObject_New(zebraEnumItem, &zebraEnumItem_Type); + zbarEnumItem *self = PyObject_New(zbarEnumItem, &zbarEnumItem_Type); if(!self) return(NULL); self->val.ob_ival = val; @@ -105,7 +128,7 @@ static char enum_doc[] = PyDoc_STR( /* FIXME add iteration */ static int -enum_traverse (zebraEnum *self, +enum_traverse (zbarEnum *self, visitproc visit, void *arg) { @@ -115,7 +138,7 @@ enum_traverse (zebraEnum *self, } static int -enum_clear (zebraEnum *self) +enum_clear (zbarEnum *self) { Py_CLEAR(self->byname); Py_CLEAR(self->byvalue); @@ -123,30 +146,30 @@ enum_clear (zebraEnum *self) } static void -enum_dealloc (zebraEnum *self) +enum_dealloc (zbarEnum *self) { enum_clear(self); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } -PyTypeObject zebraEnum_Type = { +PyTypeObject zbarEnum_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Enum", + .tp_name = "zbar.Enum", .tp_doc = enum_doc, - .tp_basicsize = sizeof(zebraEnum), + .tp_basicsize = sizeof(zbarEnum), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - .tp_dictoffset = offsetof(zebraEnum, byname), + .tp_dictoffset = offsetof(zbarEnum, byname), .tp_traverse = (traverseproc)enum_traverse, .tp_clear = (inquiry)enum_clear, .tp_dealloc = (destructor)enum_dealloc, }; -zebraEnum* -zebraEnum_New () +zbarEnum* +zbarEnum_New () { - zebraEnum *self = PyObject_GC_New(zebraEnum, &zebraEnum_Type); + zbarEnum *self = PyObject_GC_New(zbarEnum, &zbarEnum_Type); if(!self) return(NULL); self->byname = PyDict_New(); @@ -159,12 +182,12 @@ zebraEnum_New () } int -zebraEnum_Add (zebraEnum *self, - int val, - const char *name) +zbarEnum_Add (zbarEnum *self, + int val, + const char *name) { - zebraEnumItem *item; - item = zebraEnumItem_New(self->byname, self->byvalue, val, name); + zbarEnumItem *item; + item = zbarEnumItem_New(self->byname, self->byvalue, val, name); if(!item) return(-1); return(0); diff --git a/python/exception.c b/python/exception.c index 9056b95c..47432b0a 100644 --- a/python/exception.c +++ b/python/exception.c @@ -1,17 +1,40 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static inline PyObject* -exc_get_message (zebraException *self, +exc_get_message (zbarException *self, void *closure) { PyBaseExceptionObject *super = (PyBaseExceptionObject*)self; if(!PyString_Size(super->message)) { Py_CLEAR(super->message); - if(!self->obj || !zebraProcessor_Check(self->obj)) - super->message = PyString_FromString("unknown zebra error"); + if(!self->obj || !zbarProcessor_Check(self->obj)) + super->message = PyString_FromString("unknown zbar error"); else { - const void *zobj = ((zebraProcessor*)self->obj)->zproc; - super->message = PyString_FromString(_zebra_error_string(zobj, 1)); + const void *zobj = ((zbarProcessor*)self->obj)->zproc; + super->message = PyString_FromString(_zbar_error_string(zobj, 1)); } } Py_INCREF(super->message); @@ -19,7 +42,7 @@ exc_get_message (zebraException *self, } static int -exc_init (zebraException *self, +exc_init (zbarException *self, PyObject *args, PyObject *kwds) { @@ -39,7 +62,7 @@ exc_init (zebraException *self, } static int -exc_traverse (zebraException *self, +exc_traverse (zbarException *self, visitproc visit, void *arg) { @@ -49,7 +72,7 @@ exc_traverse (zebraException *self, } static int -exc_clear (zebraException *self) +exc_clear (zbarException *self) { Py_CLEAR(self->obj); ((PyTypeObject*)PyExc_Exception)->tp_clear((PyObject*)self); @@ -57,20 +80,20 @@ exc_clear (zebraException *self) } static void -exc_dealloc (zebraException *self) +exc_dealloc (zbarException *self) { exc_clear(self); ((PyTypeObject*)PyExc_Exception)->tp_dealloc((PyObject*)self); } static PyObject* -exc_str (zebraException *self) +exc_str (zbarException *self) { return(exc_get_message(self, NULL)); } static int -exc_set_message (zebraException *self, +exc_set_message (zbarException *self, PyObject *value, void *closure) { @@ -89,10 +112,10 @@ static PyGetSetDef exc_getset[] = { { NULL, }, }; -PyTypeObject zebraException_Type = { +PyTypeObject zbarException_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Exception", - .tp_basicsize = sizeof(zebraException), + .tp_name = "zbar.Exception", + .tp_basicsize = sizeof(zbarException), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_init = (initproc)exc_init, @@ -104,19 +127,19 @@ PyTypeObject zebraException_Type = { }; PyObject* -zebraErr_Set (PyObject *self) +zbarErr_Set (PyObject *self) { - const void *zobj = ((zebraProcessor*)self)->zproc; - zebra_error_t err = _zebra_get_error_code(zobj); + const void *zobj = ((zbarProcessor*)self)->zproc; + zbar_error_t err = _zbar_get_error_code(zobj); - if(err == ZEBRA_ERR_NOMEM) + if(err == ZBAR_ERR_NOMEM) PyErr_NoMemory(); - else if(err < ZEBRA_ERR_NUM) { - PyObject *type = zebra_exc[err]; + else if(err < ZBAR_ERR_NUM) { + PyObject *type = zbar_exc[err]; assert(type); PyErr_SetObject(type, self); } else - PyErr_SetObject(zebra_exc[0], self); + PyErr_SetObject(zbar_exc[0], self); return(NULL); } diff --git a/python/image.c b/python/image.c index e110122a..901c856b 100644 --- a/python/image.c +++ b/python/image.c @@ -1,4 +1,27 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char symboliter_doc[] = PyDoc_STR( "symbol iterator.\n" @@ -6,7 +29,7 @@ static char symboliter_doc[] = PyDoc_STR( "iterates over decode results attached to an image."); static int -symboliter_traverse (zebraSymbolIter *self, +symboliter_traverse (zbarSymbolIter *self, visitproc visit, void *arg) { @@ -15,43 +38,43 @@ symboliter_traverse (zebraSymbolIter *self, } static int -symboliter_clear (zebraSymbolIter *self) +symboliter_clear (zbarSymbolIter *self) { Py_CLEAR(self->img); return(0); } static void -symboliter_dealloc (zebraSymbolIter *self) +symboliter_dealloc (zbarSymbolIter *self) { symboliter_clear(self); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } -static zebraSymbolIter* -symboliter_iter (zebraSymbolIter *self) +static zbarSymbolIter* +symboliter_iter (zbarSymbolIter *self) { Py_INCREF(self); return(self); } -static zebraSymbol* -symboliter_iternext (zebraSymbolIter *self) +static zbarSymbol* +symboliter_iternext (zbarSymbolIter *self) { if(!self->zsym) - self->zsym = zebra_image_first_symbol(self->img->zimg); + self->zsym = zbar_image_first_symbol(self->img->zimg); else - self->zsym = zebra_symbol_next(self->zsym); + self->zsym = zbar_symbol_next(self->zsym); if(!self->zsym) return(NULL); - return(zebraSymbol_FromSymbol(self->img, self->zsym)); + return(zbarSymbol_FromSymbol(self->img, self->zsym)); } -PyTypeObject zebraSymbolIter_Type = { +PyTypeObject zbarSymbolIter_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.SymbolIter", + .tp_name = "zbar.SymbolIter", .tp_doc = symboliter_doc, - .tp_basicsize = sizeof(zebraSymbolIter), + .tp_basicsize = sizeof(zbarSymbolIter), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_traverse = (traverseproc)symboliter_traverse, @@ -61,11 +84,11 @@ PyTypeObject zebraSymbolIter_Type = { .tp_iternext = (iternextfunc)symboliter_iternext, }; -static zebraSymbolIter* -zebraSymbolIter_New (zebraImage *img) +static zbarSymbolIter* +zbarSymbolIter_New (zbarImage *img) { - zebraSymbolIter *self; - self = PyObject_GC_New(zebraSymbolIter, &zebraSymbolIter_Type); + zbarSymbolIter *self; + self = PyObject_GC_New(zbarSymbolIter, &zbarSymbolIter_Type); if(!self) return(NULL); @@ -81,26 +104,26 @@ static char image_doc[] = PyDoc_STR( "\n" "stores image data samples along with associated format and size metadata."); -static zebraImage* +static zbarImage* image_new (PyTypeObject *type, PyObject *args, PyObject *kwds) { - zebraImage *self = (zebraImage*)type->tp_alloc(type, 0); + zbarImage *self = (zbarImage*)type->tp_alloc(type, 0); if(!self) return(NULL); - self->zimg = zebra_image_create(); + self->zimg = zbar_image_create(); if(!self->zimg) { Py_DECREF(self); return(NULL); } - zebra_image_set_userdata(self->zimg, self); + zbar_image_set_userdata(self->zimg, self); return(self); } static int -image_traverse (zebraImage *self, +image_traverse (zbarImage *self, visitproc visit, void *arg) { @@ -109,47 +132,47 @@ image_traverse (zebraImage *self, } static int -image_clear (zebraImage *self) +image_clear (zbarImage *self) { - zebra_image_t *zimg = self->zimg; + zbar_image_t *zimg = self->zimg; self->zimg = NULL; if(zimg) { - assert(zebra_image_get_userdata(zimg) == self); + assert(zbar_image_get_userdata(zimg) == self); if(self->data) { - /* attach data directly to zebra image */ - zebra_image_set_userdata(zimg, self->data); + /* attach data directly to zbar image */ + zbar_image_set_userdata(zimg, self->data); self->data = NULL; } else - zebra_image_set_userdata(zimg, NULL); - zebra_image_destroy(zimg); + zbar_image_set_userdata(zimg, NULL); + zbar_image_destroy(zimg); } return(0); } static void -image_dealloc (zebraImage *self) +image_dealloc (zbarImage *self) { image_clear(self); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } -static zebraSymbolIter* -image_iter (zebraImage *self) +static zbarSymbolIter* +image_iter (zbarImage *self) { - return(zebraSymbolIter_New(self)); + return(zbarSymbolIter_New(self)); } static PyObject* -image_get_format (zebraImage *self, +image_get_format (zbarImage *self, void *closure) { - unsigned long format = zebra_image_get_format(self->zimg); + unsigned long format = zbar_image_get_format(self->zimg); return(PyString_FromStringAndSize((char*)&format, 4)); } static int -image_set_format (zebraImage *self, +image_set_format (zbarImage *self, PyObject *value, void *closure) { @@ -166,21 +189,21 @@ image_set_format (zebraImage *self, format); return(-1); } - zebra_image_set_format(self->zimg,*((unsigned long*)format)); + zbar_image_set_format(self->zimg,*((unsigned long*)format)); return(0); } static PyObject* -image_get_size (zebraImage *self, +image_get_size (zbarImage *self, void *closure) { - unsigned int width = zebra_image_get_width(self->zimg); - unsigned int height = zebra_image_get_height(self->zimg); + unsigned int width = zbar_image_get_width(self->zimg); + unsigned int height = zbar_image_get_height(self->zimg); return(PyTuple_Pack(2, PyInt_FromLong(width), PyInt_FromLong(height))); } static int -image_set_size (zebraImage *self, +image_set_size (zbarImage *self, PyObject *value, void *closure) { @@ -206,7 +229,7 @@ image_set_size (zebraImage *self, if(height == -1 && PyErr_Occurred()) goto error; - zebra_image_set_size(self->zimg, width, height); + zbar_image_set_size(self->zimg, width, height); rc = 0; error: @@ -219,17 +242,17 @@ image_set_size (zebraImage *self, } static PyObject* -image_get_int (zebraImage *self, +image_get_int (zbarImage *self, void *closure) { unsigned int val = -1; switch((int)closure) { case 0: - val = zebra_image_get_width(self->zimg); break; + val = zbar_image_get_width(self->zimg); break; case 1: - val = zebra_image_get_height(self->zimg); break; + val = zbar_image_get_height(self->zimg); break; case 2: - val = zebra_image_get_sequence(self->zimg); break; + val = zbar_image_get_sequence(self->zimg); break; default: assert(0); } @@ -237,7 +260,7 @@ image_get_int (zebraImage *self, } static int -image_set_int (zebraImage *self, +image_set_int (zbarImage *self, PyObject *value, void *closure) { @@ -248,15 +271,15 @@ image_set_int (zebraImage *self, } switch((int)closure) { case 0: - tmp = zebra_image_get_height(self->zimg); - zebra_image_set_size(self->zimg, val, tmp); + tmp = zbar_image_get_height(self->zimg); + zbar_image_set_size(self->zimg, val, tmp); break; case 1: - tmp = zebra_image_get_width(self->zimg); - zebra_image_set_size(self->zimg, tmp, val); + tmp = zbar_image_get_width(self->zimg); + zbar_image_set_size(self->zimg, tmp, val); break; case 2: - zebra_image_set_sequence(self->zimg, val); + zbar_image_set_sequence(self->zimg, val); default: assert(0); } @@ -264,17 +287,17 @@ image_set_int (zebraImage *self, } static PyObject* -image_get_data (zebraImage *self, +image_get_data (zbarImage *self, void *closure) { - assert(zebra_image_get_userdata(self->zimg) == self); + assert(zbar_image_get_userdata(self->zimg) == self); if(self->data) { Py_INCREF(self->data); return(self->data); } - const char *data = zebra_image_get_data(self->zimg); - unsigned long datalen = zebra_image_get_data_length(self->zimg); + const char *data = zbar_image_get_data(self->zimg); + unsigned long datalen = zbar_image_get_data_length(self->zimg); if(!data || !datalen) { Py_INCREF(Py_None); return(Py_None); @@ -286,14 +309,14 @@ image_get_data (zebraImage *self, } void -image_cleanup (zebra_image_t *zimg) +image_cleanup (zbar_image_t *zimg) { - PyObject *data = zebra_image_get_userdata(zimg); - zebra_image_set_userdata(zimg, NULL); + PyObject *data = zbar_image_get_userdata(zimg); + zbar_image_set_userdata(zimg, NULL); if(!data) return; /* FIXME internal error */ - if(PyObject_TypeCheck(data, &zebraImage_Type)) { - zebraImage *self = (zebraImage*)data; + if(PyObject_TypeCheck(data, &zbarImage_Type)) { + zbarImage *self = (zbarImage*)data; assert(self->zimg == zimg); Py_CLEAR(self->data); } @@ -302,12 +325,12 @@ image_cleanup (zebra_image_t *zimg) } static int -image_set_data (zebraImage *self, +image_set_data (zbarImage *self, PyObject *value, void *closure) { if(!value) { - zebra_image_free_data(self->zimg); + zbar_image_free_data(self->zimg); return(0); } char *data; @@ -316,10 +339,10 @@ image_set_data (zebraImage *self, return(-1); Py_INCREF(value); - zebra_image_set_data(self->zimg, data, datalen, image_cleanup); + zbar_image_set_data(self->zimg, data, datalen, image_cleanup); assert(!self->data); self->data = value; - zebra_image_set_userdata(self->zimg, self); + zbar_image_set_userdata(self->zimg, self); return(0); } @@ -337,7 +360,7 @@ static PyGetSetDef image_getset[] = { }; static int -image_init (zebraImage *self, +image_init (zbarImage *self, PyObject *args, PyObject *kwds) { @@ -349,7 +372,7 @@ image_init (zebraImage *self, return(-1); if(width > 0 && height > 0) - zebra_image_set_size(self->zimg, width, height); + zbar_image_set_size(self->zimg, width, height); if(format && image_set_format(self, format, NULL)) return(-1); if(data && image_set_data(self, data, NULL)) @@ -357,8 +380,8 @@ image_init (zebraImage *self, return(0); } -static zebraImage* -image_convert (zebraImage *self, +static zbarImage* +image_convert (zbarImage *self, PyObject *args, PyObject *kwds) { @@ -377,24 +400,24 @@ image_convert (zebraImage *self, return(NULL); } - zebraImage *img = PyObject_GC_New(zebraImage, &zebraImage_Type); + zbarImage *img = PyObject_GC_New(zbarImage, &zbarImage_Type); if(!img) return(NULL); img->data = NULL; if(width > 0 && height > 0) img->zimg = - zebra_image_convert_resize(self->zimg, + zbar_image_convert_resize(self->zimg, *((unsigned long*)format), width, height); else - img->zimg = zebra_image_convert(self->zimg, *((unsigned long*)format)); + img->zimg = zbar_image_convert(self->zimg, *((unsigned long*)format)); if(!img->zimg) { /* FIXME propagate exception */ Py_DECREF(img); return(NULL); } - zebra_image_set_userdata(img->zimg, img); + zbar_image_set_userdata(img->zimg, img); return(img); } @@ -404,11 +427,11 @@ static PyMethodDef image_methods[] = { { NULL, }, }; -PyTypeObject zebraImage_Type = { +PyTypeObject zbarImage_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Image", + .tp_name = "zbar.Image", .tp_doc = image_doc, - .tp_basicsize = sizeof(zebraImage), + .tp_basicsize = sizeof(zbarImage), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)image_new, @@ -421,26 +444,26 @@ PyTypeObject zebraImage_Type = { .tp_iter = (getiterfunc)image_iter, }; -zebraImage* -zebraImage_FromImage (zebra_image_t *zimg) +zbarImage* +zbarImage_FromImage (zbar_image_t *zimg) { - zebraImage *self = PyObject_GC_New(zebraImage, &zebraImage_Type); + zbarImage *self = PyObject_GC_New(zbarImage, &zbarImage_Type); if(!self) return(NULL); - zebra_image_ref(zimg, 1); - zebra_image_set_userdata(zimg, self); + zbar_image_ref(zimg, 1); + zbar_image_set_userdata(zimg, self); self->zimg = zimg; self->data = NULL; return(self); } int -zebraImage_validate (zebraImage *img) +zbarImage_validate (zbarImage *img) { - if(!zebra_image_get_width(img->zimg) || - !zebra_image_get_height(img->zimg) || - !zebra_image_get_data(img->zimg) || - !zebra_image_get_data_length(img->zimg)) { + if(!zbar_image_get_width(img->zimg) || + !zbar_image_get_height(img->zimg) || + !zbar_image_get_data(img->zimg) || + !zbar_image_get_data_length(img->zimg)) { PyErr_Format(PyExc_ValueError, "image size and data must be defined"); return(-1); } diff --git a/python/imagescanner.c b/python/imagescanner.c index cf528b76..1500e71d 100644 --- a/python/imagescanner.c +++ b/python/imagescanner.c @@ -1,11 +1,34 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char imagescanner_doc[] = PyDoc_STR( "scan images for barcodes.\n" "\n" "attaches symbols to image for each decoded result."); -static zebraImageScanner* +static zbarImageScanner* imagescanner_new (PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -14,11 +37,11 @@ imagescanner_new (PyTypeObject *type, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebraImageScanner *self = (zebraImageScanner*)type->tp_alloc(type, 0); + zbarImageScanner *self = (zbarImageScanner*)type->tp_alloc(type, 0); if(!self) return(NULL); - self->zscn = zebra_image_scanner_create(); + self->zscn = zbar_image_scanner_create(); if(!self->zscn) { Py_DECREF(self); return(NULL); @@ -28,26 +51,26 @@ imagescanner_new (PyTypeObject *type, } static void -imagescanner_dealloc (zebraImageScanner *self) +imagescanner_dealloc (zbarImageScanner *self) { - zebra_image_scanner_destroy(self->zscn); + zbar_image_scanner_destroy(self->zscn); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } static PyObject* -imagescanner_set_config (zebraImageScanner *self, +imagescanner_set_config (zbarImageScanner *self, PyObject *args, PyObject *kwds) { - zebra_symbol_type_t sym = ZEBRA_NONE; - zebra_config_t cfg = ZEBRA_CFG_ENABLE; + zbar_symbol_type_t sym = ZBAR_NONE; + zbar_config_t cfg = ZBAR_CFG_ENABLE; int val = 1; static char *kwlist[] = { "symbology", "config", "value", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwlist, &sym, &cfg, &val)) return(NULL); - if(zebra_image_scanner_set_config(self->zscn, sym, cfg, val)) { + if(zbar_image_scanner_set_config(self->zscn, sym, cfg, val)) { PyErr_SetString(PyExc_ValueError, "invalid configuration setting"); return(NULL); } @@ -55,7 +78,7 @@ imagescanner_set_config (zebraImageScanner *self, } static PyObject* -imagescanner_parse_config (zebraImageScanner *self, +imagescanner_parse_config (zbarImageScanner *self, PyObject *args, PyObject *kwds) { @@ -64,7 +87,7 @@ imagescanner_parse_config (zebraImageScanner *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &cfg)) return(NULL); - if(zebra_image_scanner_parse_config(self->zscn, cfg)) { + if(zbar_image_scanner_parse_config(self->zscn, cfg)) { PyErr_Format(PyExc_ValueError, "invalid configuration setting: %s", cfg); return(NULL); @@ -73,7 +96,7 @@ imagescanner_parse_config (zebraImageScanner *self, } static PyObject* -imagescanner_enable_cache (zebraImageScanner *self, +imagescanner_enable_cache (zbarImageScanner *self, PyObject *args, PyObject *kwds) { @@ -83,25 +106,25 @@ imagescanner_enable_cache (zebraImageScanner *self, object_to_bool, &enable)) return(NULL); - zebra_image_scanner_enable_cache(self->zscn, enable); + zbar_image_scanner_enable_cache(self->zscn, enable); Py_RETURN_NONE; } static PyObject* -imagescanner_scan (zebraImageScanner *self, +imagescanner_scan (zbarImageScanner *self, PyObject *args, PyObject *kwds) { - zebraImage *img = NULL; + zbarImage *img = NULL; static char *kwlist[] = { "image", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, - &zebraImage_Type, &img)) + &zbarImage_Type, &img)) return(NULL); - if(zebraImage_validate(img)) + if(zbarImage_validate(img)) return(NULL); - int n = zebra_scan_image(self->zscn, img->zimg); + int n = zbar_scan_image(self->zscn, img->zimg); if(n < 0) { PyErr_Format(PyExc_ValueError, "unsupported image format"); return(NULL); @@ -121,11 +144,11 @@ static PyMethodDef imagescanner_methods[] = { { NULL, }, }; -PyTypeObject zebraImageScanner_Type = { +PyTypeObject zbarImageScanner_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.ImageScanner", + .tp_name = "zbar.ImageScanner", .tp_doc = imagescanner_doc, - .tp_basicsize = sizeof(zebraImageScanner), + .tp_basicsize = sizeof(zbarImageScanner), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_new = (newfunc)imagescanner_new, .tp_dealloc = (destructor)imagescanner_dealloc, diff --git a/python/processor.c b/python/processor.c index 8bb662d8..41745e4f 100644 --- a/python/processor.c +++ b/python/processor.c @@ -1,11 +1,34 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char processor_doc[] = PyDoc_STR( "low level decode of measured bar/space widths.\n" "\n" "FIXME."); -static zebraProcessor* +static zbarProcessor* processor_new (PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -14,12 +37,12 @@ processor_new (PyTypeObject *type, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebraProcessor *self = (zebraProcessor*)type->tp_alloc(type, 0); + zbarProcessor *self = (zbarProcessor*)type->tp_alloc(type, 0); if(!self) return(NULL); - self->zproc = zebra_processor_create(0/*FIXME*/); - zebra_processor_set_userdata(self->zproc, self); + self->zproc = zbar_processor_create(0/*FIXME*/); + zbar_processor_set_userdata(self->zproc, self); if(!self->zproc) { Py_DECREF(self); return(NULL); @@ -28,7 +51,7 @@ processor_new (PyTypeObject *type, } static int -processor_traverse (zebraProcessor *self, +processor_traverse (zbarProcessor *self, visitproc visit, void *arg) { @@ -38,43 +61,43 @@ processor_traverse (zebraProcessor *self, } static int -processor_clear (zebraProcessor *self) +processor_clear (zbarProcessor *self) { - zebra_processor_set_data_handler(self->zproc, NULL, NULL); - zebra_processor_set_userdata(self->zproc, NULL); + zbar_processor_set_data_handler(self->zproc, NULL, NULL); + zbar_processor_set_userdata(self->zproc, NULL); Py_CLEAR(self->handler); Py_CLEAR(self->closure); return(0); } static void -processor_dealloc (zebraProcessor *self) +processor_dealloc (zbarProcessor *self) { processor_clear(self); - zebra_processor_destroy(self->zproc); + zbar_processor_destroy(self->zproc); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } static PyObject* -processor_get_bool (zebraProcessor *self, +processor_get_bool (zbarProcessor *self, void *closure) { int val; switch((int)closure) { case 0: - val = zebra_processor_is_visible(self->zproc); + val = zbar_processor_is_visible(self->zproc); break; default: assert(0); return(NULL); } if(val < 0) - return(zebraErr_Set((PyObject*)self)); + return(zbarErr_Set((PyObject*)self)); return(PyBool_FromLong(val)); } static int -processor_set_bool (zebraProcessor *self, +processor_set_bool (zbarProcessor *self, PyObject *value, void *closure) { @@ -87,17 +110,17 @@ processor_set_bool (zebraProcessor *self, return(-1); switch((int)closure) { case 0: - rc = zebra_processor_set_visible(self->zproc, val); + rc = zbar_processor_set_visible(self->zproc, val); break; case 1: - rc = zebra_processor_set_active(self->zproc, val); + rc = zbar_processor_set_active(self->zproc, val); break; default: assert(0); return(-1); } if(rc < 0) { - zebraErr_Set((PyObject*)self); + zbarErr_Set((PyObject*)self); return(-1); } return(0); @@ -112,19 +135,19 @@ static PyGetSetDef processor_getset[] = { }; static PyObject* -processor_set_config (zebraProcessor *self, +processor_set_config (zbarProcessor *self, PyObject *args, PyObject *kwds) { - zebra_symbol_type_t sym = ZEBRA_NONE; - zebra_config_t cfg = ZEBRA_CFG_ENABLE; + zbar_symbol_type_t sym = ZBAR_NONE; + zbar_config_t cfg = ZBAR_CFG_ENABLE; int val = 1; static char *kwlist[] = { "symbology", "config", "value", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwlist, &sym, &cfg, &val)) return(NULL); - if(zebra_processor_set_config(self->zproc, sym, cfg, val)) { + if(zbar_processor_set_config(self->zproc, sym, cfg, val)) { PyErr_SetString(PyExc_ValueError, "invalid configuration setting"); return(NULL); } @@ -132,7 +155,7 @@ processor_set_config (zebraProcessor *self, } static PyObject* -processor_init_ (zebraProcessor *self, +processor_init_ (zbarProcessor *self, PyObject *args, PyObject *kwds) { @@ -143,13 +166,13 @@ processor_init_ (zebraProcessor *self, &dev, object_to_bool, &disp)) return(NULL); - if(zebra_processor_init(self->zproc, dev, disp)) - return(zebraErr_Set((PyObject*)self)); + if(zbar_processor_init(self->zproc, dev, disp)) + return(zbarErr_Set((PyObject*)self)); Py_RETURN_NONE; } static PyObject* -processor_parse_config (zebraProcessor *self, +processor_parse_config (zbarProcessor *self, PyObject *args, PyObject *kwds) { @@ -158,7 +181,7 @@ processor_parse_config (zebraProcessor *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &cfg)) return(NULL); - if(zebra_processor_parse_config(self->zproc, cfg)) { + if(zbar_processor_parse_config(self->zproc, cfg)) { PyErr_Format(PyExc_ValueError, "invalid configuration setting: %s", cfg); return(NULL); @@ -182,7 +205,7 @@ object_to_timeout (PyObject *obj, } static PyObject* -processor_user_wait (zebraProcessor *self, +processor_user_wait (zbarProcessor *self, PyObject *args, PyObject *kwds) { @@ -192,14 +215,14 @@ processor_user_wait (zebraProcessor *self, object_to_timeout, &timeout)) return(NULL); - int rc = zebra_processor_user_wait(self->zproc, timeout); + int rc = zbar_processor_user_wait(self->zproc, timeout); if(rc < 0) - return(zebraErr_Set((PyObject*)self)); + return(zbarErr_Set((PyObject*)self)); return(PyInt_FromLong(rc)); } static PyObject* -processor_process_one (zebraProcessor *self, +processor_process_one (zbarProcessor *self, PyObject *args, PyObject *kwds) { @@ -209,44 +232,44 @@ processor_process_one (zebraProcessor *self, object_to_timeout, &timeout)) return(NULL); - int rc = zebra_process_one(self->zproc, timeout); + int rc = zbar_process_one(self->zproc, timeout); if(rc < 0) - return(zebraErr_Set((PyObject*)self)); + return(zbarErr_Set((PyObject*)self)); return(PyInt_FromLong(rc)); } static PyObject* -processor_process_image (zebraProcessor *self, +processor_process_image (zbarProcessor *self, PyObject *args, PyObject *kwds) { - zebraImage *img = NULL; + zbarImage *img = NULL; static char *kwlist[] = { "image", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, - &zebraImage_Type, &img)) + &zbarImage_Type, &img)) return(NULL); - if(zebraImage_validate(img)) + if(zbarImage_validate(img)) return(NULL); - int n = zebra_process_image(self->zproc, img->zimg); + int n = zbar_process_image(self->zproc, img->zimg); if(n < 0) - return(zebraErr_Set((PyObject*)self)); + return(zbarErr_Set((PyObject*)self)); return(PyInt_FromLong(n)); } void -process_handler (zebra_image_t *zimg, +process_handler (zbar_image_t *zimg, const void *userdata) { - zebraProcessor *self = (zebraProcessor*)userdata; + zbarProcessor *self = (zbarProcessor*)userdata; assert(self); assert(self->handler); assert(self->closure); - zebraImage *img = zebra_image_get_userdata(zimg); + zbarImage *img = zbar_image_get_userdata(zimg); if(!img || img->zimg != zimg) { - img = zebraImage_FromImage(zimg); + img = zbarImage_FromImage(zimg); if(!img) { PyErr_NoMemory(); return; @@ -268,7 +291,7 @@ process_handler (zebra_image_t *zimg, } static PyObject* -processor_set_data_handler (zebraProcessor *self, +processor_set_data_handler (zbarProcessor *self, PyObject *args, PyObject *kwds) { @@ -295,11 +318,11 @@ processor_set_data_handler (zebraProcessor *self, Py_INCREF(closure); self->closure = closure; - zebra_processor_set_data_handler(self->zproc, process_handler, self); + zbar_processor_set_data_handler(self->zproc, process_handler, self); } else { self->handler = self->closure = NULL; - zebra_processor_set_data_handler(self->zproc, NULL, self); + zbar_processor_set_data_handler(self->zproc, NULL, self); } Py_RETURN_NONE; } @@ -322,11 +345,11 @@ static PyMethodDef processor_methods[] = { { NULL, }, }; -PyTypeObject zebraProcessor_Type = { +PyTypeObject zbarProcessor_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Processor", + .tp_name = "zbar.Processor", .tp_doc = processor_doc, - .tp_basicsize = sizeof(zebraProcessor), + .tp_basicsize = sizeof(zbarProcessor), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)processor_new, diff --git a/python/scanner.c b/python/scanner.c index fb4d7bd9..b0b4c210 100644 --- a/python/scanner.c +++ b/python/scanner.c @@ -1,4 +1,27 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char scanner_doc[] = PyDoc_STR( "low level intensity sample stream scanner. identifies \"bar\" edges" @@ -6,28 +29,28 @@ static char scanner_doc[] = PyDoc_STR( "\n" "FIXME."); -static zebraScanner* +static zbarScanner* scanner_new (PyTypeObject *type, PyObject *args, PyObject *kwds) { - zebraDecoder *decoder = NULL; + zbarDecoder *decoder = NULL; static char *kwlist[] = { "decoder", NULL }; if(!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", kwlist, - &decoder, zebraDecoder_Type)) + &decoder, zbarDecoder_Type)) return(NULL); - zebraScanner *self = (zebraScanner*)type->tp_alloc(type, 0); + zbarScanner *self = (zbarScanner*)type->tp_alloc(type, 0); if(!self) return(NULL); - zebra_decoder_t *zdcode = NULL; + zbar_decoder_t *zdcode = NULL; if(decoder) { Py_INCREF(decoder); self->decoder = decoder; zdcode = decoder->zdcode; } - self->zscn = zebra_scanner_create(zdcode); + self->zscn = zbar_scanner_create(zdcode); if(!self->zscn) { Py_DECREF(self); return(NULL); @@ -37,7 +60,7 @@ scanner_new (PyTypeObject *type, } static int -scanner_traverse (zebraScanner *self, +scanner_traverse (zbarScanner *self, visitproc visit, void *arg) { @@ -46,35 +69,35 @@ scanner_traverse (zebraScanner *self, } static int -scanner_clear (zebraScanner *self) +scanner_clear (zbarScanner *self) { Py_CLEAR(self->decoder); return(0); } static void -scanner_dealloc (zebraScanner *self) +scanner_dealloc (zbarScanner *self) { scanner_clear(self); - zebra_scanner_destroy(self->zscn); + zbar_scanner_destroy(self->zscn); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } static PyObject* -scanner_get_width (zebraScanner *self, +scanner_get_width (zbarScanner *self, void *closure) { - unsigned int width = zebra_scanner_get_width(self->zscn); + unsigned int width = zbar_scanner_get_width(self->zscn); return(PyInt_FromLong(width)); } -static zebraEnumItem* -scanner_get_color (zebraScanner *self, +static zbarEnumItem* +scanner_get_color (zbarScanner *self, void *closure) { - zebra_color_t zcol = zebra_scanner_get_color(self->zscn); - assert(zcol == ZEBRA_BAR || zcol == ZEBRA_SPACE); - zebraEnumItem *color = color_enum[zcol]; + zbar_color_t zcol = zbar_scanner_get_color(self->zscn); + assert(zcol == ZBAR_BAR || zcol == ZBAR_SPACE); + zbarEnumItem *color = color_enum[zcol]; Py_INCREF((PyObject*)color); return(color); } @@ -86,7 +109,7 @@ static PyGetSetDef scanner_getset[] = { }; static PyObject* -scanner_reset (zebraScanner *self, +scanner_reset (zbarScanner *self, PyObject *args, PyObject *kwds) { @@ -94,12 +117,12 @@ scanner_reset (zebraScanner *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebra_scanner_reset(self->zscn); + zbar_scanner_reset(self->zscn); Py_RETURN_NONE; } static PyObject* -scanner_new_scan (zebraScanner *self, +scanner_new_scan (zbarScanner *self, PyObject *args, PyObject *kwds) { @@ -107,12 +130,12 @@ scanner_new_scan (zebraScanner *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) return(NULL); - zebra_scanner_new_scan(self->zscn); + zbar_scanner_new_scan(self->zscn); Py_RETURN_NONE; } -static zebraEnumItem* -scanner_scan_y (zebraScanner *self, +static zbarEnumItem* +scanner_scan_y (zbarScanner *self, PyObject *args, PyObject *kwds) { @@ -122,16 +145,16 @@ scanner_scan_y (zebraScanner *self, if(!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &y)) return(NULL); - zebra_symbol_type_t sym = zebra_scan_y(self->zscn, y); + zbar_symbol_type_t sym = zbar_scan_y(self->zscn, y); if(PyErr_Occurred()) /* propagate errors during callback */ return(NULL); - if(sym == ZEBRA_NONE) { + if(sym == ZBAR_NONE) { /* hardcode most common case */ Py_INCREF((PyObject*)symbol_NONE); return(symbol_NONE); } - return(zebraSymbol_LookupEnum(sym)); + return(zbarSymbol_LookupEnum(sym)); } static PyMethodDef scanner_methods[] = { @@ -144,11 +167,11 @@ static PyMethodDef scanner_methods[] = { { NULL, }, }; -PyTypeObject zebraScanner_Type = { +PyTypeObject zbarScanner_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Scanner", + .tp_name = "zbar.Scanner", .tp_doc = scanner_doc, - .tp_basicsize = sizeof(zebraScanner), + .tp_basicsize = sizeof(zbarScanner), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)scanner_new, diff --git a/python/symbol.c b/python/symbol.c index d631a937..9b4e0ab9 100644 --- a/python/symbol.c +++ b/python/symbol.c @@ -1,4 +1,27 @@ -#include "zebramodule.h" +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" static char symbol_doc[] = PyDoc_STR( "symbol result object.\n" @@ -6,7 +29,7 @@ static char symbol_doc[] = PyDoc_STR( "data and associated information about a successful decode."); static int -symbol_traverse (zebraSymbol *self, +symbol_traverse (zbarSymbol *self, visitproc visit, void *arg) { @@ -15,7 +38,7 @@ symbol_traverse (zebraSymbol *self, } static int -symbol_clear (zebraSymbol *self) +symbol_clear (zbarSymbol *self) { Py_CLEAR(self->img); Py_CLEAR(self->data); @@ -24,32 +47,32 @@ symbol_clear (zebraSymbol *self) } static void -symbol_dealloc (zebraSymbol *self) +symbol_dealloc (zbarSymbol *self) { symbol_clear(self); ((PyObject*)self)->ob_type->tp_free((PyObject*)self); } -static zebraEnumItem* -symbol_get_type (zebraSymbol *self, +static zbarEnumItem* +symbol_get_type (zbarSymbol *self, void *closure) { - return(zebraSymbol_LookupEnum(zebra_symbol_get_type(self->zsym))); + return(zbarSymbol_LookupEnum(zbar_symbol_get_type(self->zsym))); } static PyObject* -symbol_get_count (zebraSymbol *self, +symbol_get_count (zbarSymbol *self, void *closure) { - return(PyInt_FromLong(zebra_symbol_get_count(self->zsym))); + return(PyInt_FromLong(zbar_symbol_get_count(self->zsym))); } static PyObject* -symbol_get_data (zebraSymbol *self, +symbol_get_data (zbarSymbol *self, void *closure) { if(!self->data) { - self->data = PyString_FromString(zebra_symbol_get_data(self->zsym)); + self->data = PyString_FromString(zbar_symbol_get_data(self->zsym)); if(!self->data) return(NULL); } @@ -58,18 +81,18 @@ symbol_get_data (zebraSymbol *self, } static PyObject* -symbol_get_location (zebraSymbol *self, +symbol_get_location (zbarSymbol *self, void *closure) { if(!self->loc) { /* build tuple of 2-tuples representing location polygon */ - unsigned int n = zebra_symbol_get_loc_size(self->zsym); + unsigned int n = zbar_symbol_get_loc_size(self->zsym); self->loc = PyTuple_New(n); unsigned int i; for(i = 0; i < n; i++) { PyObject *x, *y; - x = PyInt_FromLong(zebra_symbol_get_loc_x(self->zsym, i)); - y = PyInt_FromLong(zebra_symbol_get_loc_y(self->zsym, i)); + x = PyInt_FromLong(zbar_symbol_get_loc_x(self->zsym, i)); + y = PyInt_FromLong(zbar_symbol_get_loc_y(self->zsym, i)); PyTuple_SET_ITEM(self->loc, i, PyTuple_Pack(2, x, y)); } } @@ -85,11 +108,11 @@ static PyGetSetDef symbol_getset[] = { { NULL, }, }; -PyTypeObject zebraSymbol_Type = { +PyTypeObject zbarSymbol_Type = { PyObject_HEAD_INIT(NULL) - .tp_name = "zebra.Symbol", + .tp_name = "zbar.Symbol", .tp_doc = symbol_doc, - .tp_basicsize = sizeof(zebraSymbol), + .tp_basicsize = sizeof(zbarSymbol), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_traverse = (traverseproc)symbol_traverse, @@ -98,12 +121,12 @@ PyTypeObject zebraSymbol_Type = { .tp_getset = symbol_getset, }; -zebraSymbol* -zebraSymbol_FromSymbol (zebraImage *img, - const zebra_symbol_t *zsym) +zbarSymbol* +zbarSymbol_FromSymbol (zbarImage *img, + const zbar_symbol_t *zsym) { /* FIXME symbol object recycle cache */ - zebraSymbol *self = PyObject_GC_New(zebraSymbol, &zebraSymbol_Type); + zbarSymbol *self = PyObject_GC_New(zbarSymbol, &zbarSymbol_Type); if(!self) return(NULL); assert(img); @@ -116,13 +139,13 @@ zebraSymbol_FromSymbol (zebraImage *img, return(self); } -zebraEnumItem* -zebraSymbol_LookupEnum (zebra_symbol_type_t type) +zbarEnumItem* +zbarSymbol_LookupEnum (zbar_symbol_type_t type) { PyObject *key = PyInt_FromLong(type); - zebraEnumItem *e = (zebraEnumItem*)PyDict_GetItem(symbol_enum, key); + zbarEnumItem *e = (zbarEnumItem*)PyDict_GetItem(symbol_enum, key); if(!e) - return((zebraEnumItem*)key); + return((zbarEnumItem*)key); Py_INCREF((PyObject*)e); Py_DECREF(key); return(e); diff --git a/python/test/test_zebra.py b/python/test/test_zbar.py similarity index 75% rename from python/test/test_zebra.py rename to python/test/test_zbar.py index f0c3190a..b556d74e 100755 --- a/python/test/test_zebra.py +++ b/python/test/test_zbar.py @@ -1,7 +1,7 @@ #!/usr/bin/python import sys, os import unittest as ut -import zebra +import zbar # FIXME this needs to be conditional # would be even better to auto-select PIL or ImageMagick (or...) @@ -24,46 +24,46 @@ def load_image(): if 'VIDEO_DEVICE' in os.environ: VIDEO_DEVICE = os.environ['VIDEO_DEVICE'] -class TestZebraFunctions(ut.TestCase): +class TestZBarFunctions(ut.TestCase): def test_version(self): - ver = zebra.version() + ver = zbar.version() self.assert_(isinstance(ver, tuple)) self.assertEqual(len(ver), 2) for v in ver: self.assert_(isinstance(v, int)) def test_verbosity(self): - zebra.increase_verbosity() - zebra.set_verbosity(16) + zbar.increase_verbosity() + zbar.set_verbosity(16) def test_exceptions(self): - self.assert_(isinstance(zebra.Exception, type)) - self.assert_(issubclass(zebra.InternalError, zebra.Exception)) - self.assert_(issubclass(zebra.UnsupportedError, zebra.Exception)) - self.assert_(issubclass(zebra.InvalidRequestError, zebra.Exception)) - self.assert_(issubclass(zebra.SystemError, zebra.Exception)) - self.assert_(issubclass(zebra.LockingError, zebra.Exception)) - self.assert_(issubclass(zebra.BusyError, zebra.Exception)) - self.assert_(issubclass(zebra.X11DisplayError, zebra.Exception)) - self.assert_(issubclass(zebra.X11ProtocolError, zebra.Exception)) - self.assert_(issubclass(zebra.WindowClosed, zebra.Exception)) + self.assert_(isinstance(zbar.Exception, type)) + self.assert_(issubclass(zbar.InternalError, zbar.Exception)) + self.assert_(issubclass(zbar.UnsupportedError, zbar.Exception)) + self.assert_(issubclass(zbar.InvalidRequestError, zbar.Exception)) + self.assert_(issubclass(zbar.SystemError, zbar.Exception)) + self.assert_(issubclass(zbar.LockingError, zbar.Exception)) + self.assert_(issubclass(zbar.BusyError, zbar.Exception)) + self.assert_(issubclass(zbar.X11DisplayError, zbar.Exception)) + self.assert_(issubclass(zbar.X11ProtocolError, zbar.Exception)) + self.assert_(issubclass(zbar.WindowClosed, zbar.Exception)) class TestScanner(ut.TestCase): def setUp(self): - self.scn = zebra.Scanner() + self.scn = zbar.Scanner() def tearDown(self): del(self.scn) def test_type(self): - self.assert_(isinstance(self.scn, zebra.Scanner)) + self.assert_(isinstance(self.scn, zbar.Scanner)) self.assert_(callable(self.scn.reset)) self.assert_(callable(self.scn.new_scan)) self.assert_(callable(self.scn.scan_y)) def set_color(color): self.scn.color = color - self.assertRaises(AttributeError, set_color, zebra.BAR) + self.assertRaises(AttributeError, set_color, zbar.BAR) def set_width(width): self.scn.width = width @@ -73,13 +73,13 @@ def set_width(width): class TestDecoder(ut.TestCase): def setUp(self): - self.dcode = zebra.Decoder() + self.dcode = zbar.Decoder() def tearDown(self): del(self.dcode) def test_type(self): - self.assert_(isinstance(self.dcode, zebra.Decoder)) + self.assert_(isinstance(self.dcode, zbar.Decoder)) self.assert_(callable(self.dcode.set_config)) self.assert_(callable(self.dcode.parse_config)) self.assert_(callable(self.dcode.reset)) @@ -89,11 +89,11 @@ def test_type(self): def set_type(typ): self.dcode.type = typ - self.assertRaises(AttributeError, set_type, zebra.Symbol.CODE128) + self.assertRaises(AttributeError, set_type, zbar.Symbol.CODE128) def set_color(color): self.dcode.color = color - self.assertRaises(AttributeError, set_color, zebra.BAR) + self.assertRaises(AttributeError, set_color, zbar.BAR) def set_data(data): self.dcode.data = data @@ -101,7 +101,7 @@ def set_data(data): def test_width(self): sym = self.dcode.decode_width(5) - self.assert_(sym is zebra.Symbol.NONE) + self.assert_(sym is zbar.Symbol.NONE) self.assert_(not sym) self.assertEqual(str(sym), 'NONE') @@ -109,17 +109,17 @@ def test_width(self): self.assert_(sym is typ) def test_reset(self): - self.assert_(self.dcode.color is zebra.SPACE) + self.assert_(self.dcode.color is zbar.SPACE) sym = self.dcode.decode_width(1) - self.assert_(self.dcode.color is zebra.BAR) + self.assert_(self.dcode.color is zbar.BAR) self.dcode.reset() - self.assert_(self.dcode.color is zebra.SPACE) + self.assert_(self.dcode.color is zbar.SPACE) def test_decode(self): inline_sym = [ -1 ] def handler(dcode, closure): self.assert_(dcode is self.dcode) - if dcode.type > zebra.Symbol.PARTIAL: + if dcode.type > zbar.Symbol.PARTIAL: inline_sym[0] = dcode.type closure[0] += 1 @@ -130,36 +130,36 @@ def handler(dcode, closure): if width == ' ': continue sym = self.dcode.decode_width(int(width)) if i < len(encoded_widths) - 1: - self.assert_(sym is zebra.Symbol.NONE or - sym is zebra.Symbol.PARTIAL) + self.assert_(sym is zbar.Symbol.NONE or + sym is zbar.Symbol.PARTIAL) else: - self.assert_(sym is zebra.Symbol.EAN13) + self.assert_(sym is zbar.Symbol.EAN13) self.assertEqual(self.dcode.data, '6268964977804') - self.assert_(self.dcode.color is zebra.BAR) - self.assert_(sym is zebra.Symbol.EAN13) - self.assert_(inline_sym[0] is zebra.Symbol.EAN13) + self.assert_(self.dcode.color is zbar.BAR) + self.assert_(sym is zbar.Symbol.EAN13) + self.assert_(inline_sym[0] is zbar.Symbol.EAN13) self.assertEqual(explicit_closure, [ 2 ]) # FIXME test exception during callback class TestImage(ut.TestCase): def setUp(self): - self.image = zebra.Image(123, 456, 'Y800') + self.image = zbar.Image(123, 456, 'Y800') def tearDown(self): del(self.image) def test_type(self): - self.assert_(isinstance(self.image, zebra.Image)) + self.assert_(isinstance(self.image, zbar.Image)) self.assert_(callable(self.image.convert)) def test_new(self): self.assertEqual(self.image.format, 'Y800') self.assertEqual(self.image.size, (123, 456)) - image = zebra.Image() - self.assert_(isinstance(image, zebra.Image)) + image = zbar.Image() + self.assert_(isinstance(image, zbar.Image)) self.assertEqual(image.format, '\0\0\0\0') self.assertEqual(image.size, (0, 0)) @@ -196,13 +196,13 @@ def set_size(sz): class TestImageScanner(ut.TestCase): def setUp(self): - self.scn = zebra.ImageScanner() + self.scn = zbar.ImageScanner() def tearDown(self): del(self.scn) def test_type(self): - self.assert_(isinstance(self.scn, zebra.ImageScanner)) + self.assert_(isinstance(self.scn, zbar.ImageScanner)) self.assert_(callable(self.scn.set_config)) self.assert_(callable(self.scn.parse_config)) self.assert_(callable(self.scn.enable_cache)) @@ -221,8 +221,8 @@ def test_parse_config(self): class TestImageScan(ut.TestCase): def setUp(self): - self.scn = zebra.ImageScanner() - self.image = zebra.Image(size[0], size[1], 'Y800', data) + self.scn = zbar.ImageScanner() + self.image = zbar.Image(size[0], size[1], 'Y800', data) def tearDown(self): del(self.image) @@ -233,14 +233,14 @@ def test_scan(self): self.assertEqual(n, 1) i = iter(self.image) - self.assert_(isinstance(i, zebra.SymbolIter)) + self.assert_(isinstance(i, zbar.SymbolIter)) sym = i.next() self.assertRaises(StopIteration, i.next) # this is the only way to obtain a Symbol, # so test Symbol here - self.assert_(isinstance(sym, zebra.Symbol)) - self.assert_(sym.type is zebra.Symbol.EAN13) + self.assert_(isinstance(sym, zbar.Symbol)) + self.assert_(sym.type is zbar.Symbol.EAN13) self.assert_(sym.type is sym.EAN13) self.assertEqual(str(sym.type), 'EAN13') self.assertEqual(sym.count, 0) @@ -264,13 +264,13 @@ def test_scan_again(self): class TestProcessor(ut.TestCase): def setUp(self): - self.proc = zebra.Processor() + self.proc = zbar.Processor() def tearDown(self): del(self.proc) def test_type(self): - self.assert_(isinstance(self.proc, zebra.Processor)) + self.assert_(isinstance(self.proc, zbar.Processor)) self.assert_(callable(self.proc.init)) self.assert_(callable(self.proc.set_config)) self.assert_(callable(self.proc.parse_config)) @@ -297,7 +297,7 @@ def test_processing(self): self.assert_(self.proc.visible is True) self.assertEqual(self.proc.user_wait(1.1), 0) - self.image = zebra.Image(size[0], size[1], 'Y800', data) + self.image = zbar.Image(size[0], size[1], 'Y800', data) count = [ 0 ] def data_handler(proc, image, closure): @@ -307,13 +307,13 @@ def data_handler(proc, image, closure): count[0] += 1 symiter = iter(image) - self.assert_(isinstance(symiter, zebra.SymbolIter)) + self.assert_(isinstance(symiter, zbar.SymbolIter)) symbols = tuple(image) self.assertEqual(len(symbols), 1) for symbol in symbols: - self.assert_(isinstance(symbol, zebra.Symbol)) - self.assert_(symbol.type is zebra.Symbol.EAN13) + self.assert_(isinstance(symbol, zbar.Symbol)) + self.assert_(symbol.type is zbar.Symbol.EAN13) self.assertEqual(symbol.data, '9876543210128') closure[0] += 1 diff --git a/python/zbarmodule.c b/python/zbarmodule.c new file mode 100644 index 00000000..03c822d4 --- /dev/null +++ b/python/zbarmodule.c @@ -0,0 +1,193 @@ +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "zbarmodule.h" + +static char *exc_names[] = { + "zbar.Exception", + NULL, + "zbar.InternalError", + "zbar.UnsupportedError", + "zbar.InvalidRequestError", + "zbar.SystemError", + "zbar.LockingError", + "zbar.BusyError", + "zbar.X11DisplayError", + "zbar.X11ProtocolError", + "zbar.WindowClosed", +}; + +int +object_to_bool (PyObject *obj, + int *val) +{ + int tmp = PyObject_IsTrue(obj); + if(tmp < 0) + return(0); + *val = tmp; + return(1); +} + +PyObject *zbar_exc[ZBAR_ERR_NUM]; +zbarEnumItem *color_enum[2]; +zbarEnum *config_enum; +PyObject *symbol_enum; +zbarEnumItem *symbol_NONE; + +static PyObject* +version (PyObject *self, + PyObject *args) +{ + if(!PyArg_ParseTuple(args, "")) + return(NULL); + + unsigned int major, minor; + zbar_version(&major, &minor); + + return(Py_BuildValue("II", major, minor)); +} + +static PyObject* +set_verbosity (PyObject *self, + PyObject *args) +{ + int verbosity; + if(!PyArg_ParseTuple(args, "i", &verbosity)) + return(NULL); + + zbar_set_verbosity(verbosity); + + Py_INCREF(Py_None); + return(Py_None); +} + +static PyObject* +increase_verbosity (PyObject *self, + PyObject *args) +{ + if(!PyArg_ParseTuple(args, "")) + return(NULL); + + zbar_increase_verbosity(); + + Py_INCREF(Py_None); + return(Py_None); +} + +static PyMethodDef zbar_functions[] = { + { "version", version, METH_VARARGS, NULL }, + { "set_verbosity", set_verbosity, METH_VARARGS, NULL }, + { "increase_verbosity", increase_verbosity, METH_VARARGS, NULL }, + { NULL, }, +}; + +PyMODINIT_FUNC +initzbar () +{ + /* initialize constant containers */ + config_enum = zbarEnum_New(); + symbol_enum = PyDict_New(); + if(!config_enum || !symbol_enum) + return; + + /* initialize types */ + zbarEnumItem_Type.tp_base = &PyInt_Type; + zbarException_Type.tp_base = (PyTypeObject*)PyExc_Exception; + + if(PyType_Ready(&zbarException_Type) < 0 || + PyType_Ready(&zbarEnumItem_Type) < 0 || + PyType_Ready(&zbarEnum_Type) < 0 || + PyType_Ready(&zbarImage_Type) < 0 || + PyType_Ready(&zbarSymbol_Type) < 0 || + PyType_Ready(&zbarSymbolIter_Type) < 0 || + PyType_Ready(&zbarProcessor_Type) < 0 || + PyType_Ready(&zbarImageScanner_Type) < 0 || + PyType_Ready(&zbarDecoder_Type) < 0 || + PyType_Ready(&zbarScanner_Type) < 0) + return; + + zbar_exc[0] = (PyObject*)&zbarException_Type; + zbar_exc[ZBAR_ERR_NOMEM] = NULL; + zbar_error_t ei; + for(ei = ZBAR_ERR_INTERNAL; ei < ZBAR_ERR_NUM; ei++) { + zbar_exc[ei] = PyErr_NewException(exc_names[ei], zbar_exc[0], NULL); + if(!zbar_exc[ei]) + return; + } + + /* internally created/read-only type overrides */ + zbarEnum_Type.tp_new = NULL; + zbarEnum_Type.tp_setattr = NULL; + zbarEnum_Type.tp_setattro = NULL; + + /* initialize module */ + PyObject *mod = Py_InitModule("zbar", zbar_functions); + if(!mod) + return; + + /* add types to module */ + PyModule_AddObject(mod, "EnumItem", (PyObject*)&zbarEnumItem_Type); + PyModule_AddObject(mod, "Image", (PyObject*)&zbarImage_Type); + PyModule_AddObject(mod, "Config", (PyObject*)config_enum); + PyModule_AddObject(mod, "Symbol", (PyObject*)&zbarSymbol_Type); + PyModule_AddObject(mod, "SymbolIter", (PyObject*)&zbarSymbolIter_Type); + PyModule_AddObject(mod, "Processor", (PyObject*)&zbarProcessor_Type); + PyModule_AddObject(mod, "ImageScanner", (PyObject*)&zbarImageScanner_Type); + PyModule_AddObject(mod, "Decoder", (PyObject*)&zbarDecoder_Type); + PyModule_AddObject(mod, "Scanner", (PyObject*)&zbarScanner_Type); + + for(ei = 0; ei < ZBAR_ERR_NUM; ei++) + if(zbar_exc[ei]) + PyModule_AddObject(mod, exc_names[ei] + 5, zbar_exc[ei]); + + /* add constants */ + PyObject *dict = PyModule_GetDict(mod); + color_enum[ZBAR_SPACE] = + zbarEnumItem_New(dict, NULL, ZBAR_SPACE, "SPACE"); + color_enum[ZBAR_BAR] = + zbarEnumItem_New(dict, NULL, ZBAR_BAR, "BAR"); + + zbarEnum_Add(config_enum, ZBAR_CFG_ENABLE, "ENABLE"); + zbarEnum_Add(config_enum, ZBAR_CFG_ADD_CHECK, "ADD_CHECK"); + zbarEnum_Add(config_enum, ZBAR_CFG_EMIT_CHECK, "EMIT_CHECK"); + zbarEnum_Add(config_enum, ZBAR_CFG_ASCII, "ASCII"); + zbarEnum_Add(config_enum, ZBAR_CFG_MIN_LEN, "MIN_LEN"); + zbarEnum_Add(config_enum, ZBAR_CFG_MAX_LEN, "MAX_LEN"); + zbarEnum_Add(config_enum, ZBAR_CFG_X_DENSITY, "X_DENSITY"); + zbarEnum_Add(config_enum, ZBAR_CFG_Y_DENSITY, "Y_DENSITY"); + + PyObject *tp_dict = zbarSymbol_Type.tp_dict; + symbol_NONE = + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_NONE, "NONE"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_PARTIAL, "PARTIAL"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_EAN8, "EAN8"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_UPCE, "UPCE"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_ISBN10, "ISBN10"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_UPCA, "UPCA"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_EAN13, "EAN13"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_ISBN13, "ISBN13"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_I25, "I25"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_CODE39, "CODE39"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_PDF417, "PDF417"); + zbarEnumItem_New(tp_dict, symbol_enum, ZBAR_CODE128, "CODE128"); +} diff --git a/python/zbarmodule.h b/python/zbarmodule.h new file mode 100644 index 00000000..e968d746 --- /dev/null +++ b/python/zbarmodule.h @@ -0,0 +1,141 @@ +/*------------------------------------------------------------------------ + * Copyright 2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include +#include +#include + +#ifndef _ZBARMODULE_H_ +#define _ZBARMODULE_H_ + +typedef struct { + PyBaseExceptionObject base; + PyObject *obj; +} zbarException; + +extern PyTypeObject zbarException_Type; +extern PyObject *zbar_exc[ZBAR_ERR_NUM]; + +extern PyObject *zbarErr_Set(PyObject *self); + +typedef struct { + PyIntObject val; /* integer value is super type */ + PyObject *name; /* associated string name */ +} zbarEnumItem; + +extern PyTypeObject zbarEnumItem_Type; + +extern zbarEnumItem *zbarEnumItem_New(PyObject *byname, + PyObject *byvalue, + int val, + const char *name); + +typedef struct { + PyObject_HEAD + PyObject *byname, *byvalue; /* zbarEnumItem content dictionaries */ +} zbarEnum; + +extern PyTypeObject zbarEnum_Type; + +extern zbarEnum *zbarEnum_New(); +extern int zbarEnum_Add(zbarEnum *self, + int val, + const char *name); + +typedef struct { + PyObject_HEAD + zbar_image_t *zimg; + PyObject *data; +} zbarImage; + +extern PyTypeObject zbarImage_Type; + +extern zbarImage *zbarImage_FromImage(zbar_image_t *zimg); +extern int zbarImage_validate(zbarImage *image); + +typedef struct { + PyObject_HEAD + const zbar_symbol_t *zsym; + zbarImage *img; + PyObject *data; + PyObject *loc; +} zbarSymbol; + +extern PyTypeObject zbarSymbol_Type; + +extern zbarSymbol *zbarSymbol_FromSymbol(zbarImage *img, + const zbar_symbol_t *zsym); +extern zbarEnumItem *zbarSymbol_LookupEnum(zbar_symbol_type_t type); + +typedef struct { + PyObject_HEAD + const zbar_symbol_t *zsym; + zbarImage *img; +} zbarSymbolIter; + +extern PyTypeObject zbarSymbolIter_Type; + +typedef struct { + PyObject_HEAD + zbar_processor_t *zproc; + PyObject *handler; + PyObject *closure; +} zbarProcessor; + +extern PyTypeObject zbarProcessor_Type; + +#define zbarProcessor_Check(obj) PyObject_TypeCheck(obj, &zbarProcessor_Type) + +typedef struct { + PyObject_HEAD + zbar_image_scanner_t *zscn; +} zbarImageScanner; + +extern PyTypeObject zbarImageScanner_Type; + +typedef struct { + PyObject_HEAD + zbar_decoder_t *zdcode; + PyObject *handler; + PyObject *args; +} zbarDecoder; + +extern PyTypeObject zbarDecoder_Type; + +typedef struct { + PyObject_HEAD + zbar_scanner_t *zscn; + zbarDecoder *decoder; +} zbarScanner; + +extern PyTypeObject zbarScanner_Type; + +extern zbarEnumItem *color_enum[2]; +extern zbarEnum *config_enum; +extern PyObject *symbol_enum; +extern zbarEnumItem *symbol_NONE; + +int object_to_bool(PyObject *obj, + int *val); + +#endif diff --git a/python/zebramodule.c b/python/zebramodule.c deleted file mode 100644 index 3df32020..00000000 --- a/python/zebramodule.c +++ /dev/null @@ -1,170 +0,0 @@ -#include "zebramodule.h" - -static char *exc_names[] = { - "zebra.Exception", - NULL, - "zebra.InternalError", - "zebra.UnsupportedError", - "zebra.InvalidRequestError", - "zebra.SystemError", - "zebra.LockingError", - "zebra.BusyError", - "zebra.X11DisplayError", - "zebra.X11ProtocolError", - "zebra.WindowClosed", -}; - -int -object_to_bool (PyObject *obj, - int *val) -{ - int tmp = PyObject_IsTrue(obj); - if(tmp < 0) - return(0); - *val = tmp; - return(1); -} - -PyObject *zebra_exc[ZEBRA_ERR_NUM]; -zebraEnumItem *color_enum[2]; -zebraEnum *config_enum; -PyObject *symbol_enum; -zebraEnumItem *symbol_NONE; - -static PyObject* -version (PyObject *self, - PyObject *args) -{ - if(!PyArg_ParseTuple(args, "")) - return(NULL); - - unsigned int major, minor; - zebra_version(&major, &minor); - - return(Py_BuildValue("II", major, minor)); -} - -static PyObject* -set_verbosity (PyObject *self, - PyObject *args) -{ - int verbosity; - if(!PyArg_ParseTuple(args, "i", &verbosity)) - return(NULL); - - zebra_set_verbosity(verbosity); - - Py_INCREF(Py_None); - return(Py_None); -} - -static PyObject* -increase_verbosity (PyObject *self, - PyObject *args) -{ - if(!PyArg_ParseTuple(args, "")) - return(NULL); - - zebra_increase_verbosity(); - - Py_INCREF(Py_None); - return(Py_None); -} - -static PyMethodDef zebra_functions[] = { - { "version", version, METH_VARARGS, NULL }, - { "set_verbosity", set_verbosity, METH_VARARGS, NULL }, - { "increase_verbosity", increase_verbosity, METH_VARARGS, NULL }, - { NULL, }, -}; - -PyMODINIT_FUNC -initzebra () -{ - /* initialize constant containers */ - config_enum = zebraEnum_New(); - symbol_enum = PyDict_New(); - if(!config_enum || !symbol_enum) - return; - - /* initialize types */ - zebraEnumItem_Type.tp_base = &PyInt_Type; - zebraException_Type.tp_base = (PyTypeObject*)PyExc_Exception; - - if(PyType_Ready(&zebraException_Type) < 0 || - PyType_Ready(&zebraEnumItem_Type) < 0 || - PyType_Ready(&zebraEnum_Type) < 0 || - PyType_Ready(&zebraImage_Type) < 0 || - PyType_Ready(&zebraSymbol_Type) < 0 || - PyType_Ready(&zebraSymbolIter_Type) < 0 || - PyType_Ready(&zebraProcessor_Type) < 0 || - PyType_Ready(&zebraImageScanner_Type) < 0 || - PyType_Ready(&zebraDecoder_Type) < 0 || - PyType_Ready(&zebraScanner_Type) < 0) - return; - - zebra_exc[0] = (PyObject*)&zebraException_Type; - zebra_exc[ZEBRA_ERR_NOMEM] = NULL; - zebra_error_t ei; - for(ei = ZEBRA_ERR_INTERNAL; ei < ZEBRA_ERR_NUM; ei++) { - zebra_exc[ei] = PyErr_NewException(exc_names[ei], zebra_exc[0], NULL); - if(!zebra_exc[ei]) - return; - } - - /* internally created/read-only type overrides */ - zebraEnum_Type.tp_new = NULL; - zebraEnum_Type.tp_setattr = NULL; - zebraEnum_Type.tp_setattro = NULL; - - /* initialize module */ - PyObject *mod = Py_InitModule("zebra", zebra_functions); - if(!mod) - return; - - /* add types to module */ - PyModule_AddObject(mod, "EnumItem", (PyObject*)&zebraEnumItem_Type); - PyModule_AddObject(mod, "Image", (PyObject*)&zebraImage_Type); - PyModule_AddObject(mod, "Config", (PyObject*)config_enum); - PyModule_AddObject(mod, "Symbol", (PyObject*)&zebraSymbol_Type); - PyModule_AddObject(mod, "SymbolIter", (PyObject*)&zebraSymbolIter_Type); - PyModule_AddObject(mod, "Processor", (PyObject*)&zebraProcessor_Type); - PyModule_AddObject(mod, "ImageScanner", (PyObject*)&zebraImageScanner_Type); - PyModule_AddObject(mod, "Decoder", (PyObject*)&zebraDecoder_Type); - PyModule_AddObject(mod, "Scanner", (PyObject*)&zebraScanner_Type); - - for(ei = 0; ei < ZEBRA_ERR_NUM; ei++) - if(zebra_exc[ei]) - PyModule_AddObject(mod, exc_names[ei] + 6, zebra_exc[ei]); - - /* add constants */ - PyObject *dict = PyModule_GetDict(mod); - color_enum[ZEBRA_SPACE] = - zebraEnumItem_New(dict, NULL, ZEBRA_SPACE, "SPACE"); - color_enum[ZEBRA_BAR] = - zebraEnumItem_New(dict, NULL, ZEBRA_BAR, "BAR"); - - zebraEnum_Add(config_enum, ZEBRA_CFG_ENABLE, "ENABLE"); - zebraEnum_Add(config_enum, ZEBRA_CFG_ADD_CHECK, "ADD_CHECK"); - zebraEnum_Add(config_enum, ZEBRA_CFG_EMIT_CHECK, "EMIT_CHECK"); - zebraEnum_Add(config_enum, ZEBRA_CFG_ASCII, "ASCII"); - zebraEnum_Add(config_enum, ZEBRA_CFG_MIN_LEN, "MIN_LEN"); - zebraEnum_Add(config_enum, ZEBRA_CFG_MAX_LEN, "MAX_LEN"); - zebraEnum_Add(config_enum, ZEBRA_CFG_X_DENSITY, "X_DENSITY"); - zebraEnum_Add(config_enum, ZEBRA_CFG_Y_DENSITY, "Y_DENSITY"); - - PyObject *tp_dict = zebraSymbol_Type.tp_dict; - symbol_NONE = - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_NONE, "NONE"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_PARTIAL, "PARTIAL"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_EAN8, "EAN8"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_UPCE, "UPCE"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_ISBN10, "ISBN10"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_UPCA, "UPCA"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_EAN13, "EAN13"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_ISBN13, "ISBN13"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_I25, "I25"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_CODE39, "CODE39"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_PDF417, "PDF417"); - zebraEnumItem_New(tp_dict, symbol_enum, ZEBRA_CODE128, "CODE128"); -} diff --git a/python/zebramodule.h b/python/zebramodule.h deleted file mode 100644 index 3985c872..00000000 --- a/python/zebramodule.h +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include - -#ifndef _ZEBRAMODULE_H_ -#define _ZEBRAMODULE_H_ - -typedef struct { - PyBaseExceptionObject base; - PyObject *obj; -} zebraException; - -extern PyTypeObject zebraException_Type; -extern PyObject *zebra_exc[ZEBRA_ERR_NUM]; - -extern PyObject *zebraErr_Set(PyObject *self); - -typedef struct { - PyIntObject val; /* integer value is super type */ - PyObject *name; /* associated string name */ -} zebraEnumItem; - -extern PyTypeObject zebraEnumItem_Type; - -extern zebraEnumItem *zebraEnumItem_New(PyObject *byname, - PyObject *byvalue, - int val, - const char *name); - -typedef struct { - PyObject_HEAD - PyObject *byname, *byvalue; /* zebraEnumItem content dictionaries */ -} zebraEnum; - -extern PyTypeObject zebraEnum_Type; - -extern zebraEnum *zebraEnum_New(); -extern int zebraEnum_Add(zebraEnum *self, - int val, - const char *name); - -typedef struct { - PyObject_HEAD - zebra_image_t *zimg; - PyObject *data; -} zebraImage; - -extern PyTypeObject zebraImage_Type; - -extern zebraImage *zebraImage_FromImage(zebra_image_t *zimg); -extern int zebraImage_validate(zebraImage *image); - -typedef struct { - PyObject_HEAD - const zebra_symbol_t *zsym; - zebraImage *img; - PyObject *data; - PyObject *loc; -} zebraSymbol; - -extern PyTypeObject zebraSymbol_Type; - -extern zebraSymbol *zebraSymbol_FromSymbol(zebraImage *img, - const zebra_symbol_t *zsym); -extern zebraEnumItem *zebraSymbol_LookupEnum(zebra_symbol_type_t type); - -typedef struct { - PyObject_HEAD - const zebra_symbol_t *zsym; - zebraImage *img; -} zebraSymbolIter; - -extern PyTypeObject zebraSymbolIter_Type; - -typedef struct { - PyObject_HEAD - zebra_processor_t *zproc; - PyObject *handler; - PyObject *closure; -} zebraProcessor; - -extern PyTypeObject zebraProcessor_Type; - -#define zebraProcessor_Check(obj) PyObject_TypeCheck(obj, &zebraProcessor_Type) - -typedef struct { - PyObject_HEAD - zebra_image_scanner_t *zscn; -} zebraImageScanner; - -extern PyTypeObject zebraImageScanner_Type; - -typedef struct { - PyObject_HEAD - zebra_decoder_t *zdcode; - PyObject *handler; - PyObject *args; -} zebraDecoder; - -extern PyTypeObject zebraDecoder_Type; - -typedef struct { - PyObject_HEAD - zebra_scanner_t *zscn; - zebraDecoder *decoder; -} zebraScanner; - -extern PyTypeObject zebraScanner_Type; - -extern zebraEnumItem *color_enum[2]; -extern zebraEnum *config_enum; -extern PyObject *symbol_enum; -extern zebraEnumItem *symbol_NONE; - -int object_to_bool(PyObject *obj, - int *val); - -#endif diff --git a/qt/Makefile.am.inc b/qt/Makefile.am.inc index 9999b922..dc1525e0 100644 --- a/qt/Makefile.am.inc +++ b/qt/Makefile.am.inc @@ -1,15 +1,15 @@ -lib_LTLIBRARIES += qt/libzebraqt.la -qt_libzebraqt_la_CPPFLAGS = -Iqt $(QT_CFLAGS) $(AM_CPPFLAGS) -qt_libzebraqt_la_LDFLAGS = -version-info $(ZQT_LIB_VERSION) $(AM_LDFLAGS) -qt_libzebraqt_la_LIBADD = $(QT_LIBS) zebra/libzebra.la $(AM_LIBADD) +lib_LTLIBRARIES += qt/libzbarqt.la +qt_libzbarqt_la_CPPFLAGS = -Iqt $(QT_CFLAGS) $(AM_CPPFLAGS) +qt_libzbarqt_la_LDFLAGS = -version-info $(ZQT_LIB_VERSION) $(AM_LDFLAGS) +qt_libzbarqt_la_LIBADD = $(QT_LIBS) zbar/libzbar.la $(AM_LIBADD) -qt_libzebraqt_la_SOURCES = qt/QZebra.cpp qt/QZebraThread.h qt/QZebraThread.cpp -nodist_qt_libzebraqt_la_SOURCES = qt/moc_QZebra.cpp qt/moc_QZebraThread.cpp -BUILT_SOURCES += $(nodist_qt_libzebraqt_la_SOURCES) -DISTCLEANFILES += $(nodist_qt_libzebraqt_la_SOURCES) +qt_libzbarqt_la_SOURCES = qt/QZBar.cpp qt/QZBarThread.h qt/QZBarThread.cpp +nodist_qt_libzbarqt_la_SOURCES = qt/moc_QZBar.cpp qt/moc_QZBarThread.cpp +BUILT_SOURCES += $(nodist_qt_libzbarqt_la_SOURCES) +DISTCLEANFILES += $(nodist_qt_libzbarqt_la_SOURCES) qt/moc_%.cpp: qt/%.h - $(MOC) $(qt_libzebraqt_la_CPPFLAGS) $< -o $@ + $(MOC) $(qt_libzbarqt_la_CPPFLAGS) $< -o $@ -qt/moc_%.cpp: include/zebra/%.h - $(MOC) $(qt_libzebraqt_la_CPPFLAGS) $< -o $@ +qt/moc_%.cpp: include/zbar/%.h + $(MOC) $(qt_libzbarqt_la_CPPFLAGS) $< -o $@ diff --git a/qt/QZebra.cpp b/qt/QZBar.cpp similarity index 73% rename from qt/QZebra.cpp rename to qt/QZBar.cpp index 5011112f..d4246be4 100644 --- a/qt/QZebra.cpp +++ b/qt/QZBar.cpp @@ -1,35 +1,35 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ #include #include #include -#include -#include "QZebraThread.h" +#include +#include "QZBarThread.h" -using namespace zebra; +using namespace zbar; -QZebra::QZebra (QWidget *parent) +QZBar::QZBar (QWidget *parent) : QWidget(parent), thread(NULL), _videoDevice(), @@ -42,7 +42,7 @@ QZebra::QZebra (QWidget *parent) sizing.setHeightForWidth(true); setSizePolicy(sizing); - thread = new QZebraThread; + thread = new QZBarThread; if(testAttribute(Qt::WA_WState_Created)) thread->window.attach(x11Info().display(), winId()); connect(thread, SIGNAL(videoOpened(bool)), @@ -58,48 +58,48 @@ QZebra::QZebra (QWidget *parent) thread->start(); } -QZebra::~QZebra () +QZBar::~QZBar () { if(thread) { thread->window.attach(NULL); - thread->pushEvent(new QEvent((QEvent::Type)QZebraThread::Exit)); + thread->pushEvent(new QEvent((QEvent::Type)QZBarThread::Exit)); thread->wait(); thread = NULL; } } -QString QZebra::videoDevice () const +QString QZBar::videoDevice () const { return(_videoDevice); } -void QZebra::setVideoDevice (const QString& videoDevice) +void QZBar::setVideoDevice (const QString& videoDevice) { if(!thread) return; if(_videoDevice != videoDevice) { _videoDevice = videoDevice; _videoEnabled = !_videoDevice.isEmpty(); - thread->pushEvent(new QZebraThread::VideoDeviceEvent(videoDevice)); + thread->pushEvent(new QZBarThread::VideoDeviceEvent(videoDevice)); } } -bool QZebra::isVideoEnabled () const +bool QZBar::isVideoEnabled () const { return(_videoEnabled); } -void QZebra::setVideoEnabled (bool videoEnabled) +void QZBar::setVideoEnabled (bool videoEnabled) { if(!thread) return; if(_videoEnabled != videoEnabled) { _videoEnabled = videoEnabled; - thread->pushEvent(new QZebraThread::VideoEnabledEvent(videoEnabled)); + thread->pushEvent(new QZBarThread::VideoEnabledEvent(videoEnabled)); } } -bool QZebra::isVideoOpened () const +bool QZBar::isVideoOpened () const { if(!thread) return(false); @@ -107,21 +107,21 @@ bool QZebra::isVideoOpened () const return(thread->_videoOpened); } -void QZebra::scanImage (const QImage &image) +void QZBar::scanImage (const QImage &image) { if(!thread) return; - thread->pushEvent(new QZebraThread::ScanImageEvent(image)); + thread->pushEvent(new QZBarThread::ScanImageEvent(image)); } -void QZebra::dragEnterEvent (QDragEnterEvent *event) +void QZBar::dragEnterEvent (QDragEnterEvent *event) { if(event->mimeData()->hasImage() || event->mimeData()->hasUrls()) event->acceptProposedAction(); } -void QZebra::dropEvent (QDropEvent *event) +void QZBar::dropEvent (QDropEvent *event) { if(event->mimeData()->hasImage()) { QImage image = qvariant_cast(event->mimeData()->imageData()); @@ -144,7 +144,7 @@ void QZebra::dropEvent (QDropEvent *event) } } -QSize QZebra::sizeHint () const +QSize QZBar::sizeHint () const { if(!thread) return(QSize(640, 480)); @@ -152,7 +152,7 @@ QSize QZebra::sizeHint () const return(QSize(thread->reqWidth, thread->reqHeight)); } -int QZebra::heightForWidth (int width) const +int QZBar::heightForWidth (int width) const { if(thread) { QMutexLocker locker(&thread->mutex); @@ -164,26 +164,26 @@ int QZebra::heightForWidth (int width) const return(width * 3 / 4); } -void QZebra::paintEvent (QPaintEvent *) +void QZBar::paintEvent (QPaintEvent *) { if(thread) thread->window.redraw(); } -void QZebra::resizeEvent (QResizeEvent *event) +void QZBar::resizeEvent (QResizeEvent *event) { QSize size = event->size(); if(thread) thread->window.resize(size.rwidth(), size.rheight()); } -void QZebra::changeEvent(QEvent *event) +void QZBar::changeEvent(QEvent *event) { if(event->type() == QEvent::ParentChange) thread->window.attach(x11Info().display(), winId()); } -void QZebra::sizeChange () +void QZBar::sizeChange () { update(); updateGeometry(); diff --git a/qt/QZebraThread.cpp b/qt/QZBarThread.cpp similarity index 84% rename from qt/QZebraThread.cpp rename to qt/QZBarThread.cpp index 957aa7ef..a193470d 100644 --- a/qt/QZebraThread.cpp +++ b/qt/QZBarThread.cpp @@ -1,34 +1,34 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ #include -#include "QZebraThread.h" +#include "QZBarThread.h" -using namespace zebra; +using namespace zbar; static const QString textFormat("%1%2:%3"); -QZebraThread::QZebraThread () +QZBarThread::QZBarThread () : reqWidth(DEFAULT_WIDTH), reqHeight(DEFAULT_HEIGHT), video(NULL), @@ -40,7 +40,7 @@ QZebraThread::QZebraThread () scanner.set_handler(*this); } -void QZebraThread::image_callback (Image &image) +void QZBarThread::image_callback (Image &image) { for(Image::SymbolIterator sym = image.symbol_begin(); sym != image.symbol_end(); @@ -56,7 +56,7 @@ void QZebraThread::image_callback (Image &image) } } -void QZebraThread::processImage (Image &image) +void QZBarThread::processImage (Image &image) { scanner.scan(image); window.draw(image); @@ -67,7 +67,7 @@ void QZebraThread::processImage (Image &image) emit update(); } -void QZebraThread::enableVideo (bool enable) +void QZBarThread::enableVideo (bool enable) { if(!video) { videoRunning = videoEnabled = false; @@ -88,7 +88,7 @@ void QZebraThread::enableVideo (bool enable) } } -void QZebraThread::openVideo (const QString &device) +void QZBarThread::openVideo (const QString &device) { if(videoRunning) enableVideo(false); @@ -133,25 +133,25 @@ void QZebraThread::openVideo (const QString &device) } -void QZebraThread::videoDeviceEvent (VideoDeviceEvent *e) +void QZBarThread::videoDeviceEvent (VideoDeviceEvent *e) { openVideo(e->device); } -void QZebraThread::videoEnabledEvent (VideoEnabledEvent *e) +void QZBarThread::videoEnabledEvent (VideoEnabledEvent *e) { if(videoRunning && !e->enabled) enableVideo(false); videoEnabled = e->enabled; } -void QZebraThread::scanImageEvent (ScanImageEvent *e) +void QZBarThread::scanImageEvent (ScanImageEvent *e) { if(videoRunning) enableVideo(false); try { - image = new QZebraImage(e->image); + image = new QZBarImage(e->image); processImage(*image); } catch(std::exception &e) { @@ -160,7 +160,7 @@ void QZebraThread::scanImageEvent (ScanImageEvent *e) } } -bool QZebraThread::event (QEvent *e) +bool QZBarThread::event (QEvent *e) { switch(e->type()) { case VideoDevice: @@ -184,7 +184,7 @@ bool QZebraThread::event (QEvent *e) } -void QZebraThread::run () +void QZBarThread::run () { QEvent *e = NULL; while(running) { diff --git a/qt/QZebraThread.h b/qt/QZBarThread.h similarity index 85% rename from qt/QZebraThread.h rename to qt/QZBarThread.h index a78e7ac3..0e4b0001 100644 --- a/qt/QZebraThread.h +++ b/qt/QZBarThread.h @@ -1,42 +1,42 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ -#ifndef _QZEBRATHREAD_H_ -#define _QZEBRATHREAD_H_ +#ifndef _QZBARTHREAD_H_ +#define _QZBARTHREAD_H_ #include #include #include #include -#include -#include -#include +#include +#include +#include #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 480 -namespace zebra { +namespace zbar { -class QZebraThread +class QZBarThread : public QThread, public Image::Handler { @@ -100,7 +100,7 @@ class QZebraThread Window window; - QZebraThread(); + QZBarThread(); void pushEvent (QEvent *e) { @@ -141,7 +141,7 @@ class QZebraThread private: Video *video; ImageScanner scanner; - QZebraImage *image; + QZBarImage *image; bool running; bool videoRunning; bool videoEnabled; diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc index 3267e7e6..64d0b3f1 100644 --- a/test/Makefile.am.inc +++ b/test/Makefile.am.inc @@ -1,27 +1,27 @@ check_PROGRAMS += test/test_decode test_test_decode_SOURCES = test/test_decode.c test/pdf417_encode.h test_test_decode_CFLAGS = -Wno-unused $(AM_CFLAGS) -test_test_decode_LDADD = zebra/libzebra.la $(AM_LDADD) +test_test_decode_LDADD = zbar/libzbar.la $(AM_LDADD) TEST_IMAGE_SOURCES = test/test_images.c test/test_images.h check_PROGRAMS += test/test_convert test_test_convert_SOURCES = test/test_convert.c $(TEST_IMAGE_SOURCES) -test_test_convert_LDADD = zebra/libzebra.la $(AM_LDADD) +test_test_convert_LDADD = zbar/libzbar.la $(AM_LDADD) if HAVE_POLL check_PROGRAMS += test/test_proc test_test_proc_SOURCES = test/test_proc.c $(TEST_IMAGE_SOURCES) -test_test_proc_LDADD = zebra/libzebra.la $(AM_LDADD) +test_test_proc_LDADD = zbar/libzbar.la $(AM_LDADD) check_PROGRAMS += test/test_cpp test_test_cpp_SOURCES = test/test_cpp.cpp -test_test_cpp_LDADD = zebra/libzebra.la $(AM_LDADD) +test_test_cpp_LDADD = zbar/libzbar.la $(AM_LDADD) if HAVE_JPEG check_PROGRAMS += test/test_jpeg test_test_jpeg_SOURCES = test/test_jpeg.c -test_test_jpeg_LDADD = zebra/libzebra.la $(AM_LDADD) +test_test_jpeg_LDADD = zbar/libzbar.la $(AM_LDADD) endif endif @@ -29,14 +29,14 @@ if HAVE_MAGICK check_PROGRAMS += test/dbg_scan test_dbg_scan_SOURCES = test/dbg_scan.cpp test_dbg_scan_CPPFLAGS = $(MAGICK_CFLAGS) $(AM_CPPFLAGS) -test_dbg_scan_LDADD = $(MAGICK_LIBS) zebra/libzebra.la $(AM_LDADD) +test_dbg_scan_LDADD = $(MAGICK_LIBS) zbar/libzbar.la $(AM_LDADD) endif if HAVE_GTK check_PROGRAMS += test/test_gtk test_test_gtk_SOURCES = test/test_gtk.c test/scan_video.c test_test_gtk_CPPFLAGS = $(GTK_CFLAGS) $(AM_CPPFLAGS) -test_test_gtk_LDADD = $(GTK_LIBS) gtk/libzebragtk.la $(AM_LDADD) +test_test_gtk_LDADD = $(GTK_LIBS) gtk/libzbargtk.la $(AM_LDADD) endif if HAVE_QT @@ -44,7 +44,7 @@ check_PROGRAMS += test/test_qt test_test_qt_SOURCES = test/test_qt.cpp test/scan_video.c nodist_test_test_qt_SOURCES = test/moc_test_qt.h test_test_qt_CPPFLAGS = -Itest $(QT_CFLAGS) $(AM_CPPFLAGS) -test_test_qt_LDADD = $(QT_LIBS) qt/libzebraqt.la $(AM_LDADD) +test_test_qt_LDADD = $(QT_LIBS) qt/libzbarqt.la $(AM_LDADD) BUILT_SOURCES += $(nodist_test_test_qt_SOURCES) DISTCLEANFILES += $(nodist_test_test_qt_SOURCES) diff --git a/test/dbg_scan.cpp b/test/dbg_scan.cpp index fcaf59d1..e0e52c5e 100644 --- a/test/dbg_scan.cpp +++ b/test/dbg_scan.cpp @@ -1,46 +1,46 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include #include #include -#include +#include using namespace std; -using namespace zebra; +using namespace zbar; -#ifndef ZEBRA_FIXED -# define ZEBRA_FIXED 5 +#ifndef ZBAR_FIXED +# define ZBAR_FIXED 5 #endif -#define ZEBRA_FRAC (1 << ZEBRA_FIXED) +#define ZBAR_FRAC (1 << ZBAR_FIXED) Decoder decoder; Scanner scanner; /* undocumented API for drawing cutesy debug graphics */ -extern "C" void zebra_scanner_get_state(const zebra_scanner_t *scn, +extern "C" void zbar_scanner_get_state(const zbar_scanner_t *scn, unsigned *x, unsigned *cur_edge, unsigned *last_edge, @@ -156,7 +156,7 @@ void scan_image (const char *filename) for(unsigned i = 0; i < width; i++) { int edge = scanner.scan_y(raw[i]); unsigned x; - zebra_scanner_get_state(scanner.get_c_scanner(), &x, + zbar_scanner_get_state(scanner.get_c_scanner(), &x, &cur_edge[i], &last_edge[i], &y0[i], &y1[i], &y2[i], &y1_thr[i]); #ifdef DEBUG_SCANNER @@ -166,19 +166,19 @@ void scan_image (const char *filename) if(edge) { last_edge[i] += i - x; unsigned w = scanner.get_width(); - svg << "" << endl << "" << endl << w << "" << endl; - zebra_symbol_type_t sym = decoder.decode_width(w); - if(sym > ZEBRA_PARTIAL) { + zbar_symbol_type_t sym = decoder.decode_width(w); + if(sym > ZBAR_PARTIAL) { svg << "" << decoder.get_data_string() << "" << endl; } @@ -192,7 +192,7 @@ void scan_image (const char *filename) << "" << endl << "" << endl << "" << endl @@ -207,7 +207,7 @@ void scan_image (const char *filename) << "" << endl << " 1) srcfmt = *(uint32_t*)argv[1]; - zebra_image_t *img = zebra_image_create(); - zebra_image_set_size(img, 640, 480); - zebra_image_set_format(img, srcfmt); + zbar_image_t *img = zbar_image_create(); + zbar_image_set_size(img, 640, 480); + zbar_image_set_format(img, srcfmt); if(test_image_bars(img)) return(2); - if(zebra_image_write(img, "base")) + if(zbar_image_write(img, "base")) return(1); return(0); } diff --git a/test/test_cpp.cpp b/test/test_cpp.cpp index 3eec707b..14c1c220 100644 --- a/test/test_cpp.cpp +++ b/test/test_cpp.cpp @@ -1,29 +1,29 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ // NB do not put anything before this header // it's here to check that we didn't omit any dependencies -#include +#include int main (int argc, char **argv) { @@ -31,13 +31,13 @@ int main (int argc, char **argv) if(argc > 1) video_dev = argv[1]; - zebra::Processor proc = zebra::Processor(true, video_dev); + zbar::Processor proc = zbar::Processor(true, video_dev); proc.set_visible(); proc.set_active(); try { proc.user_wait(); } - catch(zebra::ClosedError) { } + catch(zbar::ClosedError) { } return(0); } diff --git a/test/test_decode.c b/test/test_decode.c index d240654a..4fd743fc 100644 --- a/test/test_decode.c +++ b/test/test_decode.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -27,19 +27,19 @@ #include #include -#include +#include -zebra_decoder_t *decoder; +zbar_decoder_t *decoder; -static void symbol_handler (zebra_decoder_t *decoder) +static void symbol_handler (zbar_decoder_t *decoder) { - zebra_symbol_type_t sym = zebra_decoder_get_type(decoder); - if(sym <= ZEBRA_PARTIAL) + zbar_symbol_type_t sym = zbar_decoder_get_type(decoder); + if(sym <= ZBAR_PARTIAL) return; printf("%s%s:%s\n", - zebra_get_symbol_name(sym), - zebra_get_addon_name(sym), - zebra_decoder_get_data(decoder)); + zbar_get_symbol_name(sym), + zbar_get_addon_name(sym), + zbar_decoder_get_data(decoder)); /* FIXME add check! */ } @@ -48,7 +48,7 @@ static void encode_junk (int n) printf("encode random junk...\n"); int i; for(i = 0; i < n; i++) - zebra_decode_width(decoder, 10. * (rand() / (RAND_MAX + 1.))); + zbar_decode_width(decoder, 10. * (rand() / (RAND_MAX + 1.))); } #define FWD 1 @@ -65,7 +65,7 @@ static void encode (uint64_t units, while(units) { unsigned char w = (fwd) ? units & 0xf : units >> 0x3c; - zebra_decode_width(decoder, w); + zbar_decode_width(decoder, w); if(fwd) units >>= 4; else @@ -451,9 +451,9 @@ int main (int argc, char **argv) * - simulate dark "swelling" and light "blooming" * - inject parity errors */ - decoder = zebra_decoder_create(); - zebra_decoder_set_handler(decoder, symbol_handler); - zebra_decoder_set_config(decoder, 0, ZEBRA_CFG_MIN_LEN, 0); + decoder = zbar_decoder_create(); + zbar_decoder_set_handler(decoder, symbol_handler); + zbar_decoder_set_config(decoder, 0, ZBAR_CFG_MIN_LEN, 0); encode_junk(rnd_size + 1); @@ -501,6 +501,6 @@ int main (int argc, char **argv) encode_junk(rnd_size); - zebra_decoder_destroy(decoder); + zbar_decoder_destroy(decoder); return(0); } diff --git a/test/test_gtk.c b/test/test_gtk.c index c632d551..eef91215 100644 --- a/test/test_gtk.c +++ b/test/test_gtk.c @@ -1,28 +1,28 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include -#include +#include static GtkWidget *window = NULL; static GtkWidget *status_image = NULL; @@ -37,15 +37,15 @@ int scan_video(void *add_device, * puts the decoded result in the textbox */ static void decoded (GtkWidget *widget, - zebra_symbol_type_t symbol, + zbar_symbol_type_t symbol, const char *result, gpointer data) { GtkTextBuffer *resultbuf = gtk_text_view_get_buffer(results); GtkTextIter end; gtk_text_buffer_get_end_iter(resultbuf, &end); - gtk_text_buffer_insert(resultbuf, &end, zebra_get_symbol_name(symbol), -1); - gtk_text_buffer_insert(resultbuf, &end, zebra_get_addon_name(symbol), -1); + gtk_text_buffer_insert(resultbuf, &end, zbar_get_symbol_name(symbol), -1); + gtk_text_buffer_insert(resultbuf, &end, zbar_get_addon_name(symbol), -1); gtk_text_buffer_insert(resultbuf, &end, ":", -1); gtk_text_buffer_insert(resultbuf, &end, result, -1); gtk_text_buffer_insert(resultbuf, &end, "\n", -1); @@ -59,9 +59,9 @@ static void video_enabled (GObject *object, GParamSpec *param, gpointer data) { - ZebraGtk *zebra = ZEBRA_GTK(object); - gboolean enabled = zebra_gtk_get_video_enabled(zebra); - gboolean opened = zebra_gtk_get_video_opened(zebra); + ZBarGtk *zbar = ZBAR_GTK(object); + gboolean enabled = zbar_gtk_get_video_enabled(zbar); + gboolean opened = zbar_gtk_get_video_opened(zbar); GtkToggleButton *button = GTK_TOGGLE_BUTTON(data); gboolean active = gtk_toggle_button_get_active(button); @@ -73,9 +73,9 @@ static void video_opened (GObject *object, GParamSpec *param, gpointer data) { - ZebraGtk *zebra = ZEBRA_GTK(object); - gboolean opened = zebra_gtk_get_video_opened(zebra); - gboolean enabled = zebra_gtk_get_video_enabled(zebra); + ZBarGtk *zbar = ZBAR_GTK(object); + gboolean opened = zbar_gtk_get_video_opened(zbar); + gboolean enabled = zbar_gtk_get_video_enabled(zbar); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), opened && enabled); gtk_widget_set_sensitive(GTK_WIDGET(data), opened); @@ -88,7 +88,7 @@ static void video_changed (GtkWidget *widget, { const char *video_device = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); - zebra_gtk_set_video_device(ZEBRA_GTK(data), + zbar_gtk_set_video_device(ZBAR_GTK(data), ((video_device && video_device[0] != '<') ? video_device : NULL)); @@ -97,12 +97,12 @@ static void video_changed (GtkWidget *widget, static void status_button_toggled (GtkToggleButton *button, gpointer data) { - ZebraGtk *zebra = ZEBRA_GTK(data); - gboolean opened = zebra_gtk_get_video_opened(zebra); - gboolean enabled = zebra_gtk_get_video_enabled(zebra); + ZBarGtk *zbar = ZBAR_GTK(data); + gboolean opened = zbar_gtk_get_video_opened(zbar); + gboolean enabled = zbar_gtk_get_video_enabled(zbar); gboolean active = gtk_toggle_button_get_active(button); if(opened && (active != enabled)) - zebra_gtk_set_video_enabled(ZEBRA_GTK(data), active); + zbar_gtk_set_video_enabled(ZBAR_GTK(data), active); gtk_image_set_from_stock(GTK_IMAGE(status_image), (opened && active) ? GTK_STOCK_YES : GTK_STOCK_NO, GTK_ICON_SIZE_BUTTON); @@ -128,7 +128,7 @@ static void open_button_clicked (GtkButton *button, gchar *file = gtk_file_chooser_get_filename(chooser); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(file, NULL); if(pixbuf) - zebra_gtk_scan_image(ZEBRA_GTK(data), pixbuf); + zbar_gtk_scan_image(ZBAR_GTK(data), pixbuf); else fprintf(stderr, "ERROR: unable to open image file: %s\n", file); @@ -141,7 +141,7 @@ static void open_button_clicked (GtkButton *button, /* build a simple gui w/: * - a combo box to select the desired video device - * - the zebra widget to display video + * - the zbar widget to display video * - a non-editable text box to display any results */ int main (int argc, char *argv[]) @@ -163,16 +163,16 @@ int main (int argc, char *argv[]) g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - GtkWidget *zebra = zebra_gtk_new(); + GtkWidget *zbar = zbar_gtk_new(); - g_signal_connect(G_OBJECT(zebra), "decoded", + g_signal_connect(G_OBJECT(zbar), "decoded", G_CALLBACK(decoded), NULL); /* video device list combo box */ GtkWidget *video_list = gtk_combo_box_new_text(); g_signal_connect(G_OBJECT(video_list), "changed", - G_CALLBACK(video_changed), zebra); + G_CALLBACK(video_changed), zbar); /* enable/disable status button */ GtkWidget *status_button = gtk_toggle_button_new(); @@ -184,17 +184,17 @@ int main (int argc, char *argv[]) /* bind status button state and video state */ g_signal_connect(G_OBJECT(status_button), "toggled", - G_CALLBACK(status_button_toggled), zebra); - g_signal_connect(G_OBJECT(zebra), "notify::video-enabled", + G_CALLBACK(status_button_toggled), zbar); + g_signal_connect(G_OBJECT(zbar), "notify::video-enabled", G_CALLBACK(video_enabled), status_button); - g_signal_connect(G_OBJECT(zebra), "notify::video-opened", + g_signal_connect(G_OBJECT(zbar), "notify::video-opened", G_CALLBACK(video_opened), status_button); /* open image file button */ GtkWidget *open_button = gtk_button_new_from_stock(GTK_STOCK_OPEN); g_signal_connect(G_OBJECT(open_button), "clicked", - G_CALLBACK(open_button_clicked), zebra); + G_CALLBACK(open_button_clicked), zbar); gtk_combo_box_append_text(GTK_COMBO_BOX(video_list), ""); int active = scan_video(gtk_combo_box_append_text, video_list, video_arg); @@ -215,18 +215,18 @@ int main (int argc, char *argv[]) gtk_text_view_set_cursor_visible(results, FALSE); gtk_text_view_set_left_margin(results, 4); - /* vbox for hbox, zebra test widget and result text box */ + /* vbox for hbox, zbar test widget and result text box */ GtkWidget *vbox = gtk_vbox_new(FALSE, 8); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), zebra, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), zbar, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(results), FALSE, FALSE, 0); GdkGeometry hints; hints.min_width = 320; hints.min_height = 240; - gtk_window_set_geometry_hints(GTK_WINDOW(window), zebra, &hints, + gtk_window_set_geometry_hints(GTK_WINDOW(window), zbar, &hints, GDK_HINT_MIN_SIZE); gtk_widget_show_all(window); diff --git a/test/test_images.c b/test/test_images.c index 5ecae6ca..eb205365 100644 --- a/test/test_images.c +++ b/test/test_images.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "test_images.h" typedef enum format_type_e { @@ -108,9 +108,9 @@ int test_image_check_cleanup () return(allocated_images); } -static void test_cleanup_handler (zebra_image_t *img) +static void test_cleanup_handler (zbar_image_t *img) { - void *data = (void*)zebra_image_get_data(img); + void *data = (void*)zbar_image_get_data(img); fprintf(stderr, "cleanup image data @%p\n", data); free(data); allocated_images--; @@ -336,15 +336,15 @@ static inline uint8_t *fill_bars_rgb (uint8_t *p, return(((uint8_t*)q) + headlen); } -int test_image_bars (zebra_image_t *img) +int test_image_bars (zbar_image_t *img) { allocated_images++; - unsigned w = zebra_image_get_width(img); - unsigned h = zebra_image_get_height(img); + unsigned w = zbar_image_get_width(img); + unsigned h = zbar_image_get_height(img); const format_def_t *fmt; for(fmt = formats; fmt->format; fmt++) - if(fmt->format == zebra_image_get_format(img)) + if(fmt->format == zbar_image_get_format(img)) break; if(!fmt->format) return(-1); @@ -352,7 +352,7 @@ int test_image_bars (zebra_image_t *img) unsigned long planelen = w * h; unsigned long datalen = planelen * fmt->bpp / 8; uint8_t *data = malloc(datalen); - zebra_image_set_data(img, data, datalen, test_cleanup_handler); + zbar_image_set_data(img, data, datalen, test_cleanup_handler); fprintf(stderr, "create %.4s(%08" PRIx32 ") image data %lx bytes @%p\n", (char*)&fmt->format, fmt->format, datalen, data); diff --git a/test/test_images.h b/test/test_images.h index 3a4c05a0..50dfef95 100644 --- a/test/test_images.h +++ b/test/test_images.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _TEST_IMAGES_H_ #define _TEST_IMAGES_H_ @@ -29,6 +29,6 @@ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) int test_image_check_cleanup(); -int test_image_bars(zebra_image_t*); +int test_image_bars(zbar_image_t*); #endif diff --git a/test/test_jpeg.c b/test/test_jpeg.c index b11c99c7..11947376 100644 --- a/test/test_jpeg.c +++ b/test/test_jpeg.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -29,7 +29,7 @@ #include #include -#include +#include #include "test_images.h" @@ -108,32 +108,32 @@ unsigned char rgb[8*8*3] = { int main (int argc, char **argv) { - zebra_set_verbosity(32); + zbar_set_verbosity(32); - zebra_processor_t *proc = zebra_processor_create(0); + zbar_processor_t *proc = zbar_processor_create(0); assert(proc); - if(zebra_processor_init(proc, NULL, 1)) + if(zbar_processor_init(proc, NULL, 1)) return(2); - zebra_image_t *img = zebra_image_create(); - zebra_image_set_size(img, 8, 8); - zebra_image_set_format(img, fourcc('J','P','E','G')); - zebra_image_set_data(img, jpeg, sizeof(jpeg), NULL); + zbar_image_t *img = zbar_image_create(); + zbar_image_set_size(img, 8, 8); + zbar_image_set_format(img, fourcc('J','P','E','G')); + zbar_image_set_data(img, jpeg, sizeof(jpeg), NULL); - zebra_image_t *test = zebra_image_convert(img, fourcc('Y','8','0','0')); + zbar_image_t *test = zbar_image_convert(img, fourcc('Y','8','0','0')); if(!test) return(2); printf("converted: %d x %d (%lx) %08lx\n", - zebra_image_get_width(test), - zebra_image_get_height(test), - zebra_image_get_data_length(test), - zebra_image_get_format(test)); + zbar_image_get_width(test), + zbar_image_get_height(test), + zbar_image_get_data_length(test), + zbar_image_get_format(test)); - if(zebra_process_image(proc, test) < 0) + if(zbar_process_image(proc, test) < 0) return(3); - if(zebra_processor_set_visible(proc, 1)) + if(zbar_processor_set_visible(proc, 1)) return(4); - zebra_processor_user_wait(proc, -1); + zbar_processor_user_wait(proc, -1); return(0); } diff --git a/test/test_perl.pl b/test/test_perl.pl index 7616fbf9..cc28ffbd 100755 --- a/test/test_perl.pl +++ b/test/test_perl.pl @@ -1,36 +1,36 @@ #!/usr/bin/env perl #------------------------------------------------------------------------ -# Copyright 2008 (c) Jeff Brown +# Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ use 5.006; use warnings; use strict; -use Zebra; +use Barcode::ZBar; -Zebra::set_verbosity(15); +Barcode::ZBar::set_verbosity(15); -my $proc = Zebra::Processor->new(1); +my $proc = Barcode::ZBar::Processor->new(1); $proc->init($ARGV[0] || '/dev/video0'); diff --git a/test/test_proc.c b/test/test_proc.c index 3154da8d..225c19c3 100644 --- a/test/test_proc.c +++ b/test/test_proc.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -33,10 +33,10 @@ #include #include -#include +#include #include "test_images.h" -zebra_processor_t *proc = NULL; +zbar_processor_t *proc = NULL; int input_wait (int timeout) { @@ -46,12 +46,12 @@ int input_wait (int timeout) else printf("waiting indefinitely for input..."); fflush(stdout); - int rc = zebra_processor_user_wait(proc, timeout); + int rc = zbar_processor_user_wait(proc, timeout); if(rc > 0) printf("got input\n"); else if(!rc || (rc < 0 && - zebra_processor_get_error_code(proc) == ZEBRA_ERR_CLOSED)) { + zbar_processor_get_error_code(proc) == ZBAR_ERR_CLOSED)) { printf("timed out\n"); return(0); } @@ -60,7 +60,7 @@ int input_wait (int timeout) int main (int argc, char **argv) { - zebra_set_verbosity(31); + zbar_set_verbosity(31); char *video_dev = NULL; int i, use_threads = 0, use_window = 0; for(i = 1; i < argc; i++) { @@ -76,36 +76,36 @@ int main (int argc, char **argv) video_dev = argv[i]; } - proc = zebra_processor_create(use_threads); + proc = zbar_processor_create(use_threads); assert(proc); printf("created processor (%sthreaded)\n", (!use_threads) ? "un" : ""); - if(zebra_processor_init(proc, NULL, 0)) + if(zbar_processor_init(proc, NULL, 0)) return(2); printf("initialized (video=disabled, window=disabled)\n"); - zebra_image_t *img = zebra_image_create(); - zebra_image_set_size(img, 640, 480); - zebra_image_set_format(img, fourcc('Y','V','1','2')); + zbar_image_t *img = zbar_image_create(); + zbar_image_set_size(img, 640, 480); + zbar_image_set_format(img, fourcc('Y','V','1','2')); test_image_bars(img); - if(zebra_process_image(proc, img) < 0) + if(zbar_process_image(proc, img) < 0) return(3); printf("processed test image\n"); - if(zebra_processor_init(proc, video_dev, use_window)) + if(zbar_processor_init(proc, video_dev, use_window)) return(2); printf("reinitialized (video=%s, window=%s)\n", (video_dev) ? video_dev : "disabled", (use_window) ? "enabled" : "disabled"); - if(zebra_process_image(proc, img) < 0) + if(zbar_process_image(proc, img) < 0) return(3); printf("processed test image\n"); - zebra_image_destroy(img); + zbar_image_destroy(img); if(use_window) { - if(zebra_processor_set_visible(proc, 1)) + if(zbar_processor_set_visible(proc, 1)) return(4); printf("window visible\n"); } @@ -114,14 +114,14 @@ int main (int argc, char **argv) return(5); if(video_dev) { - if(zebra_processor_set_active(proc, 1)) + if(zbar_processor_set_active(proc, 1)) return(3); printf("video activated\n"); if(input_wait((use_window) ? -1 : 4000) < 0) return(5); - if(zebra_processor_set_active(proc, 0)) + if(zbar_processor_set_active(proc, 0)) return(3); printf("video deactivated\n"); @@ -131,14 +131,14 @@ int main (int argc, char **argv) /* FIXME test process_one() */ } - if(zebra_process_image(proc, NULL)) + if(zbar_process_image(proc, NULL)) return(3); printf("flushed image\n"); if(input_wait((use_window && !video_dev) ? -1 : 2500) < 0) return(5); - zebra_processor_destroy(proc); + zbar_processor_destroy(proc); proc = NULL; if(test_image_check_cleanup()) return(32); diff --git a/test/test_pygtk.py b/test/test_pygtk.py index 270a42bb..902b8ff6 100755 --- a/test/test_pygtk.py +++ b/test/test_pygtk.py @@ -1,32 +1,32 @@ #!/usr/bin/env python #------------------------------------------------------------------------ -# Copyright 2008 (c) Jeff Brown +# Copyright 2008-2009 (c) Jeff Brown # -# This file is part of the Zebra Barcode Library. +# This file is part of the ZBar Bar Code Reader. # -# The Zebra Barcode Library is free software; you can redistribute it +# The ZBar Bar Code Reader is free software; you can redistribute it # and/or modify it under the terms of the GNU Lesser Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # -# The Zebra Barcode Library is distributed in the hope that it will be +# The ZBar Bar Code Reader is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License -# along with the Zebra Barcode Library; if not, write to the Free +# along with the ZBar Bar Code Reader; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # -# http://sourceforge.net/projects/zebra +# http://sourceforge.net/projects/zbar #------------------------------------------------------------------------ import sys, os, stat import pygtk, gtk -import zebrapygtk +import zbarpygtk -def decoded(zebra, data): - """callback invoked when a barcode is decoded by the zebra widget. +def decoded(zbar, data): + """callback invoked when a barcode is decoded by the zbar widget. displays the decoded data in the text box """ buf = results.props.buffer @@ -34,44 +34,44 @@ def decoded(zebra, data): buf.insert(end, data + "\n") results.scroll_to_iter(end, 0) -def video_enabled(zebra, param): - """callback invoked when the zebra widget enables or disables +def video_enabled(zbar, param): + """callback invoked when the zbar widget enables or disables video streaming. updates the status button state to reflect the current video state """ - enabled = zebra.get_video_enabled() + enabled = zbar.get_video_enabled() if status_button.get_active() != enabled: status_button.set_active(enabled) -def video_opened(zebra, param): - """callback invoked when the zebra widget opens or closes a video +def video_opened(zbar, param): + """callback invoked when the zbar widget opens or closes a video device. also called when a device is closed due to error. updates the status button state to reflect the current video state """ - opened = zebra.get_video_opened() + opened = zbar.get_video_opened() status_button.set_sensitive(opened) - set_status_label(opened, zebra.get_video_enabled()) + set_status_label(opened, zbar.get_video_enabled()) def video_changed(widget): """callback invoked when a new video device is selected from the - drop-down list. sets the new device for the zebra widget, + drop-down list. sets the new device for the zbar widget, which will eventually cause it to be opened and enabled """ dev = video_list.get_active_text() if dev[0] == '<': dev = '' - zebra.set_video_device(dev) + zbar.set_video_device(dev) def status_button_toggled(button): """callback invoked when the status button changes state - (interactively or programmatically). ensures the zebra widget + (interactively or programmatically). ensures the zbar widget video streaming state is consistent and updates the display of the button to represent the current state """ - opened = zebra.get_video_opened() + opened = zbar.get_video_opened() active = status_button.get_active() - if opened and (active != zebra.get_video_enabled()): - zebra.set_video_enabled(active) + if opened and (active != zbar.get_video_enabled()): + zbar.set_video_enabled(active) set_status_label(opened, active) if active: status_image.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_BUTTON) @@ -81,7 +81,7 @@ def status_button_toggled(button): def open_button_clicked(button): """callback invoked when the 'Open' button is clicked. pops up an 'Open File' dialog which the user may use to select an image file. - if the image is successfully opened, it is passed to the zebra + if the image is successfully opened, it is passed to the zbar widget which displays it and scans it for barcodes. results are returned using the same hook used to report video results """ @@ -97,7 +97,7 @@ def open_button_clicked(button): open_file = dialog.get_filename() pixbuf = gtk.gdk.pixbuf_new_from_file(open_file) if pixbuf: - zebra.scan_image(pixbuf) + zbar.scan_image(pixbuf) finally: dialog.destroy() @@ -116,7 +116,7 @@ def set_status_label(opened, enabled): if len(sys.argv) > 1: video_device = sys.argv[1] -# threads *must* be properly initialized to use zebrapygtk +# threads *must* be properly initialized to use zbarpygtk gtk.gdk.threads_init() gtk.gdk.threads_enter() @@ -125,8 +125,8 @@ def set_status_label(opened, enabled): window.set_border_width(8) window.connect("destroy", gtk.main_quit) -zebra = zebrapygtk.Gtk() -zebra.connect("decoded-text", decoded) +zbar = zbarpygtk.Gtk() +zbar.connect("decoded-text", decoded) # video device list combo box video_list = gtk.combo_box_new_text() @@ -140,8 +140,8 @@ def set_status_label(opened, enabled): # bind status button state and video state status_button.connect("toggled", status_button_toggled) -zebra.connect("notify::video-enabled", video_enabled) -zebra.connect("notify::video-opened", video_opened) +zbar.connect("notify::video-enabled", video_enabled) +zbar.connect("notify::video-opened", video_opened) # open image file button open_button = gtk.Button(stock=gtk.STOCK_OPEN) @@ -182,11 +182,11 @@ def set_status_label(opened, enabled): # combine inputs, scanner, and results vertically vbox = gtk.VBox(spacing=8) vbox.pack_start(hbox, expand=False) -vbox.pack_start(zebra) +vbox.pack_start(zbar) vbox.pack_start(results, expand=False) window.add(vbox) -window.set_geometry_hints(zebra, min_width=320, min_height=240) +window.set_geometry_hints(zbar, min_width=320, min_height=240) window.show_all() gtk.main() diff --git a/test/test_qt.cpp b/test/test_qt.cpp index 628ebc89..96d2f954 100644 --- a/test/test_qt.cpp +++ b/test/test_qt.cpp @@ -1,24 +1,24 @@ //------------------------------------------------------------------------ -// Copyright 2008 (c) Jeff Brown +// Copyright 2008-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ #include @@ -29,7 +29,7 @@ #include #include #include -#include +#include #define TEST_IMAGE_FORMATS \ "Image Files (*.png *.jpg *.jpeg *.bmp *.gif *.ppm *.pgm *.pbm *.tiff *.xpm *.xbm)" @@ -40,7 +40,7 @@ int scan_video(void *add_device, const char *default_device); } -class TestQZebra : public QWidget +class TestQZBar : public QWidget { Q_OBJECT @@ -52,7 +52,7 @@ class TestQZebra : public QWidget } public: - TestQZebra (const char *default_device) + TestQZBar (const char *default_device) { // drop-down list of video devices QComboBox *videoList = new QComboBox; @@ -84,8 +84,8 @@ class TestQZebra : public QWidget hbox->addWidget(openButton, 1); // video barcode scanner - zebra = new zebra::QZebra; - zebra->setAcceptDrops(true); + zbar = new zbar::QZBar; + zbar->setAcceptDrops(true); // text box for results QTextEdit *results = new QTextEdit; @@ -93,7 +93,7 @@ class TestQZebra : public QWidget QVBoxLayout *vbox = new QVBoxLayout; vbox->addLayout(hbox); - vbox->addWidget(zebra); + vbox->addWidget(zbar); vbox->addWidget(results); setLayout(vbox); @@ -103,25 +103,25 @@ class TestQZebra : public QWidget // directly connect combo box change signal to scanner video open connect(videoList, SIGNAL(currentIndexChanged(const QString&)), - zebra, SLOT(setVideoDevice(const QString&))); + zbar, SLOT(setVideoDevice(const QString&))); // directly connect status button state to video enabled state connect(statusButton, SIGNAL(toggled(bool)), - zebra, SLOT(setVideoEnabled(bool))); + zbar, SLOT(setVideoEnabled(bool))); // also update status button state when video is opened/closed - connect(zebra, SIGNAL(videoOpened(bool)), + connect(zbar, SIGNAL(videoOpened(bool)), statusButton, SLOT(setEnabled(bool))); // enable/disable status button when video is opened/closed - connect(zebra, SIGNAL(videoOpened(bool)), + connect(zbar, SIGNAL(videoOpened(bool)), statusButton, SLOT(setChecked(bool))); // prompt for image file to scan when openButton is clicked connect(openButton, SIGNAL(clicked()), SLOT(openImage())); // directly connect video scanner decode result to display in text box - connect(zebra, SIGNAL(decodedText(const QString&)), + connect(zbar, SIGNAL(decodedText(const QString&)), results, SLOT(append(const QString&))); if(active >= 0) @@ -134,12 +134,12 @@ public Q_SLOTS: file = QFileDialog::getOpenFileName(this, "Open Image", file, TEST_IMAGE_FORMATS); if(!file.isEmpty()) - zebra->scanImage(QImage(file)); + zbar->scanImage(QImage(file)); } private: QString file; - zebra::QZebra *zebra; + zbar::QZBar *zbar; }; #include "moc_test_qt.h" @@ -152,7 +152,7 @@ int main (int argc, char *argv[]) if(argc > 1) dev = argv[1]; - TestQZebra window(dev); + TestQZBar window(dev); window.show(); return(app.exec()); } diff --git a/test/test_video.c b/test/test_video.c index 5e9eb8a1..fa80b6bb 100644 --- a/test/test_video.c +++ b/test/test_video.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -33,15 +33,15 @@ #include #include -#include +#include #include "processor.h" /* reuse some processor guts */ #include "test_images.h" -zebra_processor_t proc; +zbar_processor_t proc; int main (int argc, char *argv[]) { - zebra_set_verbosity(10); + zbar_set_verbosity(10); const char *dev = "/dev/video0"; if(argc > 1) { @@ -57,15 +57,15 @@ int main (int argc, char *argv[]) } memset(&proc, 0, sizeof(proc)); - proc.video = zebra_video_create(); - proc.window = zebra_window_create(); + proc.video = zbar_video_create(); + proc.window = zbar_window_create(); if(!proc.video || !proc.window) { fprintf(stderr, "unable to allocate memory?!\n"); return(1); } - if(zebra_video_open(proc.video, dev)) { - zebra_video_error_spew(proc.video, 0); + if(zbar_video_open(proc.video, dev)) { + zbar_video_error_spew(proc.video, 0); fprintf(stderr, "ERROR: unable to access your video device\n" "this program requires video capture support using" @@ -81,65 +81,65 @@ int main (int argc, char *argv[]) return(1); } printf("opened video device: %s (fd=%d)\n", - dev, zebra_video_get_fd(proc.video)); + dev, zbar_video_get_fd(proc.video)); - if(_zebra_window_open(&proc, "zebra video test", 640, 480) || - zebra_window_attach(proc.window, proc.display, proc.xwin) || - _zebra_window_set_visible(&proc, 1)) + if(_zbar_window_open(&proc, "zbar video test", 640, 480) || + zbar_window_attach(proc.window, proc.display, proc.xwin) || + _zbar_window_set_visible(&proc, 1)) fprintf(stderr, "WARNING: failed to open test window\n"); - else if(zebra_negotiate_format(proc.video, proc.window)) + else if(zbar_negotiate_format(proc.video, proc.window)) fprintf(stderr, "WARNING: failed to negotiate compatible format\n"); - zebra_image_t *img = zebra_image_create(); - zebra_image_set_size(img, 640, 480); - zebra_image_set_format(img, fourcc('Y','V','1','2')); + zbar_image_t *img = zbar_image_create(); + zbar_image_set_size(img, 640, 480); + zbar_image_set_format(img, fourcc('Y','V','1','2')); test_image_bars(img); - if(proc.display && zebra_window_draw(proc.window, img)) { + if(proc.display && zbar_window_draw(proc.window, img)) { fprintf(stderr, "ERROR: drawing image\n"); - return(zebra_window_error_spew(proc.window, 0)); + return(zbar_window_error_spew(proc.window, 0)); } - if(zebra_video_enable(proc.video, 1)) { + if(zbar_video_enable(proc.video, 1)) { fprintf(stderr, "ERROR: starting video stream\n"); - return(zebra_video_error_spew(proc.video, 0)); + return(zbar_video_error_spew(proc.video, 0)); } - zebra_image_t *image = zebra_video_next_image(proc.video); + zbar_image_t *image = zbar_video_next_image(proc.video); if(!image) { fprintf(stderr, "ERROR: unable to capture image\n"); - return(zebra_video_error_spew(proc.video, 0)); + return(zbar_video_error_spew(proc.video, 0)); } - uint32_t format = zebra_image_get_format(image); - unsigned width = zebra_image_get_width(image); - unsigned height = zebra_image_get_height(image); - const uint8_t *data = zebra_image_get_data(image); + uint32_t format = zbar_image_get_format(image); + unsigned width = zbar_image_get_width(image); + unsigned height = zbar_image_get_height(image); + const uint8_t *data = zbar_image_get_data(image); printf("captured image: %d x %d %.4s @%p\n", width, height, (char*)&format, data); - if(proc.display && zebra_window_draw(proc.window, image)) { + if(proc.display && zbar_window_draw(proc.window, image)) { fprintf(stderr, "ERROR: drawing image\n"); - return(zebra_window_error_spew(proc.window, 0)); + return(zbar_window_error_spew(proc.window, 0)); } - zebra_image_destroy(image); + zbar_image_destroy(image); printf("\nstreaming...click to continue\n"); struct timespec start, end; clock_gettime(CLOCK_REALTIME, &start); int n = 0; while(1) { - if(proc.display && _zebra_window_handle_events(&proc, 0)) + if(proc.display && _zbar_window_handle_events(&proc, 0)) break; - zebra_image_t *image = zebra_video_next_image(proc.video); + zbar_image_t *image = zbar_video_next_image(proc.video); if(!image) { fprintf(stderr, "ERROR: unable to capture image\n"); - return(zebra_video_error_spew(proc.video, 0)); + return(zbar_video_error_spew(proc.video, 0)); } - if(proc.display && zebra_window_draw(proc.window, image)) { + if(proc.display && zbar_window_draw(proc.window, image)) { fprintf(stderr, "ERROR: drawing image\n"); - return(zebra_window_error_spew(proc.window, 0)); + return(zbar_window_error_spew(proc.window, 0)); } - zebra_image_destroy(image); + zbar_image_destroy(image); n++; } clock_gettime(CLOCK_REALTIME, &end); @@ -148,24 +148,24 @@ int main (int argc, char *argv[]) double fps = n / ms; printf("\nprocessed %d images in %gs @%gfps\n", n, ms, fps); - if(zebra_video_enable(proc.video, 0)) { + if(zbar_video_enable(proc.video, 0)) { fprintf(stderr, "ERROR: while stopping video stream\n"); - return(zebra_video_error_spew(proc.video, 0)); + return(zbar_video_error_spew(proc.video, 0)); } printf("\nvideo support verified\n\n"); - if(proc.display && zebra_window_draw(proc.window, img)) { + if(proc.display && zbar_window_draw(proc.window, img)) { fprintf(stderr, "error drawing image\n"); - return(zebra_window_error_spew(proc.window, 0)); + return(zbar_window_error_spew(proc.window, 0)); } - zebra_image_destroy(img); + zbar_image_destroy(img); printf("click to end...\n"); if(proc.display) - _zebra_window_handle_events(&proc, 1); + _zbar_window_handle_events(&proc, 1); - zebra_window_destroy(proc.window); - zebra_video_destroy(proc.video); + zbar_window_destroy(proc.window); + zbar_video_destroy(proc.video); if(test_image_check_cleanup()) return(32); diff --git a/test/test_window.c b/test/test_window.c index 4dbd386d..9beebe17 100644 --- a/test/test_window.c +++ b/test/test_window.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -31,26 +31,26 @@ #include #include -#include +#include #include "processor.h" #include "test_images.h" -extern int _zebra_draw_logo(zebra_image_t *img); +extern int _zbar_draw_logo(zbar_image_t *img); -zebra_processor_t proc; +zbar_processor_t proc; static void input_wait () { fprintf(stderr, "waiting for input...\n"); - _zebra_window_handle_events(&proc, 1); + _zbar_window_handle_events(&proc, 1); } int main (int argc, char *argv[]) { - zebra_set_verbosity(32); + zbar_set_verbosity(32); - err_init(&proc.err, ZEBRA_MOD_PROCESSOR); - proc.window = zebra_window_create(); + err_init(&proc.err, ZBAR_MOD_PROCESSOR); + proc.window = zbar_window_create(); if(!proc.window) { fprintf(stderr, "unable to allocate memory?!\n"); return(1); @@ -59,17 +59,17 @@ int main (int argc, char *argv[]) int width = 640 * .25; int height = 480 * .25; - if(_zebra_window_open(&proc, "zebra window test", width, height) || - zebra_window_attach(proc.window, proc.display, proc.xwin) || - _zebra_window_set_visible(&proc, 1)) { + if(_zbar_window_open(&proc, "zbar window test", width, height) || + zbar_window_attach(proc.window, proc.display, proc.xwin) || + _zbar_window_set_visible(&proc, 1)) { fprintf(stderr, "failed to open test window\n"); return(1); } input_wait(); - zebra_image_t *img = zebra_image_create(); - zebra_image_set_size(img, width, height); - /*zebra_image_set_format(img, fourcc('Y','8','0','0'));*/ + zbar_image_t *img = zbar_image_create(); + zbar_image_set_size(img, width, height); + /*zbar_image_set_format(img, fourcc('Y','8','0','0'));*/ /*fourcc('I','4','2','0')*/ /*fourcc('Y','V','1','2')*/ /*fourcc('U','Y','V','Y')*/ @@ -77,14 +77,14 @@ int main (int argc, char *argv[]) /*fourcc('R','G','B','3')*/ /*fourcc('Y','8','0','0')*/ /*test_image_bars(img);*/ - _zebra_draw_logo(img); + _zbar_draw_logo(img); - if(zebra_window_draw(proc.window, img) || - zebra_window_redraw(proc.window)) { + if(zbar_window_draw(proc.window, img) || + zbar_window_redraw(proc.window)) { fprintf(stderr, "error drawing image\n"); return(1); } - zebra_image_destroy(img); + zbar_image_destroy(img); img = NULL; input_wait(); @@ -92,7 +92,7 @@ int main (int argc, char *argv[]) /* FIXME display cmd arg images? or formats? */ fprintf(stderr, "cleaning up\n"); - zebra_window_destroy(proc.window); + zbar_window_destroy(proc.window); /* FIXME destructor check? */ if(test_image_check_cleanup()) diff --git a/zebra-gtk.pc.in b/zbar-gtk.pc.in similarity index 60% rename from zebra-gtk.pc.in rename to zbar-gtk.pc.in index b68b7dd1..fc712a25 100644 --- a/zebra-gtk.pc.in +++ b/zbar-gtk.pc.in @@ -3,10 +3,10 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: zebra-gtk +Name: zbar-gtk Description: bar code scanning and decoding GTK widget -URL: http://zebra.sourceforge.net +URL: http://zbar.sourceforge.net Version: @VERSION@ -Requires: zebra, gtk+-2.0, gthread-2.0 -Libs: -L${libdir} -lzebragtk +Requires: zbar, gtk+-2.0, gthread-2.0 +Libs: -L${libdir} -lzbargtk Cflags: -I${includedir} diff --git a/zebra-qt.pc.in b/zbar-qt.pc.in similarity index 60% rename from zebra-qt.pc.in rename to zbar-qt.pc.in index 1bcd5d78..5eadf47a 100644 --- a/zebra-qt.pc.in +++ b/zbar-qt.pc.in @@ -3,10 +3,10 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: zebra-qt +Name: zbar-qt Description: bar code scanning and decoding Qt4 widget -URL: http://zebra.sourceforge.net +URL: http://zbar.sourceforge.net Version: @VERSION@ -Requires: zebra, QtCore >= 4, QtGui >= 4 -Libs: -L${libdir} -lzebraqt +Requires: zbar, QtCore >= 4, QtGui >= 4 +Libs: -L${libdir} -lzbarqt Cflags: -I${includedir} diff --git a/zebra.pc.in b/zbar.pc.in similarity index 70% rename from zebra.pc.in rename to zbar.pc.in index 45449bee..953a5ca9 100644 --- a/zebra.pc.in +++ b/zbar.pc.in @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: zebra +Name: zbar Description: bar code scanning and decoding -URL: http://zebra.sourceforge.net +URL: http://zbar.sourceforge.net Version: @VERSION@ -Libs: -L${libdir} -lzebra +Libs: -L${libdir} -lzbar Cflags: -I${includedir} diff --git a/zebra.spec.in b/zbar.spec.in similarity index 51% rename from zebra.spec.in rename to zbar.spec.in index d50c59f2..89931cd2 100644 --- a/zebra.spec.in +++ b/zbar.spec.in @@ -1,23 +1,23 @@ -Name: zebra -Summary: bar code scanning and decoding library +Name: zbar +Summary: bar code scanning and decoding Version: @VERSION@ Release: 1 License: LGPL Group: Development/Libraries -URL: http://zebra.sourceforge.net +URL: http://zbar.sourceforge.net Packager: Vit Hrachovy -Source: zebra-%{version}.tar.gz +Source: zbar-%{version}.tar.gz Requires: ImageMagick-c++ BuildPreReq: pkgconfig, libX11-devel, python-devel, gtk2-devel, pygtk2-devel, qt-devel >= 4, ImageMagick-c++-devel Prefix: %{_prefix} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. %package devel Group: Development/Libraries @@ -25,11 +25,11 @@ Summary: bar code library extra development files Requires: %{name} = %{version} %description devel -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains header files and additional libraries used for developing applications that read bar codes with this library. @@ -40,11 +40,11 @@ Summary: bar code reader GTK widget Requires: %{name} = %{version}, gtk2 %description gtk -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains a bar code scanning widget for use with GUI applications based on GTK+-2.0. @@ -55,11 +55,11 @@ Summary: bar code reader GTK widget extra development files Requires: %{name}-gtk = %{version}, %{name}-devel = %{version}, gtk2-devel %description gtk-devel -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains header files and additional libraries used for developing GUI applications based on GTK+-2.0 that include a bar code @@ -71,11 +71,11 @@ Summary: bar code reader PyGTK widget Requires: %{name} = %{version}, pygtk2 %description pygtk -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains a bar code scanning widget for use in GUI applications based on PyGTK. @@ -86,11 +86,11 @@ Summary: bar code reader Qt widget Requires: %{name} = %{version}, qt >= 4 %description qt -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains a bar code scanning widget for use with GUI applications based on Qt4. @@ -101,18 +101,18 @@ Summary: bar code reader Qt widget extra development files Requires: %{name}-qt = %{version}, %{name}-devel = %{version}, qt-devel >= 4 %description qt-devel -The Zebra Barcode Reader library is a library for scanning and -decoding bar codes from various sources such as video streams, image -files or raw intensity sensors. It supports EAN, UPC, Code 128, Code -39 and Interleaved 2 of 5. The flexible, layered architecture features -a fast, streaming interface with a minimal memory footprint. +The ZBar Barcode Reader is a library for scanning and decoding bar +codes from various sources such as video streams, image files or raw +intensity sensors. It supports EAN, UPC, Code 128, Code 39 and +Interleaved 2 of 5. The flexible, layered architecture features a +fast, streaming interface with a minimal memory footprint. This package contains header files and additional libraries used for developing GUI applications based on Qt4 that include a bar code scanning widget. %prep -%setup -q -n zebra-%{version} +%setup -q -n zbar-%{version} %build ./configure --host=%{_host} --build=%{_build} \ @@ -137,9 +137,9 @@ ldconfig %files %defattr(-,root,root) -%{_bindir}/zebraimg -%{_bindir}/zebracam -%{_libdir}/libzebra.so.* +%{_bindir}/zbarimg +%{_bindir}/zbarcam +%{_libdir}/libzbar.so.* %{_datadir}/man/man1/* %doc %{_docdir}/%{name}-%{version}/COPYING.LIB %doc %{_docdir}/%{name}-%{version}/HACKING @@ -150,32 +150,32 @@ ldconfig %files devel %defattr(-,root,root) -%{_libdir}/libzebra.la -%{_libdir}/libzebra.a -%{_libdir}/libzebra.so -%{_libdir}/pkgconfig/zebra.pc -%{_includedir}/zebra.h -%{_includedir}/zebra/Exception.h -%{_includedir}/zebra/Symbol.h -%{_includedir}/zebra/Image.h -%{_includedir}/zebra/Scanner.h -%{_includedir}/zebra/Decoder.h -%{_includedir}/zebra/ImageScanner.h -%{_includedir}/zebra/Video.h -%{_includedir}/zebra/Window.h -%{_includedir}/zebra/Processor.h +%{_libdir}/libzbar.la +%{_libdir}/libzbar.a +%{_libdir}/libzbar.so +%{_libdir}/pkgconfig/zbar.pc +%{_includedir}/zbar.h +%{_includedir}/zbar/Exception.h +%{_includedir}/zbar/Symbol.h +%{_includedir}/zbar/Image.h +%{_includedir}/zbar/Scanner.h +%{_includedir}/zbar/Decoder.h +%{_includedir}/zbar/ImageScanner.h +%{_includedir}/zbar/Video.h +%{_includedir}/zbar/Window.h +%{_includedir}/zbar/Processor.h %files gtk %defattr(-,root,root) -%{_libdir}/libzebragtk.so.* +%{_libdir}/libzbargtk.so.* %files gtk-devel %defattr(-,root,root) -%{_libdir}/libzebragtk.la -%{_libdir}/libzebragtk.a -%{_libdir}/libzebragtk.so -%{_libdir}/pkgconfig/zebra-gtk.pc -%{_includedir}/zebra/zebragtk.h +%{_libdir}/libzbargtk.la +%{_libdir}/libzbargtk.a +%{_libdir}/libzbargtk.so +%{_libdir}/pkgconfig/zbar-gtk.pc +%{_includedir}/zbar/zbargtk.h %files pygtk %defattr(-,root,root) @@ -183,17 +183,20 @@ ldconfig %files qt %defattr(-,root,root) -%{_libdir}/libzebraqt.so.* +%{_libdir}/libzbarqt.so.* %files qt-devel %defattr(-,root,root) -%{_libdir}/libzebraqt.la -%{_libdir}/libzebraqt.a -%{_libdir}/libzebraqt.so -%{_libdir}/pkgconfig/zebra-qt.pc -%{_includedir}/zebra/QZebra*.h +%{_libdir}/libzbarqt.la +%{_libdir}/libzbarqt.a +%{_libdir}/libzbarqt.so +%{_libdir}/pkgconfig/zbar-qt.pc +%{_includedir}/zbar/QZBar*.h %changelog +* Thu Apr 16 2009 spadix +- project name change + * Thu Jul 24 2008 spadix - version 0.5 updates (new widget packages) diff --git a/zbar/Makefile.am.inc b/zbar/Makefile.am.inc new file mode 100644 index 00000000..0f142b32 --- /dev/null +++ b/zbar/Makefile.am.inc @@ -0,0 +1,62 @@ +lib_LTLIBRARIES += zbar/libzbar.la +zbar_libzbar_la_CPPFLAGS = -I$(srcdir)/zbar $(AM_CPPFLAGS) +zbar_libzbar_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION) \ + -export-symbols-regex "^(zbar|_zbar.*_error)_.*" $(AM_LDFLAGS) +zbar_libzbar_la_LIBADD = + +zbar_libzbar_la_SOURCES = zbar/debug.h zbar/config.c \ + zbar/error.h zbar/error.c zbar/symbol.h zbar/symbol.c \ + zbar/image.h zbar/image.c zbar/convert.c zbar/logo.c \ + zbar/window.h zbar/window.c zbar/video.h zbar/video.c \ + zbar/img_scanner.c zbar/scanner.c \ + zbar/decoder.h zbar/decoder.c + +if HAVE_POLL +zbar_libzbar_la_SOURCES += zbar/processor.h zbar/processor.c +endif + +if ENABLE_EAN +zbar_libzbar_la_SOURCES += zbar/decoder/ean.h zbar/decoder/ean.c +endif +if ENABLE_CODE128 +zbar_libzbar_la_SOURCES += zbar/decoder/code128.h zbar/decoder/code128.c +endif +if ENABLE_CODE39 +zbar_libzbar_la_SOURCES += zbar/decoder/code39.h zbar/decoder/code39.c +endif +if ENABLE_I25 +zbar_libzbar_la_SOURCES += zbar/decoder/i25.h zbar/decoder/i25.c +endif +if ENABLE_PDF417 +zbar_libzbar_la_SOURCES += zbar/decoder/pdf417.h zbar/decoder/pdf417.c \ + zbar/decoder/pdf417_hash.h +endif + +if HAVE_V4L1 +zbar_libzbar_la_SOURCES += zbar/video/v4l1.c +if HAVE_V4L2 +zbar_libzbar_la_SOURCES += zbar/video/v4l2.c +endif +else +zbar_libzbar_la_SOURCES += zbar/video/null.c +endif + +if HAVE_JPEG +zbar_libzbar_la_SOURCES += zbar/jpeg.c +endif + +if HAVE_X +zbar_libzbar_la_SOURCES += zbar/window/x.c zbar/window/ximage.c +zbar_libzbar_la_CPPFLAGS += $(X_CFLAGS) +zbar_libzbar_la_LDFLAGS += $(X_LIBS) +zbar_libzbar_la_LIBADD += $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS) +if HAVE_XV +zbar_libzbar_la_SOURCES += zbar/window/xv.c +zbar_libzbar_la_LIBADD += $(XV_LIBS) +endif +else +zbar_libzbar_la_SOURCES += zbar/window/null.c +endif + +zbar_libzbar_la_LDFLAGS += $(AM_LDFLAGS) +zbar_libzbar_la_LIBADD += $(AM_LIBADD) diff --git a/zebra/config.c b/zbar/config.c similarity index 71% rename from zebra/config.c rename to zbar/config.c index b6aa931e..df854d38 100644 --- a/zebra/config.c +++ b/zbar/config.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -27,11 +27,11 @@ #include #include -#include +#include -int zebra_parse_config (const char *cfgstr, - zebra_symbol_type_t *sym, - zebra_config_t *cfg, +int zbar_parse_config (const char *cfgstr, + zbar_symbol_type_t *sym, + zbar_config_t *cfg, int *val) { if(!cfgstr) @@ -45,40 +45,40 @@ int zebra_parse_config (const char *cfgstr, else if(len < 3) return(1); else if(!strncmp(cfgstr, "upca", len)) - *sym = ZEBRA_UPCA; + *sym = ZBAR_UPCA; else if(!strncmp(cfgstr, "upce", len)) - *sym = ZEBRA_UPCE; + *sym = ZBAR_UPCE; else if(!strncmp(cfgstr, "ean13", len)) - *sym = ZEBRA_EAN13; + *sym = ZBAR_EAN13; else if(!strncmp(cfgstr, "ean8", len)) - *sym = ZEBRA_EAN8; + *sym = ZBAR_EAN8; else if(!strncmp(cfgstr, "i25", len)) - *sym = ZEBRA_I25; + *sym = ZBAR_I25; else if(len < 4) return(1); else if(!strncmp(cfgstr, "scanner", len)) - *sym = ZEBRA_PARTIAL; /* FIXME lame */ + *sym = ZBAR_PARTIAL; /* FIXME lame */ else if(!strncmp(cfgstr, "isbn13", len)) - *sym = ZEBRA_ISBN13; + *sym = ZBAR_ISBN13; else if(!strncmp(cfgstr, "isbn10", len)) - *sym = ZEBRA_ISBN10; + *sym = ZBAR_ISBN10; #if 0 /* FIXME addons are configured per-main symbol type */ else if(!strncmp(cfgstr, "addon2", len)) - *sym = ZEBRA_ADDON2; + *sym = ZBAR_ADDON2; else if(!strncmp(cfgstr, "addon5", len)) - *sym = ZEBRA_ADDON5; + *sym = ZBAR_ADDON5; #endif else if(len < 6) return(1); else if(!strncmp(cfgstr, "code39", len)) - *sym = ZEBRA_CODE39; + *sym = ZBAR_CODE39; else if(!strncmp(cfgstr, "pdf417", len)) - *sym = ZEBRA_PDF417; + *sym = ZBAR_PDF417; else if(len < 7) return(1); else if(!strncmp(cfgstr, "code128", len)) - *sym = ZEBRA_CODE128; + *sym = ZBAR_CODE128; else return(1); cfgstr = dot + 1; @@ -103,29 +103,29 @@ int zebra_parse_config (const char *cfgstr, if(len < 1) return(1); else if(!strncmp(cfgstr, "y-density", len)) - *cfg = ZEBRA_CFG_Y_DENSITY; + *cfg = ZBAR_CFG_Y_DENSITY; else if(!strncmp(cfgstr, "x-density", len)) - *cfg = ZEBRA_CFG_X_DENSITY; + *cfg = ZBAR_CFG_X_DENSITY; else if(len < 2) return(1); else if(!strncmp(cfgstr, "enable", len)) - *cfg = ZEBRA_CFG_ENABLE; + *cfg = ZBAR_CFG_ENABLE; else if(len < 3) return(1); else if(!strncmp(cfgstr, "disable", len)) { - *cfg = ZEBRA_CFG_ENABLE; + *cfg = ZBAR_CFG_ENABLE; negate = !negate; /* no-disable ?!? */ } else if(!strncmp(cfgstr, "min-length", len)) - *cfg = ZEBRA_CFG_MIN_LEN; + *cfg = ZBAR_CFG_MIN_LEN; else if(!strncmp(cfgstr, "max-length", len)) - *cfg = ZEBRA_CFG_MAX_LEN; + *cfg = ZBAR_CFG_MAX_LEN; else if(!strncmp(cfgstr, "ascii", len)) - *cfg = ZEBRA_CFG_ASCII; + *cfg = ZBAR_CFG_ASCII; else if(!strncmp(cfgstr, "add-check", len)) - *cfg = ZEBRA_CFG_ADD_CHECK; + *cfg = ZBAR_CFG_ADD_CHECK; else if(!strncmp(cfgstr, "emit-check", len)) - *cfg = ZEBRA_CFG_EMIT_CHECK; + *cfg = ZBAR_CFG_EMIT_CHECK; else return(1); diff --git a/zebra/convert.c b/zbar/convert.c similarity index 77% rename from zebra/convert.c rename to zbar/convert.c index 3fc7b5f4..07aba955 100644 --- a/zebra/convert.c +++ b/zbar/convert.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "image.h" @@ -29,10 +29,10 @@ */ #define RGB_BITS(off, size) ((((8 - (size)) & 0x7) << 5) | ((off) & 0x1f)) -typedef void (conversion_handler_t)(zebra_image_t*, - const zebra_format_def_t*, - const zebra_image_t*, - const zebra_format_def_t*); +typedef void (conversion_handler_t)(zbar_image_t*, + const zbar_format_def_t*, + const zbar_image_t*, + const zbar_format_def_t*); typedef struct conversion_def_s { int cost; /* conversion "badness" */ @@ -107,62 +107,62 @@ static const uint32_t format_prefs[] = { }; static const int num_format_prefs = - sizeof(format_prefs) / sizeof(zebra_format_def_t); + sizeof(format_prefs) / sizeof(zbar_format_def_t); /* format definitions */ -static const zebra_format_def_t format_defs[] = { +static const zbar_format_def_t format_defs[] = { - { fourcc('R','G','B','4'), ZEBRA_FMT_RGB_PACKED, + { fourcc('R','G','B','4'), ZBAR_FMT_RGB_PACKED, { { 4, RGB_BITS(8, 8), RGB_BITS(16, 8), RGB_BITS(24, 8) } } }, - { fourcc('B','G','R','1'), ZEBRA_FMT_RGB_PACKED, + { fourcc('B','G','R','1'), ZBAR_FMT_RGB_PACKED, { { 1, RGB_BITS(0, 3), RGB_BITS(3, 3), RGB_BITS(6, 2) } } }, - { fourcc('4','2','2','P'), ZEBRA_FMT_YUV_PLANAR, { { 1, 0, 0 /*UV*/ } } }, - { fourcc('Y','8','0','0'), ZEBRA_FMT_GRAY, }, - { fourcc('Y','U','Y','2'), ZEBRA_FMT_YUV_PACKED, + { fourcc('4','2','2','P'), ZBAR_FMT_YUV_PLANAR, { { 1, 0, 0 /*UV*/ } } }, + { fourcc('Y','8','0','0'), ZBAR_FMT_GRAY, }, + { fourcc('Y','U','Y','2'), ZBAR_FMT_YUV_PACKED, { { 1, 0, 0, /*YUYV*/ } } }, - { fourcc('J','P','E','G'), ZEBRA_FMT_JPEG, }, - { fourcc('Y','V','Y','U'), ZEBRA_FMT_YUV_PACKED, + { fourcc('J','P','E','G'), ZBAR_FMT_JPEG, }, + { fourcc('Y','V','Y','U'), ZBAR_FMT_YUV_PACKED, { { 1, 0, 1, /*YVYU*/ } } }, - { fourcc('Y','8', 0 , 0 ), ZEBRA_FMT_GRAY, }, - { fourcc('N','V','2','1'), ZEBRA_FMT_YUV_NV, { { 1, 1, 1 /*VU*/ } } }, - { fourcc('N','V','1','2'), ZEBRA_FMT_YUV_NV, { { 1, 1, 0 /*UV*/ } } }, - { fourcc('B','G','R','3'), ZEBRA_FMT_RGB_PACKED, + { fourcc('Y','8', 0 , 0 ), ZBAR_FMT_GRAY, }, + { fourcc('N','V','2','1'), ZBAR_FMT_YUV_NV, { { 1, 1, 1 /*VU*/ } } }, + { fourcc('N','V','1','2'), ZBAR_FMT_YUV_NV, { { 1, 1, 0 /*UV*/ } } }, + { fourcc('B','G','R','3'), ZBAR_FMT_RGB_PACKED, { { 3, RGB_BITS(16, 8), RGB_BITS(8, 8), RGB_BITS(0, 8) } } }, - { fourcc('Y','V','U','9'), ZEBRA_FMT_YUV_PLANAR, { { 2, 2, 1 /*VU*/ } } }, - { fourcc('R','G','B','O'), ZEBRA_FMT_RGB_PACKED, + { fourcc('Y','V','U','9'), ZBAR_FMT_YUV_PLANAR, { { 2, 2, 1 /*VU*/ } } }, + { fourcc('R','G','B','O'), ZBAR_FMT_RGB_PACKED, { { 2, RGB_BITS(10, 5), RGB_BITS(5, 5), RGB_BITS(0, 5) } } }, - { fourcc('R','G','B','Q'), ZEBRA_FMT_RGB_PACKED, + { fourcc('R','G','B','Q'), ZBAR_FMT_RGB_PACKED, { { 2, RGB_BITS(2, 5), RGB_BITS(13, 5), RGB_BITS(8, 5) } } }, - { fourcc('G','R','E','Y'), ZEBRA_FMT_GRAY, }, - { fourcc( 3 , 0 , 0 , 0 ), ZEBRA_FMT_RGB_PACKED, + { fourcc('G','R','E','Y'), ZBAR_FMT_GRAY, }, + { fourcc( 3 , 0 , 0 , 0 ), ZBAR_FMT_RGB_PACKED, { { 4, RGB_BITS(16, 8), RGB_BITS(8, 8), RGB_BITS(0, 8) } } }, - { fourcc('Y','8',' ',' '), ZEBRA_FMT_GRAY, }, - { fourcc('I','4','2','0'), ZEBRA_FMT_YUV_PLANAR, { { 1, 1, 0 /*UV*/ } } }, - { fourcc('R','G','B','1'), ZEBRA_FMT_RGB_PACKED, + { fourcc('Y','8',' ',' '), ZBAR_FMT_GRAY, }, + { fourcc('I','4','2','0'), ZBAR_FMT_YUV_PLANAR, { { 1, 1, 0 /*UV*/ } } }, + { fourcc('R','G','B','1'), ZBAR_FMT_RGB_PACKED, { { 1, RGB_BITS(5, 3), RGB_BITS(2, 3), RGB_BITS(0, 2) } } }, - { fourcc('Y','U','1','2'), ZEBRA_FMT_YUV_PLANAR, { { 1, 1, 0 /*UV*/ } } }, - { fourcc('Y','V','1','2'), ZEBRA_FMT_YUV_PLANAR, { { 1, 1, 1 /*VU*/ } } }, - { fourcc('R','G','B','3'), ZEBRA_FMT_RGB_PACKED, + { fourcc('Y','U','1','2'), ZBAR_FMT_YUV_PLANAR, { { 1, 1, 0 /*UV*/ } } }, + { fourcc('Y','V','1','2'), ZBAR_FMT_YUV_PLANAR, { { 1, 1, 1 /*VU*/ } } }, + { fourcc('R','G','B','3'), ZBAR_FMT_RGB_PACKED, { { 3, RGB_BITS(0, 8), RGB_BITS(8, 8), RGB_BITS(16, 8) } } }, - { fourcc('R','4','4','4'), ZEBRA_FMT_RGB_PACKED, + { fourcc('R','4','4','4'), ZBAR_FMT_RGB_PACKED, { { 2, RGB_BITS(8, 4), RGB_BITS(4, 4), RGB_BITS(0, 4) } } }, - { fourcc('B','G','R','4'), ZEBRA_FMT_RGB_PACKED, + { fourcc('B','G','R','4'), ZBAR_FMT_RGB_PACKED, { { 4, RGB_BITS(16, 8), RGB_BITS(8, 8), RGB_BITS(0, 8) } } }, - { fourcc('Y','U','V','9'), ZEBRA_FMT_YUV_PLANAR, { { 2, 2, 0 /*UV*/ } } }, - { fourcc('M','J','P','G'), ZEBRA_FMT_JPEG, }, - { fourcc('4','1','1','P'), ZEBRA_FMT_YUV_PLANAR, { { 2, 0, 0 /*UV*/ } } }, - { fourcc('R','G','B','P'), ZEBRA_FMT_RGB_PACKED, + { fourcc('Y','U','V','9'), ZBAR_FMT_YUV_PLANAR, { { 2, 2, 0 /*UV*/ } } }, + { fourcc('M','J','P','G'), ZBAR_FMT_JPEG, }, + { fourcc('4','1','1','P'), ZBAR_FMT_YUV_PLANAR, { { 2, 0, 0 /*UV*/ } } }, + { fourcc('R','G','B','P'), ZBAR_FMT_RGB_PACKED, { { 2, RGB_BITS(11, 5), RGB_BITS(5, 6), RGB_BITS(0, 5) } } }, - { fourcc('R','G','B','R'), ZEBRA_FMT_RGB_PACKED, + { fourcc('R','G','B','R'), ZBAR_FMT_RGB_PACKED, { { 2, RGB_BITS(3, 5), RGB_BITS(13, 6), RGB_BITS(8, 5) } } }, - { fourcc('Y','U','Y','V'), ZEBRA_FMT_YUV_PACKED, + { fourcc('Y','U','Y','V'), ZBAR_FMT_YUV_PACKED, { { 1, 0, 0, /*YUYV*/ } } }, - { fourcc('U','Y','V','Y'), ZEBRA_FMT_YUV_PACKED, + { fourcc('U','Y','V','Y'), ZBAR_FMT_YUV_PACKED, { { 1, 0, 2, /*UYVY*/ } } }, }; static const int num_format_defs = - sizeof(format_defs) / sizeof(zebra_format_def_t); + sizeof(format_defs) / sizeof(zbar_format_def_t); #ifdef DEBUG_CONVERT static int intsort (const void *a, @@ -225,8 +225,8 @@ static inline int verify_format_sort () return(-1); } -static inline void uv_round (zebra_image_t *img, - const zebra_format_def_t *fmt) +static inline void uv_round (zbar_image_t *img, + const zbar_format_def_t *fmt) { img->width >>= fmt->p.yuv.xsub2; img->width <<= fmt->p.yuv.xsub2; @@ -234,10 +234,10 @@ static inline void uv_round (zebra_image_t *img, img->height <<= fmt->p.yuv.ysub2; } -static inline void uv_roundup (zebra_image_t *img, - const zebra_format_def_t *fmt) +static inline void uv_roundup (zbar_image_t *img, + const zbar_format_def_t *fmt) { - if(fmt->group == ZEBRA_FMT_GRAY) + if(fmt->group == ZBAR_FMT_GRAY) return; unsigned xmask = (1 << fmt->p.yuv.xsub2) - 1; if(img->width & xmask) @@ -247,10 +247,10 @@ static inline void uv_roundup (zebra_image_t *img, img->height = (img->height + ymask) & ~ymask; } -static inline unsigned long uvp_size (const zebra_image_t *img, - const zebra_format_def_t *fmt) +static inline unsigned long uvp_size (const zbar_image_t *img, + const zbar_format_def_t *fmt) { - if(fmt->group == ZEBRA_FMT_GRAY) + if(fmt->group == ZBAR_FMT_GRAY) return(0); return((img->width >> fmt->p.yuv.xsub2) * (img->height >> fmt->p.yuv.ysub2)); @@ -292,19 +292,19 @@ static inline void convert_write_rgb (uint8_t *dstp, } /* cleanup linked image by unrefing */ -static void cleanup_ref (zebra_image_t *img) +static void cleanup_ref (zbar_image_t *img) { if(img->next) - _zebra_image_refcnt(img->next, -1); + _zbar_image_refcnt(img->next, -1); } /* resize y plane, drop extra columns/rows from the right/bottom, * or duplicate last column/row to pad missing data */ -static inline void convert_y_resize (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt, +static inline void convert_y_resize (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt, size_t n) { if(dst->width == src->width && dst->height == src->height) { @@ -338,18 +338,18 @@ static inline void convert_y_resize (zebra_image_t *dst, } /* make new image w/reference to the same image data */ -static void convert_copy (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_copy (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { if(src->width == dst->width && src->height == dst->height) { dst->data = src->data; dst->datalen = src->datalen; dst->cleanup = cleanup_ref; - dst->next = (zebra_image_t*)src; - ((zebra_image_t*)src)->refcnt++; + dst->next = (zbar_image_t*)src; + ((zbar_image_t*)src)->refcnt++; } else /* NB only for GRAY/YUV_PLANAR formats */ @@ -357,10 +357,10 @@ static void convert_copy (zebra_image_t *dst, } /* append neutral UV plane to grayscale image */ -static void convert_uvp_append (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_uvp_append (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); dst->datalen = uvp_size(dst, dstfmt) * 2; @@ -377,10 +377,10 @@ static void convert_uvp_append (zebra_image_t *dst, } /* interleave YUV planes into packed YUV */ -static void convert_yuv_pack (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_yuv_pack (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); dst->datalen = dst->width * dst->height + uvp_size(dst, dstfmt) * 2; @@ -443,10 +443,10 @@ static void convert_yuv_pack (zebra_image_t *dst, /* split packed YUV samples and join into YUV planes * FIXME currently ignores color and grayscales the image */ -static void convert_yuv_unpack (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_yuv_unpack (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); unsigned long dstn = dst->width * dst->height; @@ -486,10 +486,10 @@ static void convert_yuv_unpack (zebra_image_t *dst, /* resample and resize UV plane(s) * FIXME currently ignores color and grayscales the image */ -static void convert_uvp_resample (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_uvp_resample (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); unsigned long dstn = dst->width * dst->height; @@ -503,10 +503,10 @@ static void convert_uvp_resample (zebra_image_t *dst, } /* rearrange interleaved UV componets */ -static void convert_uv_resample (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_uv_resample (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); unsigned long dstn = dst->width * dst->height; @@ -555,10 +555,10 @@ static void convert_uv_resample (zebra_image_t *dst, /* YUV planes to packed RGB * FIXME currently ignores color and grayscales the image */ -static void convert_yuvp_to_rgb (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_yuvp_to_rgb (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { dst->datalen = dst->width * dst->height * dstfmt->p.rgb.bpp; dst->data = malloc(dst->datalen); @@ -601,10 +601,10 @@ static void convert_yuvp_to_rgb (zebra_image_t *dst, /* packed RGB to YUV planes * FIXME currently ignores color and grayscales the image */ -static void convert_rgb_to_yuvp (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_rgb_to_yuvp (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); unsigned long dstn = dst->width * dst->height; @@ -654,10 +654,10 @@ static void convert_rgb_to_yuvp (zebra_image_t *dst, } /* packed YUV to packed RGB */ -static void convert_yuv_to_rgb (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_yuv_to_rgb (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { unsigned long dstn = dst->width * dst->height; dst->datalen = dstn * dstfmt->p.rgb.bpp; @@ -712,10 +712,10 @@ static void convert_yuv_to_rgb (zebra_image_t *dst, /* packed RGB to packed YUV * FIXME currently ignores color and grayscales the image */ -static void convert_rgb_to_yuv (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_rgb_to_yuv (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { uv_roundup(dst, dstfmt); dst->datalen = dst->width * dst->height + uvp_size(dst, dstfmt) * 2; @@ -767,10 +767,10 @@ static void convert_rgb_to_yuv (zebra_image_t *dst, } /* resample and resize packed RGB components */ -static void convert_rgb_resample (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_rgb_resample (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { unsigned long dstn = dst->width * dst->height; dst->datalen = dstn * dstfmt->p.rgb.bpp; @@ -825,19 +825,19 @@ static void convert_rgb_resample (zebra_image_t *dst, } #ifdef HAVE_LIBJPEG -void _zebra_convert_jpeg_to_y(zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt); - -static void convert_jpeg(zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt); +void _zbar_convert_jpeg_to_y(zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt); + +static void convert_jpeg(zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt); #endif /* group conversion matrix */ -static conversion_def_t conversions[][ZEBRA_FMT_NUM] = { +static conversion_def_t conversions[][ZBAR_FMT_NUM] = { { /* *from* GRAY */ { 0, convert_copy }, /* to GRAY */ { 8, convert_uvp_append }, /* to YUV_PLANAR */ @@ -880,7 +880,7 @@ static conversion_def_t conversions[][ZEBRA_FMT_NUM] = { }, #ifdef HAVE_LIBJPEG { /* from JPEG */ - { 96, _zebra_convert_jpeg_to_y }, /* to GRAY */ + { 96, _zbar_convert_jpeg_to_y }, /* to GRAY */ { 104, convert_jpeg }, /* to YUV_PLANAR */ { 116, convert_jpeg }, /* to YUV_PACKED */ { 256, convert_jpeg }, /* to RGB_PACKED */ @@ -899,9 +899,9 @@ static conversion_def_t conversions[][ZEBRA_FMT_NUM] = { #endif }; -const zebra_format_def_t *_zebra_format_lookup (uint32_t fmt) +const zbar_format_def_t *_zbar_format_lookup (uint32_t fmt) { - const zebra_format_def_t *def = NULL; + const zbar_format_def_t *def = NULL; int i = 0; while(i < num_format_defs) { def = &format_defs[i]; @@ -916,17 +916,17 @@ const zebra_format_def_t *_zebra_format_lookup (uint32_t fmt) #ifdef HAVE_LIBJPEG /* convert JPEG data via an intermediate format supported by libjpeg */ -static void convert_jpeg (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +static void convert_jpeg (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { /* define intermediate image in a format supported by libjpeg * (currently only grayscale) */ - zebra_image_t *tmp; + zbar_image_t *tmp; if(!src->src) { - tmp = zebra_image_create(); + tmp = zbar_image_create(); tmp->format = fourcc('Y','8','0','0'); tmp->width = dst->width; tmp->height = dst->height; @@ -938,11 +938,11 @@ static void convert_jpeg (zebra_image_t *dst, dst->height = tmp->height; } - const zebra_format_def_t *tmpfmt = _zebra_format_lookup(tmp->format); + const zbar_format_def_t *tmpfmt = _zbar_format_lookup(tmp->format); assert(tmpfmt); /* convert to intermediate format */ - _zebra_convert_jpeg_to_y(tmp, tmpfmt, src, srcfmt); + _zbar_convert_jpeg_to_y(tmp, tmpfmt, src, srcfmt); /* now convert to dst */ dst->width = tmp->width; @@ -954,16 +954,16 @@ static void convert_jpeg (zebra_image_t *dst, func(dst, dstfmt, tmp, tmpfmt); if(!src->src) - zebra_image_destroy(tmp); + zbar_image_destroy(tmp); } #endif -zebra_image_t *zebra_image_convert_resize (const zebra_image_t *src, - unsigned long fmt, - unsigned width, - unsigned height) +zbar_image_t *zbar_image_convert_resize (const zbar_image_t *src, + unsigned long fmt, + unsigned width, + unsigned height) { - zebra_image_t *dst = zebra_image_create(); + zbar_image_t *dst = zbar_image_create(); dst->format = fmt; dst->width = width; dst->height = height; @@ -974,8 +974,8 @@ zebra_image_t *zebra_image_convert_resize (const zebra_image_t *src, return(dst); } - const zebra_format_def_t *srcfmt = _zebra_format_lookup(src->format); - const zebra_format_def_t *dstfmt = _zebra_format_lookup(dst->format); + const zbar_format_def_t *srcfmt = _zbar_format_lookup(src->format); + const zbar_format_def_t *dstfmt = _zbar_format_lookup(dst->format); if(!srcfmt || !dstfmt) /* FIXME free dst */ return(NULL); @@ -991,20 +991,20 @@ zebra_image_t *zebra_image_convert_resize (const zebra_image_t *src, conversion_handler_t *func = conversions[srcfmt->group][dstfmt->group].func; - dst->cleanup = zebra_image_free_data; + dst->cleanup = zbar_image_free_data; func(dst, dstfmt, src, srcfmt); if(!dst->data) { /* conversion failed */ - zebra_image_destroy(dst); + zbar_image_destroy(dst); return(NULL); } return(dst); } -zebra_image_t *zebra_image_convert (const zebra_image_t *src, - unsigned long fmt) +zbar_image_t *zbar_image_convert (const zbar_image_t *src, + unsigned long fmt) { - return(zebra_image_convert_resize(src, fmt, src->width, src->height)); + return(zbar_image_convert_resize(src, fmt, src->width, src->height)); } static inline int has_format (uint32_t fmt, @@ -1017,9 +1017,9 @@ static inline int has_format (uint32_t fmt, } /* select least cost conversion from src format to available dsts */ -int _zebra_best_format (uint32_t src, - uint32_t *dst, - const uint32_t *dsts) +int _zbar_best_format (uint32_t src, + uint32_t *dst, + const uint32_t *dsts) { if(dst) *dst = 0; @@ -1031,14 +1031,14 @@ int _zebra_best_format (uint32_t src, *dst = src; return(0); } - const zebra_format_def_t *srcfmt = _zebra_format_lookup(src); + const zbar_format_def_t *srcfmt = _zbar_format_lookup(src); if(!srcfmt) return(-1); zprintf(8, "from %.4s(%08" PRIx32 ") to", (char*)&src, src); unsigned min_cost = -1; for(; *dsts; dsts++) { - const zebra_format_def_t *dstfmt = _zebra_format_lookup(*dsts); + const zbar_format_def_t *dstfmt = _zbar_format_lookup(*dsts); if(!dstfmt) continue; int cost; @@ -1048,7 +1048,7 @@ int _zebra_best_format (uint32_t src, else cost = conversions[srcfmt->group][dstfmt->group].cost; - if(_zebra_verbosity >= 8) + if(_zbar_verbosity >= 8) fprintf(stderr, " %.4s(%08" PRIx32 ")=%d", (char*)dsts, *dsts, cost); if(cost >= 0 && min_cost > cost) { @@ -1057,13 +1057,13 @@ int _zebra_best_format (uint32_t src, *dst = *dsts; } } - if(_zebra_verbosity >= 8) + if(_zbar_verbosity >= 8) fprintf(stderr, "\n"); return(min_cost); } -int zebra_negotiate_format (zebra_video_t *vdo, - zebra_window_t *win) +int zbar_negotiate_format (zbar_video_t *vdo, + zbar_window_t *win) { if(!vdo && !win) return(0); @@ -1075,14 +1075,14 @@ int zebra_negotiate_format (zebra_video_t *vdo, if(verify_format_sort()) { if(win) (void)window_unlock(win); - return(err_capture(errdst, SEV_FATAL, ZEBRA_ERR_INTERNAL, __func__, + return(err_capture(errdst, SEV_FATAL, ZBAR_ERR_INTERNAL, __func__, "image format list is not sorted!?")); } if((vdo && !vdo->formats) || (win && !win->formats)) { if(win) (void)window_unlock(win); - return(err_capture(errdst, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(errdst, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no input or output formats available")); } @@ -1098,7 +1098,7 @@ int zebra_negotiate_format (zebra_video_t *vdo, if(!has_format(*fmt, srcs)) continue; uint32_t win_fmt = 0; - int cost = _zebra_best_format(*fmt, &win_fmt, dsts); + int cost = _zbar_best_format(*fmt, &win_fmt, dsts); if(cost < 0) { zprintf(4, "%.4s(%08" PRIx32 ") -> ? (unsupported)\n", (char*)fmt, *fmt); @@ -1117,12 +1117,12 @@ int zebra_negotiate_format (zebra_video_t *vdo, (void)window_unlock(win); if(!min_fmt) - return(err_capture(errdst, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(errdst, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no supported image formats available")); if(!vdo) return(0); zprintf(2, "setting best format %.4s(%08" PRIx32 ") (%d)\n", (char*)&min_fmt, min_fmt, min_cost); - return(zebra_video_init(vdo, min_fmt)); + return(zbar_video_init(vdo, min_fmt)); } diff --git a/zebra/debug.h b/zbar/debug.h similarity index 87% rename from zebra/debug.h rename to zbar/debug.h index 87170187..482ca8dd 100644 --- a/zebra/debug.h +++ b/zbar/debug.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ /* varargs variations on compile time debug spew */ diff --git a/zebra/decoder.c b/zbar/decoder.c similarity index 55% rename from zebra/decoder.c rename to zbar/decoder.c index e8004a9c..663f847c 100644 --- a/zebra/decoder.c +++ b/zbar/decoder.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -26,7 +26,7 @@ #include /* snprintf */ #include /* memset, strlen */ -#include +#include #include "decoder.h" #if defined(DEBUG_DECODER) || defined(DEBUG_EAN) || defined(DEBUG_CODE128) || \ @@ -36,9 +36,9 @@ #endif #include "debug.h" -zebra_decoder_t *zebra_decoder_create () +zbar_decoder_t *zbar_decoder_create () { - zebra_decoder_t *dcode = malloc(sizeof(zebra_decoder_t)); + zbar_decoder_t *dcode = malloc(sizeof(zbar_decoder_t)); dcode->buflen = BUFFER_MIN; dcode->buf = malloc(dcode->buflen); dcode->handler = dcode->userdata = NULL; @@ -46,42 +46,42 @@ zebra_decoder_t *zebra_decoder_create () /* initialize default configs */ #ifdef ENABLE_EAN dcode->ean.enable = 1; - dcode->ean.ean13_config = ((1 << ZEBRA_CFG_ENABLE) | - (1 << ZEBRA_CFG_EMIT_CHECK)); - dcode->ean.ean8_config = ((1 << ZEBRA_CFG_ENABLE) | - (1 << ZEBRA_CFG_EMIT_CHECK)); - dcode->ean.upca_config = 1 << ZEBRA_CFG_EMIT_CHECK; - dcode->ean.upce_config = 1 << ZEBRA_CFG_EMIT_CHECK; - dcode->ean.isbn10_config = 1 << ZEBRA_CFG_EMIT_CHECK; - dcode->ean.isbn13_config = 1 << ZEBRA_CFG_EMIT_CHECK; + dcode->ean.ean13_config = ((1 << ZBAR_CFG_ENABLE) | + (1 << ZBAR_CFG_EMIT_CHECK)); + dcode->ean.ean8_config = ((1 << ZBAR_CFG_ENABLE) | + (1 << ZBAR_CFG_EMIT_CHECK)); + dcode->ean.upca_config = 1 << ZBAR_CFG_EMIT_CHECK; + dcode->ean.upce_config = 1 << ZBAR_CFG_EMIT_CHECK; + dcode->ean.isbn10_config = 1 << ZBAR_CFG_EMIT_CHECK; + dcode->ean.isbn13_config = 1 << ZBAR_CFG_EMIT_CHECK; #endif #ifdef ENABLE_I25 - dcode->i25.config = 1 << ZEBRA_CFG_ENABLE; - CFG(dcode->i25, ZEBRA_CFG_MIN_LEN) = 6; + dcode->i25.config = 1 << ZBAR_CFG_ENABLE; + CFG(dcode->i25, ZBAR_CFG_MIN_LEN) = 6; #endif #ifdef ENABLE_CODE39 - dcode->code39.config = 1 << ZEBRA_CFG_ENABLE; - CFG(dcode->code39, ZEBRA_CFG_MIN_LEN) = 6; + dcode->code39.config = 1 << ZBAR_CFG_ENABLE; + CFG(dcode->code39, ZBAR_CFG_MIN_LEN) = 6; #endif #ifdef ENABLE_CODE128 - dcode->code128.config = 1 << ZEBRA_CFG_ENABLE; + dcode->code128.config = 1 << ZBAR_CFG_ENABLE; #endif #ifdef ENABLE_PDF417 - dcode->pdf417.config = 1 << ZEBRA_CFG_ENABLE; + dcode->pdf417.config = 1 << ZBAR_CFG_ENABLE; #endif - zebra_decoder_reset(dcode); + zbar_decoder_reset(dcode); return(dcode); } -void zebra_decoder_destroy (zebra_decoder_t *dcode) +void zbar_decoder_destroy (zbar_decoder_t *dcode) { if(dcode->buf) free(dcode->buf); free(dcode); } -void zebra_decoder_reset (zebra_decoder_t *dcode) +void zbar_decoder_reset (zbar_decoder_t *dcode) { memset(dcode, 0, (long)&dcode->buf - (long)dcode); #ifdef ENABLE_EAN @@ -101,7 +101,7 @@ void zebra_decoder_reset (zebra_decoder_t *dcode) #endif } -void zebra_decoder_new_scan (zebra_decoder_t *dcode) +void zbar_decoder_new_scan (zbar_decoder_t *dcode) { /* soft reset decoder */ memset(dcode->w, 0, sizeof(dcode->w)); @@ -125,73 +125,73 @@ void zebra_decoder_new_scan (zebra_decoder_t *dcode) } -zebra_color_t zebra_decoder_get_color (const zebra_decoder_t *dcode) +zbar_color_t zbar_decoder_get_color (const zbar_decoder_t *dcode) { return(get_color(dcode)); } -const char *zebra_decoder_get_data (const zebra_decoder_t *dcode) +const char *zbar_decoder_get_data (const zbar_decoder_t *dcode) { return((char*)dcode->buf); } -zebra_decoder_handler_t * -zebra_decoder_set_handler (zebra_decoder_t *dcode, - zebra_decoder_handler_t handler) +zbar_decoder_handler_t * +zbar_decoder_set_handler (zbar_decoder_t *dcode, + zbar_decoder_handler_t handler) { - zebra_decoder_handler_t *result = dcode->handler; + zbar_decoder_handler_t *result = dcode->handler; dcode->handler = handler; return(result); } -void zebra_decoder_set_userdata (zebra_decoder_t *dcode, - void *userdata) +void zbar_decoder_set_userdata (zbar_decoder_t *dcode, + void *userdata) { dcode->userdata = userdata; } -void *zebra_decoder_get_userdata (const zebra_decoder_t *dcode) +void *zbar_decoder_get_userdata (const zbar_decoder_t *dcode) { return(dcode->userdata); } -zebra_symbol_type_t zebra_decoder_get_type (const zebra_decoder_t *dcode) +zbar_symbol_type_t zbar_decoder_get_type (const zbar_decoder_t *dcode) { return(dcode->type); } -zebra_symbol_type_t zebra_decode_width (zebra_decoder_t *dcode, - unsigned w) +zbar_symbol_type_t zbar_decode_width (zbar_decoder_t *dcode, + unsigned w) { dcode->w[dcode->idx & (DECODE_WINDOW - 1)] = w; dprintf(1, " decode[%x]: w=%d (%g)\n", dcode->idx, w, (w / 32.)); /* each decoder processes width stream in parallel */ - zebra_symbol_type_t sym = dcode->type = ZEBRA_NONE; + zbar_symbol_type_t sym = dcode->type = ZBAR_NONE; #ifdef ENABLE_EAN if((dcode->ean.enable) && - (sym = _zebra_decode_ean(dcode))) + (sym = _zbar_decode_ean(dcode))) dcode->type = sym; #endif #ifdef ENABLE_CODE39 - if(TEST_CFG(dcode->code39.config, ZEBRA_CFG_ENABLE) && - (sym = _zebra_decode_code39(dcode)) > ZEBRA_PARTIAL) + if(TEST_CFG(dcode->code39.config, ZBAR_CFG_ENABLE) && + (sym = _zbar_decode_code39(dcode)) > ZBAR_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_CODE128 - if(TEST_CFG(dcode->code128.config, ZEBRA_CFG_ENABLE) && - (sym = _zebra_decode_code128(dcode)) > ZEBRA_PARTIAL) + if(TEST_CFG(dcode->code128.config, ZBAR_CFG_ENABLE) && + (sym = _zbar_decode_code128(dcode)) > ZBAR_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_I25 - if(TEST_CFG(dcode->i25.config, ZEBRA_CFG_ENABLE) && - (sym = _zebra_decode_i25(dcode)) > ZEBRA_PARTIAL) + if(TEST_CFG(dcode->i25.config, ZBAR_CFG_ENABLE) && + (sym = _zbar_decode_i25(dcode)) > ZBAR_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_PDF417 - if(TEST_CFG(dcode->pdf417.config, ZEBRA_CFG_ENABLE) && - (sym = _zebra_decode_pdf417(dcode)) > ZEBRA_PARTIAL) + if(TEST_CFG(dcode->pdf417.config, ZBAR_CFG_ENABLE) && + (sym = _zbar_decode_pdf417(dcode)) > ZBAR_PARTIAL) dcode->type = sym; #endif @@ -199,65 +199,65 @@ zebra_symbol_type_t zebra_decode_width (zebra_decoder_t *dcode, if(dcode->type) { if(dcode->handler) dcode->handler(dcode); - if(dcode->lock && dcode->type > ZEBRA_PARTIAL) + if(dcode->lock && dcode->type > ZBAR_PARTIAL) dcode->lock = 0; } return(dcode->type); } -static inline int decoder_set_config_bool (zebra_decoder_t *dcode, - zebra_symbol_type_t sym, - zebra_config_t cfg, +static inline int decoder_set_config_bool (zbar_decoder_t *dcode, + zbar_symbol_type_t sym, + zbar_config_t cfg, int val) { unsigned *config = NULL; switch(sym) { #ifdef ENABLE_EAN - case ZEBRA_EAN13: + case ZBAR_EAN13: config = &dcode->ean.ean13_config; break; - case ZEBRA_EAN8: + case ZBAR_EAN8: config = &dcode->ean.ean8_config; break; - case ZEBRA_UPCA: + case ZBAR_UPCA: config = &dcode->ean.upca_config; break; - case ZEBRA_UPCE: + case ZBAR_UPCE: config = &dcode->ean.upce_config; break; - case ZEBRA_ISBN10: + case ZBAR_ISBN10: config = &dcode->ean.isbn10_config; break; - case ZEBRA_ISBN13: + case ZBAR_ISBN13: config = &dcode->ean.isbn13_config; break; #endif #ifdef ENABLE_I25 - case ZEBRA_I25: + case ZBAR_I25: config = &dcode->i25.config; break; #endif #ifdef ENABLE_CODE39 - case ZEBRA_CODE39: + case ZBAR_CODE39: config = &dcode->code39.config; break; #endif #ifdef ENABLE_CODE128 - case ZEBRA_CODE128: + case ZBAR_CODE128: config = &dcode->code128.config; break; #endif #ifdef ENABLE_PDF417 - case ZEBRA_PDF417: + case ZBAR_PDF417: config = &dcode->pdf417.config; break; #endif @@ -267,7 +267,7 @@ static inline int decoder_set_config_bool (zebra_decoder_t *dcode, default: return(1); } - if(!config || cfg >= ZEBRA_CFG_NUM) + if(!config || cfg >= ZBAR_CFG_NUM) return(1); if(!val) @@ -284,36 +284,36 @@ static inline int decoder_set_config_bool (zebra_decoder_t *dcode, dcode->ean.upce_config | dcode->ean.isbn10_config | dcode->ean.isbn13_config, - ZEBRA_CFG_ENABLE); + ZBAR_CFG_ENABLE); #endif return(0); } -static inline int decoder_set_config_int (zebra_decoder_t *dcode, - zebra_symbol_type_t sym, - zebra_config_t cfg, +static inline int decoder_set_config_int (zbar_decoder_t *dcode, + zbar_symbol_type_t sym, + zbar_config_t cfg, int val) { switch(sym) { #ifdef ENABLE_I25 - case ZEBRA_I25: + case ZBAR_I25: CFG(dcode->i25, cfg) = val; break; #endif #ifdef ENABLE_CODE39 - case ZEBRA_CODE39: + case ZBAR_CODE39: CFG(dcode->code39, cfg) = val; break; #endif #ifdef ENABLE_CODE128 - case ZEBRA_CODE128: + case ZBAR_CODE128: CFG(dcode->code128, cfg) = val; break; #endif #ifdef ENABLE_PDF417 - case ZEBRA_PDF417: + case ZBAR_PDF417: CFG(dcode->pdf417, cfg) = val; break; #endif @@ -324,28 +324,28 @@ static inline int decoder_set_config_int (zebra_decoder_t *dcode, return(0); } -int zebra_decoder_set_config (zebra_decoder_t *dcode, - zebra_symbol_type_t sym, - zebra_config_t cfg, - int val) +int zbar_decoder_set_config (zbar_decoder_t *dcode, + zbar_symbol_type_t sym, + zbar_config_t cfg, + int val) { - if(sym == ZEBRA_NONE) { - zebra_decoder_set_config(dcode, ZEBRA_EAN13, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_EAN8, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_UPCA, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_UPCE, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_ISBN10, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_ISBN13, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_I25, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_CODE39, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_CODE128, cfg, val); - zebra_decoder_set_config(dcode, ZEBRA_PDF417, cfg, val); + if(sym == ZBAR_NONE) { + zbar_decoder_set_config(dcode, ZBAR_EAN13, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_EAN8, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_UPCA, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_UPCE, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_ISBN10, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_ISBN13, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_I25, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_CODE39, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_CODE128, cfg, val); + zbar_decoder_set_config(dcode, ZBAR_PDF417, cfg, val); return(0); } - if(cfg >= 0 && cfg < ZEBRA_CFG_NUM) + if(cfg >= 0 && cfg < ZBAR_CFG_NUM) return(decoder_set_config_bool(dcode, sym, cfg, val)); - else if(cfg >= ZEBRA_CFG_MIN_LEN && cfg <= ZEBRA_CFG_MAX_LEN) + else if(cfg >= ZBAR_CFG_MIN_LEN && cfg <= ZBAR_CFG_MAX_LEN) return(decoder_set_config_int(dcode, sym, cfg, val)); else return(1); @@ -354,8 +354,8 @@ int zebra_decoder_set_config (zebra_decoder_t *dcode, static char *decoder_dump = NULL; -const char *_zebra_decoder_buf_dump (unsigned char *buf, - unsigned int buflen) +const char *_zbar_decoder_buf_dump (unsigned char *buf, + unsigned int buflen) { int dumplen = (buflen * 3) + 12; if(!decoder_dump || dumplen > strlen(decoder_dump)) { diff --git a/zebra/decoder.h b/zbar/decoder.h similarity index 82% rename from zebra/decoder.h rename to zbar/decoder.h index 5ae4fc00..f8ed9b59 100644 --- a/zebra/decoder.h +++ b/zbar/decoder.h @@ -1,33 +1,33 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _DECODER_H_ #define _DECODER_H_ #include /* realloc */ -#include +#include -#define NUM_CFGS (ZEBRA_CFG_MAX_LEN - ZEBRA_CFG_MIN_LEN + 1) +#define NUM_CFGS (ZBAR_CFG_MAX_LEN - ZBAR_CFG_MIN_LEN + 1) #ifdef ENABLE_EAN # include "decoder/ean.h" @@ -67,21 +67,21 @@ # define BUFFER_INCR 0x10 #endif -#define CFG(dcode, cfg) ((dcode).configs[(cfg) - ZEBRA_CFG_MIN_LEN]) +#define CFG(dcode, cfg) ((dcode).configs[(cfg) - ZBAR_CFG_MIN_LEN]) #define TEST_CFG(config, cfg) (((config) >> (cfg)) & 1) /* symbology independent decoder state */ -struct zebra_decoder_s { +struct zbar_decoder_s { unsigned char idx; /* current width index */ unsigned w[DECODE_WINDOW]; /* window of last N bar widths */ - zebra_symbol_type_t type; /* type of last decoded data */ + zbar_symbol_type_t type; /* type of last decoded data */ unsigned lock : 1; /* buffer lock */ /* everything above here is automatically reset */ unsigned char *buf; /* decoded characters */ unsigned buflen; /* dynamic buffer allocation */ void *userdata; /* application data */ - zebra_decoder_handler_t *handler; /* application callback */ + zbar_decoder_handler_t *handler; /* application callback */ /* symbology specific state */ #ifdef ENABLE_EAN @@ -102,20 +102,20 @@ struct zebra_decoder_s { }; /* return current element color */ -static inline char get_color (const zebra_decoder_t *dcode) +static inline char get_color (const zbar_decoder_t *dcode) { return(dcode->idx & 1); } /* retrieve i-th previous element width */ -static inline unsigned get_width (const zebra_decoder_t *dcode, +static inline unsigned get_width (const zbar_decoder_t *dcode, unsigned char offset) { return(dcode->w[(dcode->idx - offset) & (DECODE_WINDOW - 1)]); } /* retrieve bar+space pair width starting at offset i */ -static inline unsigned pair_width (const zebra_decoder_t *dcode, +static inline unsigned pair_width (const zbar_decoder_t *dcode, unsigned char offset) { return(get_width(dcode, offset) + get_width(dcode, offset + 1)); @@ -126,7 +126,7 @@ static inline unsigned pair_width (const zebra_decoder_t *dcode, * (<= DECODE_WINDOW - n) * - size of character is n elements */ -static inline unsigned calc_s (const zebra_decoder_t *dcode, +static inline unsigned calc_s (const zbar_decoder_t *dcode, unsigned char offset, unsigned char n) { @@ -160,7 +160,7 @@ static inline int decode_e (unsigned e, } /* acquire shared state lock */ -static inline char get_lock (zebra_decoder_t *dcode) +static inline char get_lock (zbar_decoder_t *dcode) { if(dcode->lock) return(1); @@ -169,7 +169,7 @@ static inline char get_lock (zebra_decoder_t *dcode) } /* ensure output buffer has sufficient allocation for request */ -static inline char size_buf (zebra_decoder_t *dcode, +static inline char size_buf (zbar_decoder_t *dcode, unsigned len) { if(len < dcode->buflen) @@ -190,7 +190,7 @@ static inline char size_buf (zebra_decoder_t *dcode, return(0); } -extern const char *_zebra_decoder_buf_dump (unsigned char *buf, +extern const char *_zbar_decoder_buf_dump (unsigned char *buf, unsigned int buflen); #endif diff --git a/zebra/decoder/code128.c b/zbar/decoder/code128.c similarity index 89% rename from zebra/decoder/code128.c rename to zbar/decoder/code128.c index c3a00284..3dc1120b 100644 --- a/zebra/decoder/code128.c +++ b/zbar/decoder/code128.c @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include /* memmove */ -#include +#include #include "decoder.h" #ifdef DEBUG_CODE128 @@ -188,7 +188,7 @@ static inline unsigned char calc_check (unsigned char c) return((c < 0x67) ? 0x20 : 0x10); } -static inline signed char decode6 (zebra_decoder_t *dcode) +static inline signed char decode6 (zbar_decoder_t *dcode) { /* build edge signature of character */ unsigned s = dcode->code128.s6; @@ -196,7 +196,7 @@ static inline signed char decode6 (zebra_decoder_t *dcode) if(s < 5) return(-1); /* calculate similar edge measurements */ - int sig = (get_color(dcode) == ZEBRA_BAR) + int sig = (get_color(dcode) == ZBAR_BAR) ? ((decode_e(get_width(dcode, 0) + get_width(dcode, 1), s, 11) << 12) | (decode_e(get_width(dcode, 1) + get_width(dcode, 2), s, 11) << 8) | (decode_e(get_width(dcode, 2) + get_width(dcode, 3), s, 11) << 4) | @@ -214,7 +214,7 @@ static inline signed char decode6 (zebra_decoder_t *dcode) return(-1); /* character validation */ - unsigned bars = (get_color(dcode) == ZEBRA_BAR) + unsigned bars = (get_color(dcode) == ZBAR_BAR) ? (get_width(dcode, 0) + get_width(dcode, 2) + get_width(dcode, 4)) : (get_width(dcode, 1) + get_width(dcode, 3) + get_width(dcode, 5)); bars = bars * 11 * 4 / s; @@ -226,7 +226,7 @@ static inline signed char decode6 (zebra_decoder_t *dcode) return(c & 0x7f); } -static inline unsigned char validate_checksum (zebra_decoder_t *dcode) +static inline unsigned char validate_checksum (zbar_decoder_t *dcode) { code128_decoder_t *dcode128 = &dcode->code128; if(dcode128->character < 3) @@ -243,14 +243,14 @@ static inline unsigned char validate_checksum (zebra_decoder_t *dcode) for(i = dcode128->character - 3; i; i--) { zassert(sum < 103, -1, "dir=%x i=%x sum=%x acc=%x %s\n", dcode128->direction, i, sum, acc, - _zebra_decoder_buf_dump(dcode->buf, dcode128->character)); + _zbar_decoder_buf_dump(dcode->buf, dcode128->character)); idx = (dcode128->direction) ? dcode128->character - 1 - i : i; acc += dcode->buf[idx]; if(acc >= 103) acc -= 103; zassert(acc < 103, -1, "dir=%x i=%x sum=%x acc=%x %s\n", dcode128->direction, i, sum, acc, - _zebra_decoder_buf_dump(dcode->buf, dcode128->character)); + _zbar_decoder_buf_dump(dcode->buf, dcode128->character)); sum += acc; if(sum >= 103) sum -= 103; @@ -267,7 +267,7 @@ static inline unsigned char validate_checksum (zebra_decoder_t *dcode) } /* expand and decode character set C */ -static inline unsigned postprocess_c (zebra_decoder_t *dcode, +static inline unsigned postprocess_c (zbar_decoder_t *dcode, unsigned start, unsigned end, unsigned dst) @@ -305,17 +305,17 @@ static inline unsigned postprocess_c (zebra_decoder_t *dcode, } zassert(dcode->buf[j] <= '9', delta, "start=%x end=%x i=%x j=%x %s\n", start, end, i, j, - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); zassert(code <= 9, delta, "start=%x end=%x i=%x j=%x %s\n", start, end, i, j, - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); dcode->buf[j + 1] = '0' + code; } return(delta); } /* resolve scan direction and convert to ASCII */ -static inline unsigned char postprocess (zebra_decoder_t *dcode) +static inline unsigned char postprocess (zbar_decoder_t *dcode) { code128_decoder_t *dcode128 = &dcode->code128; dprintf(2, "\n postproc len=%d", dcode128->character); @@ -332,16 +332,16 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) } zassert(dcode->buf[dcode128->character - 1] == STOP_REV, 1, "dir=%x %s\n", dcode128->direction, - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); } else zassert(dcode->buf[dcode128->character - 1] == STOP_FWD, 1, "dir=%x %s\n", dcode128->direction, - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); code = dcode->buf[0]; zassert(code >= START_A && code <= START_C, 1, "%s\n", - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); unsigned char charset = code - START_A; unsigned cexp = (code == START_C) ? 1 : 0; @@ -352,7 +352,7 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) zassert(!(code & 0x80), 1, "i=%x j=%x code=%02x charset=%x cexp=%x %s\n", i, j, code, charset, cexp, - _zebra_decoder_buf_dump(dcode->buf, dcode->code128.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); if((charset & 0x2) && (code < 100)) /* defer character set C for expansion */ @@ -373,7 +373,7 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) /* expand character set C to ASCII */ zassert(cexp, 1, "i=%x j=%x code=%02x charset=%x cexp=%x %s\n", i, j, code, charset, cexp, - _zebra_decoder_buf_dump(dcode->buf, + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); unsigned delta = postprocess_c(dcode, cexp, i, j); i += delta; @@ -398,7 +398,7 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) zassert(code >= CODE_C && code <= CODE_A, 1, "i=%x j=%x code=%02x charset=%x cexp=%x %s\n", i, j, code, charset, cexp, - _zebra_decoder_buf_dump(dcode->buf, + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); unsigned char newset = CODE_A - code; if(newset != charset) @@ -413,7 +413,7 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) if(charset & 0x2) { zassert(cexp, 1, "i=%x j=%x code=%02x charset=%x cexp=%x %s\n", i, j, code, charset, cexp, - _zebra_decoder_buf_dump(dcode->buf, + _zbar_decoder_buf_dump(dcode->buf, dcode->code128.character)); j += postprocess_c(dcode, cexp, i, j) * 2; } @@ -422,7 +422,7 @@ static inline unsigned char postprocess (zebra_decoder_t *dcode) return(0); } -zebra_symbol_type_t _zebra_decode_code128 (zebra_decoder_t *dcode) +zbar_symbol_type_t _zbar_decode_code128 (zbar_decoder_t *dcode) { code128_decoder_t *dcode128 = &dcode->code128; @@ -459,11 +459,11 @@ zebra_symbol_type_t _zebra_decode_code128 (zebra_decoder_t *dcode) /* initialize state */ dcode128->character = 0; if(c == STOP_REV) { - dcode128->direction = ZEBRA_BAR; + dcode128->direction = ZBAR_BAR; dcode128->element = 7; } else - dcode128->direction = ZEBRA_SPACE; + dcode128->direction = ZBAR_SPACE; dprintf(2, " dir=%x [valid start]", dcode128->direction); } else if((c < 0) || @@ -478,7 +478,7 @@ zebra_symbol_type_t _zebra_decode_code128 (zebra_decoder_t *dcode) zassert(dcode->buflen > dcode128->character, 0, "buflen=%x idx=%x c=%02x %s\n", dcode->buflen, dcode128->character, c, - _zebra_decoder_buf_dump(dcode->buf, dcode->buflen)); + _zbar_decoder_buf_dump(dcode->buf, dcode->buflen)); dcode->buf[dcode128->character++] = c; @@ -487,14 +487,14 @@ zebra_symbol_type_t _zebra_decode_code128 (zebra_decoder_t *dcode) ? c >= START_A && c <= START_C : c == STOP_FWD)) { /* FIXME STOP_FWD should check extra bar (and QZ!) */ - zebra_symbol_type_t sym = ZEBRA_CODE128; + zbar_symbol_type_t sym = ZBAR_CODE128; if(validate_checksum(dcode) || postprocess(dcode)) - sym = ZEBRA_NONE; - else if(dcode128->character < CFG(*dcode128, ZEBRA_CFG_MIN_LEN) || - (CFG(*dcode128, ZEBRA_CFG_MAX_LEN) > 0 && - dcode128->character > CFG(*dcode128, ZEBRA_CFG_MAX_LEN))) { + sym = ZBAR_NONE; + else if(dcode128->character < CFG(*dcode128, ZBAR_CFG_MIN_LEN) || + (CFG(*dcode128, ZBAR_CFG_MAX_LEN) > 0 && + dcode128->character > CFG(*dcode128, ZBAR_CFG_MAX_LEN))) { dprintf(2, " [invalid len]\n"); - sym = ZEBRA_NONE; + sym = ZBAR_NONE; } else dprintf(2, " [valid end]\n"); diff --git a/zebra/decoder/code128.h b/zbar/decoder/code128.h similarity index 76% rename from zebra/decoder/code128.h rename to zbar/decoder/code128.h index 2eb3d582..6e5153a9 100644 --- a/zebra/decoder/code128.h +++ b/zbar/decoder/code128.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _CODE128_H_ #define _CODE128_H_ @@ -44,6 +44,6 @@ static inline void code128_reset (code128_decoder_t *dcode128) } /* decode Code 128 symbols */ -zebra_symbol_type_t _zebra_decode_code128(zebra_decoder_t *dcode); +zbar_symbol_type_t _zbar_decode_code128(zbar_decoder_t *dcode); #endif diff --git a/zebra/decoder/code39.c b/zbar/decoder/code39.c similarity index 86% rename from zebra/decoder/code39.c rename to zbar/decoder/code39.c index 0d36883e..2edb262b 100644 --- a/zebra/decoder/code39.c +++ b/zbar/decoder/code39.c @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include /* memmove */ -#include +#include #include "decoder.h" #ifdef DEBUG_CODE39 @@ -143,7 +143,7 @@ static inline unsigned char code39_decode1 (unsigned char enc, return(enc); } -static inline signed char code39_decode9 (zebra_decoder_t *dcode) +static inline signed char code39_decode9 (zbar_decoder_t *dcode) { code39_decoder_t *dcode39 = &dcode->code39; @@ -189,7 +189,7 @@ static inline signed char code39_decode9 (zebra_decoder_t *dcode) return((dcode39->direction) ? c->rev : c->fwd); } -static inline signed char code39_decode_start (zebra_decoder_t *dcode) +static inline signed char code39_decode_start (zbar_decoder_t *dcode) { code39_decoder_t *dcode39 = &dcode->code39; @@ -198,7 +198,7 @@ static inline signed char code39_decode_start (zebra_decoder_t *dcode) dcode39->direction ^= 1; else if(c != 0x2b) { dprintf(2, "\n"); - return(ZEBRA_NONE); + return(ZBAR_NONE); } /* check leading quiet zone - spec is 10x, we require at least 3x */ @@ -206,16 +206,16 @@ static inline signed char code39_decode_start (zebra_decoder_t *dcode) if(quiet && get_width(dcode, 10) && quiet < dcode39->s9 / 4) { dprintf(2, " [invalid quiet]\n"); - return(ZEBRA_NONE); + return(ZBAR_NONE); } dcode39->element = 9; dcode39->character = 0; dprintf(1, " dir=%x [valid start]\n", dcode39->direction); - return(ZEBRA_PARTIAL); + return(ZBAR_PARTIAL); } -static inline void code39_postprocess (zebra_decoder_t *dcode) +static inline void code39_postprocess (zbar_decoder_t *dcode) { code39_decoder_t *dcode39 = &dcode->code39; int i; @@ -236,7 +236,7 @@ static inline void code39_postprocess (zebra_decoder_t *dcode) dcode->buf[i] = '\0'; } -zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) +zbar_symbol_type_t _zbar_decode_code39 (zbar_decoder_t *dcode) { code39_decoder_t *dcode39 = &dcode->code39; @@ -245,14 +245,14 @@ zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) dcode39->s9 += get_width(dcode, 0); if(dcode39->character < 0) { - if(get_color(dcode) != ZEBRA_BAR) - return(ZEBRA_NONE); + if(get_color(dcode) != ZBAR_BAR) + return(ZBAR_NONE); dprintf(2, " code39:"); return(code39_decode_start(dcode)); } if(++dcode39->element < 9) - return(ZEBRA_NONE); + return(ZBAR_NONE); dprintf(2, " code39[%c%02d+%x]", (dcode39->direction) ? '<' : '>', @@ -264,18 +264,18 @@ zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) dcode->buf[dcode39->character - 1] == 0x2b) { /* STOP */ /* trim STOP character */ dcode39->character--; - zebra_symbol_type_t sym = ZEBRA_CODE39; + zbar_symbol_type_t sym = ZBAR_CODE39; /* trailing quiet zone check */ if(space < dcode39->width / 4) { dprintf(2, " [invalid qz]\n"); - sym = ZEBRA_NONE; + sym = ZBAR_NONE; } - else if(dcode39->character < CFG(*dcode39, ZEBRA_CFG_MIN_LEN) || - (CFG(*dcode39, ZEBRA_CFG_MAX_LEN) > 0 && - dcode39->character > CFG(*dcode39, ZEBRA_CFG_MAX_LEN))) { + else if(dcode39->character < CFG(*dcode39, ZBAR_CFG_MIN_LEN) || + (CFG(*dcode39, ZBAR_CFG_MAX_LEN) > 0 && + dcode39->character > CFG(*dcode39, ZBAR_CFG_MAX_LEN))) { dprintf(2, " [invalid len]\n"); - sym = ZEBRA_NONE; + sym = ZBAR_NONE; } else { /* FIXME checksum (needs config enable) */ @@ -295,7 +295,7 @@ zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) } dcode39->element = 0; dprintf(2, "\n"); - return(ZEBRA_NONE); + return(ZBAR_NONE); } signed char c = code39_decode9(dcode); @@ -305,7 +305,7 @@ zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) if(!dcode39->character && get_lock(dcode)) { dcode39->character = -1; dprintf(1, " [locked]\n"); - return(ZEBRA_PARTIAL); + return(ZBAR_PARTIAL); } if(c < 0 || @@ -314,14 +314,14 @@ zebra_symbol_type_t _zebra_decode_code39 (zebra_decoder_t *dcode) dprintf(1, (c < 0) ? " [aborted]\n" : " [overflow]\n"); dcode->lock = 0; dcode39->character = -1; - return(ZEBRA_NONE); + return(ZBAR_NONE); } else { - zassert(c < 0x2c, ZEBRA_NONE, "c=%02x s9=%x\n", c, dcode39->s9); + zassert(c < 0x2c, ZBAR_NONE, "c=%02x s9=%x\n", c, dcode39->s9); dprintf(2, "\n"); } dcode->buf[dcode39->character++] = c; - return(ZEBRA_NONE); + return(ZBAR_NONE); } diff --git a/zebra/decoder/code39.h b/zbar/decoder/code39.h similarity index 77% rename from zebra/decoder/code39.h rename to zbar/decoder/code39.h index 00b006fb..9b2356f6 100644 --- a/zebra/decoder/code39.h +++ b/zbar/decoder/code39.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _CODE39_H_ #define _CODE39_H_ @@ -45,6 +45,6 @@ static inline void code39_reset (code39_decoder_t *dcode39) } /* decode Code 39 symbols */ -zebra_symbol_type_t _zebra_decode_code39(zebra_decoder_t *dcode); +zbar_symbol_type_t _zbar_decode_code39(zbar_decoder_t *dcode); #endif diff --git a/zebra/decoder/ean.c b/zbar/decoder/ean.c similarity index 77% rename from zebra/decoder/ean.c rename to zbar/decoder/ean.c index 2849fa41..2ef22f04 100644 --- a/zebra/decoder/ean.c +++ b/zbar/decoder/ean.c @@ -1,28 +1,28 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include -#include +#include #include "decoder.h" #ifdef DEBUG_EAN @@ -112,7 +112,7 @@ static inline const unsigned char *dsprintbuf(ean_decoder_t *ean) /* evaluate previous N (>= 2) widths as auxiliary pattern, * using preceding 4 as character width */ -static inline signed char aux_end (zebra_decoder_t *dcode, +static inline signed char aux_end (zbar_decoder_t *dcode, unsigned char fwd) { /* reference width from previous character */ @@ -143,19 +143,19 @@ static inline signed char aux_end (zebra_decoder_t *dcode, /* determine possible auxiliary pattern * using current 4 as possible character */ -static inline signed char aux_start (zebra_decoder_t *dcode) +static inline signed char aux_start (zbar_decoder_t *dcode) { /* FIXME NB add-on has no guard in reverse */ unsigned e2 = get_width(dcode, 5) + get_width(dcode, 6); if(decode_e(e2, dcode->ean.s4, 7)) { dprintf(2, " [invalid any]"); - return(/*FIXME (get_color(dcode) == ZEBRA_SPACE) ? STATE_ADDON : */-1); + return(/*FIXME (get_color(dcode) == ZBAR_SPACE) ? STATE_ADDON : */-1); } unsigned e1 = get_width(dcode, 4) + get_width(dcode, 5); unsigned char E1 = decode_e(e1, dcode->ean.s4, 7); - if(get_color(dcode) == ZEBRA_BAR) { + if(get_color(dcode) == ZBAR_BAR) { /* check for quiet-zone */ if((get_width(dcode, 7) * 14 + 1) / dcode->ean.s4 >= 3) { if(!E1) { @@ -184,10 +184,10 @@ static inline signed char aux_start (zebra_decoder_t *dcode) } /* attempt to decode previous 4 widths (2 bars and 2 spaces) as a character */ -static inline signed char decode4 (zebra_decoder_t *dcode) +static inline signed char decode4 (zbar_decoder_t *dcode) { /* calculate similar edge measurements */ - unsigned e1 = ((get_color(dcode) == ZEBRA_BAR) + unsigned e1 = ((get_color(dcode) == ZBAR_BAR) ? get_width(dcode, 0) + get_width(dcode, 1) : get_width(dcode, 2) + get_width(dcode, 3)); unsigned e2 = get_width(dcode, 1) + get_width(dcode, 2); @@ -208,7 +208,7 @@ static inline signed char decode4 (zebra_decoder_t *dcode) */ if((1 << code) & 0x0660) { /* use sum of bar widths */ - unsigned d2 = ((get_color(dcode) == ZEBRA_BAR) + unsigned d2 = ((get_color(dcode) == ZBAR_BAR) ? get_width(dcode, 0) + get_width(dcode, 2) : get_width(dcode, 1) + get_width(dcode, 3)); d2 *= 7; @@ -226,8 +226,8 @@ static inline signed char decode4 (zebra_decoder_t *dcode) return(code); } -static inline zebra_symbol_type_t ean_part_end4 (ean_pass_t *pass, - unsigned char fwd) +static inline zbar_symbol_type_t ean_part_end4 (ean_pass_t *pass, + unsigned char fwd) { /* extract parity bits */ unsigned char par = ((pass->raw[1] & 0x10) >> 1 | @@ -238,7 +238,7 @@ static inline zebra_symbol_type_t ean_part_end4 (ean_pass_t *pass, dprintf(2, " par=%x", par); if(par && par != 0xf) /* invalid parity combination */ - return(ZEBRA_NONE); + return(ZBAR_NONE); if(!par == fwd) { /* reverse sampled digits */ @@ -255,13 +255,13 @@ static inline zebra_symbol_type_t ean_part_end4 (ean_pass_t *pass, pass->raw[1] & 0xf, pass->raw[2] & 0xf, pass->raw[3] & 0xf, pass->raw[4] & 0xf); if(!par) - return(ZEBRA_EAN8 | EAN_RIGHT); - return(ZEBRA_EAN8 | EAN_LEFT); + return(ZBAR_EAN8 | EAN_RIGHT); + return(ZBAR_EAN8 | EAN_LEFT); } -static inline zebra_symbol_type_t ean_part_end7 (ean_decoder_t *ean, - ean_pass_t *pass, - unsigned char fwd) +static inline zbar_symbol_type_t ean_part_end7 (ean_decoder_t *ean, + ean_pass_t *pass, + unsigned char fwd) { /* calculate parity index */ unsigned char par = ((fwd) @@ -287,7 +287,7 @@ static inline zebra_symbol_type_t ean_part_end7 (ean_decoder_t *ean, if(pass->raw[0] == 0xf) /* invalid parity combination */ - return(ZEBRA_NONE); + return(ZBAR_NONE); if(!par == fwd) { /* reverse sampled digits */ @@ -306,32 +306,32 @@ static inline zebra_symbol_type_t ean_part_end7 (ean_decoder_t *ean, pass->raw[4] & 0xf, pass->raw[5] & 0xf, pass->raw[6] & 0xf, par); - if(TEST_CFG(ean->ean13_config, ZEBRA_CFG_ENABLE)) { + if(TEST_CFG(ean->ean13_config, ZBAR_CFG_ENABLE)) { if(!par) - return(ZEBRA_EAN13 | EAN_RIGHT); + return(ZBAR_EAN13 | EAN_RIGHT); if(par & 0x20) - return(ZEBRA_EAN13 | EAN_LEFT); + return(ZBAR_EAN13 | EAN_LEFT); } if(par && !(par & 0x20)) - return(ZEBRA_UPCE); + return(ZBAR_UPCE); - return(ZEBRA_NONE); + return(ZBAR_NONE); } /* update state for one of 4 parallel passes */ -static inline zebra_symbol_type_t decode_pass (zebra_decoder_t *dcode, - ean_pass_t *pass) +static inline zbar_symbol_type_t decode_pass (zbar_decoder_t *dcode, + ean_pass_t *pass) { pass->state++; unsigned char idx = pass->state & STATE_IDX; unsigned char fwd = pass->state & 1; - if(get_color(dcode) == ZEBRA_SPACE && + if(get_color(dcode) == ZBAR_SPACE && (idx == 0x10 || idx == 0x11) && - TEST_CFG(dcode->ean.ean8_config, ZEBRA_CFG_ENABLE) && + TEST_CFG(dcode->ean.ean8_config, ZBAR_CFG_ENABLE) && !aux_end(dcode, fwd)) { dprintf(2, " fwd=%x", fwd); - zebra_symbol_type_t part = ean_part_end4(pass, fwd); + zbar_symbol_type_t part = ean_part_end4(pass, fwd); pass->state = -1; return(part); } @@ -361,9 +361,9 @@ static inline zebra_symbol_type_t decode_pass (zebra_decoder_t *dcode, } } - if(get_color(dcode) == ZEBRA_SPACE && + if(get_color(dcode) == ZBAR_SPACE && (idx == 0x18 || idx == 0x19)) { - zebra_symbol_type_t part = ZEBRA_NONE; + zbar_symbol_type_t part = ZBAR_NONE; dprintf(2, " fwd=%x", fwd); if(!aux_end(dcode, fwd)) part = ean_part_end7(&dcode->ean, pass, fwd); @@ -381,7 +381,7 @@ static inline signed char ean_verify_checksum (ean_decoder_t *ean, for(i = 0; i < n; i++) { unsigned char d = ean->buf[i]; zassert(d < 10, -1, "i=%x d=%x chk=%x %s\n", i, d, chk, - _zebra_decoder_buf_dump((void*)ean->buf, 18)); + _zbar_decoder_buf_dump((void*)ean->buf, 18)); chk += d; if((i ^ n) & 1) { chk += d << 1; @@ -392,12 +392,12 @@ static inline signed char ean_verify_checksum (ean_decoder_t *ean, chk -= 10; } zassert(chk < 10, -1, "chk=%x n=%x %s", chk, n, - _zebra_decoder_buf_dump((void*)ean->buf, 18)); + _zbar_decoder_buf_dump((void*)ean->buf, 18)); if(chk) chk = 10 - chk; unsigned char d = ean->buf[n]; zassert(d < 10, -1, "n=%x d=%x chk=%x %s\n", n, d, chk, - _zebra_decoder_buf_dump((void*)ean->buf, 18)); + _zbar_decoder_buf_dump((void*)ean->buf, 18)); if(chk != d) { dprintf(1, "\nchecksum mismatch %d != %d (%s)\n", chk, d, dsprintbuf(ean)); @@ -413,7 +413,7 @@ static inline unsigned char isbn10_calc_checksum (ean_decoder_t *ean) for(w = 10; w > 1; w--) { unsigned char d = ean->buf[13 - w]; zassert(d < 10, '?', "w=%x d=%x chk=%x %s\n", w, d, chk, - _zebra_decoder_buf_dump((void*)ean->buf, 18)); + _zbar_decoder_buf_dump((void*)ean->buf, 18)); chk += d * w; } chk = chk % 11; @@ -447,93 +447,93 @@ static inline void ean_expand_upce (ean_decoder_t *ean, ean->buf[11] = (decode < 5) ? pass->raw[i++] & 0xf : decode; } -static inline zebra_symbol_type_t integrate_partial (ean_decoder_t *ean, - ean_pass_t *pass, - zebra_symbol_type_t part) +static inline zbar_symbol_type_t integrate_partial (ean_decoder_t *ean, + ean_pass_t *pass, + zbar_symbol_type_t part) { /* copy raw data into holding buffer */ /* if same partial is not consistent, reset others */ dprintf(2, " integrate part=%x (%s)", part, dsprintbuf(ean)); signed char i, j; - if(part & ZEBRA_ADDON) { + if(part & ZBAR_ADDON) { /* FIXME TBD */ - for(i = (part == ZEBRA_ADDON5) ? 4 : 1; i >= 0; i--) { + for(i = (part == ZBAR_ADDON5) ? 4 : 1; i >= 0; i--) { unsigned char digit = pass->raw[i] & 0xf; if(ean->addon && ean->buf[i + 13] != digit) { /* partial mismatch - reset collected parts */ - ean->left = ean->right = ean->addon = ZEBRA_NONE; + ean->left = ean->right = ean->addon = ZBAR_NONE; } ean->buf[i + 13] = digit; } ean->addon = part; } else { - if((ean->left && ((part & ZEBRA_SYMBOL) != ean->left)) || - (ean->right && ((part & ZEBRA_SYMBOL) != ean->right))) { + if((ean->left && ((part & ZBAR_SYMBOL) != ean->left)) || + (ean->right && ((part & ZBAR_SYMBOL) != ean->right))) { /* partial mismatch - reset collected parts */ dprintf(2, " rst(type %x %x)", ean->left, ean->right); - ean->left = ean->right = ean->addon = ZEBRA_NONE; + ean->left = ean->right = ean->addon = ZBAR_NONE; } if(part & EAN_RIGHT) { - part &= ZEBRA_SYMBOL; - j = (part == ZEBRA_EAN13) ? 12 : 7; - for(i = (part == ZEBRA_EAN13) ? 6 : 4; i; i--, j--) { + part &= ZBAR_SYMBOL; + j = (part == ZBAR_EAN13) ? 12 : 7; + for(i = (part == ZBAR_EAN13) ? 6 : 4; i; i--, j--) { unsigned char digit = pass->raw[i] & 0xf; if(ean->right && ean->buf[j] != digit) { /* partial mismatch - reset collected parts */ dprintf(2, " rst(right)"); - ean->left = ean->right = ean->addon = ZEBRA_NONE; + ean->left = ean->right = ean->addon = ZBAR_NONE; } ean->buf[j] = digit; } ean->right = part; } - else if(part != ZEBRA_UPCE) /* EAN_LEFT */ { - j = (part == ZEBRA_EAN13) ? 6 : 3; - for(i = (part == ZEBRA_EAN13) ? 6 : 4; j >= 0; i--, j--) { + else if(part != ZBAR_UPCE) /* EAN_LEFT */ { + j = (part == ZBAR_EAN13) ? 6 : 3; + for(i = (part == ZBAR_EAN13) ? 6 : 4; j >= 0; i--, j--) { unsigned char digit = pass->raw[i] & 0xf; if(ean->left && ean->buf[j] != digit) { /* partial mismatch - reset collected parts */ dprintf(2, " rst(left)"); - ean->left = ean->right = ean->addon = ZEBRA_NONE; + ean->left = ean->right = ean->addon = ZBAR_NONE; } ean->buf[j] = digit; } ean->left = part; } - else /* ZEBRA_UPCE */ + else /* ZBAR_UPCE */ ean_expand_upce(ean, pass); } - if((part & ZEBRA_SYMBOL) != ZEBRA_UPCE) { + if((part & ZBAR_SYMBOL) != ZBAR_UPCE) { part = (ean->left & ean->right); if(!part) - part = ZEBRA_PARTIAL; + part = ZBAR_PARTIAL; } - if(((part == ZEBRA_EAN13 || - part == ZEBRA_UPCE) && ean_verify_checksum(ean, 12)) || - (part == ZEBRA_EAN8 && ean_verify_checksum(ean, 7))) + if(((part == ZBAR_EAN13 || + part == ZBAR_UPCE) && ean_verify_checksum(ean, 12)) || + (part == ZBAR_EAN8 && ean_verify_checksum(ean, 7))) /* invalid parity */ - part = ZEBRA_NONE; + part = ZBAR_NONE; - if(part == ZEBRA_EAN13) { + if(part == ZBAR_EAN13) { /* special case EAN-13 subsets */ - if(!ean->buf[0] && TEST_CFG(ean->upca_config, ZEBRA_CFG_ENABLE)) - part = ZEBRA_UPCA; + if(!ean->buf[0] && TEST_CFG(ean->upca_config, ZBAR_CFG_ENABLE)) + part = ZBAR_UPCA; else if(ean->buf[0] == 9 && ean->buf[1] == 7) { /* ISBN-10 has priority over ISBN-13(?) */ if(ean->buf[2] == 8 && - TEST_CFG(ean->isbn10_config, ZEBRA_CFG_ENABLE)) - part = ZEBRA_ISBN10; + TEST_CFG(ean->isbn10_config, ZBAR_CFG_ENABLE)) + part = ZBAR_ISBN10; else if((ean->buf[2] == 8 || ean->buf[2] == 9) && - TEST_CFG(ean->isbn13_config, ZEBRA_CFG_ENABLE)) - part = ZEBRA_ISBN13; + TEST_CFG(ean->isbn13_config, ZBAR_CFG_ENABLE)) + part = ZBAR_ISBN13; } } - else if(part == ZEBRA_UPCE) { - if(TEST_CFG(ean->upce_config, ZEBRA_CFG_ENABLE)) { + else if(part == ZBAR_UPCE) { + if(TEST_CFG(ean->upce_config, ZBAR_CFG_ENABLE)) { /* UPC-E was decompressed for checksum verification, * but user requested compressed result */ @@ -542,16 +542,16 @@ static inline zebra_symbol_type_t integrate_partial (ean_decoder_t *ean, ean->buf[i] = pass->raw[i - 1] & 0xf; ean->buf[i] = pass->raw[0] & 0xf; } - else if(TEST_CFG(ean->upca_config, ZEBRA_CFG_ENABLE)) + else if(TEST_CFG(ean->upca_config, ZBAR_CFG_ENABLE)) /* UPC-E reported as UPC-A has priority over EAN-13 */ - part = ZEBRA_UPCA; - else if(TEST_CFG(ean->ean13_config, ZEBRA_CFG_ENABLE)) - part = ZEBRA_EAN13; + part = ZBAR_UPCA; + else if(TEST_CFG(ean->ean13_config, ZBAR_CFG_ENABLE)) + part = ZBAR_EAN13; else - part = ZEBRA_NONE; + part = ZBAR_NONE; } - if(part > ZEBRA_PARTIAL) + if(part > ZBAR_PARTIAL) part |= ean->addon; dprintf(2, " %x/%x=%x", ean->left, ean->right, part); @@ -559,46 +559,46 @@ static inline zebra_symbol_type_t integrate_partial (ean_decoder_t *ean, } /* copy result to output buffer */ -static inline void postprocess (zebra_decoder_t *dcode, - zebra_symbol_type_t sym) +static inline void postprocess (zbar_decoder_t *dcode, + zbar_symbol_type_t sym) { ean_decoder_t *ean = &dcode->ean; - zebra_symbol_type_t base = sym & ZEBRA_SYMBOL; + zbar_symbol_type_t base = sym & ZBAR_SYMBOL; int i = 0, j = 0; - if(base > ZEBRA_PARTIAL) { - if(base == ZEBRA_UPCA) + if(base > ZBAR_PARTIAL) { + if(base == ZBAR_UPCA) i = 1; - else if(base == ZEBRA_UPCE) { + else if(base == ZBAR_UPCE) { i = 1; base--; } - else if(base == ZEBRA_ISBN13) - base = ZEBRA_EAN13; - else if(base == ZEBRA_ISBN10) + else if(base == ZBAR_ISBN13) + base = ZBAR_EAN13; + else if(base == ZBAR_ISBN10) i = 3; - if(base == ZEBRA_ISBN10 || - !TEST_CFG(ean_get_config(ean, sym), ZEBRA_CFG_EMIT_CHECK)) + if(base == ZBAR_ISBN10 || + !TEST_CFG(ean_get_config(ean, sym), ZBAR_CFG_EMIT_CHECK)) base--; for(; j < base && ean->buf[i] >= 0; i++, j++) dcode->buf[j] = ean->buf[i] + '0'; - if((sym & ZEBRA_SYMBOL) == ZEBRA_ISBN10 && j == 9 && - TEST_CFG(ean->isbn10_config, ZEBRA_CFG_EMIT_CHECK)) + if((sym & ZBAR_SYMBOL) == ZBAR_ISBN10 && j == 9 && + TEST_CFG(ean->isbn10_config, ZBAR_CFG_EMIT_CHECK)) /* recalculate ISBN-10 check digit */ dcode->buf[j++] = isbn10_calc_checksum(ean); } - if(sym & ZEBRA_ADDON) + if(sym & ZBAR_ADDON) for(i = 13; ean->buf[i] >= 0; i++, j++) dcode->buf[j] = ean->buf[i] + '0'; dcode->buf[j] = '\0'; } -zebra_symbol_type_t _zebra_decode_ean (zebra_decoder_t *dcode) +zbar_symbol_type_t _zbar_decode_ean (zbar_decoder_t *dcode) { /* process upto 4 separate passes */ - zebra_symbol_type_t sym = ZEBRA_NONE; + zbar_symbol_type_t sym = ZBAR_NONE; unsigned char pass_idx = dcode->idx & 3; /* update latest character width */ @@ -613,7 +613,7 @@ zebra_symbol_type_t _zebra_decode_ean (zebra_decoder_t *dcode) { dprintf(2, " ean[%x/%x]: idx=%x st=%d s=%d", pass_idx, i, dcode->idx, pass->state, dcode->ean.s4); - zebra_symbol_type_t part = decode_pass(dcode, pass); + zbar_symbol_type_t part = decode_pass(dcode, pass); if(part) { /* update accumulated data from new partial decode */ sym = integrate_partial(&dcode->ean, pass, part); @@ -622,12 +622,12 @@ zebra_symbol_type_t _zebra_decode_ean (zebra_decoder_t *dcode) dprintf(2, " sym=%x", sym); dcode->ean.pass[0].state = dcode->ean.pass[1].state = -1; dcode->ean.pass[2].state = dcode->ean.pass[3].state = -1; - if(sym > ZEBRA_PARTIAL) { + if(sym > ZBAR_PARTIAL) { if(!get_lock(dcode)) postprocess(dcode, sym); else { dprintf(1, " [locked]"); - sym = ZEBRA_PARTIAL; + sym = ZBAR_PARTIAL; } } } diff --git a/zebra/decoder/ean.h b/zbar/decoder/ean.h similarity index 66% rename from zebra/decoder/ean.h rename to zbar/decoder/ean.h index cb57f3c7..183b841e 100644 --- a/zebra/decoder/ean.h +++ b/zbar/decoder/ean.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _EAN_H_ #define _EAN_H_ @@ -34,9 +34,9 @@ typedef struct ean_pass_s { /* EAN/UPC specific decode state */ typedef struct ean_decoder_s { ean_pass_t pass[4]; /* state of each parallel decode attempt */ - zebra_symbol_type_t left; /* current holding buffer contents */ - zebra_symbol_type_t right; - zebra_symbol_type_t addon; + zbar_symbol_type_t left; /* current holding buffer contents */ + zbar_symbol_type_t right; + zbar_symbol_type_t addon; unsigned s4; /* character width */ signed char buf[18]; /* holding buffer */ @@ -61,24 +61,24 @@ static inline void ean_new_scan (ean_decoder_t *ean) static inline void ean_reset (ean_decoder_t *ean) { ean_new_scan(ean); - ean->left = ean->right = ean->addon = ZEBRA_NONE; + ean->left = ean->right = ean->addon = ZBAR_NONE; } static inline unsigned ean_get_config (ean_decoder_t *ean, - zebra_symbol_type_t sym) + zbar_symbol_type_t sym) { - switch(sym & ZEBRA_SYMBOL) { - case ZEBRA_EAN13: return(ean->ean13_config); - case ZEBRA_EAN8: return(ean->ean8_config); - case ZEBRA_UPCA: return(ean->upca_config); - case ZEBRA_UPCE: return(ean->upce_config); - case ZEBRA_ISBN10: return(ean->isbn10_config); - case ZEBRA_ISBN13: return(ean->isbn13_config); + switch(sym & ZBAR_SYMBOL) { + case ZBAR_EAN13: return(ean->ean13_config); + case ZBAR_EAN8: return(ean->ean8_config); + case ZBAR_UPCA: return(ean->upca_config); + case ZBAR_UPCE: return(ean->upce_config); + case ZBAR_ISBN10: return(ean->isbn10_config); + case ZBAR_ISBN13: return(ean->isbn13_config); default: return(0); } } /* decode EAN/UPC symbols */ -zebra_symbol_type_t _zebra_decode_ean(zebra_decoder_t *dcode); +zbar_symbol_type_t _zbar_decode_ean(zbar_decoder_t *dcode); #endif diff --git a/zebra/decoder/i25.c b/zbar/decoder/i25.c similarity index 80% rename from zebra/decoder/i25.c rename to zbar/decoder/i25.c index 588eb846..ffa0e3d5 100644 --- a/zebra/decoder/i25.c +++ b/zbar/decoder/i25.c @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include /* memmove */ -#include +#include #include "decoder.h" #ifdef DEBUG_I25 @@ -45,7 +45,7 @@ static inline unsigned char i25_decode1 (unsigned char enc, return(enc); } -static inline unsigned char i25_decode10 (zebra_decoder_t *dcode, +static inline unsigned char i25_decode10 (zbar_decoder_t *dcode, unsigned char offset) { i25_decoder_t *dcode25 = &dcode->i25; @@ -88,11 +88,11 @@ static inline unsigned char i25_decode10 (zebra_decoder_t *dcode, return(enc); } -static inline signed char i25_decode_start (zebra_decoder_t *dcode) +static inline signed char i25_decode_start (zbar_decoder_t *dcode) { i25_decoder_t *dcode25 = &dcode->i25; if(dcode25->s10 < 10) - return(ZEBRA_NONE); + return(ZBAR_NONE); unsigned char enc = 0; unsigned char i = 10; @@ -100,24 +100,24 @@ static inline signed char i25_decode_start (zebra_decoder_t *dcode) enc = i25_decode1(enc, get_width(dcode, i++), dcode25->s10); enc = i25_decode1(enc, get_width(dcode, i++), dcode25->s10); - if((get_color(dcode) == ZEBRA_BAR) + if((get_color(dcode) == ZBAR_BAR) ? enc != 4 : i25_decode1(enc, get_width(dcode, i++), dcode25->s10)) - return(ZEBRA_NONE); + return(ZBAR_NONE); /* check leading quiet zone - spec is 10x(?), we require at least 7x */ unsigned quiet = get_width(dcode, i++); if(quiet && get_width(dcode, i++) && quiet < dcode25->s10 / 4) - return(ZEBRA_NONE); + return(ZBAR_NONE); dcode25->direction = get_color(dcode); dcode25->element = 1; dcode25->character = 0; - return(ZEBRA_PARTIAL); + return(ZBAR_PARTIAL); } -static inline signed char i25_decode_end (zebra_decoder_t *dcode) +static inline signed char i25_decode_end (zbar_decoder_t *dcode) { i25_decoder_t *dcode25 = &dcode->i25; @@ -125,7 +125,7 @@ static inline signed char i25_decode_end (zebra_decoder_t *dcode) if(get_width(dcode, 0) < dcode25->width / 4 || decode_e(get_width(dcode, 1), dcode25->width, 45) > 2 || decode_e(get_width(dcode, 2), dcode25->width, 45) > 2) - return(ZEBRA_NONE); + return(ZBAR_NONE); /* check exit condition */ unsigned char E = decode_e(get_width(dcode, 3), dcode25->width, 45); @@ -133,7 +133,7 @@ static inline signed char i25_decode_end (zebra_decoder_t *dcode) ? E - 3 > 4 : (E > 2 || decode_e(get_width(dcode, 4), dcode25->width, 45) > 2)) - return(ZEBRA_NONE); + return(ZBAR_NONE); if(dcode25->direction) { /* reverse buffer */ @@ -147,22 +147,22 @@ static inline signed char i25_decode_end (zebra_decoder_t *dcode) } } - if(dcode25->character < CFG(*dcode25, ZEBRA_CFG_MIN_LEN) || - (CFG(*dcode25, ZEBRA_CFG_MAX_LEN) > 0 && - dcode25->character > CFG(*dcode25, ZEBRA_CFG_MAX_LEN))) { + if(dcode25->character < CFG(*dcode25, ZBAR_CFG_MIN_LEN) || + (CFG(*dcode25, ZBAR_CFG_MAX_LEN) > 0 && + dcode25->character > CFG(*dcode25, ZBAR_CFG_MAX_LEN))) { dprintf(2, " [invalid len]\n"); dcode->lock = 0; dcode25->character = -1; - return(ZEBRA_NONE); + return(ZBAR_NONE); } dcode->buf[dcode25->character] = '\0'; dprintf(2, " [valid end]\n"); dcode25->character = -1; - return(ZEBRA_I25); + return(ZBAR_I25); } -zebra_symbol_type_t _zebra_decode_i25 (zebra_decoder_t *dcode) +zbar_symbol_type_t _zbar_decode_i25 (zbar_decoder_t *dcode) { i25_decoder_t *dcode25 = &dcode->i25; @@ -172,12 +172,12 @@ zebra_symbol_type_t _zebra_decode_i25 (zebra_decoder_t *dcode) if(dcode25->character < 0 && !i25_decode_start(dcode)) - return(ZEBRA_NONE); + return(ZBAR_NONE); if(--dcode25->element == 6 - dcode25->direction) return(i25_decode_end(dcode)); else if(dcode25->element) - return(ZEBRA_NONE); + return(ZBAR_NONE); /* FIXME check current character width against previous */ dcode25->width = dcode25->s10; @@ -190,7 +190,7 @@ zebra_symbol_type_t _zebra_decode_i25 (zebra_decoder_t *dcode) if(!dcode25->character && get_lock(dcode)) { dcode25->character = -1; dprintf(2, " [locked]\n"); - return(ZEBRA_PARTIAL); + return(ZBAR_PARTIAL); } unsigned char c = i25_decode10(dcode, 1); @@ -202,7 +202,7 @@ zebra_symbol_type_t _zebra_decode_i25 (zebra_decoder_t *dcode) dprintf(2, (c > 9) ? " [aborted]\n" : " [overflow]\n"); dcode->lock = 0; dcode25->character = -1; - return(ZEBRA_NONE); + return(ZBAR_NONE); } dcode->buf[dcode25->character++] = c + '0'; @@ -212,12 +212,12 @@ zebra_symbol_type_t _zebra_decode_i25 (zebra_decoder_t *dcode) dprintf(2, " [aborted]\n"); dcode->lock = 0; dcode25->character = -1; - return(ZEBRA_NONE); + return(ZBAR_NONE); } else dprintf(2, "\n"); dcode->buf[dcode25->character++] = c + '0'; dcode25->element = 10; - return((dcode25->character == 2) ? ZEBRA_PARTIAL : ZEBRA_NONE); + return((dcode25->character == 2) ? ZBAR_PARTIAL : ZBAR_NONE); } diff --git a/zebra/decoder/i25.h b/zbar/decoder/i25.h similarity index 77% rename from zebra/decoder/i25.h rename to zbar/decoder/i25.h index bcec89aa..4f4bee0f 100644 --- a/zebra/decoder/i25.h +++ b/zbar/decoder/i25.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _I25_H_ #define _I25_H_ @@ -45,6 +45,6 @@ static inline void i25_reset (i25_decoder_t *i25) } /* decode interleaved 2 of 5 symbols */ -zebra_symbol_type_t _zebra_decode_i25(zebra_decoder_t *dcode); +zbar_symbol_type_t _zbar_decode_i25(zbar_decoder_t *dcode); #endif diff --git a/zebra/decoder/pdf417.c b/zbar/decoder/pdf417.c similarity index 81% rename from zebra/decoder/pdf417.c rename to zbar/decoder/pdf417.c index cc21caf6..2c9f043a 100644 --- a/zebra/decoder/pdf417.c +++ b/zbar/decoder/pdf417.c @@ -1,29 +1,29 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include -#include +#include #include "decoder.h" #include "pdf417_hash.h" @@ -35,7 +35,7 @@ #define PDF417_STOP 0xbff -static inline signed short pdf417_decode8 (zebra_decoder_t *dcode) +static inline signed short pdf417_decode8 (zbar_decoder_t *dcode) { /* build edge signature of character * from similar edge measurements @@ -49,7 +49,7 @@ static inline signed short pdf417_decode8 (zebra_decoder_t *dcode) signed char e; unsigned char i; for(i = 0; i < 7; i++) { - if(get_color(dcode) == ZEBRA_SPACE) + if(get_color(dcode) == ZBAR_SPACE) e = decode_e(get_width(dcode, i) + get_width(dcode, i + 1), s, 17); else @@ -70,7 +70,7 @@ static inline signed short pdf417_decode8 (zebra_decoder_t *dcode) dprintf(2, " k=%d", clst); zassert(clst >= 0 && clst < 9, -1, "dir=%x sig=%lx k=%x %s\n", dcode->pdf417.direction, sig, clst, - _zebra_decoder_buf_dump(dcode->buf, dcode->pdf417.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->pdf417.character)); if(clst != 0 && clst != 3 && clst != 6) { if(get_color(dcode) && clst == 7 && sig == 0x080007) @@ -86,7 +86,7 @@ static inline signed short pdf417_decode8 (zebra_decoder_t *dcode) zassert(g[0] >= 0 && g[1] >= 0 && g[2] >= 0, -1, "dir=%x sig=%lx k=%x g0=%03x g1=%03x g2=%03x %s\n", dcode->pdf417.direction, sig, clst, g[0], g[1], g[2], - _zebra_decoder_buf_dump(dcode->buf, dcode->pdf417.character)); + _zbar_decoder_buf_dump(dcode->buf, dcode->pdf417.character)); unsigned short c = (g[0] + g[1] + g[2]) & PDF417_HASH_MASK; dprintf(2, " g0=%x g1=%x g2=%x c=%03d(%d)", @@ -94,14 +94,14 @@ static inline signed short pdf417_decode8 (zebra_decoder_t *dcode) return(c); } -static inline signed char pdf417_decode_start(zebra_decoder_t *dcode) +static inline signed char pdf417_decode_start(zbar_decoder_t *dcode) { unsigned s = dcode->pdf417.s8; if(s < 8) return(0); int ei = decode_e(get_width(dcode, 0) + get_width(dcode, 1), s, 17); - int ex = (get_color(dcode) == ZEBRA_SPACE) ? 2 : 6; + int ex = (get_color(dcode) == ZBAR_SPACE) ? 2 : 6; if(ei != ex) return(0); @@ -110,12 +110,12 @@ static inline signed char pdf417_decode_start(zebra_decoder_t *dcode) return(0); ei = decode_e(get_width(dcode, 2) + get_width(dcode, 3), s, 17); - ex = (get_color(dcode) == ZEBRA_SPACE) ? 0 : 2; + ex = (get_color(dcode) == ZBAR_SPACE) ? 0 : 2; if(ei != ex) return(0); ei = decode_e(get_width(dcode, 3) + get_width(dcode, 4), s, 17); - ex = (get_color(dcode) == ZEBRA_SPACE) ? 0 : 2; + ex = (get_color(dcode) == ZBAR_SPACE) ? 0 : 2; if(ei != ex) return(0); @@ -128,14 +128,14 @@ static inline signed char pdf417_decode_start(zebra_decoder_t *dcode) return(0); ei = decode_e(get_width(dcode, 6) + get_width(dcode, 7), s, 17); - ex = (get_color(dcode) == ZEBRA_SPACE) ? 7 : 1; + ex = (get_color(dcode) == ZBAR_SPACE) ? 7 : 1; if(ei != ex) return(0); ei = decode_e(get_width(dcode, 7) + get_width(dcode, 8), s, 17); - ex = (get_color(dcode) == ZEBRA_SPACE) ? 8 : 1; + ex = (get_color(dcode) == ZBAR_SPACE) ? 8 : 1; - if(get_color(dcode) == ZEBRA_BAR) { + if(get_color(dcode) == ZBAR_BAR) { /* stop character has extra bar */ if(ei != 1) return(0); @@ -163,10 +163,10 @@ static inline signed char pdf417_decode_start(zebra_decoder_t *dcode) dcode417->character = 0; dprintf(2, " [valid start]\n"); - return(ZEBRA_PARTIAL); + return(ZBAR_PARTIAL); } -zebra_symbol_type_t _zebra_decode_pdf417 (zebra_decoder_t *dcode) +zbar_symbol_type_t _zbar_decode_pdf417 (zbar_decoder_t *dcode) { pdf417_decoder_t *dcode417 = &dcode->pdf417; @@ -192,10 +192,10 @@ zebra_symbol_type_t _zebra_decode_pdf417 (zebra_decoder_t *dcode) int c = dcode417->character; dcode->lock = 0; dcode417->character = -1; - zassert(get_color(dcode) == dcode417->direction, ZEBRA_NONE, + zassert(get_color(dcode) == dcode417->direction, ZBAR_NONE, "color=%x dir=%x char=%d elem=0 %s\n", get_color(dcode), dcode417->direction, c, - _zebra_decoder_buf_dump(dcode->buf, c)); + _zbar_decoder_buf_dump(dcode->buf, c)); } signed short c = pdf417_decode8(dcode); diff --git a/zebra/decoder/pdf417.h b/zbar/decoder/pdf417.h similarity index 76% rename from zebra/decoder/pdf417.h rename to zbar/decoder/pdf417.h index ffe43a9e..38e96889 100644 --- a/zebra/decoder/pdf417.h +++ b/zbar/decoder/pdf417.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _PDF417_H_ #define _PDF417_H_ @@ -44,6 +44,6 @@ static inline void pdf417_reset (pdf417_decoder_t *pdf417) } /* decode PDF417 symbols */ -zebra_symbol_type_t _zebra_decode_pdf417(zebra_decoder_t *dcode); +zbar_symbol_type_t _zbar_decode_pdf417(zbar_decoder_t *dcode); #endif diff --git a/zebra/decoder/pdf417_hash.h b/zbar/decoder/pdf417_hash.h similarity index 98% rename from zebra/decoder/pdf417_hash.h rename to zbar/decoder/pdf417_hash.h index aaeb8b52..12b4f35e 100644 --- a/zebra/decoder/pdf417_hash.h +++ b/zbar/decoder/pdf417_hash.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _PDF417_HASH_H_ #define _PDF417_HASH_H_ diff --git a/zebra/error.c b/zbar/error.c similarity index 70% rename from zebra/error.c rename to zbar/error.c index f1fb986a..2fb38486 100644 --- a/zebra/error.c +++ b/zbar/error.c @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "error.h" #include -int _zebra_verbosity = 0; +int _zbar_verbosity = 0; static const char * const sev_str[] = { "FATAL ERROR", "ERROR", "OK", "WARNING", "NOTE" @@ -34,7 +34,7 @@ static const char * const sev_str[] = { static const char * const mod_str[] = { "processor", "video", "window", "image scanner", "" }; -#define MOD_MAX (strlen(mod_str[ZEBRA_MOD_IMAGE_SCANNER])) +#define MOD_MAX (strlen(mod_str[ZBAR_MOD_IMAGE_SCANNER])) static const char const * err_str[] = { "no error", /* OK */ @@ -50,53 +50,53 @@ static const char const * err_str[] = { "output window is closed", /* CLOSED */ "unknown error" /* NUM */ }; -#define ERR_MAX (strlen(err_str[ZEBRA_ERR_CLOSED])) +#define ERR_MAX (strlen(err_str[ZBAR_ERR_CLOSED])) -int zebra_version (unsigned *major, - unsigned *minor) +int zbar_version (unsigned *major, + unsigned *minor) { if(major) - *major = ZEBRA_VERSION_MAJOR; + *major = ZBAR_VERSION_MAJOR; if(minor) - *minor = ZEBRA_VERSION_MINOR; + *minor = ZBAR_VERSION_MINOR; return(0); } -void zebra_set_verbosity (int level) +void zbar_set_verbosity (int level) { - _zebra_verbosity = level; + _zbar_verbosity = level; } -void zebra_increase_verbosity () +void zbar_increase_verbosity () { - if(!_zebra_verbosity) - _zebra_verbosity++; + if(!_zbar_verbosity) + _zbar_verbosity++; else - _zebra_verbosity <<= 1; + _zbar_verbosity <<= 1; } -int _zebra_error_spew (const void *container, - int verbosity) +int _zbar_error_spew (const void *container, + int verbosity) { const errinfo_t *err = container; assert(err->magic == ERRINFO_MAGIC); - fprintf(stderr, "%s", _zebra_error_string(err, verbosity)); + fprintf(stderr, "%s", _zbar_error_string(err, verbosity)); return(-err->sev); } -zebra_error_t _zebra_get_error_code (const void *container) +zbar_error_t _zbar_get_error_code (const void *container) { const errinfo_t *err = container; assert(err->magic == ERRINFO_MAGIC); return(err->type); } -/* ERROR: zebra video in v4l1_set_format(): +/* ERROR: zbar video in v4l1_set_format(): * system error: blah[: blah] */ -const char *_zebra_error_string (const void *container, - int verbosity) +const char *_zbar_error_string (const void *container, + int verbosity) { errinfo_t *err = (errinfo_t*)container; assert(err->magic == ERRINFO_MAGIC); @@ -108,21 +108,21 @@ const char *_zebra_error_string (const void *container, sev = sev_str[1]; const char *mod; - if(err->module >= ZEBRA_MOD_PROCESSOR && - err->module < ZEBRA_MOD_UNKNOWN) + if(err->module >= ZBAR_MOD_PROCESSOR && + err->module < ZBAR_MOD_UNKNOWN) mod = mod_str[err->module]; else - mod = mod_str[ZEBRA_MOD_UNKNOWN]; + mod = mod_str[ZBAR_MOD_UNKNOWN]; const char *func = (err->func) ? err->func : ""; const char *type; - if(err->type >= 0 && err->type < ZEBRA_ERR_NUM) + if(err->type >= 0 && err->type < ZBAR_ERR_NUM) type = err_str[err->type]; else - type = err_str[ZEBRA_ERR_NUM]; + type = err_str[ZBAR_ERR_NUM]; - char basefmt[] = "%s: zebra %s in %s():\n %s: "; + char basefmt[] = "%s: zbar %s in %s():\n %s: "; int len = SEV_MAX + MOD_MAX + ERR_MAX + strlen(func) + sizeof(basefmt); err->buf = realloc(err->buf, len); len = sprintf(err->buf, basefmt, sev, mod, func, type); @@ -149,7 +149,7 @@ const char *_zebra_error_string (const void *container, return(""); } - if(err->type == ZEBRA_ERR_SYSTEM) { + if(err->type == ZBAR_ERR_SYSTEM) { char sysfmt[] = ": %s (%d)\n"; const char *syserr = strerror(err->errnum); err->buf = realloc(err->buf, len + strlen(sysfmt) + strlen(syserr)); diff --git a/zebra/error.h b/zbar/error.h similarity index 83% rename from zebra/error.h rename to zbar/error.h index 6f20ae11..4c9945fe 100644 --- a/zebra/error.h +++ b/zbar/error.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _ERROR_H_ #define _ERROR_H_ @@ -33,7 +33,7 @@ #include #include -#include +#include #if __STDC_VERSION__ < 199901L # if __GNUC__ >= 2 @@ -54,11 +54,11 @@ typedef enum errsev_e { } errsev_t; typedef enum errmodule_e { - ZEBRA_MOD_PROCESSOR, - ZEBRA_MOD_VIDEO, - ZEBRA_MOD_WINDOW, - ZEBRA_MOD_IMAGE_SCANNER, - ZEBRA_MOD_UNKNOWN, + ZBAR_MOD_PROCESSOR, + ZBAR_MOD_VIDEO, + ZBAR_MOD_WINDOW, + ZBAR_MOD_IMAGE_SCANNER, + ZBAR_MOD_UNKNOWN, } errmodule_t; typedef struct errinfo_s { @@ -68,19 +68,19 @@ typedef struct errinfo_s { int errnum; /* errno for system errors */ errsev_t sev; - zebra_error_t type; + zbar_error_t type; const char *func; /* reporting function */ const char *detail; /* description */ char *arg_str; /* single string argument */ int arg_int; /* single integer argument */ } errinfo_t; -extern int _zebra_verbosity; +extern int _zbar_verbosity; /* FIXME don't we need varargs hacks here? */ #define zprintf(level, format, ...) do { \ - if(_zebra_verbosity >= level) \ + if(_zbar_verbosity >= level) \ fprintf(stderr, "%s: " format, __func__ , ##__VA_ARGS__); \ } while(0) @@ -105,26 +105,26 @@ static inline int err_copy (void *dst_c, static inline int err_capture (const void *container, errsev_t sev, - zebra_error_t type, + zbar_error_t type, const char *func, const char *detail) { errinfo_t *err = (errinfo_t*)container; assert(err->magic == ERRINFO_MAGIC); - if(type == ZEBRA_ERR_SYSTEM) + if(type == ZBAR_ERR_SYSTEM) err->errnum = errno; err->sev = sev; err->type = type; err->func = func; err->detail = detail; - if(_zebra_verbosity >= 1) - _zebra_error_spew(err, 0); + if(_zbar_verbosity >= 1) + _zbar_error_spew(err, 0); return(-1); } static inline int err_capture_str (const void *container, errsev_t sev, - zebra_error_t type, + zbar_error_t type, const char *func, const char *detail, const char *arg) @@ -139,7 +139,7 @@ static inline int err_capture_str (const void *container, static inline int err_capture_int (const void *container, errsev_t sev, - zebra_error_t type, + zbar_error_t type, const char *func, const char *detail, int arg) @@ -152,7 +152,7 @@ static inline int err_capture_int (const void *container, static inline int err_capture_num (const void *container, errsev_t sev, - zebra_error_t type, + zbar_error_t type, const char *func, const char *detail, int num) diff --git a/zebra/image.c b/zbar/image.c similarity index 59% rename from zebra/image.c rename to zbar/image.c index 426e20b7..c1506be2 100644 --- a/zebra/image.c +++ b/zbar/image.c @@ -1,107 +1,107 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "error.h" #include "image.h" -zebra_image_t *zebra_image_create () +zbar_image_t *zbar_image_create () { - zebra_image_t *img = calloc(1, sizeof(zebra_image_t)); + zbar_image_t *img = calloc(1, sizeof(zbar_image_t)); img->refcnt = 1; img->srcidx = -1; return(img); } -void zebra_image_destroy (zebra_image_t *img) +void zbar_image_destroy (zbar_image_t *img) { - _zebra_image_refcnt(img, -1); + _zbar_image_refcnt(img, -1); } -void zebra_image_ref (zebra_image_t *img, - int refs) +void zbar_image_ref (zbar_image_t *img, + int refs) { - _zebra_image_refcnt(img, refs); + _zbar_image_refcnt(img, refs); } -unsigned long zebra_image_get_format (const zebra_image_t *img) +unsigned long zbar_image_get_format (const zbar_image_t *img) { return(img->format); } -unsigned zebra_image_get_sequence (const zebra_image_t *img) +unsigned zbar_image_get_sequence (const zbar_image_t *img) { return(img->seq); } -unsigned zebra_image_get_width (const zebra_image_t *img) +unsigned zbar_image_get_width (const zbar_image_t *img) { return(img->width); } -unsigned zebra_image_get_height (const zebra_image_t *img) +unsigned zbar_image_get_height (const zbar_image_t *img) { return(img->height); } -const void *zebra_image_get_data (const zebra_image_t *img) +const void *zbar_image_get_data (const zbar_image_t *img) { return(img->data); } -unsigned long zebra_image_get_data_length (const zebra_image_t *img) +unsigned long zbar_image_get_data_length (const zbar_image_t *img) { return(img->datalen); } -void zebra_image_set_format (zebra_image_t *img, - unsigned long fmt) +void zbar_image_set_format (zbar_image_t *img, + unsigned long fmt) { img->format = fmt; } -void zebra_image_set_sequence (zebra_image_t *img, - unsigned seq) +void zbar_image_set_sequence (zbar_image_t *img, + unsigned seq) { img->seq = seq; } -void zebra_image_set_size (zebra_image_t *img, - unsigned w, - unsigned h) +void zbar_image_set_size (zbar_image_t *img, + unsigned w, + unsigned h) { img->width = w; img->height = h; } -inline void zebra_image_free_data (zebra_image_t *img) +inline void zbar_image_free_data (zbar_image_t *img) { if(!img) return; if(img->src) { /* replace video image w/new copy */ assert(img->refcnt); - zebra_image_t *newimg = zebra_image_create(); - memcpy(newimg, img, sizeof(zebra_image_t)); + zbar_image_t *newimg = zbar_image_create(); + memcpy(newimg, img, sizeof(zbar_image_t)); /* recycle video image */ newimg->cleanup(newimg); /* detach old image from src */ @@ -110,7 +110,7 @@ inline void zebra_image_free_data (zebra_image_t *img) img->srcidx = -1; } else if(img->cleanup && img->data) { - if(img->cleanup != zebra_image_free_data) + if(img->cleanup != zbar_image_free_data) img->cleanup(img); else free((void*)img->data); @@ -118,31 +118,31 @@ inline void zebra_image_free_data (zebra_image_t *img) img->data = NULL; } -void zebra_image_set_data (zebra_image_t *img, - const void *data, - unsigned long len, - zebra_image_cleanup_handler_t *cleanup) +void zbar_image_set_data (zbar_image_t *img, + const void *data, + unsigned long len, + zbar_image_cleanup_handler_t *cleanup) { - zebra_image_free_data(img); + zbar_image_free_data(img); img->data = data; img->datalen = len; img->cleanup = cleanup; } -void zebra_image_set_userdata (zebra_image_t *img, - void *userdata) +void zbar_image_set_userdata (zbar_image_t *img, + void *userdata) { img->userdata = userdata; } -void *zebra_image_get_userdata (const zebra_image_t *img) +void *zbar_image_get_userdata (const zbar_image_t *img) { return(img->userdata); } -zebra_image_t *zebra_image_copy (const zebra_image_t *src) +zbar_image_t *zbar_image_copy (const zbar_image_t *src) { - zebra_image_t *dst = zebra_image_create(); + zbar_image_t *dst = zbar_image_create(); dst->format = src->format; dst->width = src->width; dst->height = src->height; @@ -150,11 +150,11 @@ zebra_image_t *zebra_image_copy (const zebra_image_t *src) dst->data = malloc(src->datalen); assert(dst->data); memcpy((void*)dst->data, src->data, src->datalen); - dst->cleanup = zebra_image_free_data; + dst->cleanup = zbar_image_free_data; return(dst); } -const zebra_symbol_t *zebra_image_first_symbol (const zebra_image_t *img) +const zbar_symbol_t *zbar_image_first_symbol (const zbar_image_t *img) { /* symbols stored on root image */ while(img->next) @@ -168,8 +168,8 @@ typedef struct zimg_hdr_s { uint32_t size; } zimg_hdr_t; -int zebra_image_write (const zebra_image_t *img, - const char *filebase) +int zbar_image_write (const zbar_image_t *img, + const char *filebase) { int len = strlen(filebase) + 16; char filename[len]; diff --git a/zebra/image.h b/zbar/image.h similarity index 71% rename from zebra/image.h rename to zbar/image.h index 45a97a14..a70c72a7 100644 --- a/zebra/image.h +++ b/zbar/image.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _IMAGE_H_ #define _IMAGE_H_ @@ -30,7 +30,7 @@ #include #include -#include +#include #include "error.h" #include "symbol.h" @@ -46,20 +46,20 @@ /* coarse image format categorization. * to limit conversion variations */ -typedef enum zebra_format_group_e { - ZEBRA_FMT_GRAY, - ZEBRA_FMT_YUV_PLANAR, - ZEBRA_FMT_YUV_PACKED, - ZEBRA_FMT_RGB_PACKED, - ZEBRA_FMT_YUV_NV, - ZEBRA_FMT_JPEG, +typedef enum zbar_format_group_e { + ZBAR_FMT_GRAY, + ZBAR_FMT_YUV_PLANAR, + ZBAR_FMT_YUV_PACKED, + ZBAR_FMT_RGB_PACKED, + ZBAR_FMT_YUV_NV, + ZBAR_FMT_JPEG, /* enum size */ - ZEBRA_FMT_NUM -} zebra_format_group_t; + ZBAR_FMT_NUM +} zbar_format_group_t; -struct zebra_image_s { +struct zbar_image_s { uint32_t format; /* fourcc image format code */ unsigned width, height; /* image size */ const void *data; /* image sample data */ @@ -67,21 +67,21 @@ struct zebra_image_s { void *userdata; /* user specified data associated w/image */ /* cleanup handler */ - zebra_image_cleanup_handler_t *cleanup; + zbar_image_cleanup_handler_t *cleanup; int refcnt; /* reference count */ - zebra_video_t *src; /* originator */ + zbar_video_t *src; /* originator */ int srcidx; /* index used by originator */ - zebra_image_t *next; /* internal image lists */ + zbar_image_t *next; /* internal image lists */ unsigned seq; /* page/frame sequence number */ int nsyms; /* number of valid symbols */ - zebra_symbol_t *syms; /* first of decoded symbol results */ + zbar_symbol_t *syms; /* first of decoded symbol results */ }; /* description of an image format */ -typedef struct zebra_format_def_s { +typedef struct zbar_format_def_s { uint32_t format; /* fourcc */ - zebra_format_group_t group; /* coarse categorization */ + zbar_format_group_t group; /* coarse categorization */ union { uint8_t gen[4]; /* raw bytes */ struct { @@ -97,10 +97,10 @@ typedef struct zebra_format_def_s { } yuv; uint32_t cmp; /* quick compare equivalent formats */ } p; -} zebra_format_def_t; +} zbar_format_def_t; -static inline void _zebra_image_refcnt (zebra_image_t *img, - int delta) +static inline void _zbar_image_refcnt (zbar_image_t *img, + int delta) { img->refcnt += delta; assert(img->refcnt >= 0); @@ -112,7 +112,7 @@ static inline void _zebra_image_refcnt (zebra_image_t *img, } } -extern int _zebra_best_format(uint32_t, uint32_t*, const uint32_t*); -extern const zebra_format_def_t *_zebra_format_lookup(uint32_t); +extern int _zbar_best_format(uint32_t, uint32_t*, const uint32_t*); +extern const zbar_format_def_t *_zbar_format_lookup(uint32_t); #endif diff --git a/zebra/img_scanner.c b/zbar/img_scanner.c similarity index 68% rename from zebra/img_scanner.c rename to zbar/img_scanner.c index cea83391..0d1cdd8d 100644 --- a/zebra/img_scanner.c +++ b/zbar/img_scanner.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -32,7 +32,7 @@ #include /* strlen, strcmp, memset, memcpy */ #include -#include +#include #include "error.h" #include "image.h" @@ -63,38 +63,38 @@ */ #define CACHE_TIMEOUT (CACHE_HYSTERESIS * 2) /* ms */ -#define NUM_SCN_CFGS (ZEBRA_CFG_Y_DENSITY - ZEBRA_CFG_X_DENSITY + 1) +#define NUM_SCN_CFGS (ZBAR_CFG_Y_DENSITY - ZBAR_CFG_X_DENSITY + 1) -#define CFG(iscn, cfg) ((iscn)->configs[(cfg) - ZEBRA_CFG_X_DENSITY]) +#define CFG(iscn, cfg) ((iscn)->configs[(cfg) - ZBAR_CFG_X_DENSITY]) /* image scanner state */ -struct zebra_image_scanner_s { - zebra_scanner_t *scn; /* associated linear intensity scanner */ - zebra_decoder_t *dcode; /* associated symbol decoder */ +struct zbar_image_scanner_s { + zbar_scanner_t *scn; /* associated linear intensity scanner */ + zbar_decoder_t *dcode; /* associated symbol decoder */ const void *userdata; /* application data */ /* user result callback */ - zebra_image_data_handler_t *handler; + zbar_image_data_handler_t *handler; - zebra_image_t *img; /* currently scanning image *root* */ + zbar_image_t *img; /* currently scanning image *root* */ int nsyms; /* total cached symbols */ - zebra_symbol_t *syms; /* recycled symbols */ + zbar_symbol_t *syms; /* recycled symbols */ int enable_cache; /* current result cache state */ - zebra_symbol_t *cache; /* inter-image result cache entries */ + zbar_symbol_t *cache; /* inter-image result cache entries */ /* configuration settings */ int configs[NUM_SCN_CFGS]; }; -static inline void recycle_syms (zebra_image_scanner_t *iscn, - zebra_image_t *img) +static inline void recycle_syms (zbar_image_scanner_t *iscn, + zbar_image_t *img) { /* walk to root of clone tree */ while(img) { img->nsyms = 0; - zebra_symbol_t *sym = img->syms; + zbar_symbol_t *sym = img->syms; if(sym) { /* recycle image symbols */ iscn->nsyms++; @@ -112,19 +112,19 @@ static inline void recycle_syms (zebra_image_scanner_t *iscn, } } -static inline zebra_symbol_t *alloc_sym (zebra_image_scanner_t *iscn, - zebra_symbol_type_t type, - const char *data) +static inline zbar_symbol_t *alloc_sym (zbar_image_scanner_t *iscn, + zbar_symbol_type_t type, + const char *data) { /* recycle old or alloc new symbol */ - zebra_symbol_t *sym = iscn->syms; + zbar_symbol_t *sym = iscn->syms; if(sym) { iscn->syms = sym->next; assert(iscn->nsyms); iscn->nsyms--; } else { - sym = calloc(1, sizeof(zebra_symbol_t)); + sym = calloc(1, sizeof(zbar_symbol_t)); assert(!iscn->nsyms); } @@ -142,18 +142,18 @@ static inline zebra_symbol_t *alloc_sym (zebra_image_scanner_t *iscn, return(sym); } -static inline zebra_symbol_t *cache_lookup (zebra_image_scanner_t *iscn, - zebra_symbol_t *sym) +static inline zbar_symbol_t *cache_lookup (zbar_image_scanner_t *iscn, + zbar_symbol_t *sym) { /* search for matching entry in cache */ - zebra_symbol_t **entry = &iscn->cache; + zbar_symbol_t **entry = &iscn->cache; while(*entry) { if((*entry)->type == sym->type && !strcmp((*entry)->data, sym->data)) break; if((sym->time - (*entry)->time) > CACHE_TIMEOUT) { /* recycle stale cache entry */ - zebra_symbol_t *next = (*entry)->next; + zbar_symbol_t *next = (*entry)->next; (*entry)->next = iscn->syms; iscn->syms = *entry; iscn->nsyms++; @@ -165,20 +165,20 @@ static inline zebra_symbol_t *cache_lookup (zebra_image_scanner_t *iscn, return(*entry); } -static void symbol_handler (zebra_image_scanner_t *iscn, +static void symbol_handler (zbar_image_scanner_t *iscn, int x, int y) { - zebra_symbol_type_t type = zebra_decoder_get_type(iscn->dcode); - /* FIXME assert(type == ZEBRA_PARTIAL) */ + zbar_symbol_type_t type = zbar_decoder_get_type(iscn->dcode); + /* FIXME assert(type == ZBAR_PARTIAL) */ /* FIXME debug flag to save/display all PARTIALs */ - if(type <= ZEBRA_PARTIAL) + if(type <= ZBAR_PARTIAL) return; - const char *data = zebra_decoder_get_data(iscn->dcode); + const char *data = zbar_decoder_get_data(iscn->dcode); /* FIXME deprecate - instead check (x, y) inside existing polygon */ - zebra_symbol_t *sym; + zbar_symbol_t *sym; for(sym = iscn->img->syms; sym; sym = sym->next) if(sym->type == type && !strcmp(sym->data, data)) { @@ -211,7 +211,7 @@ static void symbol_handler (zebra_image_scanner_t *iscn, iscn->img->nsyms++; if(iscn->enable_cache) { - zebra_symbol_t *entry = cache_lookup(iscn, sym); + zbar_symbol_t *entry = cache_lookup(iscn, sym); if(!entry) { entry = alloc_sym(iscn, sym->type, sym->data); entry->time = sym->time - CACHE_HYSTERESIS; @@ -241,72 +241,72 @@ static void symbol_handler (zebra_image_scanner_t *iscn, iscn->handler(iscn->img, iscn->userdata); } -zebra_image_scanner_t *zebra_image_scanner_create () +zbar_image_scanner_t *zbar_image_scanner_create () { - zebra_image_scanner_t *iscn = calloc(1, sizeof(zebra_image_scanner_t)); + zbar_image_scanner_t *iscn = calloc(1, sizeof(zbar_image_scanner_t)); if(!iscn) return(NULL); - iscn->dcode = zebra_decoder_create(); - iscn->scn = zebra_scanner_create(iscn->dcode); + iscn->dcode = zbar_decoder_create(); + iscn->scn = zbar_scanner_create(iscn->dcode); if(!iscn->dcode || !iscn->scn) { - zebra_image_scanner_destroy(iscn); + zbar_image_scanner_destroy(iscn); return(NULL); } /* apply default configuration */ - CFG(iscn, ZEBRA_CFG_X_DENSITY) = 16; - CFG(iscn, ZEBRA_CFG_Y_DENSITY) = 16; + CFG(iscn, ZBAR_CFG_X_DENSITY) = 16; + CFG(iscn, ZBAR_CFG_Y_DENSITY) = 16; return(iscn); } -void zebra_image_scanner_destroy (zebra_image_scanner_t *iscn) +void zbar_image_scanner_destroy (zbar_image_scanner_t *iscn) { if(iscn->scn) - zebra_scanner_destroy(iscn->scn); + zbar_scanner_destroy(iscn->scn); iscn->scn = NULL; if(iscn->dcode) - zebra_decoder_destroy(iscn->dcode); + zbar_decoder_destroy(iscn->dcode); iscn->dcode = NULL; while(iscn->syms) { - zebra_symbol_t *next = iscn->syms->next; + zbar_symbol_t *next = iscn->syms->next; sym_destroy(iscn->syms); iscn->syms = next; } free(iscn); } -zebra_image_data_handler_t* -zebra_image_scanner_set_data_handler (zebra_image_scanner_t *iscn, - zebra_image_data_handler_t *handler, - const void *userdata) +zbar_image_data_handler_t* +zbar_image_scanner_set_data_handler (zbar_image_scanner_t *iscn, + zbar_image_data_handler_t *handler, + const void *userdata) { - zebra_image_data_handler_t *result = iscn->handler; + zbar_image_data_handler_t *result = iscn->handler; iscn->handler = handler; iscn->userdata = userdata; return(result); } -int zebra_image_scanner_set_config (zebra_image_scanner_t *iscn, - zebra_symbol_type_t sym, - zebra_config_t cfg, - int val) +int zbar_image_scanner_set_config (zbar_image_scanner_t *iscn, + zbar_symbol_type_t sym, + zbar_config_t cfg, + int val) { - if(cfg >= ZEBRA_CFG_X_DENSITY && cfg <= ZEBRA_CFG_Y_DENSITY) { - if(sym > ZEBRA_PARTIAL) + if(cfg >= ZBAR_CFG_X_DENSITY && cfg <= ZBAR_CFG_Y_DENSITY) { + if(sym > ZBAR_PARTIAL) return(1); CFG(iscn, cfg) = val; return(0); } - return(zebra_decoder_set_config(iscn->dcode, sym, cfg, val)); + return(zbar_decoder_set_config(iscn->dcode, sym, cfg, val)); } -void zebra_image_scanner_enable_cache(zebra_image_scanner_t *iscn, - int enable) +void zbar_image_scanner_enable_cache(zbar_image_scanner_t *iscn, + int enable) { if(iscn->cache) { /* recycle all cached syms */ - zebra_symbol_t *entry; + zbar_symbol_t *entry; for(entry = iscn->cache; entry->next; entry = entry->next) iscn->nsyms++; iscn->nsyms++; @@ -317,20 +317,20 @@ void zebra_image_scanner_enable_cache(zebra_image_scanner_t *iscn, iscn->enable_cache = enable; } -static inline void quiet_border (zebra_image_scanner_t *iscn, +static inline void quiet_border (zbar_image_scanner_t *iscn, unsigned samples, int x, int y) { unsigned i; for(i = samples; i; i--) - if(zebra_scan_y(iscn->scn, 255)) + if(zbar_scan_y(iscn->scn, 255)) symbol_handler(iscn, x, y); /* flush final transition with 2 black pixels */ for(i = 2; i; i--) - if(zebra_scan_y(iscn->scn, 0)) + if(zbar_scan_y(iscn->scn, 0)) symbol_handler(iscn, x, y); - if(zebra_scanner_new_scan(iscn->scn)) + if(zbar_scanner_new_scan(iscn->scn)) symbol_handler(iscn, x, y); } @@ -340,26 +340,26 @@ static inline void quiet_border (zebra_image_scanner_t *iscn, p += (dx) + ((intptr_t)(dy) * w); \ } while(0); -int zebra_scan_image (zebra_image_scanner_t *iscn, - zebra_image_t *img) +int zbar_scan_image (zbar_image_scanner_t *iscn, + zbar_image_t *img) { recycle_syms(iscn, img); /* get grayscale image, convert if necessary */ - img = zebra_image_convert(img, fourcc('Y','8','0','0')); + img = zbar_image_convert(img, fourcc('Y','8','0','0')); if(!img) return(-1); - unsigned w = zebra_image_get_width(img); - unsigned h = zebra_image_get_height(img); - const uint8_t *data = zebra_image_get_data(img); + unsigned w = zbar_image_get_width(img); + unsigned h = zbar_image_get_height(img); + const uint8_t *data = zbar_image_get_data(img); /* FIXME less arbitrary lead-out default */ int quiet = w / 32; if(quiet < 8) quiet = 8; - int density = CFG(iscn, ZEBRA_CFG_Y_DENSITY); + int density = CFG(iscn, ZBAR_CFG_Y_DENSITY); if(density > 0) { const uint8_t *p = data; int x = 0, y = 0; @@ -369,14 +369,14 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, border = h / 2; movedelta(0, border); - if(zebra_scanner_new_scan(iscn->scn)) + if(zbar_scanner_new_scan(iscn->scn)) symbol_handler(iscn, x, y); while(y < h) { zprintf(32, "img_x+: %03x,%03x @%p\n", x, y, p); while(x < w) { ASSERT_POS; - if(zebra_scan_y(iscn->scn, *p)) + if(zbar_scan_y(iscn->scn, *p)) symbol_handler(iscn, x, y); movedelta(1, 0); } @@ -389,7 +389,7 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, zprintf(32, "img_x-: %03x,%03x @%p\n", x, y, p); while(x > 0) { ASSERT_POS; - if(zebra_scan_y(iscn->scn, *p)) + if(zbar_scan_y(iscn->scn, *p)) symbol_handler(iscn, x, y); movedelta(-1, 0); } @@ -399,7 +399,7 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, } } - density = CFG(iscn, ZEBRA_CFG_X_DENSITY); + density = CFG(iscn, ZBAR_CFG_X_DENSITY); if(density > 0) { const uint8_t *p = data; int x = 0, y = 0; @@ -413,7 +413,7 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, zprintf(32, "img_y+: %03x,%03x @%p\n", x, y, p); while(y < h) { ASSERT_POS; - if(zebra_scan_y(iscn->scn, *p)) + if(zbar_scan_y(iscn->scn, *p)) symbol_handler(iscn, x, y); movedelta(0, 1); } @@ -426,7 +426,7 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, zprintf(32, "img_y-: %03x,%03x @%p\n", x, y, p); while(y >= 0) { ASSERT_POS; - if(zebra_scan_y(iscn->scn, *p)) + if(zbar_scan_y(iscn->scn, *p)) symbol_handler(iscn, x, y); movedelta(0, -1); } @@ -437,6 +437,6 @@ int zebra_scan_image (zebra_image_scanner_t *iscn, } /* release reference to converted image */ - zebra_image_destroy(img); + zbar_image_destroy(img); return(iscn->img->nsyms); } diff --git a/zebra/jpeg.c b/zbar/jpeg.c similarity index 82% rename from zebra/jpeg.c rename to zbar/jpeg.c index d20aaea1..e489197c 100644 --- a/zebra/jpeg.c +++ b/zbar/jpeg.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -28,7 +28,7 @@ #include /* FIXME tmp debug */ #undef HAVE_STDLIB_H -#include +#include #include "image.h" #include "video.h" @@ -41,7 +41,7 @@ typedef struct errenv_s { jmp_buf env; } errenv_t; -void zebra_jpeg_error (j_common_ptr cinfo) +void zbar_jpeg_error (j_common_ptr cinfo) { errenv_t *jerr = (errenv_t*)cinfo->err; assert(jerr->valid); @@ -52,10 +52,10 @@ void zebra_jpeg_error (j_common_ptr cinfo) #endif -typedef struct zebra_src_mgr_s { +typedef struct zbar_src_mgr_s { struct jpeg_source_mgr src; - const zebra_image_t *img; -} zebra_src_mgr_t; + const zbar_image_t *img; +} zbar_src_mgr_t; static const JOCTET fake_eoi[2] = { 0xff, JPEG_EOI }; @@ -63,7 +63,7 @@ void init_source (j_decompress_ptr cinfo) { /* buffer/length refer to compressed data */ /* FIXME find img */ - const zebra_image_t *img = ((zebra_src_mgr_t*)cinfo->src)->img; + const zbar_image_t *img = ((zbar_src_mgr_t*)cinfo->src)->img; cinfo->src->next_input_byte = img->data; cinfo->src->bytes_in_buffer = img->datalen; } @@ -88,7 +88,7 @@ void term_source (j_decompress_ptr cinfo) /* nothing todo */ } -struct jpeg_decompress_struct * _zebra_jpeg_decomp_create () +struct jpeg_decompress_struct * _zbar_jpeg_decomp_create () { j_decompress_ptr cinfo = calloc(1, sizeof(struct jpeg_decompress_struct)); if(!cinfo) @@ -101,7 +101,7 @@ struct jpeg_decompress_struct * _zebra_jpeg_decomp_create () } cinfo->err = jpeg_std_error(&jerr->err); - jerr->err.error_exit = zebra_jpeg_error; + jerr->err.error_exit = zbar_jpeg_error; jerr->valid = 1; if(setjmp(jerr->env)) { @@ -121,7 +121,7 @@ struct jpeg_decompress_struct * _zebra_jpeg_decomp_create () return(cinfo); } -void _zebra_jpeg_decomp_destroy (struct jpeg_decompress_struct *cinfo) +void _zbar_jpeg_decomp_destroy (struct jpeg_decompress_struct *cinfo) { if(cinfo->err) { free(cinfo->err); @@ -137,16 +137,16 @@ void _zebra_jpeg_decomp_destroy (struct jpeg_decompress_struct *cinfo) } /* invoke libjpeg to decompress JPEG format to luminance plane */ -void _zebra_convert_jpeg_to_y (zebra_image_t *dst, - const zebra_format_def_t *dstfmt, - const zebra_image_t *src, - const zebra_format_def_t *srcfmt) +void _zbar_convert_jpeg_to_y (zbar_image_t *dst, + const zbar_format_def_t *dstfmt, + const zbar_image_t *src, + const zbar_format_def_t *srcfmt) { /* create decompressor, or use cached video stream decompressor */ errenv_t *jerr = NULL; j_decompress_ptr cinfo; if(!src->src) - cinfo = _zebra_jpeg_decomp_create(); + cinfo = _zbar_jpeg_decomp_create(); else { cinfo = src->src->jpeg; assert(cinfo); @@ -169,7 +169,7 @@ void _zebra_convert_jpeg_to_y (zebra_image_t *dst, /* setup input image */ if(!cinfo->src) { - cinfo->src = calloc(1, sizeof(zebra_src_mgr_t)); + cinfo->src = calloc(1, sizeof(zbar_src_mgr_t)); cinfo->src->init_source = init_source; cinfo->src->fill_input_buffer = fill_input_buffer; cinfo->src->skip_input_data = skip_input_data; @@ -178,7 +178,7 @@ void _zebra_convert_jpeg_to_y (zebra_image_t *dst, } cinfo->src->next_input_byte = NULL; cinfo->src->bytes_in_buffer = 0; - ((zebra_src_mgr_t*)cinfo->src)->img = src; + ((zbar_src_mgr_t*)cinfo->src)->img = src; int rc = jpeg_read_header(cinfo, TRUE); zprintf(30, "header: %s\n", (rc == 2) ? "tables-only" : "normal"); @@ -209,7 +209,7 @@ void _zebra_convert_jpeg_to_y (zebra_image_t *dst, if(!dst->data) { dst->datalen = datalen; dst->data = malloc(dst->datalen); - dst->cleanup = zebra_image_free_data; + dst->cleanup = zbar_image_free_data; } else assert(datalen <= dst->datalen); @@ -231,5 +231,5 @@ void _zebra_convert_jpeg_to_y (zebra_image_t *dst, jerr->valid = 0; if(!src->src && cinfo) /* cleanup only if we allocated locally */ - _zebra_jpeg_decomp_destroy(cinfo); + _zbar_jpeg_decomp_destroy(cinfo); } diff --git a/zbar/logo.c b/zbar/logo.c new file mode 100644 index 00000000..0b43a99f --- /dev/null +++ b/zbar/logo.c @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------ + * Copyright 2008-2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include +#include "window.h" +#include "error.h" + +int _zbar_draw_logo (zbar_window_t *w) +{ + _zbar_window_clear(w); + return(0); +} diff --git a/zebra/processor.c b/zbar/processor.c similarity index 70% rename from zebra/processor.c rename to zbar/processor.c index ec029e83..240d2663 100644 --- a/zebra/processor.c +++ b/zbar/processor.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "processor.h" @@ -37,7 +37,7 @@ static inline void proc_mutex_unlock (void *arg) } /* acquire window access semaphore */ -static inline int proc_lock (zebra_processor_t *proc) +static inline int proc_lock (zbar_processor_t *proc) { if(!proc->threaded) return(0); @@ -51,13 +51,13 @@ static inline int proc_lock (zebra_processor_t *proc) } pthread_cleanup_pop(1); if(rc) - err_capture(proc, SEV_ERROR, ZEBRA_ERR_LOCKING, __func__, + err_capture(proc, SEV_ERROR, ZBAR_ERR_LOCKING, __func__, "unable to lock processor"); return(rc); } /* release window access semaphore */ -static inline void proc_unlock (zebra_processor_t *proc) +static inline void proc_unlock (zbar_processor_t *proc) { if(!proc->threaded) return; @@ -86,36 +86,36 @@ static inline void proc_destroy_thread (pthread_t thread, #endif /* lock is already held */ -static inline int process_image (zebra_processor_t *proc, - zebra_image_t *img) +static inline int process_image (zbar_processor_t *proc, + zbar_image_t *img) { if(img) { - uint32_t format = zebra_image_get_format(img); + uint32_t format = zbar_image_get_format(img); zprintf(16, "processing: %.4s(%08" PRIx32 ") %dx%d @%p\n", (char*)&format, format, - zebra_image_get_width(img), zebra_image_get_height(img), - zebra_image_get_data(img)); + zbar_image_get_width(img), zbar_image_get_height(img), + zbar_image_get_data(img)); /* FIXME locking all other interfaces while processing is conservative * but easier for now and we don't expect this to take long... */ - int nsyms = zebra_scan_image(proc->scanner, img); + int nsyms = zbar_scan_image(proc->scanner, img); if(nsyms < 0) - return(err_capture(proc, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, + return(err_capture(proc, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "unknown image format")); - if(_zebra_verbosity >= 8) { - const zebra_symbol_t *sym = zebra_image_first_symbol(img); + if(_zbar_verbosity >= 8) { + const zbar_symbol_t *sym = zbar_image_first_symbol(img); while(sym) { - zebra_symbol_type_t type = zebra_symbol_get_type(sym); - int count = zebra_symbol_get_count(sym); + zbar_symbol_type_t type = zbar_symbol_get_type(sym); + int count = zbar_symbol_get_count(sym); zprintf(8, "%s%s: %s (%s)\n", - zebra_get_symbol_name(type), - zebra_get_addon_name(type), - zebra_symbol_get_data(sym), + zbar_get_symbol_name(type), + zbar_get_addon_name(type), + zbar_symbol_get_data(sym), (count < 0) ? "uncertain" : (count > 0) ? "duplicate" : "new"); - sym = zebra_symbol_next(sym); + sym = zbar_symbol_next(sym); } } @@ -127,44 +127,44 @@ static inline int process_image (zebra_processor_t *proc, } if(proc->force_output) { - img = zebra_image_convert(img, proc->force_output); + img = zbar_image_convert(img, proc->force_output); if(!img) - return(err_capture(proc, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, + return(err_capture(proc, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "unknown image format")); } } /* display to window if enabled */ if(proc->window && - (zebra_window_draw(proc->window, img) || - _zebra_window_invalidate(proc->window))) + (zbar_window_draw(proc->window, img) || + _zbar_window_invalidate(proc->window))) return(err_copy(proc, proc->window)); #if 0 /* FIXME still don't understand why we need this */ - if(proc->window && _zebra_window_handle_events(proc, 0)) + if(proc->window && _zbar_window_handle_events(proc, 0)) return(-1); #endif if(proc->force_output && img) - zebra_image_destroy(img); + zbar_image_destroy(img); return(0); } /* used by poll interface. lock is already held */ -static int proc_video_handler (zebra_processor_t *proc, +static int proc_video_handler (zbar_processor_t *proc, int i) { if(!proc->active) return(0); /* not expected to block */ - zebra_image_t *img = zebra_video_next_image(proc->video); + zbar_image_t *img = zbar_video_next_image(proc->video); if(!img) return(-1); int rc = process_image(proc, img); - zebra_image_destroy(img); + zbar_image_destroy(img); return(rc); } -static inline int proc_poll_inputs (zebra_processor_t *proc, +static inline int proc_poll_inputs (zbar_processor_t *proc, poll_desc_t *p, int timeout) { @@ -213,7 +213,7 @@ static inline int proc_calc_abstime (struct timespec *abstime, } #ifdef HAVE_LIBPTHREAD -static inline int proc_event_wait_threaded (zebra_processor_t *proc, +static inline int proc_event_wait_threaded (zbar_processor_t *proc, unsigned event, int timeout, struct timespec *abstime) @@ -245,21 +245,21 @@ static inline int proc_event_wait_threaded (zebra_processor_t *proc, } #endif -static inline int proc_event_wait_unthreaded (zebra_processor_t *proc, +static inline int proc_event_wait_unthreaded (zbar_processor_t *proc, unsigned event, int timeout, struct timespec *abstime) { - int blocking = proc->active && zebra_video_get_fd(proc->video) < 0; + int blocking = proc->active && zbar_video_get_fd(proc->video) < 0; proc->events &= ~event; /* unthreaded, poll here for window input */ while(!(proc->events & event)) { if(blocking) { - zebra_image_t *img = zebra_video_next_image(proc->video); + zbar_image_t *img = zbar_video_next_image(proc->video); if(!img) return(-1); process_image(proc, img); - zebra_image_destroy(img); + zbar_image_destroy(img); } int reltime = timeout; if(reltime >= 0) { @@ -295,7 +295,7 @@ static inline int proc_event_wait_unthreaded (zebra_processor_t *proc, return(1); } -static inline int proc_event_wait (zebra_processor_t *proc, +static inline int proc_event_wait (zbar_processor_t *proc, unsigned event, int timeout) { @@ -311,7 +311,7 @@ static inline int proc_event_wait (zebra_processor_t *proc, #ifdef HAVE_LIBPTHREAD /* make a thread-local copy of polling data */ -static inline void proc_cache_polling (zebra_processor_t *proc) +static inline void proc_cache_polling (zbar_processor_t *proc) { (void)proc_lock(proc); int n = proc->polling.num; @@ -335,7 +335,7 @@ static inline void proc_block_sigs () /* input handler thread to poll available inputs */ static void *proc_input_thread (void *arg) { - zebra_processor_t *proc = arg; + zbar_processor_t *proc = arg; proc_block_sigs(); /* wait for registered inputs and process using associated handler */ @@ -359,7 +359,7 @@ static void *proc_input_thread (void *arg) /* separate thread to handle non-pollable video (v4l1) */ static void *proc_video_thread (void *arg) { - zebra_processor_t *proc = arg; + zbar_processor_t *proc = arg; proc_block_sigs(); (void)proc_lock(proc); @@ -376,26 +376,26 @@ static void *proc_video_thread (void *arg) pthread_cleanup_pop(1); /* unlocked blocking image input */ - zebra_image_t *img = zebra_video_next_image(proc->video); + zbar_image_t *img = zbar_video_next_image(proc->video); if(!img) return(NULL); (void)proc_lock(proc); if(proc->active) process_image(proc, img); - zebra_image_destroy(img); + zbar_image_destroy(img); } } #endif -zebra_processor_t *zebra_processor_create (int threaded) +zbar_processor_t *zbar_processor_create (int threaded) { - zebra_processor_t *proc = calloc(1, sizeof(zebra_processor_t)); + zbar_processor_t *proc = calloc(1, sizeof(zbar_processor_t)); if(!proc) return(NULL); - err_init(&proc->err, ZEBRA_MOD_PROCESSOR); + err_init(&proc->err, ZBAR_MOD_PROCESSOR); proc->kick_fds[0] = proc->kick_fds[1] = -1; - proc->scanner = zebra_image_scanner_create(); + proc->scanner = zbar_image_scanner_create(); if(!proc->scanner) { free(proc); return(NULL); @@ -419,22 +419,22 @@ zebra_processor_t *zebra_processor_create (int threaded) return(proc); } -void zebra_processor_destroy (zebra_processor_t *proc) +void zbar_processor_destroy (zbar_processor_t *proc) { (void)proc_lock(proc); proc_destroy_thread(proc->video_thread, &proc->video_started); proc_destroy_thread(proc->input_thread, &proc->input_started); if(proc->window) { - zebra_window_destroy(proc->window); + zbar_window_destroy(proc->window); proc->window = NULL; - _zebra_window_close(proc); + _zbar_window_close(proc); } if(proc->video) { - zebra_video_destroy(proc->video); + zbar_video_destroy(proc->video); proc->video = NULL; } if(proc->scanner) { - zebra_image_scanner_destroy(proc->scanner); + zbar_image_scanner_destroy(proc->scanner); proc->scanner = NULL; } proc_unlock(proc); @@ -463,9 +463,9 @@ void zebra_processor_destroy (zebra_processor_t *proc) free(proc); } -int zebra_processor_init (zebra_processor_t *proc, - const char *dev, - int enable_display) +int zbar_processor_init (zbar_processor_t *proc, + const char *dev, + int enable_display) { if(proc_lock(proc) < 0) return(-1); @@ -475,16 +475,16 @@ int zebra_processor_init (zebra_processor_t *proc, int rc = 0; if(proc->video) { if(dev) - zebra_video_open(proc->video, NULL); + zbar_video_open(proc->video, NULL); else { - zebra_video_destroy(proc->video); + zbar_video_destroy(proc->video); proc->video = NULL; } } if(proc->window) { - zebra_window_destroy(proc->window); + zbar_window_destroy(proc->window); proc->window = NULL; - _zebra_window_close(proc); + _zbar_window_close(proc); } if(!dev && !enable_display) @@ -492,38 +492,38 @@ int zebra_processor_init (zebra_processor_t *proc, goto done; if(enable_display) { - proc->window = zebra_window_create(); + proc->window = zbar_window_create(); if(!proc->window) { - rc = err_capture(proc, SEV_FATAL, ZEBRA_ERR_NOMEM, + rc = err_capture(proc, SEV_FATAL, ZBAR_ERR_NOMEM, __func__, "allocating window resources"); goto done; } } if(dev) { - proc->video = zebra_video_create(); + proc->video = zbar_video_create(); if(!proc->video) { - rc = err_capture(proc, SEV_FATAL, ZEBRA_ERR_NOMEM, + rc = err_capture(proc, SEV_FATAL, ZBAR_ERR_NOMEM, __func__, "allocating video resources"); goto done; } if(proc->req_width || proc->req_height) - zebra_video_request_size(proc->video, + zbar_video_request_size(proc->video, proc->req_width, proc->req_height); if(proc->req_v4l) - zebra_video_request_interface(proc->video, proc->req_v4l); + zbar_video_request_interface(proc->video, proc->req_v4l); if((proc->req_iomode && - zebra_video_request_iomode(proc->video, proc->req_iomode)) || - zebra_video_open(proc->video, dev)) { + zbar_video_request_iomode(proc->video, proc->req_iomode)) || + zbar_video_open(proc->video, dev)) { rc = err_copy(proc, proc->video); goto done; } - if(zebra_video_get_fd(proc->video) < 0 && proc->threaded) { + if(zbar_video_get_fd(proc->video) < 0 && proc->threaded) { #ifdef HAVE_LIBPTHREAD /* spawn blocking video thread */ if((rc = pthread_create(&proc->video_thread, NULL, proc_video_thread, proc))) { - rc = err_capture_num(proc, SEV_ERROR, ZEBRA_ERR_SYSTEM, + rc = err_capture_num(proc, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "spawning video thread", rc); goto done; } @@ -539,7 +539,7 @@ int zebra_processor_init (zebra_processor_t *proc, /* spawn input monitor thread */ if((rc = pthread_create(&proc->input_thread, NULL, proc_input_thread, proc))) { - rc = err_capture_num(proc, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + rc = err_capture_num(proc, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "spawning input thread", rc); goto done; } @@ -552,37 +552,37 @@ int zebra_processor_init (zebra_processor_t *proc, /* arbitrary default */ int width = 640, height = 480; if(proc->video) { - width = zebra_video_get_width(proc->video); - height = zebra_video_get_height(proc->video); + width = zbar_video_get_width(proc->video); + height = zbar_video_get_height(proc->video); } - if(_zebra_window_open(proc, "zebra barcode reader", width, height)) { + if(_zbar_window_open(proc, "zbar barcode reader", width, height)) { rc = -1; goto done; } - else if(zebra_window_attach(proc->window, proc->display, proc->xwin)) { + else if(zbar_window_attach(proc->window, proc->display, proc->xwin)) { rc = err_copy(proc, proc->window); goto done; } } if(proc->video && proc->force_input) { - if(zebra_video_init(proc->video, proc->force_input)) + if(zbar_video_init(proc->video, proc->force_input)) rc = err_copy(proc, proc->video); } else if(proc->video) - while(zebra_negotiate_format(proc->video, proc->window)) { + while(zbar_negotiate_format(proc->video, proc->window)) { if(proc->video && proc->window) { fprintf(stderr, "WARNING: no compatible input to output format\n" "...trying again with output disabled\n"); - zebra_window_destroy(proc->window); + zbar_window_destroy(proc->window); proc->window = NULL; } else { zprintf(1, "ERROR: no compatible %s format\n", (proc->video) ? "video input" : "window output"); - rc = err_capture(proc, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, + rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no compatible image format"); goto done; } @@ -593,22 +593,22 @@ int zebra_processor_init (zebra_processor_t *proc, return(rc); } -zebra_image_data_handler_t* -zebra_processor_set_data_handler (zebra_processor_t *proc, - zebra_image_data_handler_t *handler, - const void *userdata) +zbar_image_data_handler_t* +zbar_processor_set_data_handler (zbar_processor_t *proc, + zbar_image_data_handler_t *handler, + const void *userdata) { if(proc_lock(proc) < 0) return(NULL); - zebra_image_data_handler_t *result = proc->handler; + zbar_image_data_handler_t *result = proc->handler; proc->handler = handler; proc->userdata = userdata; proc_unlock(proc); return(result); } -void zebra_processor_set_userdata (zebra_processor_t *proc, - void *userdata) +void zbar_processor_set_userdata (zbar_processor_t *proc, + void *userdata) { if(proc_lock(proc) < 0) return; @@ -616,52 +616,52 @@ void zebra_processor_set_userdata (zebra_processor_t *proc, proc_unlock(proc); } -void *zebra_processor_get_userdata (const zebra_processor_t *proc) +void *zbar_processor_get_userdata (const zbar_processor_t *proc) { return((void*)proc->userdata); } -int zebra_processor_set_config (zebra_processor_t *proc, - zebra_symbol_type_t sym, - zebra_config_t cfg, - int val) +int zbar_processor_set_config (zbar_processor_t *proc, + zbar_symbol_type_t sym, + zbar_config_t cfg, + int val) { - return(zebra_image_scanner_set_config(proc->scanner, sym, cfg, val)); + return(zbar_image_scanner_set_config(proc->scanner, sym, cfg, val)); } -int zebra_processor_request_size (zebra_processor_t *proc, - unsigned width, - unsigned height) +int zbar_processor_request_size (zbar_processor_t *proc, + unsigned width, + unsigned height) { proc->req_width = width; proc->req_height = height; return(0); } -int zebra_processor_request_interface (zebra_processor_t *proc, - int ver) +int zbar_processor_request_interface (zbar_processor_t *proc, + int ver) { proc->req_v4l = ver; return(0); } -int zebra_processor_request_iomode (zebra_processor_t *proc, - int iomode) +int zbar_processor_request_iomode (zbar_processor_t *proc, + int iomode) { proc->req_iomode = iomode; return(0); } -int zebra_processor_force_format (zebra_processor_t *proc, - unsigned long input, - unsigned long output) +int zbar_processor_force_format (zbar_processor_t *proc, + unsigned long input, + unsigned long output) { proc->force_input = input; proc->force_output = output; return(0); } -int zebra_processor_is_visible (zebra_processor_t *proc) +int zbar_processor_is_visible (zbar_processor_t *proc) { if(proc_lock(proc) < 0) return(-1); @@ -670,29 +670,29 @@ int zebra_processor_is_visible (zebra_processor_t *proc) return(visible); } -int zebra_processor_set_visible (zebra_processor_t *proc, - int visible) +int zbar_processor_set_visible (zbar_processor_t *proc, + int visible) { if(proc_lock(proc) < 0) return(-1); int rc = 0; if(proc->window) { if(proc->video) - rc = _zebra_window_resize(proc, - zebra_video_get_width(proc->video), - zebra_video_get_height(proc->video)); + rc = _zbar_window_resize(proc, + zbar_video_get_width(proc->video), + zbar_video_get_height(proc->video)); if(!rc) - rc = _zebra_window_set_visible(proc, visible); + rc = _zbar_window_set_visible(proc, visible); } else if(visible) - rc = err_capture(proc, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "processor display window not initialized"); proc_unlock(proc); return(rc); } -int zebra_processor_user_wait (zebra_processor_t *proc, - int timeout) +int zbar_processor_user_wait (zbar_processor_t *proc, + int timeout) { if(proc_lock(proc) < 0) return(-1); @@ -703,13 +703,13 @@ int zebra_processor_user_wait (zebra_processor_t *proc, rc = proc->input; proc_unlock(proc); if(!proc->visible) - return(err_capture(proc, SEV_WARNING, ZEBRA_ERR_CLOSED, __func__, + return(err_capture(proc, SEV_WARNING, ZBAR_ERR_CLOSED, __func__, "display window not available for input")); return(rc); } -int zebra_processor_set_active (zebra_processor_t *proc, - int active) +int zbar_processor_set_active (zbar_processor_t *proc, + int active) { if(proc_lock(proc) < 0) return(-1); @@ -717,10 +717,10 @@ int zebra_processor_set_active (zebra_processor_t *proc, proc_unlock(proc); return(-1); } - zebra_image_scanner_enable_cache(proc->scanner, active); - int rc = zebra_video_enable(proc->video, active); + zbar_image_scanner_enable_cache(proc->scanner, active); + int rc = zbar_video_enable(proc->video, active); if(!rc) { - int vid_fd = zebra_video_get_fd(proc->video); + int vid_fd = zbar_video_get_fd(proc->video); if(vid_fd >= 0) { if(active) add_poll(proc, vid_fd, proc_video_handler); @@ -748,17 +748,17 @@ int zebra_processor_set_active (zebra_processor_t *proc, return(rc); } -int zebra_process_one (zebra_processor_t *proc, - int timeout) +int zbar_process_one (zbar_processor_t *proc, + int timeout) { if(proc_lock(proc) < 0) return(-1); int rc = 0; if(proc->video) { - zebra_image_scanner_enable_cache(proc->scanner, 1); - rc = zebra_video_enable(proc->video, 1); + zbar_image_scanner_enable_cache(proc->scanner, 1); + rc = zbar_video_enable(proc->video, 1); /* FIXME failure recovery? */ - int vid_fd = zebra_video_get_fd(proc->video); + int vid_fd = zbar_video_get_fd(proc->video); if(vid_fd >= 0) add_poll(proc, vid_fd, proc_video_handler); proc->active = 1; @@ -766,12 +766,12 @@ int zebra_process_one (zebra_processor_t *proc, pthread_cond_broadcast(&proc->event); #endif proc_event_wait(proc, EVENT_OUTPUT, timeout); - rc = zebra_video_enable(proc->video, 0); + rc = zbar_video_enable(proc->video, 0); if(vid_fd >= 0) remove_poll(proc, vid_fd); proc->active = 0; proc->events &= ~EVENT_INPUT; - zebra_image_scanner_enable_cache(proc->scanner, 0); + zbar_image_scanner_enable_cache(proc->scanner, 0); } else rc = -1; @@ -779,21 +779,21 @@ int zebra_process_one (zebra_processor_t *proc, return(rc); } -int zebra_process_image (zebra_processor_t *proc, - zebra_image_t *img) +int zbar_process_image (zbar_processor_t *proc, + zbar_image_t *img) { if(proc_lock(proc) < 0) return(-1); int rc = 0; if(img && proc->window) - rc = _zebra_window_resize(proc, - zebra_image_get_width(img), - zebra_image_get_height(img)); + rc = _zbar_window_resize(proc, + zbar_image_get_width(img), + zbar_image_get_height(img)); if(!rc) { - zebra_image_scanner_enable_cache(proc->scanner, 0); + zbar_image_scanner_enable_cache(proc->scanner, 0); rc = process_image(proc, img); if(proc->active) - zebra_image_scanner_enable_cache(proc->scanner, 1); + zbar_image_scanner_enable_cache(proc->scanner, 1); } proc_unlock(proc); return(rc); diff --git a/zebra/processor.h b/zbar/processor.h similarity index 81% rename from zebra/processor.h rename to zbar/processor.h index b9f48beb..cda4b6b6 100644 --- a/zebra/processor.h +++ b/zbar/processor.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _PROCESSOR_H_ #define _PROCESSOR_H_ @@ -40,10 +40,10 @@ # include #endif -#include +#include #include "error.h" -typedef int (poll_handler_t)(zebra_processor_t*, int); +typedef int (poll_handler_t)(zbar_processor_t*, int); /* poll information */ typedef struct poll_desc_s { @@ -52,15 +52,15 @@ typedef struct poll_desc_s { poll_handler_t **handlers; /* poll handlers */ } poll_desc_t; -struct zebra_processor_s { +struct zbar_processor_s { errinfo_t err; /* error reporting */ const void *userdata; /* application data */ - zebra_video_t *video; /* input video device abstraction */ - zebra_window_t *window; /* output window abstraction */ - zebra_image_scanner_t *scanner; /* barcode scanner */ + zbar_video_t *video; /* input video device abstraction */ + zbar_window_t *window; /* output window abstraction */ + zbar_image_scanner_t *scanner; /* barcode scanner */ - zebra_image_data_handler_t *handler; /* application data handler */ + zbar_image_data_handler_t *handler; /* application data handler */ unsigned req_width, req_height; /* application requested video size */ int req_v4l, req_iomode; /* application requested v4l version */ @@ -111,7 +111,7 @@ static inline int alloc_polls (volatile poll_desc_t *p) return(0); } -static inline int add_poll (zebra_processor_t *proc, +static inline int add_poll (zbar_processor_t *proc, int fd, poll_handler_t *handler) { @@ -133,7 +133,7 @@ static inline int add_poll (zebra_processor_t *proc, return(i); } -static inline int remove_poll (zebra_processor_t *proc, +static inline int remove_poll (zbar_processor_t *proc, int fd) { int i; @@ -161,7 +161,7 @@ static inline int remove_poll (zebra_processor_t *proc, return(rc); } -static inline void emit (zebra_processor_t *proc, +static inline void emit (zbar_processor_t *proc, unsigned mask) { proc->events |= mask; @@ -172,11 +172,11 @@ static inline void emit (zebra_processor_t *proc, #endif } -extern int _zebra_window_open(zebra_processor_t*, char*, unsigned, unsigned); -extern int _zebra_window_close(zebra_processor_t*); -extern int _zebra_window_set_visible(zebra_processor_t*, int); -extern int _zebra_window_invalidate(zebra_window_t*); -extern int _zebra_window_resize(zebra_processor_t*, unsigned, unsigned); -extern int _zebra_window_handle_events(zebra_processor_t*, int); +extern int _zbar_window_open(zbar_processor_t*, char*, unsigned, unsigned); +extern int _zbar_window_close(zbar_processor_t*); +extern int _zbar_window_set_visible(zbar_processor_t*, int); +extern int _zbar_window_invalidate(zbar_window_t*); +extern int _zbar_window_resize(zbar_processor_t*, unsigned, unsigned); +extern int _zbar_window_handle_events(zbar_processor_t*, int); #endif diff --git a/zebra/scanner.c b/zbar/scanner.c similarity index 61% rename from zebra/scanner.c rename to zbar/scanner.c index ad924775..248ca566 100644 --- a/zebra/scanner.c +++ b/zbar/scanner.c @@ -1,66 +1,66 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include #include /* malloc, free, abs */ #include /* memset */ -#include +#include #ifdef DEBUG_SCANNER # define DEBUG_LEVEL (DEBUG_SCANNER) #endif #include "debug.h" -#ifndef ZEBRA_FIXED -# define ZEBRA_FIXED 5 +#ifndef ZBAR_FIXED +# define ZBAR_FIXED 5 #endif -#define ROUND (1 << (ZEBRA_FIXED - 1)) +#define ROUND (1 << (ZBAR_FIXED - 1)) /* FIXME add runtime config API for these */ -#ifndef ZEBRA_SCANNER_THRESH_MIN -# define ZEBRA_SCANNER_THRESH_MIN 4 +#ifndef ZBAR_SCANNER_THRESH_MIN +# define ZBAR_SCANNER_THRESH_MIN 4 #endif -#ifndef ZEBRA_SCANNER_THRESH_INIT_WEIGHT -# define ZEBRA_SCANNER_THRESH_INIT_WEIGHT .44 +#ifndef ZBAR_SCANNER_THRESH_INIT_WEIGHT +# define ZBAR_SCANNER_THRESH_INIT_WEIGHT .44 #endif -#define THRESH_INIT ((unsigned)((ZEBRA_SCANNER_THRESH_INIT_WEIGHT \ - * (1 << (ZEBRA_FIXED + 1)) + 1) / 2)) +#define THRESH_INIT ((unsigned)((ZBAR_SCANNER_THRESH_INIT_WEIGHT \ + * (1 << (ZBAR_FIXED + 1)) + 1) / 2)) -#ifndef ZEBRA_SCANNER_THRESH_FADE -# define ZEBRA_SCANNER_THRESH_FADE 8 +#ifndef ZBAR_SCANNER_THRESH_FADE +# define ZBAR_SCANNER_THRESH_FADE 8 #endif -#ifndef ZEBRA_SCANNER_EWMA_WEIGHT -# define ZEBRA_SCANNER_EWMA_WEIGHT .78 +#ifndef ZBAR_SCANNER_EWMA_WEIGHT +# define ZBAR_SCANNER_EWMA_WEIGHT .78 #endif -#define EWMA_WEIGHT ((unsigned)((ZEBRA_SCANNER_EWMA_WEIGHT \ - * (1 << (ZEBRA_FIXED + 1)) + 1) / 2)) +#define EWMA_WEIGHT ((unsigned)((ZBAR_SCANNER_EWMA_WEIGHT \ + * (1 << (ZBAR_FIXED + 1)) + 1) / 2)) /* scanner state */ -struct zebra_scanner_s { - zebra_decoder_t *decoder; /* associated bar width decoder */ +struct zbar_scanner_s { + zbar_decoder_t *decoder; /* associated bar width decoder */ unsigned y1_min_thresh; /* minimum threshold */ unsigned x; /* relative scan position of next sample */ @@ -74,40 +74,40 @@ struct zebra_scanner_s { unsigned width; /* last element width */ }; -zebra_scanner_t *zebra_scanner_create (zebra_decoder_t *dcode) +zbar_scanner_t *zbar_scanner_create (zbar_decoder_t *dcode) { - zebra_scanner_t *scn = malloc(sizeof(zebra_scanner_t)); + zbar_scanner_t *scn = malloc(sizeof(zbar_scanner_t)); scn->decoder = dcode; - scn->y1_min_thresh = ZEBRA_SCANNER_THRESH_MIN; - zebra_scanner_reset(scn); + scn->y1_min_thresh = ZBAR_SCANNER_THRESH_MIN; + zbar_scanner_reset(scn); return(scn); } -void zebra_scanner_destroy (zebra_scanner_t *scn) +void zbar_scanner_destroy (zbar_scanner_t *scn) { free(scn); } -zebra_symbol_type_t zebra_scanner_reset (zebra_scanner_t *scn) +zbar_symbol_type_t zbar_scanner_reset (zbar_scanner_t *scn) { - memset(&scn->x, 0, sizeof(zebra_scanner_t) + (void*)scn - (void*)&scn->x); + memset(&scn->x, 0, sizeof(zbar_scanner_t) + (void*)scn - (void*)&scn->x); scn->y1_thresh = scn->y1_min_thresh; if(scn->decoder) - zebra_decoder_reset(scn->decoder); - return(ZEBRA_NONE); + zbar_decoder_reset(scn->decoder); + return(ZBAR_NONE); } -unsigned zebra_scanner_get_width (const zebra_scanner_t *scn) +unsigned zbar_scanner_get_width (const zbar_scanner_t *scn) { return(scn->width); } -zebra_color_t zebra_scanner_get_color (const zebra_scanner_t *scn) +zbar_color_t zbar_scanner_get_color (const zbar_scanner_t *scn) { - return((scn->y1_sign <= 0) ? ZEBRA_SPACE : ZEBRA_BAR); + return((scn->y1_sign <= 0) ? ZBAR_SPACE : ZBAR_BAR); } -static inline unsigned calc_thresh (zebra_scanner_t *scn) +static inline unsigned calc_thresh (zbar_scanner_t *scn) { /* threshold 1st to improve noise rejection */ unsigned thresh = scn->y1_thresh; @@ -116,13 +116,13 @@ static inline unsigned calc_thresh (zebra_scanner_t *scn) return(scn->y1_min_thresh); } /* slowly return threshold to min */ - unsigned dx = (scn->x << ZEBRA_FIXED) - scn->last_edge; + unsigned dx = (scn->x << ZBAR_FIXED) - scn->last_edge; unsigned long t = thresh * dx; t /= scn->width; - t /= ZEBRA_SCANNER_THRESH_FADE; + t /= ZBAR_SCANNER_THRESH_FADE; dprintf(1, " thr=%d t=%ld x=%d last=%d.%d (%d)", - thresh, t, scn->x, scn->last_edge >> ZEBRA_FIXED, - scn->last_edge & ((1 << ZEBRA_FIXED) - 1), dx); + thresh, t, scn->x, scn->last_edge >> ZBAR_FIXED, + scn->last_edge & ((1 << ZBAR_FIXED) - 1), dx); if(thresh > t) { thresh -= t; if(thresh > scn->y1_min_thresh) @@ -132,43 +132,43 @@ static inline unsigned calc_thresh (zebra_scanner_t *scn) return(scn->y1_min_thresh); } -static inline zebra_symbol_type_t process_edge (zebra_scanner_t *scn, - int y1) +static inline zbar_symbol_type_t process_edge (zbar_scanner_t *scn, + int y1) { scn->width = scn->cur_edge - scn->last_edge; dprintf(1, " sgn=%d cur=%d.%d w=%d (%s)\n", - scn->y1_sign, scn->cur_edge >> ZEBRA_FIXED, - scn->cur_edge & ((1 << ZEBRA_FIXED) - 1), scn->width, + scn->y1_sign, scn->cur_edge >> ZBAR_FIXED, + scn->cur_edge & ((1 << ZBAR_FIXED) - 1), scn->width, ((y1 > 0) ? "SPACE" : "BAR")); scn->last_edge = scn->cur_edge; /* pass to decoder */ if(scn->width || (y1 > 0)) { if(scn->decoder) - return(zebra_decode_width(scn->decoder, scn->width)); - return(ZEBRA_PARTIAL); + return(zbar_decode_width(scn->decoder, scn->width)); + return(ZBAR_PARTIAL); } /* skip initial transition */ - return(ZEBRA_NONE); + return(ZBAR_NONE); } -zebra_symbol_type_t zebra_scanner_new_scan (zebra_scanner_t *scn) +zbar_symbol_type_t zbar_scanner_new_scan (zbar_scanner_t *scn) { /* finalize outstanding edge */ - zebra_symbol_type_t edge = process_edge(scn, 0); + zbar_symbol_type_t edge = process_edge(scn, 0); /* reset color to SPACE * (actually just resets everything) */ - memset(&scn->x, 0, sizeof(zebra_scanner_t) + (void*)scn - (void*)&scn->x); + memset(&scn->x, 0, sizeof(zbar_scanner_t) + (void*)scn - (void*)&scn->x); scn->y1_thresh = scn->y1_min_thresh; if(scn->decoder) - zebra_decoder_new_scan(scn->decoder); + zbar_decoder_new_scan(scn->decoder); return(edge); } -zebra_symbol_type_t zebra_scan_y (zebra_scanner_t *scn, - int y) +zbar_symbol_type_t zbar_scan_y (zbar_scanner_t *scn, + int y) { /* FIXME calc and clip to max y range... */ /* retrieve short value history */ @@ -176,7 +176,7 @@ zebra_symbol_type_t zebra_scan_y (zebra_scanner_t *scn, register int y0_0 = y0_1; if(scn->x) { /* update weighted moving average */ - y0_0 += ((int)((y - y0_1) * EWMA_WEIGHT)) >> ZEBRA_FIXED; + y0_0 += ((int)((y - y0_1) * EWMA_WEIGHT)) >> ZBAR_FIXED; scn->y0[scn->x & 3] = y0_0; } else @@ -198,7 +198,7 @@ zebra_symbol_type_t zebra_scan_y (zebra_scanner_t *scn, dprintf(1, "scan: y=%d y0=%d y1=%d y2=%d", y, y0_1, y1_1, y2_1); - zebra_symbol_type_t edge = ZEBRA_NONE; + zbar_symbol_type_t edge = ZBAR_NONE; /* 2nd zero-crossing is 1st local min/max - could be edge */ if((!y2_1 || ((y2_1 > 0) ? y2_2 < 0 : y2_2 > 0)) && @@ -217,20 +217,20 @@ zebra_symbol_type_t zebra_scan_y (zebra_scanner_t *scn, /* adaptive thresholding */ /* start at multiple of new min/max */ - scn->y1_thresh = (abs(y1_1) * THRESH_INIT + ROUND) >> ZEBRA_FIXED; + scn->y1_thresh = (abs(y1_1) * THRESH_INIT + ROUND) >> ZBAR_FIXED; dprintf(1, " thr=%d", scn->y1_thresh); if(scn->y1_thresh < scn->y1_min_thresh) scn->y1_thresh = scn->y1_min_thresh; /* update current edge */ int d = y2_1 - y2_2; - scn->cur_edge = 1 << ZEBRA_FIXED; + scn->cur_edge = 1 << ZBAR_FIXED; if(!d) scn->cur_edge >>= 1; else if(y2_1) /* interpolate zero crossing */ - scn->cur_edge -= ((y2_1 << ZEBRA_FIXED) + 1) / d; - scn->cur_edge += scn->x << ZEBRA_FIXED; + scn->cur_edge -= ((y2_1 << ZBAR_FIXED) + 1) / d; + scn->cur_edge += scn->x << ZBAR_FIXED; } } else @@ -242,14 +242,14 @@ zebra_symbol_type_t zebra_scan_y (zebra_scanner_t *scn, } /* undocumented API for drawing cutesy debug graphics */ -void zebra_scanner_get_state (const zebra_scanner_t *scn, - unsigned *x, - unsigned *cur_edge, - unsigned *last_edge, - int *y0, - int *y1, - int *y2, - int *y1_thresh) +void zbar_scanner_get_state (const zbar_scanner_t *scn, + unsigned *x, + unsigned *cur_edge, + unsigned *last_edge, + int *y0, + int *y1, + int *y2, + int *y1_thresh) { register int y0_0 = scn->y0[(scn->x - 1) & 3]; register int y0_1 = scn->y0[(scn->x - 2) & 3]; @@ -261,6 +261,6 @@ void zebra_scanner_get_state (const zebra_scanner_t *scn, if(y1) *y1 = y0_1 - y0_2; if(y2) *y2 = y0_0 - (y0_1 * 2) + y0_2; /* NB not quite accurate (uses updated x) */ - zebra_scanner_t *mut_scn = (zebra_scanner_t*)scn; + zbar_scanner_t *mut_scn = (zbar_scanner_t*)scn; if(y1_thresh) *y1_thresh = calc_thresh(mut_scn); } diff --git a/zebra/symbol.c b/zbar/symbol.c similarity index 60% rename from zebra/symbol.c rename to zbar/symbol.c index de444229..61dc28fe 100644 --- a/zebra/symbol.c +++ b/zbar/symbol.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -26,57 +26,57 @@ #include #include -#include +#include #include "symbol.h" -const char *zebra_get_symbol_name (zebra_symbol_type_t sym) +const char *zbar_get_symbol_name (zbar_symbol_type_t sym) { - switch(sym & ZEBRA_SYMBOL) { - case ZEBRA_EAN8: return("EAN-8"); - case ZEBRA_UPCE: return("UPC-E"); - case ZEBRA_ISBN10: return("ISBN-10"); - case ZEBRA_UPCA: return("UPC-A"); - case ZEBRA_EAN13: return("EAN-13"); - case ZEBRA_ISBN13: return("ISBN-13"); - case ZEBRA_I25: return("I2/5"); - case ZEBRA_CODE39: return("CODE-39"); - case ZEBRA_CODE128: return("CODE-128"); - case ZEBRA_PDF417: return("PDF417"); + switch(sym & ZBAR_SYMBOL) { + case ZBAR_EAN8: return("EAN-8"); + case ZBAR_UPCE: return("UPC-E"); + case ZBAR_ISBN10: return("ISBN-10"); + case ZBAR_UPCA: return("UPC-A"); + case ZBAR_EAN13: return("EAN-13"); + case ZBAR_ISBN13: return("ISBN-13"); + case ZBAR_I25: return("I2/5"); + case ZBAR_CODE39: return("CODE-39"); + case ZBAR_CODE128: return("CODE-128"); + case ZBAR_PDF417: return("PDF417"); default: return("UNKNOWN"); } } -const char *zebra_get_addon_name (zebra_symbol_type_t sym) +const char *zbar_get_addon_name (zbar_symbol_type_t sym) { - switch(sym & ZEBRA_ADDON) { - case ZEBRA_ADDON2: return("+2"); - case ZEBRA_ADDON5: return("+5"); + switch(sym & ZBAR_ADDON) { + case ZBAR_ADDON2: return("+2"); + case ZBAR_ADDON5: return("+5"); default: return(""); } } -zebra_symbol_type_t zebra_symbol_get_type (const zebra_symbol_t *sym) +zbar_symbol_type_t zbar_symbol_get_type (const zbar_symbol_t *sym) { return(sym->type); } -const char *zebra_symbol_get_data (const zebra_symbol_t *sym) +const char *zbar_symbol_get_data (const zbar_symbol_t *sym) { return(sym->data); } -int zebra_symbol_get_count (const zebra_symbol_t *sym) +int zbar_symbol_get_count (const zbar_symbol_t *sym) { return(sym->cache_count); } -unsigned zebra_symbol_get_loc_size (const zebra_symbol_t *sym) +unsigned zbar_symbol_get_loc_size (const zbar_symbol_t *sym) { return(sym->npts); } -int zebra_symbol_get_loc_x (const zebra_symbol_t *sym, - unsigned idx) +int zbar_symbol_get_loc_x (const zbar_symbol_t *sym, + unsigned idx) { if(idx < sym->npts) return(sym->pts[idx].x); @@ -84,8 +84,8 @@ int zebra_symbol_get_loc_x (const zebra_symbol_t *sym, return(-1); } -int zebra_symbol_get_loc_y (const zebra_symbol_t *sym, - unsigned idx) +int zbar_symbol_get_loc_y (const zbar_symbol_t *sym, + unsigned idx) { if(idx < sym->npts) return(sym->pts[idx].y); @@ -93,7 +93,7 @@ int zebra_symbol_get_loc_y (const zebra_symbol_t *sym, return(-1); } -const zebra_symbol_t *zebra_symbol_next (const zebra_symbol_t *sym) +const zbar_symbol_t *zbar_symbol_next (const zbar_symbol_t *sym) { return((sym) ? sym->next : NULL); } @@ -115,11 +115,11 @@ static inline void growbuf (unsigned **buf, { } -char *zebra_symbol_xml (const zebra_symbol_t *sym, - char **buf, - unsigned *len) +char *zbar_symbol_xml (const zbar_symbol_t *sym, + char **buf, + unsigned *len) { - const char *type = zebra_get_symbol_name(sym->type); + const char *type = zbar_get_symbol_name(sym->type); unsigned datalen = strlen(sym->data); unsigned maxlen = (strlen(xmlfmt[0]) + strlen(xmlfmt[1]) + strlen(xmlfmt[2]) + strlen(xmlfmt[3]) + diff --git a/zebra/symbol.h b/zbar/symbol.h similarity index 72% rename from zebra/symbol.h rename to zbar/symbol.h index 5bafa217..9fb44aba 100644 --- a/zebra/symbol.h +++ b/zbar/symbol.h @@ -1,37 +1,37 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _SYMBOL_H_ #define _SYMBOL_H_ #include -#include +#include typedef struct point_s { int x, y; } point_t; -struct zebra_symbol_s { - zebra_symbol_type_t type; /* symbol type */ +struct zbar_symbol_s { + zbar_symbol_type_t type; /* symbol type */ unsigned int datalen; /* allocation size of data */ char *data; /* ascii symbol data */ @@ -39,12 +39,12 @@ struct zebra_symbol_s { unsigned npts; /* number of points in location polygon */ point_t *pts; /* list of points in location polygon */ - zebra_symbol_t *next; /* linked list of results */ + zbar_symbol_t *next; /* linked list of results */ unsigned long time; /* relative symbol capture time */ int cache_count; /* cache state */ }; -static inline void sym_add_point (zebra_symbol_t *sym, +static inline void sym_add_point (zbar_symbol_t *sym, int x, int y) { @@ -55,7 +55,7 @@ static inline void sym_add_point (zebra_symbol_t *sym, sym->pts[i].y = y; } -static inline void sym_destroy (zebra_symbol_t *sym) +static inline void sym_destroy (zbar_symbol_t *sym) { if(sym->pts) free(sym->pts); diff --git a/zebra/video.c b/zbar/video.c similarity index 64% rename from zebra/video.c rename to zbar/video.c index ad8d7407..0944aae6 100644 --- a/zebra/video.c +++ b/zbar/video.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "video.h" @@ -26,13 +26,13 @@ #ifdef HAVE_LIBJPEG -extern struct jpeg_decompress_struct *_zebra_jpeg_decomp_create(); -extern void _zebra_jpeg_decomp_destroy(struct jpeg_decompress_struct *cinfo); +extern struct jpeg_decompress_struct *_zbar_jpeg_decomp_create(); +extern void _zbar_jpeg_decomp_destroy(struct jpeg_decompress_struct *cinfo); #endif -static void _zebra_video_recycle_image (zebra_image_t *img) +static void _zbar_video_recycle_image (zbar_image_t *img) { - zebra_video_t *vdo = img->src; + zbar_video_t *vdo = img->src; assert(vdo); assert(img->srcidx >= 0); (void)video_lock(vdo); @@ -44,9 +44,9 @@ static void _zebra_video_recycle_image (zebra_image_t *img) (void)video_unlock(vdo); } -static void _zebra_video_recycle_shadow (zebra_image_t *img) +static void _zbar_video_recycle_shadow (zbar_image_t *img) { - zebra_video_t *vdo = img->src; + zbar_video_t *vdo = img->src; assert(vdo); assert(img->srcidx == -1); (void)video_lock(vdo); @@ -55,12 +55,12 @@ static void _zebra_video_recycle_shadow (zebra_image_t *img) (void)video_unlock(vdo); } -zebra_video_t *zebra_video_create () +zbar_video_t *zbar_video_create () { - zebra_video_t *vdo = calloc(1, sizeof(zebra_video_t)); + zbar_video_t *vdo = calloc(1, sizeof(zbar_video_t)); if(!vdo) return(NULL); - err_init(&vdo->err, ZEBRA_MOD_VIDEO); + err_init(&vdo->err, ZBAR_MOD_VIDEO); vdo->fd = -1; #ifdef HAVE_LIBPTHREAD @@ -71,22 +71,22 @@ zebra_video_t *zebra_video_create () #endif /* pre-allocate images */ - vdo->num_images = ZEBRA_VIDEO_IMAGES_MAX; - vdo->images = calloc(ZEBRA_VIDEO_IMAGES_MAX, sizeof(zebra_image_t*)); + vdo->num_images = ZBAR_VIDEO_IMAGES_MAX; + vdo->images = calloc(ZBAR_VIDEO_IMAGES_MAX, sizeof(zbar_image_t*)); if(!vdo->images) { - zebra_video_destroy(vdo); + zbar_video_destroy(vdo); return(NULL); } int i; - for(i = 0; i < ZEBRA_VIDEO_IMAGES_MAX; i++) { - zebra_image_t *img = vdo->images[i] = zebra_image_create(); + for(i = 0; i < ZBAR_VIDEO_IMAGES_MAX; i++) { + zbar_image_t *img = vdo->images[i] = zbar_image_create(); if(!img) { - zebra_video_destroy(vdo); + zbar_video_destroy(vdo); return(NULL); } img->refcnt = 0; - img->cleanup = _zebra_video_recycle_image; + img->cleanup = _zbar_video_recycle_image; img->srcidx = i; img->src = vdo; } @@ -94,19 +94,19 @@ zebra_video_t *zebra_video_create () return(vdo); } -void zebra_video_destroy (zebra_video_t *vdo) +void zbar_video_destroy (zbar_video_t *vdo) { if(vdo->fd >= 0) - zebra_video_open(vdo, NULL); + zbar_video_open(vdo, NULL); if(vdo->images) { int i; - for(i = 0; i < ZEBRA_VIDEO_IMAGES_MAX; i++) + for(i = 0; i < ZBAR_VIDEO_IMAGES_MAX; i++) if(vdo->images[i]) free(vdo->images[i]); free(vdo->images); } while(vdo->shadow_image) { - zebra_image_t *img = vdo->shadow_image; + zbar_image_t *img = vdo->shadow_image; vdo->shadow_image = img->next; free((void*)img->data); img->data = NULL; @@ -122,43 +122,43 @@ void zebra_video_destroy (zebra_video_t *vdo) #endif #ifdef HAVE_LIBJPEG if(vdo->jpeg_img) { - zebra_image_destroy(vdo->jpeg_img); + zbar_image_destroy(vdo->jpeg_img); vdo->jpeg_img = NULL; } if(vdo->jpeg) { - _zebra_jpeg_decomp_destroy(vdo->jpeg); + _zbar_jpeg_decomp_destroy(vdo->jpeg); vdo->jpeg = NULL; } #endif free(vdo); } -int zebra_video_open (zebra_video_t *vdo, - const char *dev) +int zbar_video_open (zbar_video_t *vdo, + const char *dev) { - return(_zebra_video_open(vdo, dev)); + return(_zbar_video_open(vdo, dev)); } -int zebra_video_get_fd (const zebra_video_t *vdo) +int zbar_video_get_fd (const zbar_video_t *vdo) { if(vdo->fd >= 0 && vdo->intf == VIDEO_V4L2) return(vdo->fd); if(vdo->intf != VIDEO_V4L2) - return(err_capture(vdo, SEV_WARNING, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__, "v4l1 API does not support polling")); - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video device not opened")); } -int zebra_video_request_size (zebra_video_t *vdo, - unsigned width, - unsigned height) +int zbar_video_request_size (zbar_video_t *vdo, + unsigned width, + unsigned height) { if(vdo->initialized) /* FIXME re-init different format? */ - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "already initialized, unable to resize")); vdo->width = width; @@ -167,46 +167,46 @@ int zebra_video_request_size (zebra_video_t *vdo, return(0); } -int zebra_video_request_interface (zebra_video_t *vdo, - int ver) +int zbar_video_request_interface (zbar_video_t *vdo, + int ver) { if(vdo->fd >= 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "device already opened, unable to change interface")); vdo->intf = (video_interface_t)ver; zprintf(1, "request interface version %d\n", vdo->intf); return(0); } -int zebra_video_request_iomode (zebra_video_t *vdo, - int iomode) +int zbar_video_request_iomode (zbar_video_t *vdo, + int iomode) { if(vdo->fd >= 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "device already opened, unable to change iomode")); if(iomode < 0 || iomode > VIDEO_USERPTR) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "invalid iomode requested")); vdo->iomode = iomode; return(0); } -int zebra_video_get_width (const zebra_video_t *vdo) +int zbar_video_get_width (const zbar_video_t *vdo) { return(vdo->width); } -int zebra_video_get_height (const zebra_video_t *vdo) +int zbar_video_get_height (const zbar_video_t *vdo) { return(vdo->height); } -uint32_t zebra_video_get_format (const zebra_video_t *vdo) +uint32_t zbar_video_get_format (const zbar_video_t *vdo) { return(vdo->format); } -static inline int video_init_images (zebra_video_t *vdo) +static inline int video_init_images (zbar_video_t *vdo) { assert(vdo->datalen); @@ -215,7 +215,7 @@ static inline int video_init_images (zebra_video_t *vdo) vdo->buflen = vdo->num_images * vdo->datalen; vdo->buf = malloc(vdo->buflen); if(!vdo->buf) - return(err_capture(vdo, SEV_FATAL, ZEBRA_ERR_NOMEM, __func__, + return(err_capture(vdo, SEV_FATAL, ZBAR_ERR_NOMEM, __func__, "unable to allocate image buffers")); zprintf(1, "pre-allocated %d %s buffers size=0x%lx\n", vdo->num_images, (vdo->iomode == VIDEO_READWRITE) ? "READ" : "USERPTR", @@ -223,7 +223,7 @@ static inline int video_init_images (zebra_video_t *vdo) } int i; for(i = 0; i < vdo->num_images; i++) { - zebra_image_t *img = vdo->images[i]; + zbar_image_t *img = vdo->images[i]; img->format = vdo->format; img->width = vdo->width; img->height = vdo->height; @@ -242,12 +242,12 @@ static inline int video_init_images (zebra_video_t *vdo) return(0); } -int zebra_video_init (zebra_video_t *vdo, - unsigned long fmt) +int zbar_video_init (zbar_video_t *vdo, + unsigned long fmt) { if(vdo->initialized) /* FIXME re-init different format? */ - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "already initialized, re-init unimplemented")); if(vdo->init(vdo, fmt)) @@ -256,16 +256,16 @@ int zebra_video_init (zebra_video_t *vdo, if(video_init_images(vdo)) return(-1); #ifdef HAVE_LIBJPEG - const zebra_format_def_t *vidfmt = _zebra_format_lookup(fmt); - if(vidfmt->group == ZEBRA_FMT_JPEG) { + const zbar_format_def_t *vidfmt = _zbar_format_lookup(fmt); + if(vidfmt->group == ZBAR_FMT_JPEG) { /* prepare for decoding */ if(!vdo->jpeg) - vdo->jpeg = _zebra_jpeg_decomp_create(); + vdo->jpeg = _zbar_jpeg_decomp_create(); if(vdo->jpeg_img) - zebra_image_destroy(vdo->jpeg_img); + zbar_image_destroy(vdo->jpeg_img); /* create intermediate image for decoder to use*/ - zebra_image_t *img = vdo->jpeg_img = zebra_image_create(); + zbar_image_t *img = vdo->jpeg_img = zbar_image_create(); img->format = fourcc('Y','8','0','0'); img->width = vdo->width; img->height = vdo->height; @@ -276,19 +276,19 @@ int zebra_video_init (zebra_video_t *vdo, return(0); } -int zebra_video_enable (zebra_video_t *vdo, - int enable) +int zbar_video_enable (zbar_video_t *vdo, + int enable) { if(vdo->active == enable) return(0); if(enable) { if(vdo->fd < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video device not opened")); if(!vdo->initialized && - zebra_negotiate_format(vdo, NULL)) + zbar_negotiate_format(vdo, NULL)) return(-1); } @@ -301,37 +301,37 @@ int zebra_video_enable (zebra_video_t *vdo, return(vdo->stop(vdo)); } -zebra_image_t *zebra_video_next_image (zebra_video_t *vdo) +zbar_image_t *zbar_video_next_image (zbar_video_t *vdo) { if(video_lock(vdo)) return(NULL); if(!vdo->active) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video not enabled"); (void)video_unlock(vdo); return(NULL); } unsigned frame = vdo->frame++; - zebra_image_t *img = vdo->dq(vdo); + zbar_image_t *img = vdo->dq(vdo); if(img) { img->seq = frame; if(vdo->num_images < 2) { /* return a *copy* of the video image and immediately recycle * the driver's buffer to avoid deadlocking the resources */ - zebra_image_t *tmp = img; + zbar_image_t *tmp = img; (void)video_lock(vdo); img = vdo->shadow_image; vdo->shadow_image = (img) ? img->next : NULL; (void)video_unlock(vdo); if(!img) { - img = zebra_image_create(); + img = zbar_image_create(); assert(img); img->refcnt = 0; img->src = vdo; /* recycle the shadow images */ - img->cleanup = _zebra_video_recycle_shadow; + img->cleanup = _zbar_video_recycle_shadow; img->format = vdo->format; img->width = vdo->width; @@ -341,7 +341,7 @@ zebra_image_t *zebra_video_next_image (zebra_video_t *vdo) } img->seq = frame; memcpy((void*)img->data, tmp->data, img->datalen); - _zebra_video_recycle_image(tmp); + _zbar_video_recycle_image(tmp); } img->refcnt++; } diff --git a/zebra/video.h b/zbar/video.h similarity index 72% rename from zebra/video.h rename to zbar/video.h index a77f3801..fa9f602d 100644 --- a/zebra/video.h +++ b/zbar/video.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _VIDEO_H_ #define _VIDEO_H_ @@ -36,12 +36,12 @@ # include #endif -#include +#include #include "error.h" /* number of images to preallocate */ -#define ZEBRA_VIDEO_IMAGES_MAX 4 +#define ZBAR_VIDEO_IMAGES_MAX 4 typedef enum video_interface_e { VIDEO_INVALID = 0, /* uninitialized */ @@ -55,7 +55,7 @@ typedef enum video_iomode_e { VIDEO_USERPTR, /* userspace buffers */ } video_iomode_t; -struct zebra_video_s { +struct zbar_video_s { errinfo_t err; /* error reporting */ int fd; /* open camera device */ unsigned width, height; /* video frame size */ @@ -74,10 +74,10 @@ struct zebra_video_s { void *buf; /* image data buffer */ int num_images; /* number of allocated images */ - zebra_image_t **images; /* indexed list of images */ - zebra_image_t *nq_image; /* last image enqueued */ - zebra_image_t *dq_image; /* first image to dequeue (when ordered) */ - zebra_image_t *shadow_image; /* special case internal double buffering */ + zbar_image_t **images; /* indexed list of images */ + zbar_image_t *nq_image; /* last image enqueued */ + zbar_image_t *dq_image; /* first image to dequeue (when ordered) */ + zbar_image_t *shadow_image; /* special case internal double buffering */ #ifdef HAVE_LIBPTHREAD pthread_mutex_t qlock; /* lock image queue */ @@ -85,18 +85,18 @@ struct zebra_video_s { #ifdef HAVE_LIBJPEG struct jpeg_decompress_struct *jpeg; /* JPEG decompressor */ - zebra_image_t *jpeg_img; /* temporary image */ + zbar_image_t *jpeg_img; /* temporary image */ #endif unsigned frame; /* frame count */ /* interface dependent methods */ - int (*init)(zebra_video_t*, uint32_t); - int (*cleanup)(zebra_video_t*); - int (*start)(zebra_video_t*); - int (*stop)(zebra_video_t*); - int (*nq)(zebra_video_t*, zebra_image_t*); - zebra_image_t* (*dq)(zebra_video_t*); + int (*init)(zbar_video_t*, uint32_t); + int (*cleanup)(zbar_video_t*); + int (*start)(zbar_video_t*); + int (*stop)(zbar_video_t*); + int (*nq)(zbar_video_t*, zbar_image_t*); + zbar_image_t* (*dq)(zbar_video_t*); }; @@ -105,11 +105,11 @@ struct zebra_video_s { /* video.next_image and video.recycle_image have to be thread safe * wrt/other apis */ -static inline int video_lock (zebra_video_t *vdo) +static inline int video_lock (zbar_video_t *vdo) { int rc = 0; if((rc = pthread_mutex_lock(&vdo->qlock))) { - err_capture(vdo, SEV_FATAL, ZEBRA_ERR_LOCKING, __func__, + err_capture(vdo, SEV_FATAL, ZBAR_ERR_LOCKING, __func__, "unable to acquire lock"); vdo->err.errnum = rc; return(-1); @@ -117,11 +117,11 @@ static inline int video_lock (zebra_video_t *vdo) return(0); } -static inline int video_unlock (zebra_video_t *vdo) +static inline int video_unlock (zbar_video_t *vdo) { int rc = 0; if((rc = pthread_mutex_unlock(&vdo->qlock))) { - err_capture(vdo, SEV_FATAL, ZEBRA_ERR_LOCKING, __func__, + err_capture(vdo, SEV_FATAL, ZBAR_ERR_LOCKING, __func__, "unable to release lock"); vdo->err.errnum = rc; return(-1); @@ -134,7 +134,7 @@ static inline int video_unlock (zebra_video_t *vdo) # define video_unlock(...) (0) #endif -extern int _zebra_video_open(zebra_video_t*, const char*); -extern int _zebra_v4l2_probe(zebra_video_t*); +extern int _zbar_video_open(zbar_video_t*, const char*); +extern int _zbar_v4l2_probe(zbar_video_t*); #endif diff --git a/zebra/video/null.c b/zbar/video/null.c similarity index 64% rename from zebra/video/null.c rename to zbar/video/null.c index 8807d286..25228700 100644 --- a/zebra/video/null.c +++ b/zbar/video/null.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown + * Copyright 2008-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "video.h" @@ -26,12 +26,12 @@ static inline int null_error (void *m, const char *func) { - return(err_capture(m, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, func, + return(err_capture(m, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, func, "not compiled with video input support")); } -int _zebra_video_open (zebra_video_t *vdo, - const char *device) +int _zbar_video_open (zbar_video_t *vdo, + const char *device) { return(null_error(vdo, __func__)); } diff --git a/zebra/video/v4l1.c b/zbar/video/v4l1.c similarity index 83% rename from zebra/video/v4l1.c rename to zbar/video/v4l1.c index 585f9ca8..2fb07928 100644 --- a/zebra/video/v4l1.c +++ b/zbar/video/v4l1.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -80,8 +80,8 @@ static const v4l1_format_t v4l1_formats[17] = { { fourcc('Y','U','V','9'), 9 }, /* YUV410P */ }; -static int v4l1_nq (zebra_video_t *vdo, - zebra_image_t *img) +static int v4l1_nq (zbar_video_t *vdo, + zbar_image_t *img) { /* v4l1 maintains queued buffers in order */ img->next = NULL; @@ -102,15 +102,15 @@ static int v4l1_nq (zebra_video_t *vdo, vmap.height = vdo->height; vmap.format = vdo->palette; if(ioctl(vdo->fd, VIDIOCMCAPTURE, &vmap) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "initiating video capture (VIDIOCMCAPTURE)")); return(0); } -static zebra_image_t *v4l1_dq (zebra_video_t *vdo) +static zbar_image_t *v4l1_dq (zbar_video_t *vdo) { - zebra_image_t *img = NULL; + zbar_image_t *img = NULL; img = vdo->dq_image; if(img) { vdo->dq_image = img->next; @@ -121,7 +121,7 @@ static zebra_image_t *v4l1_dq (zebra_video_t *vdo) if(!img) { /* FIXME block until available? */ - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_BUSY, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_BUSY, __func__, "all allocated video images busy"); return(NULL); } @@ -129,27 +129,27 @@ static zebra_image_t *v4l1_dq (zebra_video_t *vdo) if(vdo->iomode == VIDEO_MMAP) { int frame = img->srcidx; if(ioctl(vdo->fd, VIDIOCSYNC, &frame) < 0) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "capturing video image (VIDIOCSYNC)"); return(NULL); } } else if(read(vdo->fd, (void*)img->data, img->datalen) != img->datalen) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "reading video image"); return(NULL); } return(img); } -static int v4l1_mmap_buffers (zebra_video_t *vdo) +static int v4l1_mmap_buffers (zbar_video_t *vdo) { #ifdef HAVE_SYS_MMAN_H /* map camera image to memory */ struct video_mbuf vbuf; memset(&vbuf, 0, sizeof(vbuf)); if(ioctl(vdo->fd, VIDIOCGMBUF, &vbuf) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video frame buffers (VIDIOCGMBUF)")); assert(vbuf.frames && vbuf.size); @@ -158,12 +158,12 @@ static int v4l1_mmap_buffers (zebra_video_t *vdo) vdo->buf = mmap(0, vbuf.size, PROT_READ | PROT_WRITE, MAP_SHARED, vdo->fd, 0); if(vdo->buf == MAP_FAILED) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "mapping video frame buffers")); int i; for(i = 0; i < vbuf.frames; i++) { - zebra_image_t *img = vdo->images[i]; + zbar_image_t *img = vdo->images[i]; zprintf(2, " [%02d] @%08x\n", img->srcidx, vbuf.offsets[i]); img->data = vdo->buf + vbuf.offsets[i]; img->datalen = vdo->datalen; @@ -180,12 +180,12 @@ static int v4l1_mmap_buffers (zebra_video_t *vdo) } return(0); #else - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "memory mapping not supported")); #endif } -static int v4l1_start (zebra_video_t *vdo) +static int v4l1_start (zbar_video_t *vdo) { /* enqueue all buffers */ int i; @@ -196,7 +196,7 @@ static int v4l1_start (zebra_video_t *vdo) return(0); } -static int v4l1_stop (zebra_video_t *vdo) +static int v4l1_stop (zbar_video_t *vdo) { int i; for(i = 0; i < vdo->num_images; i++) @@ -205,13 +205,13 @@ static int v4l1_stop (zebra_video_t *vdo) return(video_unlock(vdo)); } -static inline int v4l1_set_format (zebra_video_t *vdo, +static inline int v4l1_set_format (zbar_video_t *vdo, uint32_t fmt) { struct video_picture vpic; memset(&vpic, 0, sizeof(vpic)); if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video format (VIDIOCGPICT)")); vdo->palette = 0; @@ -220,18 +220,18 @@ static inline int v4l1_set_format (zebra_video_t *vdo, if(v4l1_formats[ifmt].format == fmt) break; if(!fmt || ifmt >= VIDEO_PALETTE_YUV410P) - return(err_capture_int(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "invalid v4l1 format: %08x", fmt)); vpic.palette = ifmt; vpic.depth = v4l1_formats[ifmt].bpp; if(ioctl(vdo->fd, VIDIOCSPICT, &vpic) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "setting format (VIDIOCSPICT)")); memset(&vpic, 0, sizeof(vpic)); if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video format (VIDIOCGPICT)")); if(vpic.palette != ifmt || vpic.depth != v4l1_formats[ifmt].bpp) { @@ -240,7 +240,7 @@ static inline int v4l1_set_format (zebra_video_t *vdo, " but probed palette %d with depth %d bpp?" " ...continuing anyway\n", ifmt, v4l1_formats[ifmt].bpp, vpic.palette, vpic.depth); - err_capture_int(vdo, SEV_WARNING, ZEBRA_ERR_INVALID, __func__, + err_capture_int(vdo, SEV_WARNING, ZBAR_ERR_INVALID, __func__, "driver format (%x) inconsistency", fmt); } vdo->format = fmt; @@ -253,7 +253,7 @@ static inline int v4l1_set_format (zebra_video_t *vdo, return(0); } -static int v4l1_init (zebra_video_t *vdo, +static int v4l1_init (zbar_video_t *vdo, uint32_t fmt) { if(v4l1_set_format(vdo, fmt)) @@ -263,13 +263,13 @@ static int v4l1_init (zebra_video_t *vdo, return(0); } -static int v4l1_cleanup (zebra_video_t *vdo) +static int v4l1_cleanup (zbar_video_t *vdo) { #ifdef HAVE_SYS_MMAN_H /* FIXME should avoid holding onto mmap'd buffers so long? */ if(vdo->iomode == VIDEO_MMAP && vdo->buf) { if(munmap(vdo->buf, vdo->buflen)) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "unmapping video frame buffers")); vdo->buf = NULL; /* FIXME reset image */ @@ -278,7 +278,7 @@ static int v4l1_cleanup (zebra_video_t *vdo) return(0); } -static int v4l1_probe_iomode (zebra_video_t *vdo) +static int v4l1_probe_iomode (zbar_video_t *vdo) { vdo->iomode = VIDEO_READWRITE; #ifdef HAVE_SYS_MMAN_H @@ -286,7 +286,7 @@ static int v4l1_probe_iomode (zebra_video_t *vdo) memset(&vbuf, 0, sizeof(vbuf)); if(ioctl(vdo->fd, VIDIOCGMBUF, &vbuf) < 0) { if(errno != EINVAL) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video frame buffers (VIDIOCGMBUF)")); /* not supported */ return(0); @@ -302,12 +302,12 @@ static int v4l1_probe_iomode (zebra_video_t *vdo) return(0); } -static inline int v4l1_probe_formats (zebra_video_t *vdo) +static inline int v4l1_probe_formats (zbar_video_t *vdo) { struct video_picture vpic; memset(&vpic, 0, sizeof(vpic)); if(ioctl(vdo->fd, VIDIOCGPICT, &vpic) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying format (VIDIOCGPICT)")); vdo->format = 0; @@ -319,7 +319,7 @@ static inline int v4l1_probe_formats (zebra_video_t *vdo) vdo->formats = calloc(16, sizeof(uint32_t)); if(!vdo->formats) - return(err_capture(vdo, SEV_FATAL, ZEBRA_ERR_NOMEM, __func__, + return(err_capture(vdo, SEV_FATAL, ZBAR_ERR_NOMEM, __func__, "allocating format list")); int num_formats = 0; @@ -351,12 +351,12 @@ static inline int v4l1_probe_formats (zebra_video_t *vdo) return(v4l1_set_format(vdo, vdo->format)); } -static inline int v4l1_init_window (zebra_video_t *vdo) +static inline int v4l1_init_window (zbar_video_t *vdo) { struct video_window vwin; memset(&vwin, 0, sizeof(vwin)); if(ioctl(vdo->fd, VIDIOCGWIN, &vwin) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video window settings (VIDIOCGWIN)")); zprintf(1, "current window: %d x %d @(%d, %d)%s\n", @@ -384,7 +384,7 @@ static inline int v4l1_init_window (zebra_video_t *vdo) /* re-query resulting parameters */ memset(&vwin, 0, sizeof(vwin)); if(ioctl(vdo->fd, VIDIOCGWIN, &vwin) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video window settings (VIDIOCGWIN)")); zprintf(1, " final window: %d x %d @(%d, %d)%s\n", @@ -395,13 +395,13 @@ static inline int v4l1_init_window (zebra_video_t *vdo) return(0); } -static int _zebra_v4l1_probe (zebra_video_t *vdo) +static int _zbar_v4l1_probe (zbar_video_t *vdo) { /* check capabilities */ struct video_capability vcap; memset(&vcap, 0, sizeof(vcap)); if(ioctl(vdo->fd, VIDIOCGCAP, &vcap) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "video4linux version 1 not supported (VIDIOCGCAP)")); zprintf(1, "%s (%sCAPTURE) (%d x %d) - (%d x %d)\n", @@ -409,7 +409,7 @@ static int _zebra_v4l1_probe (zebra_video_t *vdo) vcap.minwidth, vcap.minheight, vcap.maxwidth, vcap.maxheight); if(!(vcap.type & VID_TYPE_CAPTURE)) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "v4l1 device does not support CAPTURE")); if(!vdo->width || !vdo->height) { @@ -432,8 +432,8 @@ static int _zebra_v4l1_probe (zebra_video_t *vdo) return(0); } -int _zebra_video_open (zebra_video_t *vdo, - const char *dev) +int _zbar_video_open (zbar_video_t *vdo, + const char *dev) { /* close open device */ if(vdo->fd >= 0) { @@ -460,19 +460,19 @@ int _zebra_video_open (zebra_video_t *vdo, vdo->fd = open(dev, O_RDWR); if(vdo->fd < 0) - return(err_capture_str(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture_str(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "opening video device '%s'", dev)); zprintf(1, "opened camera device %s (fd=%d)\n", dev, vdo->fd); int rc = -1; #ifdef HAVE_LINUX_VIDEODEV2_H if(vdo->intf != VIDEO_V4L1) - rc = _zebra_v4l2_probe(vdo); + rc = _zbar_v4l2_probe(vdo); if(rc) #else zprintf(1, "WARNING: not compiled with v4l2 support, trying v4l1\n"); #endif - rc = _zebra_v4l1_probe(vdo); + rc = _zbar_v4l1_probe(vdo); if(rc && vdo->fd >= 0) { close(vdo->fd); vdo->fd = -1; diff --git a/zebra/video/v4l2.c b/zbar/video/v4l2.c similarity index 85% rename from zebra/video/v4l2.c rename to zbar/video/v4l2.c index e4c622af..e09b8f9a 100644 --- a/zebra/video/v4l2.c +++ b/zbar/video/v4l2.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -45,8 +45,8 @@ #define V4L2_FORMATS_MAX 64 -static int v4l2_nq (zebra_video_t *vdo, - zebra_image_t *img) +static int v4l2_nq (zbar_video_t *vdo, + zbar_image_t *img) { if(vdo->iomode != VIDEO_READWRITE) { if(video_unlock(vdo)) @@ -66,7 +66,7 @@ static int v4l2_nq (zebra_video_t *vdo, vbuf.index = img->srcidx; /* FIXME workaround broken drivers */ } if(ioctl(vdo->fd, VIDIOC_QBUF, &vbuf) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "queuing video buffer (VIDIOC_QBUF)")); } else { @@ -77,9 +77,9 @@ static int v4l2_nq (zebra_video_t *vdo, return(0); } -static zebra_image_t *v4l2_dq (zebra_video_t *vdo) +static zbar_image_t *v4l2_dq (zbar_video_t *vdo) { - zebra_image_t *img; + zbar_image_t *img; if(vdo->iomode != VIDEO_READWRITE) { if(video_unlock(vdo)) @@ -94,7 +94,7 @@ static zebra_image_t *v4l2_dq (zebra_video_t *vdo) vbuf.memory = V4L2_MEMORY_USERPTR; if(ioctl(vdo->fd, VIDIOC_DQBUF, &vbuf) < 0) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "dequeuing video buffer (VIDIOC_DQBUF)"); return(NULL); } @@ -123,7 +123,7 @@ static zebra_image_t *v4l2_dq (zebra_video_t *vdo) if(video_unlock(vdo)) return(NULL); if(!img) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_BUSY, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_BUSY, __func__, "all allocated video images busy"); return(NULL); } @@ -131,7 +131,7 @@ static zebra_image_t *v4l2_dq (zebra_video_t *vdo) /* FIXME should read entire image */ unsigned long datalen = read(vdo->fd, (void*)img->data, img->datalen); if(datalen < 0) { - err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "reading video image"); return(NULL); } @@ -142,7 +142,7 @@ static zebra_image_t *v4l2_dq (zebra_video_t *vdo) return(img); } -static int v4l2_start (zebra_video_t *vdo) +static int v4l2_start (zbar_video_t *vdo) { /* enqueue all buffers */ int i; @@ -156,12 +156,12 @@ static int v4l2_start (zebra_video_t *vdo) enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_STREAMON, &type) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "starting video stream (VIDIOC_STREAMON)")); return(0); } -static int v4l2_stop (zebra_video_t *vdo) +static int v4l2_stop (zbar_video_t *vdo) { int i; for(i = 0; i < vdo->num_images; i++) @@ -175,12 +175,12 @@ static int v4l2_stop (zebra_video_t *vdo) enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_STREAMOFF, &type) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "stopping video stream (VIDIOC_STREAMOFF)")); return(0); } -static int v4l2_cleanup (zebra_video_t *vdo) +static int v4l2_cleanup (zbar_video_t *vdo) { if(vdo->iomode == VIDEO_READWRITE) return(0); @@ -192,10 +192,10 @@ static int v4l2_cleanup (zebra_video_t *vdo) rb.memory = V4L2_MEMORY_MMAP; int i; for(i = 0; i < vdo->num_images; i++) { - zebra_image_t *img = vdo->images[i]; + zbar_image_t *img = vdo->images[i]; if(img->data && munmap((void*)img->data, img->datalen)) - err_capture(vdo, SEV_WARNING, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__, "unmapping video frame buffers"); img->data = NULL; img->datalen = 0; @@ -208,13 +208,13 @@ static int v4l2_cleanup (zebra_video_t *vdo) * should implicitly disable streaming */ if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0) - err_capture(vdo, SEV_WARNING, ZEBRA_ERR_SYSTEM, __func__, + err_capture(vdo, SEV_WARNING, ZBAR_ERR_SYSTEM, __func__, "releasing video frame buffers (VIDIOC_REQBUFS)"); return(0); } -static int v4l2_mmap_buffers (zebra_video_t *vdo) +static int v4l2_mmap_buffers (zbar_video_t *vdo) { struct v4l2_requestbuffers rb; memset(&rb, 0, sizeof(rb)); @@ -222,12 +222,12 @@ static int v4l2_mmap_buffers (zebra_video_t *vdo) rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; rb.memory = V4L2_MEMORY_MMAP; if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "requesting video frame buffers (VIDIOC_REQBUFS)")); zprintf(1, "mapping %u buffers (of %d requested)\n", rb.count, vdo->num_images); if(!rb.count) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "driver returned 0 buffers")); if(vdo->num_images > rb.count) vdo->num_images = rb.count; @@ -242,7 +242,7 @@ static int v4l2_mmap_buffers (zebra_video_t *vdo) vbuf.index = i; if(ioctl(vdo->fd, VIDIOC_QUERYBUF, &vbuf) < 0) /* FIXME cleanup */ - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying video buffer (VIDIOC_QUERYBUF)")); if(vbuf.length < vdo->datalen) @@ -251,13 +251,13 @@ static int v4l2_mmap_buffers (zebra_video_t *vdo) i, vbuf.length, vdo->datalen, vdo->width, vdo->height, (char*)&vdo->format, vdo->format); - zebra_image_t *img = vdo->images[i]; + zbar_image_t *img = vdo->images[i]; img->datalen = vbuf.length; img->data = mmap(NULL, vbuf.length, PROT_READ | PROT_WRITE, MAP_SHARED, vdo->fd, vbuf.m.offset); if(img->data == MAP_FAILED) /* FIXME cleanup */ - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "mapping video frame buffers")); zprintf(2, " buf[%d] 0x%lx bytes @%p\n", i, img->datalen, img->data); @@ -265,7 +265,7 @@ static int v4l2_mmap_buffers (zebra_video_t *vdo) return(0); } -static int v4l2_set_format (zebra_video_t *vdo, +static int v4l2_set_format (zbar_video_t *vdo, uint32_t fmt) { struct v4l2_format vfmt; @@ -289,7 +289,7 @@ static int v4l2_set_format (zebra_video_t *vdo, vpix->field = V4L2_FIELD_INTERLACED; if(ioctl(vdo->fd, VIDIOC_S_FMT, &vfmt) < 0) - return(err_capture_int(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "setting format %x (VIDIOC_S_FMT)", fmt)); zprintf(0, "WARNING: broken driver returned error when non-interlaced" @@ -301,17 +301,17 @@ static int v4l2_set_format (zebra_video_t *vdo, memset(&newfmt, 0, sizeof(newfmt)); newfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_G_FMT, &newfmt) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying format (VIDIOC_G_FMT)")); if(newpix->field != V4L2_FIELD_NONE) - err_capture(vdo, SEV_WARNING, ZEBRA_ERR_INVALID, __func__, + err_capture(vdo, SEV_WARNING, ZBAR_ERR_INVALID, __func__, "video driver only supports interlaced format," " vertical scanning may not work"); if(newpix->pixelformat != fmt /* FIXME bpl/bpp checks? */) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video driver can't provide compatible format")); vdo->format = fmt; @@ -325,7 +325,7 @@ static int v4l2_set_format (zebra_video_t *vdo, return(0); } -static int v4l2_init (zebra_video_t *vdo, +static int v4l2_init (zbar_video_t *vdo, uint32_t fmt) { if(v4l2_set_format(vdo, fmt)) @@ -335,7 +335,7 @@ static int v4l2_init (zebra_video_t *vdo, return(0); } -static int v4l2_probe_iomode (zebra_video_t *vdo) +static int v4l2_probe_iomode (zbar_video_t *vdo) { struct v4l2_requestbuffers rb; memset(&rb, 0, sizeof(rb)); @@ -348,11 +348,11 @@ static int v4l2_probe_iomode (zebra_video_t *vdo) if(ioctl(vdo->fd, VIDIOC_REQBUFS, &rb) < 0) { if(vdo->iomode) - return(err_capture_int(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture_int(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "unsupported iomode requested (%d)", vdo->iomode)); else if(errno != EINVAL) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying streaming mode (VIDIOC_REQBUFS)")); #ifdef HAVE_SYS_MMAN_H vdo->iomode = VIDEO_MMAP; @@ -367,7 +367,7 @@ static int v4l2_probe_iomode (zebra_video_t *vdo) return(0); } -static inline int v4l2_probe_formats (zebra_video_t *vdo) +static inline int v4l2_probe_formats (zbar_video_t *vdo) { zprintf(2, "enumerating supported formats:\n"); struct v4l2_fmtdesc desc; @@ -384,7 +384,7 @@ static inline int v4l2_probe_formats (zebra_video_t *vdo) vdo->formats[desc.index] = desc.pixelformat; } if(!desc.index) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "enumerating video formats (VIDIOC_ENUM_FMT)")); vdo->formats[desc.index] = 0; @@ -393,7 +393,7 @@ static inline int v4l2_probe_formats (zebra_video_t *vdo) memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying current video format (VIDIO_G_FMT)")); zprintf(1, "current format: %.4s(%08x) %u x %u%s (line=0x%x size=0x%x)\n", @@ -423,7 +423,7 @@ static inline int v4l2_probe_formats (zebra_video_t *vdo) memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_G_FMT, &fmt) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying current video format (VIDIOC_G_FMT)")); zprintf(1, "final format: %.4s(%08x) %u x %u%s (line=0x%x size=0x%x)\n", @@ -438,14 +438,14 @@ static inline int v4l2_probe_formats (zebra_video_t *vdo) return(0); } -static inline int v4l2_reset_crop (zebra_video_t *vdo) +static inline int v4l2_reset_crop (zbar_video_t *vdo) { /* check cropping */ struct v4l2_cropcap ccap; memset(&ccap, 0, sizeof(ccap)); ccap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(ioctl(vdo->fd, VIDIOC_CROPCAP, &ccap) < 0) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "querying crop support (VIDIOC_CROPCAP)")); zprintf(1, "crop bounds: %d x %d @ (%d, %d)\n", @@ -467,18 +467,18 @@ static inline int v4l2_reset_crop (zebra_video_t *vdo) crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; crop.c = ccap.defrect; if(ioctl(vdo->fd, VIDIOC_S_CROP, &crop) < 0 && errno != EINVAL) - return(err_capture(vdo, SEV_ERROR, ZEBRA_ERR_SYSTEM, __func__, + return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_SYSTEM, __func__, "setting default crop window (VIDIOC_S_CROP)")); return(0); } -int _zebra_v4l2_probe (zebra_video_t *vdo) +int _zbar_v4l2_probe (zbar_video_t *vdo) { /* check capabilities */ struct v4l2_capability vcap; memset(&vcap, 0, sizeof(vcap)); if(ioctl(vdo->fd, VIDIOC_QUERYCAP, &vcap) < 0) - return(err_capture(vdo, SEV_WARNING, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__, "video4linux version 2 not supported (VIDIOC_QUERYCAP)")); @@ -494,7 +494,7 @@ int _zebra_v4l2_probe (zebra_video_t *vdo) if(!(vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE) || !(vcap.capabilities & (V4L2_CAP_READWRITE | V4L2_CAP_STREAMING))) - return(err_capture(vdo, SEV_WARNING, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(vdo, SEV_WARNING, ZBAR_ERR_UNSUPPORTED, __func__, "v4l2 device does not support usable CAPTURE")); if(v4l2_reset_crop(vdo)) diff --git a/zebra/window.c b/zbar/window.c similarity index 52% rename from zebra/window.c rename to zbar/window.c index 6a0283f1..2faa9d4f 100644 --- a/zebra/window.c +++ b/zbar/window.c @@ -1,59 +1,55 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "window.h" #include "image.h" -extern int _zebra_draw_logo(zebra_image_t *img); +extern int _zbar_draw_logo(zbar_window_t *w); -zebra_window_t *zebra_window_create () +zbar_window_t *zbar_window_create () { - zebra_window_t *w = calloc(1, sizeof(zebra_window_t)); + zbar_window_t *w = calloc(1, sizeof(zbar_window_t)); if(!w) return(NULL); - err_init(&w->err, ZEBRA_MOD_WINDOW); + err_init(&w->err, ZBAR_MOD_WINDOW); w->overlay = 1; return(w); } -void zebra_window_destroy (zebra_window_t *w) +void zbar_window_destroy (zbar_window_t *w) { /* detach */ - zebra_window_attach(w, NULL, 0); - if(w->logo) { - _zebra_image_refcnt(w->logo, -1); - w->logo = NULL; - } + zbar_window_attach(w, NULL, 0); err_cleanup(&w->err); free(w); } -int zebra_window_attach (zebra_window_t *w, - void *display, - unsigned long drawable) +int zbar_window_attach (zbar_window_t *w, + void *display, + unsigned long drawable) { /* release image */ - zebra_window_draw(w, NULL); + zbar_window_draw(w, NULL); if(w->cleanup) { w->cleanup(w); w->cleanup = NULL; @@ -63,24 +59,24 @@ int zebra_window_attach (zebra_window_t *w, free(w->formats); w->formats = NULL; } - return(_zebra_window_attach(w, display, drawable)); + return(_zbar_window_attach(w, display, drawable)); } -static inline int window_draw_overlay (zebra_window_t *w) +static inline int window_draw_overlay (zbar_window_t *w) { /* FIXME TBD - * _zebra_draw_line, _zebra_draw_polygon, _zebra_draw_text, etc... + * _zbar_draw_line, _zbar_draw_polygon, _zbar_draw_text, etc... */ if(!w->overlay) return(0); if(w->overlay >= 1 && w->image) { /* FIXME outline each symbol */ - const zebra_symbol_t *sym = zebra_image_first_symbol(w->image); + const zbar_symbol_t *sym = zbar_image_first_symbol(w->image); for(; sym; sym = sym->next) { int i; for(i = 0; i < sym->npts; i++) { uint32_t color = ((sym->cache_count < 0) ? 4 : 2); - _zebra_window_draw_marker(w, color, &sym->pts[i]); + _zbar_window_draw_marker(w, color, &sym->pts[i]); } } } @@ -90,45 +86,42 @@ static inline int window_draw_overlay (zebra_window_t *w) return(0); } -inline int zebra_window_redraw (zebra_window_t *w) +inline int zbar_window_redraw (zbar_window_t *w) { if(window_lock(w)) return(-1); - if(!w->draw_image || !w->logo) { + if(!w->draw_image) { (void)window_unlock(w); - return(_zebra_window_clear(w)); + return(_zbar_window_clear(w)); } - int rc; + int rc = 0; if(w->image) rc = w->draw_image(w, w->image); - else { - rc = w->draw_image(w, w->logo); - if(w->image) - w->logo->refcnt++; - } + else + _zbar_draw_logo(w); if(!rc) rc = window_draw_overlay(w); (void)window_unlock(w); return(rc); } -int zebra_window_draw (zebra_window_t *w, - zebra_image_t *img) +int zbar_window_draw (zbar_window_t *w, + zbar_image_t *img) { if(window_lock(w)) return(-1); if(!w->draw_image) img = NULL; if(w->image) - _zebra_image_refcnt(w->image, -1); + _zbar_image_refcnt(w->image, -1); w->image = img; if(img) img->refcnt++; return(window_unlock(w)); } -void zebra_window_set_overlay (zebra_window_t *w, - int lvl) +void zbar_window_set_overlay (zbar_window_t *w, + int lvl) { if(lvl < 0) lvl = 0; @@ -141,21 +134,13 @@ void zebra_window_set_overlay (zebra_window_t *w, (void)window_unlock(w); } -int zebra_window_resize (zebra_window_t *w, - unsigned width, - unsigned height) +int zbar_window_resize (zbar_window_t *w, + unsigned width, + unsigned height) { if(window_lock(w)) return(-1); w->width = width; w->height = height; - if(!w->logo) { - w->logo = zebra_image_create(); - w->logo->refcnt++; - } - if(w->logo->width != width || w->logo->height != height) { - zebra_image_set_size(w->logo, width, height); - _zebra_draw_logo(w->logo); - } return(window_unlock(w)); } diff --git a/zebra/window.h b/zbar/window.h similarity index 72% rename from zebra/window.h rename to zbar/window.h index 520cf2d7..e9abfeeb 100644 --- a/zebra/window.h +++ b/zbar/window.h @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #ifndef _WINDOW_H_ #define _WINDOW_H_ @@ -44,13 +44,13 @@ # include #endif -#include +#include #include "image.h" #include "error.h" -struct zebra_window_s { +struct zbar_window_s { errinfo_t err; /* error reporting */ - zebra_image_t *image; /* last displayed image + zbar_image_t *image; /* last displayed image * NB image access must be locked! */ unsigned overlay; /* user set overlay level */ @@ -58,13 +58,12 @@ struct zebra_window_s { uint32_t format; /* output format */ unsigned width, height; /* current output size */ unsigned max_width, max_height; - zebra_image_t *logo; /* logo image for current width x height */ uint32_t *formats; /* supported formats (zero terminated) */ /* interface dependent methods */ - int (*draw_image)(zebra_window_t*, zebra_image_t*); - int (*cleanup)(zebra_window_t*); + int (*draw_image)(zbar_window_t*, zbar_image_t*); + int (*cleanup)(zbar_window_t*); #ifdef HAVE_X Display *display; /* display connection */ @@ -104,11 +103,11 @@ struct zebra_window_s { /* window.draw has to be thread safe wrt/other apis * FIXME should be a semaphore */ -static inline int window_lock (zebra_window_t *w) +static inline int window_lock (zbar_window_t *w) { int rc = 0; if((rc = pthread_mutex_lock(&w->imglock))) { - err_capture(w, SEV_FATAL, ZEBRA_ERR_LOCKING, __func__, + err_capture(w, SEV_FATAL, ZBAR_ERR_LOCKING, __func__, "unable to acquire lock"); w->err.errnum = rc; return(-1); @@ -116,11 +115,11 @@ static inline int window_lock (zebra_window_t *w) return(0); } -static inline int window_unlock (zebra_window_t *w) +static inline int window_unlock (zbar_window_t *w) { int rc = 0; if((rc = pthread_mutex_unlock(&w->imglock))) { - err_capture(w, SEV_FATAL, ZEBRA_ERR_LOCKING, __func__, + err_capture(w, SEV_FATAL, ZBAR_ERR_LOCKING, __func__, "unable to release lock"); w->err.errnum = rc; return(-1); @@ -133,7 +132,7 @@ static inline int window_unlock (zebra_window_t *w) # define window_unlock(...) (0) #endif -static inline int _zebra_window_add_format (zebra_window_t *w, +static inline int _zbar_window_add_format (zbar_window_t *w, uint32_t fmt) { int i; @@ -147,22 +146,22 @@ static inline int _zebra_window_add_format (zebra_window_t *w, return(i); } -extern int _zebra_window_probe_ximage(zebra_window_t*); -extern int _zebra_window_probe_xshm(zebra_window_t*); -extern int _zebra_window_probe_xv(zebra_window_t*); +extern int _zbar_window_probe_ximage(zbar_window_t*); +extern int _zbar_window_probe_xshm(zbar_window_t*); +extern int _zbar_window_probe_xv(zbar_window_t*); -extern int _zebra_window_attach(zebra_window_t*, void*, unsigned long); +extern int _zbar_window_attach(zbar_window_t*, void*, unsigned long); -extern int _zebra_window_clear(zebra_window_t*); +extern int _zbar_window_clear(zbar_window_t*); -extern int _zebra_window_draw_marker(zebra_window_t*, uint32_t, +extern int _zbar_window_draw_marker(zbar_window_t*, uint32_t, const point_t*); #if 0 -extern int _zebra_window_draw_line(zebra_window_t*, uint32_t, +extern int _zbar_window_draw_line(zbar_window_t*, uint32_t, const point_t*, const point_t*); -extern int _zebra_window_draw_outline(zebra_window_t*, uint32_t, +extern int _zbar_window_draw_outline(zbar_window_t*, uint32_t, const symbol_t*); -extern int _zebra_window_draw_text(zebra_window_t*, uint32_t, +extern int _zbar_window_draw_text(zbar_window_t*, uint32_t, const point_t*, const char*); #endif diff --git a/zbar/window/null.c b/zbar/window/null.c new file mode 100644 index 00000000..20182c1a --- /dev/null +++ b/zbar/window/null.c @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------ + * Copyright 2008-2009 (c) Jeff Brown + * + * This file is part of the ZBar Bar Code Reader. + * + * The ZBar Bar Code Reader is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * The ZBar Bar Code Reader is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with the ZBar Bar Code Reader; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * http://sourceforge.net/projects/zbar + *------------------------------------------------------------------------*/ + +#include "window.h" + +static inline int null_error (void *m, + const char *func) +{ + return(err_capture(m, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, func, + "not compiled with output window support")); +} + +int _zbar_window_attach (zbar_window_t *w, + void *display, + unsigned long win) +{ + return(null_error(w, __func__)); +} + +int _zbar_window_handle_events (zbar_processor_t *proc, + int block) +{ + return(null_error(proc, __func__)); +} + +int _zbar_window_open (zbar_processor_t *proc, + char *title, + unsigned width, + unsigned height) +{ + return(null_error(proc, __func__)); +} + +int _zbar_window_close (zbar_processor_t *proc) +{ + return(null_error(proc, __func__)); +} + +int _zbar_window_resize (zbar_processor_t *proc, + unsigned width, + unsigned height) +{ + return(null_error(proc, __func__)); +} + +int _zbar_window_set_visible (zbar_processor_t *proc, + int visible) +{ + return(null_error(proc, __func__)); +} + +int _zbar_window_clear (zbar_window_t *w) +{ + return(null_error(w, __func__)); +} + +int _zbar_window_invalidate (zbar_window_t *w) +{ + return(0); +} + +int _zbar_window_draw_marker(zbar_window_t *w, + uint32_t rgb, + const point_t *p) +{ + return(null_error(w, __func__)); +} diff --git a/zebra/window/x.c b/zbar/window/x.c similarity index 75% rename from zebra/window/x.c rename to zbar/window/x.c index 88729af8..9c140d46 100644 --- a/zebra/window/x.c +++ b/zbar/window/x.c @@ -1,31 +1,31 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "window.h" #include "processor.h" #include -static inline int window_alloc_colors (zebra_window_t *w) +static inline int window_alloc_colors (zbar_window_t *w) { Colormap cmap = DefaultColormap(w->display, DefaultScreen(w->display)); XColor color; @@ -41,7 +41,7 @@ static inline int window_alloc_colors (zebra_window_t *w) return(0); } -static inline int window_hide_cursor (zebra_window_t *w) +static inline int window_hide_cursor (zbar_window_t *w) { /* FIXME this seems lame...there must be a better way */ Pixmap empty = XCreatePixmap(w->display, w->xwin, 1, 1, 1); @@ -60,9 +60,9 @@ static inline int window_hide_cursor (zebra_window_t *w) return(0); } -int _zebra_window_attach (zebra_window_t *w, - void *display, - unsigned long win) +int _zbar_window_attach (zbar_window_t *w, + void *display, + unsigned long win) { if(w->display) { /* cleanup existing resources */ @@ -89,15 +89,15 @@ int _zebra_window_attach (zebra_window_t *w, /* FIXME add interface preference override */ #ifdef HAVE_X11_EXTENSIONS_XVLIB_H - if(!_zebra_window_probe_xv(w)) + if(!_zbar_window_probe_xv(w)) return(0); #endif zprintf(1, "falling back to XImage\n"); - return(_zebra_window_probe_ximage(w)); + return(_zbar_window_probe_ximage(w)); } -static int x_handle_event (zebra_processor_t *proc) +static int x_handle_event (zbar_processor_t *proc) { XEvent ev; XNextEvent(proc->display, &ev); @@ -106,13 +106,13 @@ static int x_handle_event (zebra_processor_t *proc) case Expose: /* FIXME ignore when running */ if(!ev.xexpose.count) - zebra_window_redraw(proc->window); + zbar_window_redraw(proc->window); break; case ConfigureNotify: zprintf(3, "resized to %d x %d\n", ev.xconfigure.width, ev.xconfigure.height); - zebra_window_resize(proc->window, + zbar_window_resize(proc->window, ev.xconfigure.width, ev.xconfigure.height); break; @@ -123,8 +123,8 @@ static int x_handle_event (zebra_processor_t *proc) (ev.xclient.data.l[0] == XInternAtom(proc->display, "WM_DELETE_WINDOW", 0))) { zprintf(3, "WM_DELETE_WINDOW\n"); - _zebra_window_set_visible(proc, 0); - return(err_capture(proc, SEV_WARNING, ZEBRA_ERR_CLOSED, __func__, + _zbar_window_set_visible(proc, 0); + return(err_capture(proc, SEV_WARNING, ZBAR_ERR_CLOSED, __func__, "user closed display window")); } @@ -150,8 +150,8 @@ static int x_handle_event (zebra_processor_t *proc) return(0); } -int _zebra_window_handle_events (zebra_processor_t *proc, - int block) +int _zbar_window_handle_events (zbar_processor_t *proc, + int block) { int rc = 0; while(!rc && (block || XPending(proc->display))) { @@ -161,8 +161,8 @@ int _zebra_window_handle_events (zebra_processor_t *proc, switch(rc) { case 'q': - _zebra_window_set_visible(proc, 0); - rc = err_capture(proc, SEV_WARNING, ZEBRA_ERR_CLOSED, __func__, + _zbar_window_set_visible(proc, 0); + rc = err_capture(proc, SEV_WARNING, ZBAR_ERR_CLOSED, __func__, "user closed display window"); break; @@ -170,7 +170,7 @@ int _zebra_window_handle_events (zebra_processor_t *proc, /* FIXME localtime not threadsafe */ /* FIXME need ms resolution */ /*struct tm *t = localtime(time(NULL));*/ - zebra_image_write(proc->window->image, "zebra"); + zbar_image_write(proc->window->image, "zbar"); break; } } @@ -180,17 +180,17 @@ int _zebra_window_handle_events (zebra_processor_t *proc, return(rc); } -static int x_connection_handler (zebra_processor_t *proc, +static int x_connection_handler (zbar_processor_t *proc, int i) { - return(_zebra_window_handle_events(proc, 0)); + return(_zbar_window_handle_events(proc, 0)); } -static int x_internal_handler (zebra_processor_t *proc, +static int x_internal_handler (zbar_processor_t *proc, int i) { XProcessInternalConnection(proc->display, proc->polling.fds[i].fd); - return(_zebra_window_handle_events(proc, 0)); + return(_zbar_window_handle_events(proc, 0)); } static void x_internal_watcher (Display *display, @@ -199,21 +199,21 @@ static void x_internal_watcher (Display *display, Bool opening, XPointer *watch_arg) { - zebra_processor_t *proc = (void*)client_arg; + zbar_processor_t *proc = (void*)client_arg; if(opening) add_poll(proc, fd, x_internal_handler); else remove_poll(proc, fd); } -int _zebra_window_open (zebra_processor_t *proc, - char *title, - unsigned width, - unsigned height) +int _zbar_window_open (zbar_processor_t *proc, + char *title, + unsigned width, + unsigned height) { proc->display = XOpenDisplay(NULL); if(!proc->display) - return(err_capture_str(proc, SEV_ERROR, ZEBRA_ERR_XDISPLAY, __func__, + return(err_capture_str(proc, SEV_ERROR, ZBAR_ERR_XDISPLAY, __func__, "unable to open X display", XDisplayName(NULL))); @@ -232,15 +232,15 @@ int _zebra_window_open (zebra_processor_t *proc, CopyFromParent, CWEventMask, &attr); if(!proc->xwin) { XCloseDisplay(proc->display); - return(err_capture(proc, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture(proc, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "creating window")); } XStoreName(proc->display, proc->xwin, title); XClassHint *class_hint = XAllocClassHint(); - class_hint->res_name = "zebra"; - class_hint->res_class = "zebra"; + class_hint->res_name = "zbar"; + class_hint->res_class = "zbar"; XSetClassHint(proc->display, proc->xwin, class_hint); XFree(class_hint); class_hint = NULL; @@ -252,7 +252,7 @@ int _zebra_window_open (zebra_processor_t *proc, return(0); } -int _zebra_window_close (zebra_processor_t *proc) +int _zbar_window_close (zbar_processor_t *proc) { if(proc->display) { if(proc->xwin) { @@ -266,20 +266,20 @@ int _zebra_window_close (zebra_processor_t *proc) return(0); } -int _zebra_window_resize (zebra_processor_t *proc, - unsigned width, - unsigned height) +int _zbar_window_resize (zbar_processor_t *proc, + unsigned width, + unsigned height) { if(proc->display) { XResizeWindow(proc->display, proc->xwin, width, height); - _zebra_window_clear(proc->window); + _zbar_window_clear(proc->window); XFlush(proc->display); } return(0); } -int _zebra_window_set_visible (zebra_processor_t *proc, - int visible) +int _zbar_window_set_visible (zbar_processor_t *proc, + int visible) { if(visible) XMapRaised(proc->display, proc->xwin); @@ -290,7 +290,7 @@ int _zebra_window_set_visible (zebra_processor_t *proc, return(0); } -int _zebra_window_invalidate (zebra_window_t *w) +int _zbar_window_invalidate (zbar_window_t *w) { if(!w->display) return(0); @@ -299,7 +299,7 @@ int _zebra_window_invalidate (zebra_window_t *w) return(0); } -int _zebra_window_clear (zebra_window_t *w) +int _zbar_window_clear (zbar_window_t *w) { if(!w->display) return(0); @@ -309,9 +309,9 @@ int _zebra_window_clear (zebra_window_t *w) return(0); } -int _zebra_window_draw_marker(zebra_window_t *w, - uint32_t rgb, - const point_t *p) +int _zbar_window_draw_marker(zbar_window_t *w, + uint32_t rgb, + const point_t *p) { XSetForeground(w->display, w->gc, w->colors[rgb]); diff --git a/zebra/window/ximage.c b/zbar/window/ximage.c similarity index 83% rename from zebra/window/ximage.c rename to zbar/window/ximage.c index 539eb202..67c15e1a 100644 --- a/zebra/window/ximage.c +++ b/zbar/window/ximage.c @@ -1,29 +1,29 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "window.h" -static int ximage_cleanup (zebra_window_t *w) +static int ximage_cleanup (zbar_window_t *w) { if(w->img.x) free(w->img.x); @@ -31,8 +31,8 @@ static int ximage_cleanup (zebra_window_t *w) return(0); } -static inline int ximage_init (zebra_window_t *w, - zebra_image_t *img) +static inline int ximage_init (zbar_window_t *w, + zbar_image_t *img) { if(w->img.x) { free(w->img.x); @@ -40,9 +40,9 @@ static inline int ximage_init (zebra_window_t *w, } if(w->src_format != img->format && w->format != img->format) { - _zebra_best_format(img->format, &w->format, w->formats); + _zbar_best_format(img->format, &w->format, w->formats); if(!w->format) { - err_capture_int(w, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + err_capture_int(w, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no conversion from %x to supported formats", img->format); return(-1); @@ -58,8 +58,8 @@ static inline int ximage_init (zebra_window_t *w, ximg->bitmap_bit_order = MSBFirst; ximg->bitmap_pad = 8; - const zebra_format_def_t *fmt = _zebra_format_lookup(w->format); - if(fmt->group == ZEBRA_FMT_RGB_PACKED) { + const zbar_format_def_t *fmt = _zbar_format_lookup(w->format); + if(fmt->group == ZBAR_FMT_RGB_PACKED) { ximg->depth = ximg->bits_per_pixel = fmt->p.rgb.bpp << 3; ximg->red_mask = (0xff >> RGB_SIZE(fmt->p.rgb.red)) @@ -77,7 +77,7 @@ static inline int ximage_init (zebra_window_t *w, } if(!XInitImage(ximg)) - return(err_capture_int(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture_int(w, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "unable to init XImage for format %x", w->format)); zprintf(3, "new XImage %.4s(%08" PRIx32 ") %dx%d" @@ -89,8 +89,8 @@ static inline int ximage_init (zebra_window_t *w, return(0); } -static int ximage_draw (zebra_window_t *w, - zebra_image_t *img) +static int ximage_draw (zbar_window_t *w, + zbar_image_t *img) { XImage *ximg = w->img.x; if(!ximg || @@ -104,8 +104,8 @@ static int ximage_draw (zebra_window_t *w, } if(img->format != w->format) { /* save *converted* image for redraw */ - w->image = zebra_image_convert(img, w->format); - zebra_image_destroy(img); + w->image = zbar_image_convert(img, w->format); + zbar_image_destroy(img); img = w->image; } @@ -175,10 +175,10 @@ static uint32_t ximage_formats[4][5] = { }, }; -static int ximage_probe_format (zebra_window_t *w, +static int ximage_probe_format (zbar_window_t *w, uint32_t format) { - const zebra_format_def_t *fmt = _zebra_format_lookup(format); + const zbar_format_def_t *fmt = _zbar_format_lookup(format); XVisualInfo visreq, *visuals = NULL; memset(&visreq, 0, sizeof(XVisualInfo)); @@ -209,13 +209,13 @@ static int ximage_probe_format (zebra_window_t *w, return(0); } -int _zebra_window_probe_ximage (zebra_window_t *w) +int _zbar_window_probe_ximage (zbar_window_t *w) { /* FIXME determine supported formats/depths */ int n; XPixmapFormatValues *formats = XListPixmapFormats(w->display, &n); if(!formats) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "unable to query XImage formats")); int i; @@ -234,7 +234,7 @@ int _zebra_window_probe_ximage (zebra_window_t *w) i, formats[i].depth, formats[i].bits_per_pixel, (char*)&ximage_formats[fmtidx][j], ximage_formats[fmtidx][j]); - _zebra_window_add_format(w, ximage_formats[fmtidx][j]); + _zbar_window_add_format(w, ximage_formats[fmtidx][j]); n++; } if(!n) @@ -244,7 +244,7 @@ int _zebra_window_probe_ximage (zebra_window_t *w) XFree(formats); if(!w->formats || !w->formats[0]) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no usable XImage formats found")); w->draw_image = ximage_draw; diff --git a/zebra/window/xv.c b/zbar/window/xv.c similarity index 87% rename from zebra/window/xv.c rename to zbar/window/xv.c index 78c93028..de5b227a 100644 --- a/zebra/window/xv.c +++ b/zbar/window/xv.c @@ -1,30 +1,30 @@ /*------------------------------------------------------------------------ - * Copyright 2007-2008 (c) Jeff Brown + * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include "window.h" #include /* strcmp */ -static int xv_cleanup (zebra_window_t *w) +static int xv_cleanup (zbar_window_t *w) { if(w->img.xv) { XFree(w->img.xv); @@ -44,8 +44,8 @@ static int xv_cleanup (zebra_window_t *w) return(0); } -static inline int xv_init (zebra_window_t *w, - zebra_image_t *img) +static inline int xv_init (zbar_window_t *w, + zbar_image_t *img) { if(w->img.xv) { XFree(w->img.xv); @@ -53,9 +53,9 @@ static inline int xv_init (zebra_window_t *w, } if(w->src_format != img->format && w->format != img->format) { - _zebra_best_format(img->format, &w->format, w->formats); + _zbar_best_format(img->format, &w->format, w->formats); if(!w->format) { - err_capture_int(w, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + err_capture_int(w, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "no conversion from %x to supported Xv formats", img->format); return(-1); @@ -92,7 +92,7 @@ static inline int xv_init (zebra_window_t *w, if(w->dst_width < img->width || xvimg->height < img->height) { XFree(xvimg); /* FIXME fallback to XImage... */ - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_UNSUPPORTED, __func__, "output image size mismatch (XvCreateImage)")); } w->img.xv = xvimg; @@ -100,8 +100,8 @@ static inline int xv_init (zebra_window_t *w, return(0); } -static int xv_draw (zebra_window_t *w, - zebra_image_t *img) +static int xv_draw (zbar_window_t *w, + zbar_image_t *img) { XvImage *xvimg = w->img.xv; /* FIXME preserve aspect ratio (config?) */ @@ -122,10 +122,10 @@ static int xv_draw (zebra_window_t *w, w->src_width = img->width; w->src_height = img->height; /* save *converted* image for redraw */ - w->image = zebra_image_convert_resize(img, w->format, + w->image = zbar_image_convert_resize(img, w->format, w->dst_width, xvimg->height); - zebra_image_destroy(img); + zbar_image_destroy(img); img = w->image; } @@ -139,11 +139,11 @@ static int xv_draw (zebra_window_t *w, return(0); } -static inline int xv_add_format (zebra_window_t *w, +static inline int xv_add_format (zbar_window_t *w, uint32_t fmt, XvPortID port) { - int i = _zebra_window_add_format(w, fmt); + int i = _zbar_window_add_format(w, fmt); if(!w->formats[i + 1]) w->xv_ports = realloc(w->xv_ports, (i + 1) * sizeof(uint32_t)); @@ -153,13 +153,13 @@ static inline int xv_add_format (zebra_window_t *w, return(i); } -static int xv_probe_port (zebra_window_t *w, +static int xv_probe_port (zbar_window_t *w, XvPortID port) { unsigned n; XvEncodingInfo *encodings = NULL; if(XvQueryEncodings(w->display, port, &n, &encodings)) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "querying XVideo encodings")); zprintf(1, "probing port %u with %d encodings:\n", (unsigned)port, n); @@ -181,7 +181,7 @@ static int xv_probe_port (zebra_window_t *w, encodings = NULL; if(!width || !height) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_INVALID, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "no XV_IMAGE encodings found")); zprintf(1, "max XV_IMAGE size %dx%d\n", width, height); if(w->max_width > width) @@ -192,7 +192,7 @@ static int xv_probe_port (zebra_window_t *w, XvImageFormatValues *formats = XvListImageFormats(w->display, port, (int*)&n); if(!formats) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "querying XVideo image formats")); zprintf(1, "%d image formats\n", n); @@ -210,7 +210,7 @@ static int xv_probe_port (zebra_window_t *w, return(0); } -int _zebra_window_probe_xv (zebra_window_t *w) +int _zbar_window_probe_xv (zbar_window_t *w) { unsigned xv_major, xv_minor, xv_req, xv_ev, xv_err; if(XvQueryExtension(w->display, &xv_major, &xv_minor, @@ -224,7 +224,7 @@ int _zebra_window_probe_xv (zebra_window_t *w) unsigned n; XvAdaptorInfo *adaptors = NULL; if(XvQueryAdaptors(w->display, w->xwin, &n, &adaptors)) - return(err_capture(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__, + return(err_capture(w, SEV_ERROR, ZBAR_ERR_XPROTO, __func__, "unable to query XVideo adaptors")); w->num_xv_adaptors = 0; diff --git a/zbarcam/Makefile.am.inc b/zbarcam/Makefile.am.inc new file mode 100644 index 00000000..ebc369de --- /dev/null +++ b/zbarcam/Makefile.am.inc @@ -0,0 +1,5 @@ +bin_PROGRAMS += zbarcam/zbarcam +zbarcam_zbarcam_SOURCES = zbarcam/zbarcam.c +zbarcam_zbarcam_LDADD = zbar/libzbar.la +# automake bug in "monolithic mode"? +CLEANFILES += zbarcam/.libs/zbarcam diff --git a/zebracam/zebracam.c b/zbarcam/zbarcam.c similarity index 75% rename from zebracam/zebracam.c rename to zbarcam/zbarcam.c index e4025d82..898d25db 100644 --- a/zebracam/zebracam.c +++ b/zbarcam/zbarcam.c @@ -1,24 +1,24 @@ /*------------------------------------------------------------------------ * Copyright 2007-2009 (c) Jeff Brown * - * This file is part of the Zebra Barcode Library. + * This file is part of the ZBar Bar Code Reader. * - * The Zebra Barcode Library is free software; you can redistribute it + * The ZBar Bar Code Reader is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * - * The Zebra Barcode Library is distributed in the hope that it will be + * The ZBar Bar Code Reader is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free + * along with the ZBar Bar Code Reader; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * - * http://sourceforge.net/projects/zebra + * http://sourceforge.net/projects/zbar *------------------------------------------------------------------------*/ #include @@ -27,12 +27,12 @@ #include #include -#include +#include #define BELL "\a" static const char *note_usage = - "usage: zebracam [options] [/dev/video?]\n" + "usage: zbarcam [options] [/dev/video?]\n" "\n" "scan and decode bar codes from a video stream\n" "\n" @@ -52,12 +52,12 @@ static const char *note_usage = "\n"; static const char *xml_head = - "" + "" "\n"; static const char *xml_foot = "\n"; -static zebra_processor_t *proc; +static zbar_processor_t *proc; static int quiet = 0; static int xml = 0; @@ -78,31 +78,31 @@ static inline int parse_config (const char *cfgstr, int i, int n, char *arg) return(1); } - if(zebra_processor_parse_config(proc, cfgstr)) { + if(zbar_processor_parse_config(proc, cfgstr)) { fprintf(stderr, "ERROR: invalid configuration setting: %s\n", cfgstr); return(1); } return(0); } -static void data_handler (zebra_image_t *img, const void *userdata) +static void data_handler (zbar_image_t *img, const void *userdata) { - const zebra_symbol_t *sym = zebra_image_first_symbol(img); + const zbar_symbol_t *sym = zbar_image_first_symbol(img); assert(sym); int n = 0; - for(; sym; sym = zebra_symbol_next(sym)) { - if(zebra_symbol_get_count(sym)) + for(; sym; sym = zbar_symbol_next(sym)) { + if(zbar_symbol_get_count(sym)) continue; if(!xml) { - zebra_symbol_type_t type = zebra_symbol_get_type(sym); + zbar_symbol_type_t type = zbar_symbol_get_type(sym); printf("%s%s:%s\n", - zebra_get_symbol_name(type), zebra_get_addon_name(type), - zebra_symbol_get_data(sym)); + zbar_get_symbol_name(type), zbar_get_addon_name(type), + zbar_symbol_get_data(sym)); } else { if(!n) - printf("\n", zebra_image_get_sequence(img)); - printf("%s\n", zebra_symbol_xml(sym, &xml_buf, &xml_len)); + printf("\n", zbar_image_get_sequence(img)); + printf("%s\n", zbar_symbol_xml(sym, &xml_buf, &xml_len)); } n++; } @@ -117,15 +117,15 @@ static void data_handler (zebra_image_t *img, const void *userdata) int main (int argc, const char *argv[]) { - /* setup zebra library standalone processor, + /* setup zbar library standalone processor, * threads will be used if available */ - proc = zebra_processor_create(1); + proc = zbar_processor_create(1); if(!proc) { fprintf(stderr, "ERROR: unable to allocate memory?\n"); return(1); } - zebra_processor_set_data_handler(proc, data_handler, NULL); + zbar_processor_set_data_handler(proc, data_handler, NULL); const char *video_device = "/dev/video0"; int display = 1; @@ -146,7 +146,7 @@ int main (int argc, const char *argv[]) } switch(argv[i][j]) { case 'h': return(usage(0)); - case 'v': zebra_increase_verbosity(); break; + case 'v': zbar_increase_verbosity(); break; case 'q': quiet = 1; break; default: fprintf(stderr, "ERROR: unknown bundled config: -%c\n\n", @@ -179,9 +179,9 @@ int main (int argc, const char *argv[]) else if(!strcmp(argv[i], "--nodisplay")) display = 0; else if(!strcmp(argv[i], "--verbose")) - zebra_increase_verbosity(); + zbar_increase_verbosity(); else if(!strncmp(argv[i], "--verbose=", 10)) - zebra_set_verbosity(strtol(argv[i] + 10, NULL, 0)); + zbar_set_verbosity(strtol(argv[i] + 10, NULL, 0)); else if(!strncmp(argv[i], "--prescale=", 11)) { char *x = NULL; long int w = strtol(argv[i] + 11, &x, 10); @@ -192,15 +192,15 @@ int main (int argc, const char *argv[]) fprintf(stderr, "ERROR: invalid prescale: %s\n\n", argv[i]); return(usage(1)); } - zebra_processor_request_size(proc, w, h); + zbar_processor_request_size(proc, w, h); } else if(!strncmp(argv[i], "--v4l=", 6)) { long int v = strtol(argv[i] + 6, NULL, 0); - zebra_processor_request_interface(proc, v); + zbar_processor_request_interface(proc, v); } else if(!strncmp(argv[i], "--iomode=", 9)) { long int v = strtol(argv[i] + 9, NULL, 0); - zebra_processor_request_iomode(proc, v); + zbar_processor_request_iomode(proc, v); } else if(!strncmp(argv[i], "--infmt=", 8) && strlen(argv[i]) == 12) @@ -218,13 +218,13 @@ int main (int argc, const char *argv[]) } if(infmt || outfmt) - zebra_processor_force_format(proc, infmt, outfmt); + zbar_processor_force_format(proc, infmt, outfmt); /* open video device, open window */ - if(zebra_processor_init(proc, video_device, display) || + if(zbar_processor_init(proc, video_device, display) || /* show window */ - (display && zebra_processor_set_visible(proc, 1))) - return(zebra_processor_error_spew(proc, 0)); + (display && zbar_processor_set_visible(proc, 1))) + return(zbar_processor_error_spew(proc, 0)); if(xml) { printf(xml_head, video_device); @@ -232,23 +232,23 @@ int main (int argc, const char *argv[]) } /* start video */ - if(zebra_processor_set_active(proc, 1)) - return(zebra_processor_error_spew(proc, 0)); + if(zbar_processor_set_active(proc, 1)) + return(zbar_processor_error_spew(proc, 0)); /* let the callback handle data */ int rc; - while((rc = zebra_processor_user_wait(proc, -1)) >= 0) { + while((rc = zbar_processor_user_wait(proc, -1)) >= 0) { if(rc == 'q') break; } /* report any errors that aren't "window closed" */ if(rc && rc != 'q' && - zebra_processor_get_error_code(proc) != ZEBRA_ERR_CLOSED) - return(zebra_processor_error_spew(proc, 0)); + zbar_processor_get_error_code(proc) != ZBAR_ERR_CLOSED) + return(zbar_processor_error_spew(proc, 0)); /* free resources (leak check) */ - zebra_processor_destroy(proc); + zbar_processor_destroy(proc); if(xml) { printf(xml_foot); diff --git a/zbarimg/Makefile.am.inc b/zbarimg/Makefile.am.inc new file mode 100644 index 00000000..45041f93 --- /dev/null +++ b/zbarimg/Makefile.am.inc @@ -0,0 +1,6 @@ +bin_PROGRAMS += zbarimg/zbarimg +zbarimg_zbarimg_SOURCES = zbarimg/zbarimg.cpp +zbarimg_zbarimg_CPPFLAGS = $(MAGICK_CFLAGS) $(AM_CPPFLAGS) +zbarimg_zbarimg_LDADD = $(MAGICK_LIBS) zbar/libzbar.la +# automake bug in "monolithic mode"? +CLEANFILES += zbarimg/.libs/zbarimg diff --git a/zebraimg/zebraimg.cpp b/zbarimg/zbarimg.cpp similarity index 93% rename from zebraimg/zebraimg.cpp rename to zbarimg/zbarimg.cpp index 34099b19..7724022e 100644 --- a/zebraimg/zebraimg.cpp +++ b/zbarimg/zbarimg.cpp @@ -1,24 +1,24 @@ //------------------------------------------------------------------------ -// Copyright 2007-2008 (c) Jeff Brown +// Copyright 2007-2009 (c) Jeff Brown // -// This file is part of the Zebra Barcode Library. +// This file is part of the ZBar Bar Code Reader. // -// The Zebra Barcode Library is free software; you can redistribute it +// The ZBar Bar Code Reader is free software; you can redistribute it // and/or modify it under the terms of the GNU Lesser Public License as // published by the Free Software Foundation; either version 2.1 of // the License, or (at your option) any later version. // -// The Zebra Barcode Library is distributed in the hope that it will be +// The ZBar Bar Code Reader is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser Public License for more details. // // You should have received a copy of the GNU Lesser Public License -// along with the Zebra Barcode Library; if not, write to the Free +// along with the ZBar Bar Code Reader; if not, write to the Free // Software Foundation, Inc., 51 Franklin St, Fifth Floor, // Boston, MA 02110-1301 USA // -// http://sourceforge.net/projects/zebra +// http://sourceforge.net/projects/zbar //------------------------------------------------------------------------ #include @@ -47,13 +47,13 @@ #include #include -#include +#include using namespace std; -using namespace zebra; +using namespace zbar; static const char *note_usage = - "usage: zebraimg [options] ...\n" + "usage: zbarimg [options] ...\n" "\n" "scan and decode bar codes from one or more image files\n" "\n" @@ -83,7 +83,7 @@ static const char *warning_not_found = " - is there sufficient contrast/illumination?\n"; static const char *xml_head = - ""; + ""; static const char *xml_foot = ""; @@ -200,7 +200,7 @@ int main (int argc, const char *argv[]) switch(arg[j]) { case 'h': return(usage(0)); case 'q': quiet = true; break; - case 'v': zebra_increase_verbosity(); break; + case 'v': zbar_increase_verbosity(); break; case 'd': display = true; break; case 'D': break; default: @@ -220,12 +220,12 @@ int main (int argc, const char *argv[]) argv[i] = NULL; } else if(arg == "--verbose") - zebra_increase_verbosity(); + zbar_increase_verbosity(); else if(arg.substr(0, 10) == "--verbose=") { istringstream scan(arg.substr(10)); int level; scan >> level; - zebra_set_verbosity(level); + zbar_set_verbosity(level); } else if(arg == "--display") display = true; diff --git a/zebra/Makefile.am.inc b/zebra/Makefile.am.inc deleted file mode 100644 index 005e8255..00000000 --- a/zebra/Makefile.am.inc +++ /dev/null @@ -1,62 +0,0 @@ -lib_LTLIBRARIES += zebra/libzebra.la -zebra_libzebra_la_CPPFLAGS = -I$(srcdir)/zebra $(AM_CPPFLAGS) -zebra_libzebra_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION) \ - -export-symbols-regex "^(zebra|_zebra.*_error)_.*" $(AM_LDFLAGS) -zebra_libzebra_la_LIBADD = - -zebra_libzebra_la_SOURCES = zebra/debug.h zebra/config.c \ - zebra/error.h zebra/error.c zebra/symbol.h zebra/symbol.c \ - zebra/image.h zebra/image.c zebra/convert.c zebra/logo.c \ - zebra/window.h zebra/window.c zebra/video.h zebra/video.c \ - zebra/img_scanner.c zebra/scanner.c \ - zebra/decoder.h zebra/decoder.c - -if HAVE_POLL -zebra_libzebra_la_SOURCES += zebra/processor.h zebra/processor.c -endif - -if ENABLE_EAN -zebra_libzebra_la_SOURCES += zebra/decoder/ean.h zebra/decoder/ean.c -endif -if ENABLE_CODE128 -zebra_libzebra_la_SOURCES += zebra/decoder/code128.h zebra/decoder/code128.c -endif -if ENABLE_CODE39 -zebra_libzebra_la_SOURCES += zebra/decoder/code39.h zebra/decoder/code39.c -endif -if ENABLE_I25 -zebra_libzebra_la_SOURCES += zebra/decoder/i25.h zebra/decoder/i25.c -endif -if ENABLE_PDF417 -zebra_libzebra_la_SOURCES += zebra/decoder/pdf417.h zebra/decoder/pdf417.c \ - zebra/decoder/pdf417_hash.h -endif - -if HAVE_V4L1 -zebra_libzebra_la_SOURCES += zebra/video/v4l1.c -if HAVE_V4L2 -zebra_libzebra_la_SOURCES += zebra/video/v4l2.c -endif -else -zebra_libzebra_la_SOURCES += zebra/video/null.c -endif - -if HAVE_JPEG -zebra_libzebra_la_SOURCES += zebra/jpeg.c -endif - -if HAVE_X -zebra_libzebra_la_SOURCES += zebra/window/x.c zebra/window/ximage.c -zebra_libzebra_la_CPPFLAGS += $(X_CFLAGS) -zebra_libzebra_la_LDFLAGS += $(X_LIBS) -zebra_libzebra_la_LIBADD += $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS) -if HAVE_XV -zebra_libzebra_la_SOURCES += zebra/window/xv.c -zebra_libzebra_la_LIBADD += $(XV_LIBS) -endif -else -zebra_libzebra_la_SOURCES += zebra/window/null.c -endif - -zebra_libzebra_la_LDFLAGS += $(AM_LDFLAGS) -zebra_libzebra_la_LIBADD += $(AM_LIBADD) diff --git a/zebra/logo.c b/zebra/logo.c deleted file mode 100644 index 3ae5b278..00000000 --- a/zebra/logo.c +++ /dev/null @@ -1,386 +0,0 @@ -/*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown - * - * This file is part of the Zebra Barcode Library. - * - * The Zebra Barcode Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * The Zebra Barcode Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * http://sourceforge.net/projects/zebra - *------------------------------------------------------------------------*/ - -#include -#include "image.h" -#include "error.h" - -#define LOGO_WIDTH 432 -#define LOGO_HEIGHT 304 -#define LOGO_RLE_SIZE 0x62c - -static const uint8_t logo_rle[LOGO_RLE_SIZE] = { - 0x87,0x66, 0x04, 0x01, 0x60, 0x03, /*col 0*/ - 0x8f,0x0e, 0x02, 0x80,0x02, 0x02, /*col 1*/ - 0x8f,0x0a, 0x04, 0x80,0x06, 0x02, /*col 2*/ - 0x8f,0x07, 0x80,0x0a, /*col 3*/ - 0xaf,0xbf, 0x01, 0x80,0x15, /*col 8*/ - 0x87,0xf8, 0x04, 0x80,0x17, /*col 9*/ - 0x87,0xf7, 0x80,0x19, 0x01, /*col 10*/ - 0x87,0xf4, 0x80,0x1c, /*col 11*/ - 0xaf,0xa8, 0x06, 0x01, 0x80,0x27, /*col 16*/ - 0x87,0xe3, 0x06, 0x03, 0x80,0x2b, /*col 17*/ - 0x87,0xd3, 0x06, 0x04, 0x03, 0x42, 0x01, 0x80,0x2f, 0x01, /*col 18*/ - 0x87,0xcc, 0x03, 0x01, 0x80,0x41, 0x04, /*col 19*/ - 0x87,0xc9, 0x03, 0x80,0x45, /*col 20*/ - 0x87,0xc7, 0x06, 0x80,0x48, /*col 21*/ - 0x87,0xc6, 0x01, 0x80,0x48, 0x05, /*col 22*/ - 0x87,0xc4, 0x05, 0x80,0x4a, /*col 23*/ - 0xaf,0x64, 0x01, 0x80,0x67, /*col 28*/ - 0x87,0xa7, 0x80,0x68, /*col 29*/ - 0x87,0xa7, 0x80,0x68, /*col 30*/ - 0x87,0xa7, 0x80,0x68, /*col 31*/ - 0x87,0xa7, 0x80,0x68, /*col 32*/ - 0x87,0xa6, 0x06, 0x80,0x68, /*col 33*/ - 0x87,0xa6, 0x02, 0x80,0x68, /*col 34*/ - 0x87,0xa6, 0x80,0x68, 0x01, /*col 35*/ - 0x87,0xa6, 0x80,0x68, 0x01, /*col 36*/ - 0x87,0xa5, 0x05, 0x80,0x68, 0x02, /*col 37*/ - 0x87,0xa5, 0x03, 0x80,0x68, 0x01, /*col 38*/ - 0x87,0xa5, 0x02, 0x80,0x69, /*col 39*/ - 0xc7,0x02,0x20, 0x03, 0x80,0x67, 0x03, /*col 48*/ - 0x87,0xa7, 0x80,0x68, /*col 49*/ - 0x87,0xa8, 0x80,0x67, /*col 50*/ - 0x87,0xa9, 0x80,0x66, 0x06, /*col 51*/ - 0xc7,0x06,0xe8, 0x03, 0x80,0x5c, /*col 64*/ - 0x87,0xb3, 0x03, 0x80,0x5b, /*col 65*/ - 0x87,0xb4, 0x03, 0x80,0x5a, /*col 66*/ - 0x87,0xb5, 0x03, 0x80,0x59, 0x06, /*col 67*/ - 0xc7,0x0b,0xbb, 0x80,0x5b, 0x01, /*col 84*/ - 0x87,0xb4, 0x03, 0x80,0x5c, /*col 85*/ - 0x87,0xb4, 0x80,0x5d, /*col 86*/ - 0x87,0xb3, 0x80,0x5e, /*col 87*/ - 0xaf,0x73, 0x80,0x62, /*col 92*/ - 0x87,0xae, 0x04, 0x80,0x62, /*col 93*/ - 0x87,0xae, 0x80,0x62, 0x01, /*col 94*/ - 0x87,0xad, 0x80,0x63, 0x04, /*col 95*/ - 0xaf,0x6d, 0x01, 0x80,0x66, /*col 100*/ - 0x87,0xa9, 0x06, 0x80,0x67, /*col 101*/ - 0x87,0xa9, 0x80,0x67, 0x01, /*col 102*/ - 0x87,0xa8, 0x80,0x68, 0x01, /*col 103*/ - 0x87,0xa7, 0x04, 0x80,0x68, 0x02, /*col 104*/ - 0x87,0xa7, 0x80,0x69, 0x02, /*col 105*/ - 0x87,0xa6, 0x80,0x6a, 0x01, /*col 106*/ - 0x87,0xa5, 0x02, 0x80,0x6a, 0x01, /*col 107*/ - 0xc7,0x06,0xe8, 0x80,0x7f, 0x03, /*col 120*/ - 0x87,0x90, 0x80,0x81, 0x06, /*col 121*/ - 0x87,0x8e, 0x80,0x82, 0x01, /*col 122*/ - 0x87,0x8d, 0x03, 0x80,0x83, /*col 123*/ - 0xc7,0x02,0x10, 0x80,0x89, 0x04, /*col 132*/ - 0x87,0x86, 0x06, 0x80,0x8b, 0x03, 0x87,0x67, 0x01, 0x08, 0x05, /*col 133*/ - 0x87,0x09, 0x80,0x8e, 0x03, 0x87,0x62, 0x01, 0x20, 0x02, /*col 134*/ - 0x87,0x08, 0x05, 0x80,0x90, 0x03, 0x87,0x5d, 0x06, 0x38, 0x06, /*col 135*/ - 0x87,0x08, 0x80,0x93, 0x02, 0x87,0x59, 0x04, 0x48, /*col 136*/ - 0x87,0x08, 0x05, 0x80,0x95, 0x02, 0x87,0x55, 0x02, 0x50, /*col 137*/ - 0x87,0x09, 0x80,0x98, 0x05, 0x87,0x51, 0x02, 0x58, /*col 138*/ - 0x87,0x09, 0x04, 0x80,0x99, 0x01, 0x87,0x4e, 0x01, 0x60, 0x03, /*col 139*/ - 0x87,0x09, 0x80,0x9c, 0x03, 0x87,0x4a, 0x78, /*col 140*/ - 0x87,0x09, 0x03, 0x80,0x9e, 0x04, 0x87,0x46, 0x01, 0x78, /*col 141*/ - 0x87,0x0a, 0x80,0xa1, 0x01, 0x05, 0x87,0x41, 0x02, 0x80,0x01, /*col 142*/ - 0x87,0x0a, 0x04, 0x80,0xa5, 0x02, 0x05, 0x87,0x3b, 0x01, 0x80,0x02, /*col 143*/ - 0xa7,0xcd, 0x03, 0x80,0xbe, 0x02, 0x05, 0x87,0x17, 0x03, 0x80,0x09, 0x01, /*col 148*/ - 0x87,0x0e, 0x01, 0x80,0xc3, 0x01, 0x03, 0x04, 0x86,0x0c, 0x04, 0x01, 0x80,0x0c, 0x05, /*col 149*/ - 0x87,0x0f, 0x03, 0x80,0xff, /*col 150*/ - 0x87,0x11, 0x05, 0x80,0xfe, /*col 151*/ - 0xa7,0xd8, 0x80,0xf1, 0x04, /*col 156*/ - 0x87,0x1f, 0x01, 0x80,0xea, 0x06, /*col 157*/ - 0x87,0x25, 0x05, 0x80,0xe7, /*col 158*/ - 0x87,0x2a, 0x80,0xe5, /*col 159*/ - 0x87,0x2c, 0x02, 0x80,0xe2, /*col 160*/ - 0x87,0x2f, 0x01, 0x80,0xdf, /*col 161*/ - 0x87,0x31, 0x05, 0x80,0xdd, 0x05, /*col 162*/ - 0x87,0x33, 0x80,0xac, 0x01, 0x02, 0x03, 0x0c, 0x05, 0x06, 0x3f, 0x06, 0x0d, 0x04, 0x03, 0x02, 0x01, 0x80,0x0a, /*col 163*/ - 0x87,0x35, 0x80,0x8d, 0x09, 0x02, 0x03, 0x04, 0x0e, 0x87,0x28, 0x06, 0x04, 0x01, 0x48, 0x01, /*col 164*/ - 0x87,0x36, 0x02, 0x80,0x77, 0x02, 0x03, 0x0d, 0x06, 0x87,0x45, 0x04, 0x01, 0x18, 0x06, /*col 165*/ - 0x87,0x38, 0x80,0x74, 0x05, /*col 166*/ - 0x87,0x9b, 0x80,0x76, 0x06, /*col 167*/ - 0x87,0x99, 0x80,0x78, 0x06, /*col 168*/ - 0x87,0x97, 0x80,0x7a, 0x05, /*col 169*/ - 0x87,0x95, 0x01, 0x80,0x7b, 0x02, /*col 170*/ - 0x87,0x93, 0x03, 0x80,0x7e, 0x06, /*col 171*/ - 0xaf,0x51, 0x80,0x8c, 0x02, 0x06, /*col 176*/ - 0x87,0x82, 0x80,0x90, 0x02, 0x05, /*col 177*/ - 0x87,0x7e, 0x80,0x94, 0x01, 0x04, /*col 178*/ - 0x87,0x7a, 0x01, 0x80,0x98, 0x01, 0x05, /*col 179*/ - 0xaf,0x36, 0x80,0xa8, 0x01, /*col 184*/ - 0x87,0x67, 0x80,0xaa, 0x03, /*col 185*/ - 0x87,0x65, 0x80,0xac, 0x06, 0x87,0x23, 0x02, 0x10, 0x01, /*col 186*/ - 0x87,0x2b, 0x80,0xae, 0x06, 0x87,0x1f, 0x01, 0x30, /*col 187*/ - 0xa7,0xeb, 0x04, 0x80,0xc2, 0x04, 0x7f, 0x06, 0x78, 0x01, /*col 192*/ - 0x87,0x2b, 0x80,0xc9, 0x09, 0x02, 0x03, 0x04, 0x0d, 0x04, 0x80,0x03, 0x01, /*col 193*/ - 0x87,0x2b, 0x80,0xe4, 0x01, /*col 194*/ - 0x87,0x2b, 0x06, 0x80,0xe3, 0x01, /*col 195*/ - 0xa7,0xed, 0x80,0x6e, 0x87,0x22, 0x06, 0x04, 0x02, 0x80,0x2f, 0x02, /*col 200*/ - 0x87,0x2d, 0x05, 0x80,0x6e, 0x87,0x29, 0x05, 0x03, 0x01, 0x80,0x27, 0x04, /*col 201*/ - 0x87,0x2e, 0x80,0x6e, 0x05, 0x87,0x2f, 0x06, 0x04, 0x02, 0x80,0x20, /*col 202*/ - 0x87,0x2f, 0x80,0x6f, 0x87,0x36, 0x06, 0x04, 0x02, 0x80,0x18, 0x01, /*col 203*/ - 0x87,0x2f, 0x05, 0x80,0x6e, 0x05, 0x87,0x3d, 0x05, 0x03, 0x01, 0x80,0x0f, 0x02, /*col 204*/ - 0x87,0x31, 0x80,0x6f, 0x87,0x44, 0x06, 0x03, 0x78, 0x01, 0x06, /*col 205*/ - 0x87,0x39, 0x80,0x6f, 0x87,0x48, 0x06, 0x01, 0x48, 0x04, /*col 206*/ - 0x87,0x3c, 0x01, 0x80,0x6e, 0x01, 0x87,0x4b, 0x04, 0x18, 0x04, /*col 207*/ - 0xaf,0x00, 0x01, 0x80,0x6f, 0x06, /*col 212*/ - 0x87,0x9f, 0x03, 0x80,0x6f, 0x03, /*col 213*/ - 0x87,0x9f, 0x03, 0x80,0x70, /*col 214*/ - 0x87,0x9f, 0x03, 0x80,0x70, /*col 215*/ - 0x87,0x9f, 0x03, 0x80,0x70, /*col 216*/ - 0x87,0x9f, 0x03, 0x80,0x70, 0x04, /*col 217*/ - 0x87,0x9e, 0x03, 0x80,0x71, /*col 218*/ - 0x87,0x9e, 0x03, 0x80,0x71, /*col 219*/ - 0xc7,0x02,0x1e, 0x03, 0x80,0x74, /*col 228*/ - 0x87,0x9b, 0x02, 0x80,0x74, /*col 229*/ - 0x87,0x9b, 0x01, 0x80,0x74, 0x06, /*col 230*/ - 0x87,0x9a, 0x80,0x75, 0x03, /*col 231*/ - 0x87,0x9a, 0x80,0x75, 0x01, /*col 232*/ - 0x87,0x9a, 0x80,0x76, /*col 233*/ - 0x87,0x9a, 0x80,0x76, /*col 234*/ - 0x87,0x9a, 0x80,0x76, /*col 235*/ - 0xc7,0x02,0x19, 0x80,0x77, /*col 244*/ - 0x87,0x98, 0x06, 0x80,0x77, /*col 245*/ - 0x87,0x98, 0x04, 0x80,0x77, /*col 246*/ - 0x87,0x98, 0x02, 0x80,0x77, 0x06, /*col 247*/ - 0x87,0x97, 0x80,0x78, 0x06, /*col 248*/ - 0x87,0x97, 0x80,0x78, 0x05, /*col 249*/ - 0x87,0x96, 0x04, 0x80,0x78, 0x02, /*col 250*/ - 0x87,0x96, 0x80,0x7a, /*col 251*/ - 0xaf,0x55, 0x80,0x7b, 0x06, /*col 256*/ - 0x87,0x93, 0x02, 0x80,0x7b, 0x06, /*col 257*/ - 0x87,0x93, 0x80,0x7c, /*col 258*/ - 0x87,0x94, 0x80,0x7c, /*col 259*/ - 0x87,0x93, 0x04, 0x80,0x7c, /*col 260*/ - 0x87,0x93, 0x80,0x7d, /*col 261*/ - 0x87,0x93, 0x80,0x7c, 0x02, /*col 262*/ - 0x87,0x92, 0x05, 0x80,0x7c, 0x05, /*col 263*/ - 0x87,0x92, 0x01, 0x80,0x7c, /*col 264*/ - 0x87,0x93, 0x80,0x7d, /*col 265*/ - 0x87,0x93, 0x80,0x7c, 0x04, /*col 266*/ - 0x87,0x92, 0x02, 0x80,0x7c, /*col 267*/ - 0xc7,0x02,0x11, 0x80,0x7c, /*col 276*/ - 0x87,0x94, 0x80,0x7b, 0x04, /*col 277*/ - 0x87,0x93, 0x06, 0x80,0x7b, /*col 278*/ - 0x87,0x94, 0x05, 0x80,0x7a, 0x02, /*col 279*/ - 0xaf,0x54, 0x80,0x79, /*col 284*/ - 0x87,0x97, 0x80,0x78, 0x01, /*col 285*/ - 0x87,0x97, 0x80,0x78, /*col 286*/ - 0x87,0x98, 0x80,0x77, 0x03, /*col 287*/ - 0x87,0x97, 0x04, 0x80,0x77, /*col 288*/ - 0x87,0x98, 0x80,0x77, 0x03, /*col 289*/ - 0x87,0x98, 0x80,0x77, /*col 290*/ - 0x87,0x99, 0x80,0x76, 0x04, /*col 291*/ - 0xc7,0x02,0x16, 0x05, 0x80,0x72, /*col 300*/ - 0x87,0x9d, 0x01, 0x80,0x71, /*col 301*/ - 0x87,0x9e, 0x80,0x71, /*col 302*/ - 0x87,0x9f, 0x80,0x6f, 0x01, /*col 303*/ - 0x87,0x9f, 0x06, 0x80,0x6e, 0x03, /*col 304*/ - 0x87,0xa0, 0x02, 0x80,0x6d, 0x03, /*col 305*/ - 0x87,0xa1, 0x80,0x6d, 0x03, /*col 306*/ - 0x87,0xa2, 0x80,0x6c, 0x02, /*col 307*/ - 0xaf,0x62, 0x05, 0x80,0x6f, 0x01, /*col 312*/ - 0x87,0x9f, 0x05, 0x80,0x71, 0x02, 0x87,0x54, 0x05, 0x0a, 0x04, /*col 313*/ - 0x87,0x35, 0x05, 0x80,0x73, 0x03, 0x87,0x4e, 0x06, 0x38, 0x06, /*col 314*/ - 0x87,0x33, 0x05, 0x80,0x75, 0x04, 0x87,0x4a, 0x04, 0x50, 0x02, /*col 315*/ - 0x87,0x32, 0x05, 0x80,0x77, 0x05, 0x87,0x46, 0x02, 0x68, 0x01, /*col 316*/ - 0x87,0x31, 0x05, 0x80,0x79, 0x06, 0x87,0x42, 0x06, 0x80,0x01, /*col 317*/ - 0x87,0x31, 0x05, 0x80,0x7b, 0x87,0x40, 0x80,0x03, 0x03, /*col 318*/ - 0x87,0x30, 0x05, 0x80,0x7c, 0x01, 0x87,0x3b, 0x04, 0x80,0x06, /*col 319*/ - 0xa7,0xf0, 0x05, 0x80,0x85, 0x87,0x24, 0x05, 0x01, 0x80,0x13, /*col 324*/ - 0x87,0x31, 0x05, 0x80,0x86, 0x01, 0x87,0x1e, 0x06, 0x02, 0x80,0x16, 0x01, /*col 325*/ - 0x87,0x31, 0x05, 0x80,0x88, 0x02, 0x87,0x17, 0x05, 0x03, 0x01, 0x80,0x1a, /*col 326*/ - 0x87,0x32, 0x05, 0x80,0x8b, 0x01, 0x82,0x0e, 0x01, 0x80,0x21, 0x06, /*col 327*/ - 0x87,0x32, 0x05, 0x80,0xdb, 0x05, /*col 328*/ - 0x87,0x33, 0x05, 0x80,0xda, 0x02, /*col 329*/ - 0x87,0x34, 0x05, 0x80,0xca, 0x01, 0x03, 0x14, 0x48, 0x03, /*col 330*/ - 0x87,0x35, 0x05, 0x80,0xc4, 0x01, 0x04, 0x47, 0x40, 0x01, /*col 331*/ - 0xc7,0x01,0xb7, 0x01, 0x80,0xd7, 0x05, /*col 340*/ - 0x87,0x38, 0x80,0xd6, 0x06, /*col 341*/ - 0x87,0x39, 0x01, 0x80,0xd4, /*col 342*/ - 0x87,0x3c, 0x80,0xd2, 0x06, /*col 343*/ - 0xc7,0x01,0xc2, 0x04, 0x80,0x65, 0x01, 0x7f, 0x02, 0x80,0x1d, 0x03, 0x06, /*col 352*/ - 0x87,0x6a, 0x80,0x64, 0x05, 0x87,0x02, 0x06, 0x80,0x16, 0x02, 0x04, /*col 353*/ - 0x87,0x71, 0x80,0x62, 0x06, 0x87,0x05, 0x01, 0x80,0x0f, 0x03, 0x06, /*col 354*/ - 0x87,0x76, 0x02, 0x80,0x5f, 0x04, 0x87,0x08, 0x04, 0x80,0x08, 0x01, 0x04, /*col 355*/ - 0xc7,0x06,0xc7, 0x01, 0x80,0x33, 0x01, /*col 368*/ - 0x87,0xdc, 0x02, 0x80,0x30, 0x03, /*col 369*/ - 0x87,0xdf, 0x04, 0x80,0x2d, 0x04, /*col 370*/ - 0x87,0xe2, 0x06, 0x80,0x2a, 0x03, /*col 371*/ - 0xa7,0xa7, 0x04, 0x01, 0x78, 0x09, 0x02, 0x03, 0x04, 0x06, /*col 375*/ - 0x87,0xde, 0x04, 0x01, 0x80,0x34, 0x01, 0x03, 0x06, /*col 376*/ - 0x87,0xdc, 0x05, 0x03, 0x01, 0x80,0x33, 0x01, 0x06, /*col 377*/ - 0x87,0xe0, 0x06, 0x05, 0x04, 0x02, 0x01, 0x80,0x01, 0x02, 0x01, 0x80,0x19, 0x03, /*col 378*/ - 0x87,0xf3, 0x0a, 0x01, 0x80,0x1b, 0x02, /*col 379*/ - 0x87,0xf8, 0x04, 0x80,0x18, 0x05, /*col 380*/ - 0x87,0xfa, 0x06, 0x02, 0x80,0x15, /*col 381*/ - 0x87,0xfd, 0x05, 0x01, 0x80,0x12, 0x06, /*col 382*/ - 0x87,0xfe, 0x06, 0x01, 0x80,0x10, 0x05, /*col 383*/ - 0x8f,0x00, 0x06, 0x01, 0x80,0x0e, 0x02, /*col 384*/ - 0x8f,0x02, 0x06, 0x01, 0x80,0x0d, /*col 385*/ - 0x8f,0x04, 0x04, 0x80,0x0c, /*col 386*/ - 0x8f,0x05, 0x06, 0x80,0x0b, /*col 387*/ - 0x8f,0x07, 0x01, 0x80,0x09, /*col 388*/ - 0x8f,0x08, 0x03, 0x80,0x07, 0x01, /*col 389*/ - 0x8f,0x09, 0x03, 0x80,0x06, 0x03, /*col 390*/ - 0x8f,0x0a, 0x80,0x06, 0x06, /*col 391*/ - 0x8f,0x0a, 0x04, 0x80,0x05, /*col 392*/ - 0x8f,0x0c, 0x80,0x05, /*col 393*/ - 0x8f,0x0c, 0x80,0x05, /*col 394*/ - 0x8f,0x0c, 0x03, 0x80,0x03, 0x04, /*col 395*/ - 0x8f,0x0c, 0x06, 0x80,0x03, /*col 396*/ - 0x8f,0x0e, 0x80,0x03, /*col 397*/ - 0x8f,0x0e, 0x01, 0x80,0x01, 0x05, /*col 398*/ - 0x8f,0x0e, 0x06, 0x80,0x01, /*col 399*/ - 0x8f,0x10, 0x01, 0x70, 0x01, /*col 400*/ - 0x8f,0x11, 0x70, 0x06, /*col 401*/ - 0x8f,0x11, 0x03, 0x68, /*col 402*/ - 0x8f,0x13, 0x60, 0x04, /*col 403*/ - 0x8f,0x13, 0x03, 0x58, /*col 404*/ - 0x8f,0x14, 0x06, 0x50, 0x02, /*col 405*/ - 0x8f,0x15, 0x50, /*col 406*/ - 0x8f,0x16, 0x48, 0x01, /*col 407*/ - 0x8f,0x15, 0x06, 0x48, /*col 408*/ - 0x8f,0x16, 0x01, 0x48, /*col 409*/ - 0x8f,0x16, 0x48, 0x05, /*col 410*/ - 0x8f,0x15, 0x02, 0x48, /*col 411*/ - 0x8f,0x16, 0x50, /*col 412*/ - 0x8f,0x15, 0x05, 0x48, 0x03, /*col 413*/ - 0x8f,0x15, 0x50, /*col 414*/ - 0x8f,0x15, 0x06, 0x50, /*col 415*/ - 0x8f,0x15, 0x01, 0x48, 0x03, /*col 416*/ - 0x8f,0x15, 0x50, /*col 417*/ - 0x8f,0x15, 0x02, 0x48, 0x01, /*col 418*/ - 0x8f,0x15, 0x50, /*col 419*/ - 0x8f,0x15, 0x05, 0x48, 0x03, /*col 420*/ - 0x8f,0x15, 0x48, /*col 421*/ - 0x8f,0x16, 0x06, 0x40, /*col 422*/ - 0x8f,0x17, 0x01, 0x38, /*col 423*/ - 0x8f,0x18, 0x38, /*col 424*/ - 0x8f,0x18, 0x03, 0x30, 0x05, /*col 425*/ - 0x8f,0x18, 0x10, 0x07, 0x18, /*col 426*/ - 0x8f,0x18, 0x05, 0x08, 0x0f, 0x05, 0x08, 0x05, /*col 427*/ - 0x8f,0x18, 0x08, 0x1f, 0x03, 0x00, /*col 428*/ - 0x8f,0x19, 0x00, /*col 429*/ - 0x8f,0x1f, 0x01, /*col 430*/ - 0x8f,0x99, -}; - -int _zebra_draw_logo (zebra_image_t *img) -{ - unsigned w = zebra_image_get_width(img); - unsigned h = zebra_image_get_height(img); - if(w < 128 || h < 90) { - w = 128; - h = 90; - zebra_image_set_size(img, w, h); - } - - zebra_image_set_format(img, fourcc('Y','8','0','0')); - zprintf(5, "fitting (%d x %d) into (%d x %d)\n", - LOGO_WIDTH, LOGO_HEIGHT, w, h); - - unsigned sw = 1, sh = 1; - int sf; - for(sf = 3; sf >= -2; sf--) { - sw = (LOGO_WIDTH << 3) >> (3 - sf); - sh = (LOGO_HEIGHT << 3) >> (3 - sf); - /* FIXME add minimum border */ - zprintf(6, " trying << %d => %d x %d\n", sf, sw, sh); - if(sw <= w && sh <= h) - break; - } - - int datalen = w * h; - uint8_t *data = malloc(datalen); - assert(data); - zebra_image_set_data(img, data, datalen, zebra_image_free_data); - memset(data, 0xff, datalen); - - unsigned xpad = (w - sw + 1) / 2; - unsigned ypad = (h - sh + 1) / 2; - - const uint8_t *rle = logo_rle; - uint8_t *p = NULL; /* (((pix & 0x7) * 255 + 6) / 7) */ - unsigned n = 0, pix = 0x7; - unsigned x, y, i, j, mask = (sf >= 0) ? (1 << sf) - 1 : (1 << -sf) - 1; - - for(x = 0; x < LOGO_WIDTH; x++) { - p = data + (ypad * w) + xpad + ((x << 3) >> (3 - sf)); - zprintf(64, " [%03d]", x); - for(y = 0; y < LOGO_HEIGHT; y++) { - if(!n) { - pix = *(rle++); - if((pix & 0xc0) == 0xc0) { - n = *(rle++) << 8; - n += *(rle++) + 0x810; - } - else if(pix & 0x80) - n = (((pix & 0x38) << 5) | *(rle++)) + 0x10; - else - n = ((pix >> 3) & 0x0f) + 1; - pix &= 0x7; - if(sf >= 0) - pix = ((pix * 255) + 6) / 7; - if(_zebra_verbosity >= 64) - fprintf(stderr, " (%03d) pix=%02x n=%04x", y, pix, n); - - } - - if(!sf) { - *p = pix; - p += w; - } - else if(sf > 0) - for(i = 0; i <= mask; i++) { - for(j = 0; j <= mask; j++) - *(p++) = pix; - p += w - mask - 1; - } - else { - if(!((x | y) & mask)) - *p = pix; - else - *p += pix; - if((y & mask) == mask) - p += w; - } - n--; - } - if(_zebra_verbosity >= 64) - fprintf(stderr, "\n"); - } - - if(sf < 0) { - /* make 2nd pass to finish merging subsamples */ - p = data + (ypad * w) + xpad; - unsigned div = (mask + 1) * (mask + 1) * 7; - for(y = 0; y < sh; y++) { - for(x = 0; x < sw; x++, p++) - *p = (((unsigned)*p) * 255 + div - 1) / div; - p += w - sw; - } - } - - zprintf(6, " rle=%p + size=%x = %p\n", logo_rle, LOGO_RLE_SIZE, rle); - if(rle != logo_rle + LOGO_RLE_SIZE) - fprintf(stderr, "WARNING: zebra internal: logo rle not at end?\n"); - zprintf(6, " data=%p + len=%x = %p\n", data, datalen, p); - - return(0); -} diff --git a/zebra/window/null.c b/zebra/window/null.c deleted file mode 100644 index f620682b..00000000 --- a/zebra/window/null.c +++ /dev/null @@ -1,87 +0,0 @@ -/*------------------------------------------------------------------------ - * Copyright 2008 (c) Jeff Brown - * - * This file is part of the Zebra Barcode Library. - * - * The Zebra Barcode Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * The Zebra Barcode Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with the Zebra Barcode Library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - * - * http://sourceforge.net/projects/zebra - *------------------------------------------------------------------------*/ - -#include "window.h" - -static inline int null_error (void *m, - const char *func) -{ - return(err_capture(m, SEV_ERROR, ZEBRA_ERR_UNSUPPORTED, func, - "not compiled with output window support")); -} - -int _zebra_window_attach (zebra_window_t *w, - void *display, - unsigned long win) -{ - return(null_error(w, __func__)); -} - -int _zebra_window_handle_events (zebra_processor_t *proc, - int block) -{ - return(null_error(proc, __func__)); -} - -int _zebra_window_open (zebra_processor_t *proc, - char *title, - unsigned width, - unsigned height) -{ - return(null_error(proc, __func__)); -} - -int _zebra_window_close (zebra_processor_t *proc) -{ - return(null_error(proc, __func__)); -} - -int _zebra_window_resize (zebra_processor_t *proc, - unsigned width, - unsigned height) -{ - return(null_error(proc, __func__)); -} - -int _zebra_window_set_visible (zebra_processor_t *proc, - int visible) -{ - return(null_error(proc, __func__)); -} - -int _zebra_window_clear (zebra_window_t *w) -{ - return(null_error(w, __func__)); -} - -int _zebra_window_invalidate (zebra_window_t *w) -{ - return(0); -} - -int _zebra_window_draw_marker(zebra_window_t *w, - uint32_t rgb, - const point_t *p) -{ - return(null_error(w, __func__)); -} diff --git a/zebracam/Makefile.am.inc b/zebracam/Makefile.am.inc deleted file mode 100644 index 694057b5..00000000 --- a/zebracam/Makefile.am.inc +++ /dev/null @@ -1,5 +0,0 @@ -bin_PROGRAMS += zebracam/zebracam -zebracam_zebracam_SOURCES = zebracam/zebracam.c -zebracam_zebracam_LDADD = zebra/libzebra.la -# automake bug in "monolithic mode"? -CLEANFILES += zebracam/.libs/zebracam diff --git a/zebraimg/Makefile.am.inc b/zebraimg/Makefile.am.inc deleted file mode 100644 index 7d48ef8c..00000000 --- a/zebraimg/Makefile.am.inc +++ /dev/null @@ -1,6 +0,0 @@ -bin_PROGRAMS += zebraimg/zebraimg -zebraimg_zebraimg_SOURCES = zebraimg/zebraimg.cpp -zebraimg_zebraimg_CPPFLAGS = $(MAGICK_CFLAGS) $(AM_CPPFLAGS) -zebraimg_zebraimg_LDADD = $(MAGICK_LIBS) zebra/libzebra.la -# automake bug in "monolithic mode"? -CLEANFILES += zebraimg/.libs/zebraimg