Skip to content

Commit

Permalink
* improve portability of some format specifiers
Browse files Browse the repository at this point in the history
  * fix new generated file distribution errors
  * switch Qt headers to old-style names (possible Qt3 support?)
  • Loading branch information
[email protected] committed Jul 21, 2008
1 parent 1fbde9a commit 086fa0b
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 25 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
current:
* fix new generated file distribution errors
* switch Qt headers to old-style names (possible Qt3 support?)
* add independent API versioning for GTK and Qt widget libraries
* reimplement widget internals to support image scanning and
improve locking efficiency
* add image scanning to widgets. including builtin conversions from
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ dnl then set age to 0.
AC_SUBST([LIB_VERSION], [4:0:1])
AC_SUBST([RELDATE], [2008-05-31])

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], [0:0:0])

AC_DEFINE_UNQUOTED([ZEBRA_VERSION_MAJOR],
[[`echo "$PACKAGE_VERSION" | sed -e 's/\..*$//'`]],
[Program major version (before the '.') as a number])
Expand Down
2 changes: 1 addition & 1 deletion gtk/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lib_LTLIBRARIES += gtk/libzebragtk.la
gtk_libzebragtk_la_CPPFLAGS = -Igtk $(GTK_CFLAGS) $(AM_CPPFLAGS)
gtk_libzebragtk_la_LDFLAGS = -version-info $(LIB_VERSION) $(AM_LDFLAGS)
gtk_libzebragtk_la_LDFLAGS = -version-info $(ZGTK_LIB_VERSION) $(AM_LDFLAGS)
gtk_libzebragtk_la_LIBADD = $(GTK_LIBS) zebra/libzebra.la $(AM_LIBADD)

gtk_libzebragtk_la_SOURCES = gtk/zebragtk.c gtk/zebragtkprivate.h \
Expand Down
6 changes: 5 additions & 1 deletion gtk/zebragtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "zebragtkprivate.h"
#include "zebramarshal.h"

#ifndef G_PARAM_STATIC_STRINGS
# define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
#endif

#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480

Expand Down Expand Up @@ -303,7 +307,7 @@ static void *zebra_gtk_processing_thread (void *arg)
else {
gchar *dbg = g_strdup_value_contents(msg);
g_warning("unknown message type (%x) passed to thread: %s\n",
type, dbg);
(unsigned)type, dbg);
g_free(dbg);
}
g_value_unset(msg);
Expand Down
3 changes: 2 additions & 1 deletion include/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ 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 include/zebra/zebragtk.h include/zebra/QZebra.h
include/zebra/Processor.h include/zebra/zebragtk.h \
include/zebra/QZebra.h include/zebra/QZebraImage.h
2 changes: 1 addition & 1 deletion include/zebra/QZebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/// @file
/// Barcode Reader Qt4 Widget

#include <QWidget>
#include <qwidget.h>

