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

LICENSE

The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>

You can redistribute this library 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

ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.

Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.

The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:19:39 2016 +0000
Revision:
1:500d42699c34
Parent:
0:56c5742b9e2b
Add copying.txt and license.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:56c5742b9e2b 1 /*------------------------------------------------------------------------
RyoheiHagimoto 0:56c5742b9e2b 2 * Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
RyoheiHagimoto 0:56c5742b9e2b 3 *
RyoheiHagimoto 0:56c5742b9e2b 4 * This file is part of the ZBar Bar Code Reader.
RyoheiHagimoto 0:56c5742b9e2b 5 *
RyoheiHagimoto 0:56c5742b9e2b 6 * The ZBar Bar Code Reader is free software; you can redistribute it
RyoheiHagimoto 0:56c5742b9e2b 7 * and/or modify it under the terms of the GNU Lesser Public License as
RyoheiHagimoto 0:56c5742b9e2b 8 * published by the Free Software Foundation; either version 2.1 of
RyoheiHagimoto 0:56c5742b9e2b 9 * the License, or (at your option) any later version.
RyoheiHagimoto 0:56c5742b9e2b 10 *
RyoheiHagimoto 0:56c5742b9e2b 11 * The ZBar Bar Code Reader is distributed in the hope that it will be
RyoheiHagimoto 0:56c5742b9e2b 12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
RyoheiHagimoto 0:56c5742b9e2b 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
RyoheiHagimoto 0:56c5742b9e2b 14 * GNU Lesser Public License for more details.
RyoheiHagimoto 0:56c5742b9e2b 15 *
RyoheiHagimoto 0:56c5742b9e2b 16 * You should have received a copy of the GNU Lesser Public License
RyoheiHagimoto 0:56c5742b9e2b 17 * along with the ZBar Bar Code Reader; if not, write to the Free
RyoheiHagimoto 0:56c5742b9e2b 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
RyoheiHagimoto 0:56c5742b9e2b 19 * Boston, MA 02110-1301 USA
RyoheiHagimoto 0:56c5742b9e2b 20 *
RyoheiHagimoto 0:56c5742b9e2b 21 * http://sourceforge.net/projects/zbar
RyoheiHagimoto 0:56c5742b9e2b 22 *------------------------------------------------------------------------*/
RyoheiHagimoto 0:56c5742b9e2b 23
RyoheiHagimoto 0:56c5742b9e2b 24 #include <config.h>
RyoheiHagimoto 0:56c5742b9e2b 25 #include <stdlib.h> /* strtol */
RyoheiHagimoto 0:56c5742b9e2b 26 #include <string.h> /* strchr, strncmp, strlen */
RyoheiHagimoto 0:56c5742b9e2b 27 #include <errno.h>
RyoheiHagimoto 0:56c5742b9e2b 28 #include <assert.h>
RyoheiHagimoto 0:56c5742b9e2b 29
RyoheiHagimoto 0:56c5742b9e2b 30 #include <zbar.h>
RyoheiHagimoto 0:56c5742b9e2b 31
RyoheiHagimoto 0:56c5742b9e2b 32 int zbar_parse_config (const char *cfgstr,
RyoheiHagimoto 0:56c5742b9e2b 33 zbar_symbol_type_t *sym,
RyoheiHagimoto 0:56c5742b9e2b 34 zbar_config_t *cfg,
RyoheiHagimoto 0:56c5742b9e2b 35 int *val)
RyoheiHagimoto 0:56c5742b9e2b 36 {
RyoheiHagimoto 0:56c5742b9e2b 37 if(!cfgstr)
RyoheiHagimoto 0:56c5742b9e2b 38 return(1);
RyoheiHagimoto 0:56c5742b9e2b 39
RyoheiHagimoto 0:56c5742b9e2b 40 const char *dot = strchr(cfgstr, '.');
RyoheiHagimoto 0:56c5742b9e2b 41 if(dot) {
RyoheiHagimoto 0:56c5742b9e2b 42 int len = dot - cfgstr;
RyoheiHagimoto 0:56c5742b9e2b 43 if(!len || (len == 1 && !strncmp(cfgstr, "*", len)))
RyoheiHagimoto 0:56c5742b9e2b 44 *sym = 0;
RyoheiHagimoto 0:56c5742b9e2b 45 else if(len < 2)
RyoheiHagimoto 0:56c5742b9e2b 46 return(1);
RyoheiHagimoto 0:56c5742b9e2b 47 else if(!strncmp(cfgstr, "qrcode", len))
RyoheiHagimoto 0:56c5742b9e2b 48 *sym = ZBAR_QRCODE;
RyoheiHagimoto 0:56c5742b9e2b 49 else if(len < 3)
RyoheiHagimoto 0:56c5742b9e2b 50 return(1);
RyoheiHagimoto 0:56c5742b9e2b 51 else if(!strncmp(cfgstr, "upca", len))
RyoheiHagimoto 0:56c5742b9e2b 52 *sym = ZBAR_UPCA;
RyoheiHagimoto 0:56c5742b9e2b 53 else if(!strncmp(cfgstr, "upce", len))
RyoheiHagimoto 0:56c5742b9e2b 54 *sym = ZBAR_UPCE;
RyoheiHagimoto 0:56c5742b9e2b 55 else if(!strncmp(cfgstr, "ean13", len))
RyoheiHagimoto 0:56c5742b9e2b 56 *sym = ZBAR_EAN13;
RyoheiHagimoto 0:56c5742b9e2b 57 else if(!strncmp(cfgstr, "ean8", len))
RyoheiHagimoto 0:56c5742b9e2b 58 *sym = ZBAR_EAN8;
RyoheiHagimoto 0:56c5742b9e2b 59 else if(!strncmp(cfgstr, "i25", len))
RyoheiHagimoto 0:56c5742b9e2b 60 *sym = ZBAR_I25;
RyoheiHagimoto 0:56c5742b9e2b 61 else if(len < 4)
RyoheiHagimoto 0:56c5742b9e2b 62 return(1);
RyoheiHagimoto 0:56c5742b9e2b 63 else if(!strncmp(cfgstr, "scanner", len))
RyoheiHagimoto 0:56c5742b9e2b 64 *sym = ZBAR_PARTIAL; /* FIXME lame */
RyoheiHagimoto 0:56c5742b9e2b 65 else if(!strncmp(cfgstr, "isbn13", len))
RyoheiHagimoto 0:56c5742b9e2b 66 *sym = ZBAR_ISBN13;
RyoheiHagimoto 0:56c5742b9e2b 67 else if(!strncmp(cfgstr, "isbn10", len))
RyoheiHagimoto 0:56c5742b9e2b 68 *sym = ZBAR_ISBN10;
RyoheiHagimoto 0:56c5742b9e2b 69 #if 0
RyoheiHagimoto 0:56c5742b9e2b 70 /* FIXME addons are configured per-main symbol type */
RyoheiHagimoto 0:56c5742b9e2b 71 else if(!strncmp(cfgstr, "addon2", len))
RyoheiHagimoto 0:56c5742b9e2b 72 *sym = ZBAR_ADDON2;
RyoheiHagimoto 0:56c5742b9e2b 73 else if(!strncmp(cfgstr, "addon5", len))
RyoheiHagimoto 0:56c5742b9e2b 74 *sym = ZBAR_ADDON5;
RyoheiHagimoto 0:56c5742b9e2b 75 #endif
RyoheiHagimoto 0:56c5742b9e2b 76 else if(len < 6)
RyoheiHagimoto 0:56c5742b9e2b 77 return(1);
RyoheiHagimoto 0:56c5742b9e2b 78 else if(!strncmp(cfgstr, "code39", len))
RyoheiHagimoto 0:56c5742b9e2b 79 *sym = ZBAR_CODE39;
RyoheiHagimoto 0:56c5742b9e2b 80 else if(!strncmp(cfgstr, "pdf417", len))
RyoheiHagimoto 0:56c5742b9e2b 81 *sym = ZBAR_PDF417;
RyoheiHagimoto 0:56c5742b9e2b 82 else if(len < 7)
RyoheiHagimoto 0:56c5742b9e2b 83 return(1);
RyoheiHagimoto 0:56c5742b9e2b 84 else if(!strncmp(cfgstr, "code128", len))
RyoheiHagimoto 0:56c5742b9e2b 85 *sym = ZBAR_CODE128;
RyoheiHagimoto 0:56c5742b9e2b 86 else
RyoheiHagimoto 0:56c5742b9e2b 87 return(1);
RyoheiHagimoto 0:56c5742b9e2b 88 cfgstr = dot + 1;
RyoheiHagimoto 0:56c5742b9e2b 89 }
RyoheiHagimoto 0:56c5742b9e2b 90 else
RyoheiHagimoto 0:56c5742b9e2b 91 *sym = 0;
RyoheiHagimoto 0:56c5742b9e2b 92
RyoheiHagimoto 0:56c5742b9e2b 93 int len = strlen(cfgstr);
RyoheiHagimoto 0:56c5742b9e2b 94 const char *eq = strchr(cfgstr, '=');
RyoheiHagimoto 0:56c5742b9e2b 95 if(eq)
RyoheiHagimoto 0:56c5742b9e2b 96 len = eq - cfgstr;
RyoheiHagimoto 0:56c5742b9e2b 97 else
RyoheiHagimoto 0:56c5742b9e2b 98 *val = 1; /* handle this here so we can override later */
RyoheiHagimoto 0:56c5742b9e2b 99 char negate = 0;
RyoheiHagimoto 0:56c5742b9e2b 100
RyoheiHagimoto 0:56c5742b9e2b 101 if(len > 3 && !strncmp(cfgstr, "no-", 3)) {
RyoheiHagimoto 0:56c5742b9e2b 102 negate = 1;
RyoheiHagimoto 0:56c5742b9e2b 103 cfgstr += 3;
RyoheiHagimoto 0:56c5742b9e2b 104 len -= 3;
RyoheiHagimoto 0:56c5742b9e2b 105 }
RyoheiHagimoto 0:56c5742b9e2b 106
RyoheiHagimoto 0:56c5742b9e2b 107 if(len < 1)
RyoheiHagimoto 0:56c5742b9e2b 108 return(1);
RyoheiHagimoto 0:56c5742b9e2b 109 else if(!strncmp(cfgstr, "y-density", len))
RyoheiHagimoto 0:56c5742b9e2b 110 *cfg = ZBAR_CFG_Y_DENSITY;
RyoheiHagimoto 0:56c5742b9e2b 111 else if(!strncmp(cfgstr, "x-density", len))
RyoheiHagimoto 0:56c5742b9e2b 112 *cfg = ZBAR_CFG_X_DENSITY;
RyoheiHagimoto 0:56c5742b9e2b 113 else if(len < 2)
RyoheiHagimoto 0:56c5742b9e2b 114 return(1);
RyoheiHagimoto 0:56c5742b9e2b 115 else if(!strncmp(cfgstr, "enable", len))
RyoheiHagimoto 0:56c5742b9e2b 116 *cfg = ZBAR_CFG_ENABLE;
RyoheiHagimoto 0:56c5742b9e2b 117 else if(len < 3)
RyoheiHagimoto 0:56c5742b9e2b 118 return(1);
RyoheiHagimoto 0:56c5742b9e2b 119 else if(!strncmp(cfgstr, "disable", len)) {
RyoheiHagimoto 0:56c5742b9e2b 120 *cfg = ZBAR_CFG_ENABLE;
RyoheiHagimoto 0:56c5742b9e2b 121 negate = !negate; /* no-disable ?!? */
RyoheiHagimoto 0:56c5742b9e2b 122 }
RyoheiHagimoto 0:56c5742b9e2b 123 else if(!strncmp(cfgstr, "min-length", len))
RyoheiHagimoto 0:56c5742b9e2b 124 *cfg = ZBAR_CFG_MIN_LEN;
RyoheiHagimoto 0:56c5742b9e2b 125 else if(!strncmp(cfgstr, "max-length", len))
RyoheiHagimoto 0:56c5742b9e2b 126 *cfg = ZBAR_CFG_MAX_LEN;
RyoheiHagimoto 0:56c5742b9e2b 127 else if(!strncmp(cfgstr, "ascii", len))
RyoheiHagimoto 0:56c5742b9e2b 128 *cfg = ZBAR_CFG_ASCII;
RyoheiHagimoto 0:56c5742b9e2b 129 else if(!strncmp(cfgstr, "add-check", len))
RyoheiHagimoto 0:56c5742b9e2b 130 *cfg = ZBAR_CFG_ADD_CHECK;
RyoheiHagimoto 0:56c5742b9e2b 131 else if(!strncmp(cfgstr, "emit-check", len))
RyoheiHagimoto 0:56c5742b9e2b 132 *cfg = ZBAR_CFG_EMIT_CHECK;
RyoheiHagimoto 0:56c5742b9e2b 133 else if(!strncmp(cfgstr, "position", len))
RyoheiHagimoto 0:56c5742b9e2b 134 *cfg = ZBAR_CFG_POSITION;
RyoheiHagimoto 0:56c5742b9e2b 135 else
RyoheiHagimoto 0:56c5742b9e2b 136 return(1);
RyoheiHagimoto 0:56c5742b9e2b 137
RyoheiHagimoto 0:56c5742b9e2b 138 if(eq) {
RyoheiHagimoto 0:56c5742b9e2b 139 errno = 0;
RyoheiHagimoto 0:56c5742b9e2b 140 *val = strtol(eq + 1, NULL, 0);
RyoheiHagimoto 0:56c5742b9e2b 141 if(errno)
RyoheiHagimoto 0:56c5742b9e2b 142 return(1);
RyoheiHagimoto 0:56c5742b9e2b 143 }
RyoheiHagimoto 0:56c5742b9e2b 144 if(negate)
RyoheiHagimoto 0:56c5742b9e2b 145 *val = !*val;
RyoheiHagimoto 0:56c5742b9e2b 146
RyoheiHagimoto 0:56c5742b9e2b 147 return(0);
RyoheiHagimoto 0:56c5742b9e2b 148 }
RyoheiHagimoto 0:56c5742b9e2b 149