ZBar bar code reader . http://zbar.sourceforge.net/ ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependents:   GR-PEACH_Camera_in_barcode levkov_ov7670

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ean.h Source File

ean.h

00001 /*------------------------------------------------------------------------
00002  *  Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
00003  *
00004  *  This file is part of the ZBar Bar Code Reader.
00005  *
00006  *  The ZBar Bar Code Reader is free software; you can redistribute it
00007  *  and/or modify it under the terms of the GNU Lesser Public License as
00008  *  published by the Free Software Foundation; either version 2.1 of
00009  *  the License, or (at your option) any later version.
00010  *
00011  *  The ZBar Bar Code Reader is distributed in the hope that it will be
00012  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00013  *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU Lesser Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser Public License
00017  *  along with the ZBar Bar Code Reader; if not, write to the Free
00018  *  Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00019  *  Boston, MA  02110-1301  USA
00020  *
00021  *  http://sourceforge.net/projects/zbar
00022  *------------------------------------------------------------------------*/
00023 #ifndef _EAN_H_
00024 #define _EAN_H_
00025 
00026 /* state of each parallel decode attempt */
00027 typedef struct ean_pass_s {
00028     signed char state;          /* module position of w[idx] in symbol */
00029 #define STATE_ADDON 0x40        /*   scanning add-on */
00030 #define STATE_IDX   0x1f        /*   element offset into symbol */
00031     unsigned char raw[7];       /* decode in process */
00032 } ean_pass_t;
00033 
00034 /* EAN/UPC specific decode state */
00035 typedef struct ean_decoder_s {
00036     ean_pass_t pass[4];         /* state of each parallel decode attempt */
00037     zbar_symbol_type_t left;   /* current holding buffer contents */
00038     zbar_symbol_type_t right;
00039     zbar_symbol_type_t addon;
00040     unsigned s4;                /* character width */
00041     signed char buf[18];        /* holding buffer */
00042 
00043     signed char enable;
00044     unsigned ean13_config;
00045     unsigned ean8_config;
00046     unsigned upca_config;
00047     unsigned upce_config;
00048     unsigned isbn10_config;
00049     unsigned isbn13_config;
00050 } ean_decoder_t;
00051 
00052 /* reset EAN/UPC pass specific state */
00053 static inline void ean_new_scan (ean_decoder_t *ean)
00054 {
00055     ean->pass[0].state = ean->pass[1].state = -1;
00056     ean->pass[2].state = ean->pass[3].state = -1;
00057     ean->s4 = 0;
00058 }
00059 
00060 /* reset all EAN/UPC state */
00061 static inline void ean_reset (ean_decoder_t *ean)
00062 {
00063     ean_new_scan(ean);
00064     ean->left = ean->right = ean->addon = ZBAR_NONE;
00065 }
00066 
00067 static inline unsigned ean_get_config (ean_decoder_t *ean,
00068                                        zbar_symbol_type_t sym)
00069 {
00070     switch(sym & ZBAR_SYMBOL) {
00071     case ZBAR_EAN13:  return(ean->ean13_config);
00072     case ZBAR_EAN8:   return(ean->ean8_config);
00073     case ZBAR_UPCA:   return(ean->upca_config);
00074     case ZBAR_UPCE:   return(ean->upce_config);
00075     case ZBAR_ISBN10: return(ean->isbn10_config);
00076     case ZBAR_ISBN13: return(ean->isbn13_config);
00077     default:           return(0);
00078     }
00079 }
00080 
00081 /* decode EAN/UPC symbols */
00082 zbar_symbol_type_t _zbar_decode_ean(zbar_decoder_t *dcode);
00083 
00084 #endif
00085