namespace zebra {

Expand Down
2 changes: 1 addition & 1 deletion include/zebra/QZebraImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/// @file
/// QImage to Image type conversion wrapper

#include <QImage>
#include <qimage.h>
#include <zebra.h>

namespace zebra {
Expand Down
2 changes: 1 addition & 1 deletion qt/Makefile.am.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lib_LTLIBRARIES += qt/libzebraqt.la
qt_libzebraqt_la_CPPFLAGS = -Iqt $(QT_CFLAGS) $(AM_CPPFLAGS)
#qt_libzebraqt_la_LDFLAGS = -version-info $(LIB_VERSION) $(AM_LDFLAGS)
qt_libzebraqt_la_LDFLAGS = -version-info $(ZQT_LIB_VERSION) $(AM_LDFLAGS)
qt_libzebraqt_la_LIBADD = $(QT_LIBS) zebra/libzebra.la $(AM_LIBADD)

qt_libzebraqt_la_SOURCES = qt/QZebra.cpp qt/moc_QZebra.cpp \
Expand Down
4 changes: 2 additions & 2 deletions qt/QZebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// http://sourceforge.net/projects/zebra
//------------------------------------------------------------------------

#include <QResizeEvent>
#include <QX11Info>
#include <qevent.h>
#include <qx11info_x11.h>
#include <zebra/QZebra.h>
#include "QZebraThread.h"

Expand Down
6 changes: 3 additions & 3 deletions test/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ endif

if HAVE_QT
check_PROGRAMS += test/test_qt
test_test_qt_SOURCES = test/test_qt.cpp test/scan_video.c
test_test_qt_SOURCES = test/test_qt.cpp test/moc_test_qt.h test/scan_video.c
test_test_qt_CPPFLAGS = -Itest $(QT_CFLAGS) $(AM_CPPFLAGS)
test_test_qt_LDADD = $(QT_LIBS) qt/libzebraqt.la $(AM_LDADD)
BUILT_SOURCES += test/moc_test_qt.cpp
BUILT_SOURCES += test/moc_test_qt.h

test/moc_%.cpp: test/%.cpp
test/moc_%.h: test/%.cpp
$(MOC) -i $(test_test_qt_CPPFLAGS) $< -o $@
endif

Expand Down
2 changes: 1 addition & 1 deletion test/test_images.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ int test_image_bars (zebra_image_t *img)
unsigned long datalen = planelen * fmt->bpp / 8;
uint8_t *data = malloc(datalen);
zebra_image_set_data(img, data, datalen, test_cleanup_handler);
fprintf(stderr, "create %.4s(%08x) image data %lx bytes @%p\n",
fprintf(stderr, "create %.4s(%08" PRIx32 ") image data %lx bytes @%p\n",
(char*)&fmt->format, fmt->format, datalen, data);

uint8_t *p = data;
Expand Down
2 changes: 1 addition & 1 deletion test/test_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Q_SLOTS:
zebra::QZebra *zebra;
};

#include "moc_test_qt.cpp"
#include "moc_test_qt.h"

int main (int argc, char *argv[])
{
Expand Down
12 changes: 7 additions & 5 deletions zebra/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ int _zebra_best_format (uint32_t src,
if(!srcfmt)
return(-1);

zprintf(8, "from %.4s(%08x) to", (char*)&src, src);
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);
Expand All @@ -963,7 +963,8 @@ int _zebra_best_format (uint32_t src,
else
cost = conversions[srcfmt->group][dstfmt->group].cost;
if(_zebra_verbosity >= 8)
fprintf(stderr, " %.4s(%08x)=%d", (char*)dsts, *dsts, cost);
fprintf(stderr, " %.4s(%08" PRIx32 ")=%d",
(char*)dsts, *dsts, cost);
if(min_cost > cost) {
min_cost = cost;
if(dst)
Expand Down Expand Up @@ -1013,10 +1014,11 @@ int zebra_negotiate_format (zebra_video_t *vdo,
uint32_t win_fmt = 0;
int cost = _zebra_best_format(*fmt, &win_fmt, dsts);
if(cost < 0) {
zprintf(4, "%.4s(%08x) -> ? (unsupported)\n", (char*)fmt, *fmt);
zprintf(4, "%.4s(%08" PRIx32 ") -> ? (unsupported)\n",
(char*)fmt, *fmt);
continue;
}
zprintf(4, "%.4s(%08x) -> %.4s(%08x) (%d)\n",
zprintf(4, "%.4s(%08" PRIx32 ") -> %.4s(%08" PRIx32 ") (%d)\n",
(char*)fmt, *fmt, (char*)&win_fmt, win_fmt, cost);
if(min_cost > cost) {
min_cost = cost;
Expand All @@ -1034,7 +1036,7 @@ int zebra_negotiate_format (zebra_video_t *vdo,
if(!vdo)
return(0);

zprintf(2, "setting best format %.4s(%08x) (%d)\n",
zprintf(2, "setting best format %.4s(%08" PRIx32 ") (%d)\n",
(char*)&min_fmt, min_fmt, min_cost);
return(zebra_video_init(vdo, min_fmt));
}
5 changes: 3 additions & 2 deletions zebra/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ int zebra_image_write (const zebra_image_t *img,
n = snprintf(filename, len, "%s.%.4s.zimg",
filebase, (char*)&img->format);
else
n = snprintf(filename, len, "%s.%08x.zimg", filebase, img->format);
n = snprintf(filename, len, "%s.%08" PRIx32 ".zimg",
filebase, img->format);
assert(n < len);
filename[len] = '\0';

zprintf(1, "dumping %.4s(%08x) image to %s\n",
zprintf(1, "dumping %.4s(%08" PRIx32 ") image to %s\n",
(char*)&img->format, img->format, filename);

FILE *f = fopen(filename, "w");
Expand Down
2 changes: 1 addition & 1 deletion zebra/processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static inline int process_image (zebra_processor_t *proc,
{
if(img) {
uint32_t format = zebra_image_get_format(img);
zprintf(16, "processing: %.4s(%08x) %dx%d @%p\n",
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));
Expand Down
7 changes: 4 additions & 3 deletions zebra/window/ximage.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ static inline int ximage_init (zebra_window_t *w,

if(!XInitImage(ximg))
return(err_capture_int(w, SEV_ERROR, ZEBRA_ERR_XPROTO, __func__,
"unable to init XImage for format %08x",
"unable to init XImage for format %x",
w->format));
zprintf(3, "new XImage %.4s(%08x) %dx%d from %.4s(%08x) %dx%d\n",
zprintf(3, "new XImage %.4s(%08" PRIx32 ") %dx%d"
" from %.4s(%08" PRIx32 ") %dx%d\n",
(char*)&w->format, w->format, ximg->width, ximg->height,
(char*)&img->format, img->format, img->width, img->height);
zprintf(4, " masks: %08lx %08lx %08lx\n",
Expand Down Expand Up @@ -213,7 +214,7 @@ int _zebra_window_probe_ximage (zebra_window_t *w)
int j, n = 0;
for(j = 0; ximage_formats[fmtidx][j]; j++)
if(!ximage_probe_format(w, ximage_formats[fmtidx][j])) {
zprintf(2, " [%d] depth=%d bpp=%d: %.4s(%08x)\n",
zprintf(2, " [%d] depth=%d bpp=%d: %.4s(%08" PRIx32 ")\n",
i, formats[i].depth, formats[i].bits_per_pixel,
(char*)&ximage_formats[fmtidx][j],
ximage_formats[fmtidx][j]);
Expand Down
3 changes: 2 additions & 1 deletion zebra/window/xv.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ static inline int xv_init (zebra_window_t *w,
w->src_height = img->height;
XvImage *xvimg = XvCreateImage(w->display, w->img_port, w->format,
NULL, img->width, img->height);
zprintf(3, "new XvImage %.4s(%08x) %dx%d(%d) from %.4s(%08x) %dx%d\n",
zprintf(3, "new XvImage %.4s(%08" PRIx32 ") %dx%d(%d)"
" from %.4s(%08" PRIx32 ") %dx%d\n",
(char*)&w->format, w->format,
xvimg->width, xvimg->height, xvimg->pitches[0],
(char*)&img->format, img->format, img->width, img->height);
Expand Down

0 comments on commit 086fa0b

Please sign in to comment.