A streamlined version (for embedded use) of Jeff Brown's ZBar library. Visit <http://zbar.sourceforge.net> for more details.

Dependents:   BarcodeReader_F103

Committer:
hudakz
Date:
Fri Jan 10 22:06:18 2020 +0000
Revision:
1:4f5c042a2d34
Parent:
0:e33621169e44
Streamlined barcode reader library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:e33621169e44 1 /*------------------------------------------------------------------------
hudakz 0:e33621169e44 2 * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
hudakz 0:e33621169e44 3 *
hudakz 0:e33621169e44 4 * This file is part of the ZBar Bar Code Reader.
hudakz 0:e33621169e44 5 *
hudakz 0:e33621169e44 6 * The ZBar Bar Code Reader is free software; you can redistribute it
hudakz 0:e33621169e44 7 * and/or modify it under the terms of the GNU Lesser Public License as
hudakz 0:e33621169e44 8 * published by the Free Software Foundation; either version 2.1 of
hudakz 0:e33621169e44 9 * the License, or (at your option) any later version.
hudakz 0:e33621169e44 10 *
hudakz 0:e33621169e44 11 * The ZBar Bar Code Reader is distributed in the hope that it will be
hudakz 0:e33621169e44 12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
hudakz 0:e33621169e44 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
hudakz 0:e33621169e44 14 * GNU Lesser Public License for more details.
hudakz 0:e33621169e44 15 *
hudakz 0:e33621169e44 16 * You should have received a copy of the GNU Lesser Public License
hudakz 0:e33621169e44 17 * along with the ZBar Bar Code Reader; if not, write to the Free
hudakz 0:e33621169e44 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
hudakz 0:e33621169e44 19 * Boston, MA 02110-1301 USA
hudakz 0:e33621169e44 20 *
hudakz 0:e33621169e44 21 * http://sourceforge.net/projects/zbar
hudakz 0:e33621169e44 22 *------------------------------------------------------------------------*/
hudakz 0:e33621169e44 23
hudakz 0:e33621169e44 24 /* varargs variations on compile time debug spew */
hudakz 0:e33621169e44 25
hudakz 0:e33621169e44 26 #ifndef DEBUG_LEVEL
hudakz 0:e33621169e44 27
hudakz 0:e33621169e44 28 # ifdef __GNUC__
hudakz 0:e33621169e44 29 /* older versions of gcc (< 2.95) require a named varargs parameter */
hudakz 0:e33621169e44 30 # define dprintf(args...)
hudakz 0:e33621169e44 31 # else
hudakz 0:e33621169e44 32 /* unfortunately named vararg parameter is a gcc-specific extension */
hudakz 0:e33621169e44 33 # define dprintf(...)
hudakz 0:e33621169e44 34 # endif
hudakz 0:e33621169e44 35
hudakz 0:e33621169e44 36 #else
hudakz 0:e33621169e44 37
hudakz 0:e33621169e44 38 # include <stdio.h>
hudakz 0:e33621169e44 39
hudakz 0:e33621169e44 40 # ifdef __GNUC__
hudakz 0:e33621169e44 41 # define dprintf(level, args...) \
hudakz 0:e33621169e44 42 if((level) <= DEBUG_LEVEL) \
hudakz 0:e33621169e44 43 fprintf(stderr, args)
hudakz 0:e33621169e44 44 # else
hudakz 0:e33621169e44 45 # define dprintf(level, ...) \
hudakz 0:e33621169e44 46 if((level) <= DEBUG_LEVEL) \
hudakz 0:e33621169e44 47 fprintf(stderr, __VA_ARGS__)
hudakz 0:e33621169e44 48 # endif
hudakz 0:e33621169e44 49
hudakz 0:e33621169e44 50 #endif /* DEBUG_LEVEL */
hudakz 0:e33621169e44 51
hudakz 0:e33621169e44 52 /* spew warnings for non-fatal assertions.
hudakz 0:e33621169e44 53 * returns specified error code if assertion fails.
hudakz 0:e33621169e44 54 * NB check/return is still performed for NDEBUG
hudakz 0:e33621169e44 55 * only the message is inhibited
hudakz 0:e33621169e44 56 * FIXME don't we need varargs hacks here?
hudakz 0:e33621169e44 57 */
hudakz 0:e33621169e44 58 #ifndef NDEBUG
hudakz 0:e33621169e44 59
hudakz 0:e33621169e44 60 # include <stdio.h>
hudakz 0:e33621169e44 61
hudakz 0:e33621169e44 62 #if __STDC_VERSION__ < 199901L && !defined(__func__)
hudakz 0:e33621169e44 63 # if __GNUC__ >= 2
hudakz 0:e33621169e44 64 # define __func__ __FUNCTION__
hudakz 0:e33621169e44 65 # else
hudakz 0:e33621169e44 66 # define __func__ "<unknown>"
hudakz 0:e33621169e44 67 # endif
hudakz 0:e33621169e44 68 #endif
hudakz 0:e33621169e44 69
hudakz 0:e33621169e44 70 # define zassert(condition, retval, format, ...) do { \
hudakz 0:e33621169e44 71 if(!(condition)) { \
hudakz 0:e33621169e44 72 fprintf(stderr, "WARNING: %s:%d: %s:" \
hudakz 0:e33621169e44 73 " Assertion \"%s\" failed.\n\t" format, \
hudakz 0:e33621169e44 74 __FILE__, __LINE__, __func__, #condition , \
hudakz 0:e33621169e44 75 ##__VA_ARGS__); \
hudakz 0:e33621169e44 76 return(retval); \
hudakz 0:e33621169e44 77 } \
hudakz 0:e33621169e44 78 } while(0)
hudakz 0:e33621169e44 79
hudakz 0:e33621169e44 80 #else
hudakz 0:e33621169e44 81
hudakz 0:e33621169e44 82 # define zassert(condition, retval, format, ...) do { \
hudakz 0:e33621169e44 83 if(!(condition)) \
hudakz 0:e33621169e44 84 return(retval); \
hudakz 0:e33621169e44 85 } while(0)
hudakz 0:e33621169e44 86
hudakz 0:e33621169e44 87 #endif