Code format and audit, part 3

Update copyright info, remove unused code, etc.
This commit is contained in:
Robin Stuart 2016-02-20 11:29:19 +00:00
parent 8a88ffdd7b
commit 660d8148bd
13 changed files with 14979 additions and 14423 deletions

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -38,12 +38,7 @@
#define SSET "0123456789ABCDEF"
/* This file has expanded quite a bit since version 1.5 in order to accomodate
the formatting rules for EAN and UPC symbols as set out in EN 797:1995 - the
down side of this support is that the code is now vertually unreadable! */
int ps_plot(struct zint_symbol *symbol)
{
int ps_plot(struct zint_symbol *symbol) {
int i, block_width, latch, r, this_row;
float textpos, large_bar_height, preset_height, row_height, row_posn;
FILE *feps;
@ -773,4 +768,3 @@ int ps_plot(struct zint_symbol *symbol)
return error_number;
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
Redistribution and use in source and binary forms, with or without

View File

@ -68,8 +68,7 @@ static int *logt = NULL, *alog = NULL, *rspoly = NULL;
// polynomial. e.g. for ECC200 (8-bit symbols) the polynomial is
// a**8 + a**5 + a**3 + a**2 + 1, which translates to 0x12d.
void rs_init_gf(int poly)
{
void rs_init_gf(int poly) {
int m, b, p, v;
// Find the top bit, and hence the symbol size
@ -101,8 +100,7 @@ void rs_init_gf(int poly)
// (x + 2**i)*(x + 2**(i+1))*... [nsym terms]
// For ECC200, index is 1.
void rs_init_code(int nsym, int index)
{
void rs_init_code(int nsym, int index) {
int i, k;
rspoly = (int *) malloc(sizeof (int) * (nsym + 1));
@ -122,8 +120,7 @@ void rs_init_code(int nsym, int index)
}
}
void rs_encode(int len, unsigned char *data, unsigned char *res)
{
void rs_encode(int len, unsigned char *data, unsigned char *res) {
int i, k, m;
for (i = 0; i < rlen; i++)
res[i] = 0;
@ -142,8 +139,8 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
}
}
void rs_encode_long(int len, unsigned int *data, unsigned int *res)
{ /* The same as above but for larger bitlengths - Aztec code compatible */
/* The same as above but for larger bitlengths - Aztec code compatible */
void rs_encode_long(int len, unsigned int *data, unsigned int *res) {
int i, k, m;
for (i = 0; i < rlen; i++)
res[i] = 0;
@ -162,8 +159,8 @@ void rs_encode_long(int len, unsigned int *data, unsigned int *res)
}
}
void rs_free(void)
{ /* Free memory */
/* Free memory */
void rs_free(void) {
free(logt);
free(alog);
free(rspoly);

View File

@ -34,8 +34,7 @@
#define __REEDSOL_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif /* __cplusplus */
extern void rs_init_gf(int poly);

View File

@ -8,7 +8,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -56,8 +56,7 @@ int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexag
int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string);
int render_plot(struct zint_symbol *symbol, float width, float height)
{
int render_plot(struct zint_symbol *symbol, float width, float height) {
struct zint_render *render;
struct zint_render_line *line, *last_line = NULL;
struct zint_render_string *last_string = NULL;
@ -671,15 +670,13 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
return 1;
}
/*
* Create a new line with its memory allocated ready for adding to the
* rendered structure.
*
* This is much quicker than writing out each line manually (in some cases!)
*/
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length)
{
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length) {
struct zint_render_line *line;
line = (struct zint_render_line*) malloc(sizeof (struct zint_render_line));
@ -696,8 +693,7 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width,
* Add the line to the current rendering and update the last line's
* next value.
*/
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line)
{
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) {
if (*last_line)
(*last_line)->next = line;
else
@ -707,8 +703,7 @@ int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *li
return 1;
}
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width)
{
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width) {
struct zint_render_ring *ring;
ring = (struct zint_render_ring *) malloc(sizeof (struct zint_render_ring));
@ -721,8 +716,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius,
return ring;
}
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring)
{
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) {
if (*last_ring)
(*last_ring)->next = ring;
else
@ -732,8 +726,7 @@ int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ri
return 1;
}
struct zint_render_hexagon *render_plot_create_hexagon(float x, float y)
{
struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) {
struct zint_render_hexagon *hexagon;
hexagon = (struct zint_render_hexagon*) malloc(sizeof (struct zint_render_hexagon));
@ -744,8 +737,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y)
return hexagon;
}
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon)
{
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) {
if (*last_hexagon)
(*last_hexagon)->next = hexagon;
else
@ -761,8 +753,7 @@ int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexag
*/
int render_plot_add_string(struct zint_symbol *symbol,
unsigned char *text, float x, float y, float fsize, float width,
struct zint_render_string **last_string)
{
struct zint_render_string **last_string) {
struct zint_render_string *string;
string = (struct zint_render_string*) malloc(sizeof (struct zint_render_string));

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -85,8 +85,7 @@ int combins(int n, int r) {
if (n - r > r) {
minDenom = r;
maxDenom = n - r;
}
else {
} else {
minDenom = n - r;
maxDenom = r;
}
@ -119,41 +118,33 @@ int combins(int n, int r) {
* Return:
* static int widths[] = element widths
**********************************************************************/
void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
{
void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow) {
int bar;
int elmWidth;
int mxwElement;
int subVal, lessVal;
int narrowMask = 0;
for (bar = 0; bar < elements-1; bar++)
{
for (bar = 0; bar < elements - 1; bar++) {
for (elmWidth = 1, narrowMask |= (1 << bar);
;
elmWidth++, narrowMask &= ~(1<<bar))
{
elmWidth++, narrowMask &= ~(1 << bar)) {
/* get all combinations */
subVal = combins(n - elmWidth - 1, elements - bar - 2);
/* less combinations with no single-module element */
if ((!noNarrow) && (!narrowMask) &&
(n-elmWidth-(elements-bar-1) >= elements-bar-1))
{
(n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) {
subVal -= combins(n - elmWidth - (elements - bar), elements - bar - 2);
}
/* less combinations with elements > maxVal */
if (elements-bar-1 > 1)
{
if (elements - bar - 1 > 1) {
lessVal = 0;
for (mxwElement = n - elmWidth - (elements - bar - 2);
mxwElement > maxWidth;
mxwElement--)
{
mxwElement--) {
lessVal += combins(n - elmWidth - mxwElement - 1, elements - bar - 3);
}
subVal -= lessVal * (elements - 1 - bar);
}
else if (n-elmWidth > maxWidth)
{
} else if (n - elmWidth > maxWidth) {
subVal--;
}
val -= subVal;
@ -167,8 +158,8 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
return;
}
int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
{ /* GS1 DataBar-14 */
/* GS1 DataBar-14 */
int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int error_number = 0, i, j, mask;
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
int data_character[4], data_group[4], v_odd[4], v_even[4];
@ -306,24 +297,60 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
/* Calculate odd and even subset values */
if((data_character[0] >= 0) && (data_character[0] <= 160)) { data_group[0] = 0; }
if((data_character[0] >= 161) && (data_character[0] <= 960)) { data_group[0] = 1; }
if((data_character[0] >= 961) && (data_character[0] <= 2014)) { data_group[0] = 2; }
if((data_character[0] >= 2015) && (data_character[0] <= 2714)) { data_group[0] = 3; }
if((data_character[0] >= 2715) && (data_character[0] <= 2840)) { data_group[0] = 4; }
if((data_character[1] >= 0) && (data_character[1] <= 335)) { data_group[1] = 5; }
if((data_character[1] >= 336) && (data_character[1] <= 1035)) { data_group[1] = 6; }
if((data_character[1] >= 1036) && (data_character[1] <= 1515)) { data_group[1] = 7; }
if((data_character[1] >= 1516) && (data_character[1] <= 1596)) { data_group[1] = 8; }
if((data_character[3] >= 0) && (data_character[3] <= 335)) { data_group[3] = 5; }
if((data_character[3] >= 336) && (data_character[3] <= 1035)) { data_group[3] = 6; }
if((data_character[3] >= 1036) && (data_character[3] <= 1515)) { data_group[3] = 7; }
if((data_character[3] >= 1516) && (data_character[3] <= 1596)) { data_group[3] = 8; }
if((data_character[2] >= 0) && (data_character[2] <= 160)) { data_group[2] = 0; }
if((data_character[2] >= 161) && (data_character[2] <= 960)) { data_group[2] = 1; }
if((data_character[2] >= 961) && (data_character[2] <= 2014)) { data_group[2] = 2; }
if((data_character[2] >= 2015) && (data_character[2] <= 2714)) { data_group[2] = 3; }
if((data_character[2] >= 2715) && (data_character[2] <= 2840)) { data_group[2] = 4; }
if ((data_character[0] >= 0) && (data_character[0] <= 160)) {
data_group[0] = 0;
}
if ((data_character[0] >= 161) && (data_character[0] <= 960)) {
data_group[0] = 1;
}
if ((data_character[0] >= 961) && (data_character[0] <= 2014)) {
data_group[0] = 2;
}
if ((data_character[0] >= 2015) && (data_character[0] <= 2714)) {
data_group[0] = 3;
}
if ((data_character[0] >= 2715) && (data_character[0] <= 2840)) {
data_group[0] = 4;
}
if ((data_character[1] >= 0) && (data_character[1] <= 335)) {
data_group[1] = 5;
}
if ((data_character[1] >= 336) && (data_character[1] <= 1035)) {
data_group[1] = 6;
}
if ((data_character[1] >= 1036) && (data_character[1] <= 1515)) {
data_group[1] = 7;
}
if ((data_character[1] >= 1516) && (data_character[1] <= 1596)) {
data_group[1] = 8;
}
if ((data_character[3] >= 0) && (data_character[3] <= 335)) {
data_group[3] = 5;
}
if ((data_character[3] >= 336) && (data_character[3] <= 1035)) {
data_group[3] = 6;
}
if ((data_character[3] >= 1036) && (data_character[3] <= 1515)) {
data_group[3] = 7;
}
if ((data_character[3] >= 1516) && (data_character[3] <= 1596)) {
data_group[3] = 8;
}
if ((data_character[2] >= 0) && (data_character[2] <= 160)) {
data_group[2] = 0;
}
if ((data_character[2] >= 161) && (data_character[2] <= 960)) {
data_group[2] = 1;
}
if ((data_character[2] >= 961) && (data_character[2] <= 2014)) {
data_group[2] = 2;
}
if ((data_character[2] >= 2015) && (data_character[2] <= 2714)) {
data_group[2] = 3;
}
if ((data_character[2] >= 2715) && (data_character[2] <= 2840)) {
data_group[2] = 4;
}
v_odd[0] = (data_character[0] - g_sum_table[data_group[0]]) / t_table[data_group[0]];
v_even[0] = (data_character[0] - g_sum_table[data_group[0]]) % t_table[data_group[0]];
@ -374,8 +401,12 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
checksum %= 79;
/* Calculate the two check characters */
if(checksum >= 8) { checksum++; }
if(checksum >= 72) { checksum++; }
if (checksum >= 8) {
checksum++;
}
if (checksum >= 72) {
checksum++;
}
c_left = checksum / 9;
c_right = checksum % 9;
@ -401,7 +432,9 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '0';
for (i = 0; i < 46; i++) {
for (j = 0; j < total_widths[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
}
writer++;
}
if (latch == '1') {
@ -410,12 +443,15 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '1';
}
}
if(symbol->width < writer) { symbol->width = writer; }
if (symbol->width < writer) {
symbol->width = writer;
}
if (symbol->symbology == BARCODE_RSS14_CC) {
/* separator pattern for composite symbol */
for (i = 4; i < 92; i++) {
if (!(module_is_set(symbol, separator_row + 1, i))) {
set_module(symbol, separator_row, i); }
set_module(symbol, separator_row, i);
}
}
latch = '1';
for (i = 16; i < 32; i++) {
@ -472,7 +508,9 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
check_digit = 10 - (count % 10);
if (check_digit == 10) { check_digit = 0; }
if (check_digit == 10) {
check_digit = 0;
}
hrt[13] = itoc(check_digit);
uconcat(symbol->text, (unsigned char*) hrt);
@ -559,7 +597,9 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
}
symbol->rows = symbol->rows + 1;
if(symbol->width < 50) { symbol->width = 50; }
if (symbol->width < 50) {
symbol->width = 50;
}
}
if ((symbol->symbology == BARCODE_RSS14STACK_OMNI) || (symbol->symbology == BARCODE_RSS14_OMNI_CC)) {
@ -568,7 +608,11 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '0';
for (i = 0; i < 23; i++) {
for (j = 0; j < total_widths[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
} else {
unset_module(symbol, symbol->rows, writer);
}
writer++;
}
latch = (latch == '1' ? '0' : '1');
@ -583,7 +627,11 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '1';
for (i = 23; i < 46; i++) {
for (j = 0; j < total_widths[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer + 2); } else { unset_module(symbol, symbol->rows, writer + 2); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer + 2);
} else {
unset_module(symbol, symbol->rows, writer + 2);
}
writer++;
}
if (latch == '1') {
@ -641,7 +689,9 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
}
symbol->row_height[symbol->rows - 1] = 1;
if(symbol->width < 50) { symbol->width = 50; }
if (symbol->width < 50) {
symbol->width = 50;
}
if (symbol->symbology == BARCODE_RSS14_OMNI_CC) {
/* separator pattern for composite symbol */
for (i = 4; i < 46; i++) {
@ -672,8 +722,8 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
return error_number;
}
int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
{ /* GS1 DataBar Limited */
/* GS1 DataBar Limited */
int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int error_number = 0, i, mask;
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
int left_group, right_group, left_odd, left_even, right_odd, right_even;
@ -748,41 +798,65 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
left_group = 0;
strcpy(temp, "183063");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 1; }
if (islarger(left_reg, accum)) {
left_group = 1;
}
strcpy(temp, "820063");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 2; }
if (islarger(left_reg, accum)) {
left_group = 2;
}
strcpy(temp, "1000775");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 3; }
if (islarger(left_reg, accum)) {
left_group = 3;
}
strcpy(temp, "1491020");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 4; }
if (islarger(left_reg, accum)) {
left_group = 4;
}
strcpy(temp, "1979844");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 5; }
if (islarger(left_reg, accum)) {
left_group = 5;
}
strcpy(temp, "1996938");
binary_load(accum, temp, strlen(temp));
if(islarger(left_reg, accum)) { left_group = 6; }
if (islarger(left_reg, accum)) {
left_group = 6;
}
right_group = 0;
strcpy(temp, "183063");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 1; }
if (islarger(right_reg, accum)) {
right_group = 1;
}
strcpy(temp, "820063");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 2; }
if (islarger(right_reg, accum)) {
right_group = 2;
}
strcpy(temp, "1000775");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 3; }
if (islarger(right_reg, accum)) {
right_group = 3;
}
strcpy(temp, "1491020");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 4; }
if (islarger(right_reg, accum)) {
right_group = 4;
}
strcpy(temp, "1979844");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 5; }
if (islarger(right_reg, accum)) {
right_group = 5;
}
strcpy(temp, "1996938");
binary_load(accum, temp, strlen(temp));
if(islarger(right_reg, accum)) { right_group = 6; }
if (islarger(right_reg, accum)) {
right_group = 6;
}
switch (left_group) {
case 1: strcpy(temp, "183064");
@ -915,12 +989,18 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '0';
for (i = 0; i < 46; i++) {
for (j = 0; j < total_widths[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
} else {
unset_module(symbol, symbol->rows, writer);
}
writer++;
}
latch = (latch == '1' ? '0' : '1');
}
if(symbol->width < writer) { symbol->width = writer; }
if (symbol->width < writer) {
symbol->width = writer;
}
symbol->rows = symbol->rows + 1;
/* add separator pattern if composite symbol */
@ -954,7 +1034,9 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
check_digit = 10 - (count % 10);
if (check_digit == 10) { check_digit = 0; }
if (check_digit == 10) {
check_digit = 0;
}
hrt[13] = itoc(check_digit);
hrt[14] = '\0';
@ -964,9 +1046,10 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
return error_number;
}
int general_rules(char field[], char type[])
{ /* Attempts to apply encoding rules from secions 7.2.5.5.1 to 7.2.5.5.3
of ISO/IEC 24724:2006 */
/* Attempts to apply encoding rules from secions 7.2.5.5.1 to 7.2.5.5.3
* of ISO/IEC 24724:2006 */
int general_rules(char field[], char type[]) {
int block[2][200], block_count, i, j, k;
char current, next, last;
@ -1080,8 +1163,8 @@ int general_rules(char field[], char type[])
}
}
int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[])
{ /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
/* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[]) {
int encoding_method, i, mask, j, read_posn, latch, debug = 0, last_mode = ISOIEC;
#ifndef _MSC_VER
char general_field[strlen(source)], general_field_type[strlen(source)];
@ -1134,7 +1217,9 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
/* (01) and (3103) */
weight = atof(weight_str) / 1000.0;
if(weight <= 32.767) { encoding_method = 3; }
if (weight <= 32.767) {
encoding_method = 3;
}
}
if (strlen(source) == 34) {
@ -1239,20 +1324,48 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
switch (encoding_method) { /* Encoding method - Table 10 */
case 1: concat(binary_string, "1XX"); read_posn = 16; break;
case 2: concat(binary_string, "00XX"); read_posn = 0; break;
case 3: concat(binary_string, "0100"); read_posn = strlen(source); break;
case 4: concat(binary_string, "0101"); read_posn = strlen(source); break;
case 5: concat(binary_string, "01100XX"); read_posn = 20; break;
case 6: concat(binary_string, "01101XX"); read_posn = 23; break;
case 7: concat(binary_string, "0111000"); read_posn = strlen(source); break;
case 8: concat(binary_string, "0111001"); read_posn = strlen(source); break;
case 9: concat(binary_string, "0111010"); read_posn = strlen(source); break;
case 10: concat(binary_string, "0111011"); read_posn = strlen(source); break;
case 11: concat(binary_string, "0111100"); read_posn = strlen(source); break;
case 12: concat(binary_string, "0111101"); read_posn = strlen(source); break;
case 13: concat(binary_string, "0111110"); read_posn = strlen(source); break;
case 14: concat(binary_string, "0111111"); read_posn = strlen(source); break;
case 1: concat(binary_string, "1XX");
read_posn = 16;
break;
case 2: concat(binary_string, "00XX");
read_posn = 0;
break;
case 3: concat(binary_string, "0100");
read_posn = strlen(source);
break;
case 4: concat(binary_string, "0101");
read_posn = strlen(source);
break;
case 5: concat(binary_string, "01100XX");
read_posn = 20;
break;
case 6: concat(binary_string, "01101XX");
read_posn = 23;
break;
case 7: concat(binary_string, "0111000");
read_posn = strlen(source);
break;
case 8: concat(binary_string, "0111001");
read_posn = strlen(source);
break;
case 9: concat(binary_string, "0111010");
read_posn = strlen(source);
break;
case 10: concat(binary_string, "0111011");
read_posn = strlen(source);
break;
case 11: concat(binary_string, "0111100");
read_posn = strlen(source);
break;
case 12: concat(binary_string, "0111101");
read_posn = strlen(source);
break;
case 13: concat(binary_string, "0111110");
read_posn = strlen(source);
break;
case 14: concat(binary_string, "0111111");
read_posn = strlen(source);
break;
}
if (debug) printf("Setting binary = %s\n", binary_string);
@ -1302,8 +1415,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
mask = mask >> 1;
}
}
}
@ -1339,8 +1450,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
concat(binary_string, (group_val & mask) ? "1" : "0");
mask = mask >> 1;
}
}
if (encoding_method == 4) {
@ -1379,7 +1488,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
concat(binary_string, (group_val & mask) ? "1" : "0");
mask = mask >> 1;
}
}
@ -1442,7 +1550,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
concat(binary_string, (group_val & mask) ? "1" : "0");
mask = mask >> 1;
}
}
if (encoding_method == 5) {
@ -1465,10 +1572,14 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
switch (source[19]) {
case '0': concat(binary_string, "00"); break;
case '1': concat(binary_string, "01"); break;
case '2': concat(binary_string, "10"); break;
case '3': concat(binary_string, "11"); break;
case '0': concat(binary_string, "00");
break;
case '1': concat(binary_string, "01");
break;
case '2': concat(binary_string, "10");
break;
case '3': concat(binary_string, "11");
break;
}
}
@ -1495,10 +1606,14 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
switch (source[19]) {
case '0': concat(binary_string, "00"); break;
case '1': concat(binary_string, "01"); break;
case '2': concat(binary_string, "10"); break;
case '3': concat(binary_string, "11"); break;
case '0': concat(binary_string, "00");
break;
case '1': concat(binary_string, "01");
break;
case '2': concat(binary_string, "10");
break;
case '3': concat(binary_string, "11");
break;
}
for (i = 0; i < 3; i++) {
@ -1512,8 +1627,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
concat(binary_string, (group_val & mask) ? "1" : "0");
mask = mask >> 1;
}
}
/* The compressed data field has been processed if appropriate - the
@ -1531,28 +1644,35 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
for (i = 0; i < strlen(general_field); i++) {
/* Table 13 - ISO/IEC 646 encodation */
if ((general_field[i] < ' ') || (general_field[i] > 'z')) {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
} else {
general_field_type[i] = ISOIEC;
}
if (general_field[i] == '#') {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
if (general_field[i] == '$') {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
if (general_field[i] == '@') {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
if (general_field[i] == 92) {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
if (general_field[i] == '^') {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
if (general_field[i] == 96) {
general_field_type[i] = INVALID_CHAR; latch = 1;
general_field_type[i] = INVALID_CHAR;
latch = 1;
}
/* Table 12 - Alphanumeric encodation */
@ -1583,7 +1703,6 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
/* FNC1 can be encoded in any system */
general_field_type[i] = ANY_ENC;
}
}
general_field_type[strlen(general_field)] = '\0';
@ -1698,7 +1817,10 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
last_mode = ALPHA;
if(general_field[i] == '[') { concat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */
if (general_field[i] == '[') {
concat(binary_string, "01111");
last_mode = NUMERIC;
} /* FNC1/Numeric latch */
if (general_field[i] == '*') concat(binary_string, "111010"); /* asterisk */
if (general_field[i] == ',') concat(binary_string, "111011"); /* comma */
if (general_field[i] == '-') concat(binary_string, "111100"); /* minus or hyphen */
@ -1754,7 +1876,10 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
last_mode = ISOIEC;
if(general_field[i] == '[') { concat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */
if (general_field[i] == '[') {
concat(binary_string, "01111");
last_mode = NUMERIC;
} /* FNC1/Numeric latch */
if (general_field[i] == '!') concat(binary_string, "11101000"); /* exclamation mark */
if (general_field[i] == 34) concat(binary_string, "11101001"); /* quotation mark */
if (general_field[i] == 37) concat(binary_string, "11101010"); /* percent sign */
@ -1785,8 +1910,12 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if (debug) printf("\tLength: %d\n", (int) strlen(binary_string));
remainder = 12 - (strlen(binary_string) % 12);
if(remainder == 12) { remainder = 0; }
if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); }
if (remainder == 12) {
remainder = 0;
}
if (strlen(binary_string) < 36) {
remainder = 36 - strlen(binary_string);
}
if (latch == 1) {
/* There is still one more numeric digit to encode */
@ -1825,8 +1954,12 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
}
remainder = 12 - (strlen(binary_string) % 12);
if(remainder == 12) { remainder = 0; }
if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); }
if (remainder == 12) {
remainder = 0;
}
if (strlen(binary_string) < 36) {
remainder = 36 - strlen(binary_string);
}
if (debug) printf("Resultant binary = %s\n", binary_string);
if (debug) printf("\tLength: %d\n", (int) strlen(binary_string));
}
@ -1853,7 +1986,11 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
/* Patch variable length symbol bit field */
d1 = ((strlen(binary_string) / 12) + 1) & 1;
if(strlen(binary_string) <= 156) { d2 = 0; } else { d2 = 1; }
if (strlen(binary_string) <= 156) {
d2 = 0;
} else {
d2 = 1;
}
if (encoding_method == 1) {
binary_string[2] = d1 ? '1' : '0';
@ -1872,8 +2009,8 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
return 0;
}
int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
{ /* GS1 DataBar Expanded */
/* GS1 DataBar Expanded */
int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int i, j, k, l, data_chars, vs[21], group[21], v_odd[21], v_even[21];
char substring[21][14], latch;
int char_widths[21][8], checksum, check_widths[8], c_group;
@ -1894,7 +2031,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
if (symbol->input_mode != GS1_MODE) {
/* GS1 data has not been verified yet */
i = gs1_verify(symbol, source, src_len, reduced);
if(i != 0) { return i; }
if (i != 0) {
return i;
}
}
if ((symbol->symbology == BARCODE_RSS_EXP_CC) || (symbol->symbology == BARCODE_RSS_EXPSTACK_CC)) {
@ -1928,26 +2067,29 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
for (i = 0; i < data_chars; i++) {
vs[i] = 0;
if(substring[i][0] == '1') { vs[i] += 2048; }
if(substring[i][1] == '1') { vs[i] += 1024; }
if(substring[i][2] == '1') { vs[i] += 512; }
if(substring[i][3] == '1') { vs[i] += 256; }
if(substring[i][4] == '1') { vs[i] += 128; }
if(substring[i][5] == '1') { vs[i] += 64; }
if(substring[i][6] == '1') { vs[i] += 32; }
if(substring[i][7] == '1') { vs[i] += 16; }
if(substring[i][8] == '1') { vs[i] += 8; }
if(substring[i][9] == '1') { vs[i] += 4; }
if(substring[i][10] == '1') { vs[i] += 2; }
if(substring[i][11] == '1') { vs[i] += 1; }
for (int p = 0; p < 12; p++) {
if (substring[i][p] == '1') {
vs[i] += (0x800 >> p);
}
}
}
for (i = 0; i < data_chars; i++) {
if(vs[i] <= 347) { group[i] = 1; }
if((vs[i] >= 348) && (vs[i] <= 1387)) { group[i] = 2; }
if((vs[i] >= 1388) && (vs[i] <= 2947)) { group[i] = 3; }
if((vs[i] >= 2948) && (vs[i] <= 3987)) { group[i] = 4; }
if(vs[i] >= 3988) { group[i] = 5; }
if (vs[i] <= 347) {
group[i] = 1;
}
if ((vs[i] >= 348) && (vs[i] <= 1387)) {
group[i] = 2;
}
if ((vs[i] >= 1388) && (vs[i] <= 2947)) {
group[i] = 3;
}
if ((vs[i] >= 2948) && (vs[i] <= 3987)) {
group[i] = 4;
}
if (vs[i] >= 3988) {
group[i] = 5;
}
v_odd[i] = (vs[i] - g_sum_exp[group[i] - 1]) / t_even_exp[group[i] - 1];
v_even[i] = (vs[i] - g_sum_exp[group[i] - 1]) % t_even_exp[group[i] - 1];
@ -1977,11 +2119,21 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
check_char = (211 * ((data_chars + 1) - 4)) + (checksum % 211);
if(check_char <= 347) { c_group = 1; }
if((check_char >= 348) && (check_char <= 1387)) { c_group = 2; }
if((check_char >= 1388) && (check_char <= 2947)) { c_group = 3; }
if((check_char >= 2948) && (check_char <= 3987)) { c_group = 4; }
if(check_char >= 3988) { c_group = 5; }
if (check_char <= 347) {
c_group = 1;
}
if ((check_char >= 348) && (check_char <= 1387)) {
c_group = 2;
}
if ((check_char >= 1388) && (check_char <= 2947)) {
c_group = 3;
}
if ((check_char >= 2948) && (check_char <= 3987)) {
c_group = 4;
}
if (check_char >= 3988) {
c_group = 5;
}
c_odd = (check_char - g_sum_exp[c_group - 1]) / t_even_exp[c_group - 1];
c_even = (check_char - g_sum_exp[c_group - 1]) % t_even_exp[c_group - 1];
@ -2041,7 +2193,11 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '0';
for (i = 0; i < pattern_width; i++) {
for (j = 0; j < elements[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
} else {
unset_module(symbol, symbol->rows, writer);
}
writer++;
}
if (latch == '1') {
@ -2050,7 +2206,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '1';
}
}
if(symbol->width < writer) { symbol->width = writer; }
if (symbol->width < writer) {
symbol->width = writer;
}
symbol->rows = symbol->rows + 1;
if (symbol->symbology == BARCODE_RSS_EXP_CC) {
for (j = 4; j < (symbol->width - 4); j++) {
@ -2185,7 +2343,11 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
writer = 0;
for (i = 0; i < elements_in_sub; i++) {
for (j = 0; j < sub_elements[i]; j++) {
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
if (latch == '1') {
set_module(symbol, symbol->rows, writer);
} else {
unset_module(symbol, symbol->rows, writer);
}
writer++;
}
if (latch == '1') {
@ -2194,7 +2356,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
latch = '1';
}
}
if(symbol->width < writer) { symbol->width = writer; }
if (symbol->width < writer) {
symbol->width = writer;
}
if (current_row != 1) {
/* middle separator pattern (above current row) */

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2007 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2007-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -38,12 +38,30 @@
#define ALPHA_OR_ISO 121
/* RSS-14 Tables */
static int g_sum_table[9] = { 0, 161, 961, 2015, 2715, 0, 336, 1036, 1516};
static int t_table[9] = { 1, 10, 34, 70, 126, 4, 20, 48, 81};
static int modules_odd[9] = { 12, 10, 8, 6, 4, 5, 7, 9, 11 };
static int modules_even[9] = { 4, 6, 8, 10, 12, 10, 8, 6, 4 };
static int widest_odd[9] = { 8, 6, 4, 3, 1, 2, 4, 6, 8 };
static int widest_even[9] = { 1, 3, 5, 6, 8, 7, 5, 3, 1 };
static int g_sum_table[9] = {
0, 161, 961, 2015, 2715, 0, 336, 1036, 1516
};
static int t_table[9] = {
1, 10, 34, 70, 126, 4, 20, 48, 81
};
static int modules_odd[9] = {
12, 10, 8, 6, 4, 5, 7, 9, 11
};
static int modules_even[9] = {
4, 6, 8, 10, 12, 10, 8, 6, 4
};
static int widest_odd[9] = {
8, 6, 4, 3, 1, 2, 4, 6, 8
};
static int widest_even[9] = {
1, 3, 5, 6, 8, 7, 5, 3, 1
};
static int widths[8];
static int finder_pattern[45] = {
3, 8, 2, 1, 1,
@ -56,7 +74,9 @@ static int finder_pattern[45] = {
1, 5, 7, 1, 1,
1, 3, 9, 1, 1
};
static int checksum_weight[32] = { /* Table 5 */
static int checksum_weight[32] = {
/* Table 5 */
1, 3, 9, 27, 2, 6, 18, 54,
4, 12, 36, 29, 8, 24, 72, 58,
16, 48, 65, 37, 32, 17, 51, 74,
@ -64,15 +84,32 @@ static int checksum_weight[32] = { /* Table 5 */
};
/* RSS Limited Tables */
static int t_even_ltd[7] = { 28, 728, 6454, 203, 2408, 1, 16632 };
static int modules_odd_ltd[7] = { 17, 13, 9, 15, 11, 19, 7 };
static int modules_even_ltd[7] = { 9, 13, 17, 11, 15, 7, 19 };
static int widest_odd_ltd[7] = { 6, 5, 3, 5, 4, 8, 1 };
static int widest_even_ltd[7] = { 3, 4, 6, 4, 5, 1, 8 };
static int checksum_weight_ltd[28] = { /* Table 7 */
static int t_even_ltd[7] = {
28, 728, 6454, 203, 2408, 1, 16632
};
static int modules_odd_ltd[7] = {
17, 13, 9, 15, 11, 19, 7
};
static int modules_even_ltd[7] = {
9, 13, 17, 11, 15, 7, 19
};
static int widest_odd_ltd[7] = {
6, 5, 3, 5, 4, 8, 1
};
static int widest_even_ltd[7] = {
3, 4, 6, 4, 5, 1, 8
};
static int checksum_weight_ltd[28] = {
/* Table 7 */
1, 3, 9, 27, 81, 65, 17, 51, 64, 14, 42, 37, 22, 66,
20, 60, 2, 6, 18, 54, 73, 41, 34, 13, 39, 28, 84, 74
};
static int finder_pattern_ltd[1246] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1,
@ -166,13 +203,32 @@ static int finder_pattern_ltd[1246] = {
};
/* RSS Expanded Tables */
static int g_sum_exp[5] = { 0, 348, 1388, 2948, 3988 };
static int t_even_exp[5] = { 4, 20, 52, 104, 204 };
static int modules_odd_exp[5] = { 12, 10, 8, 6, 4 };
static int modules_even_exp[5] = { 5, 7, 9, 11, 13 };
static int widest_odd_exp[5] = { 7, 5, 4, 3, 1 };
static int widest_even_exp[5] = { 2, 4, 5, 6, 8 };
static int checksum_weight_exp[184] = { /* Table 14 */
static int g_sum_exp[5] = {
0, 348, 1388, 2948, 3988
};
static int t_even_exp[5] = {
4, 20, 52, 104, 204
};
static int modules_odd_exp[5] = {
12, 10, 8, 6, 4
};
static int modules_even_exp[5] = {
5, 7, 9, 11, 13
};
static int widest_odd_exp[5] = {
7, 5, 4, 3, 1
};
static int widest_even_exp[5] = {
2, 4, 5, 6, 8
};
static int checksum_weight_exp[184] = {
/* Table 14 */
1, 3, 9, 27, 81, 32, 96, 77,
20, 60, 180, 118, 143, 7, 21, 63,
189, 145, 13, 39, 117, 140, 209, 205,
@ -197,7 +253,9 @@ static int checksum_weight_exp[184] = { /* Table 14 */
55, 165, 73, 8, 24, 72, 5, 15,
45, 135, 194, 160, 58, 174, 100, 89
};
static int finder_pattern_exp[60] = { /* Table 15 */
static int finder_pattern_exp[60] = {
/* Table 15 */
1, 8, 4, 1, 1,
1, 1, 4, 8, 1,
3, 6, 4, 1, 1,
@ -211,7 +269,9 @@ static int finder_pattern_exp[60] = { /* Table 15 */
2, 2, 9, 1, 1,
1, 1, 9, 2, 2
};
static int finder_sequence[198] = { /* Table 16 */
static int finder_sequence[198] = {
/* Table 16 */
1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0,
1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
@ -223,6 +283,7 @@ static int finder_sequence[198] = { /* Table 16 */
1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
};
static int weight_rows[210] = {
0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -1,7 +1,7 @@
/* sjis.h - Unicode to Shift JIS lookup table
libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -38,8 +38,7 @@
#define SSET "0123456789ABCDEF"
int svg_plot(struct zint_symbol *symbol)
{
int svg_plot(struct zint_symbol *symbol) {
int i, block_width, latch, r, this_row;
float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0;
FILE *fsvg;
@ -611,4 +610,3 @@ int svg_plot(struct zint_symbol *symbol)
return error_number;
}

View File

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -37,8 +37,7 @@
#include <stdlib.h>
#include "common.h"
static char *TeleTable[] =
{
static char *TeleTable[] ={
"1111111111111111", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
@ -54,10 +53,10 @@ static char *TeleTable[] =
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111","331111111111","111113111113", "31111111111111","111311111113","131111111113"};
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113"
};
int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
{
int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) {
unsigned int i, count, check_digit;
int error_number;
char dest[512]; /*14 + 30 * 14 + 14 + 14 + 1 ~ 512 */
@ -84,7 +83,9 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
check_digit = 127 - (count % 127);
if(check_digit == 127) { check_digit = 0; }
if (check_digit == 127) {
check_digit = 0;
}
concat(dest, TeleTable[check_digit]);
/* Stop character */
@ -102,8 +103,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len)
return error_number;
}
int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
{
int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
unsigned int i, count, check_digit, glyph;
int error_number, temp_length = src_len;
char dest[1024]; /* 14 + 60 * 14 + 14 + 14 + 1 ~ 1024 */
@ -125,8 +125,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
/* Add a leading zero if required */
if (temp_length & 1)
{
if (temp_length & 1) {
memmove(temp + 1, temp, temp_length);
temp[0] = '0';
@ -136,8 +135,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
/* Start character */
strcpy(dest, TeleTable['_']);
for (i = 0; i < temp_length; i += 2)
{
for (i = 0; i < temp_length; i += 2) {
if (temp[i] == 'X') {
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
return ZINT_ERROR_INVALID_DATA;
@ -155,7 +153,9 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
check_digit = 127 - (count % 127);
if(check_digit == 127) { check_digit = 0; }
if (check_digit == 127) {
check_digit = 0;
}
concat(dest, TeleTable[check_digit]);
/* Stop character */
@ -165,4 +165,3 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
ustrcpy(symbol->text, temp);
return error_number;
}

View File

@ -1,7 +1,7 @@
/* upcean.c - Handles UPC, EAN and ISBN
libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -40,22 +40,47 @@
/* UPC and EAN tables checked against EN 797:1996 */
static const char *UPCParity0[10] = {"BBBAAA", "BBABAA", "BBAABA", "BBAAAB", "BABBAA", "BAABBA", "BAAABB",
"BABABA", "BABAAB", "BAABAB"}; /* Number set for UPC-E symbol (EN Table 4) */
static const char *UPCParity1[10] = {"AAABBB", "AABABB", "AABBAB", "AABBBA", "ABAABB", "ABBAAB", "ABBBAA",
"ABABAB", "ABABBA", "ABBABA"}; /* Not covered by BS EN 797:1995 */
static const char *EAN2Parity[4] = {"AA", "AB", "BA", "BB"}; /* Number sets for 2-digit add-on (EN Table 6) */
static const char *EAN5Parity[10] = {"BBAAA", "BABAA", "BAABA", "BAAAB", "ABBAA", "AABBA", "AAABB", "ABABA",
"ABAAB", "AABAB"}; /* Number set for 5-digit add-on (EN Table 7) */
static const char *EAN13Parity[10] = {"AAAAA", "ABABB", "ABBAB", "ABBBA", "BAABB", "BBAAB", "BBBAA", "BABAB",
"BABBA", "BBABA"}; /* Left hand of the EAN-13 symbol (EN Table 3) */
static const char *EANsetA[10] = {"3211", "2221", "2122", "1411", "1132", "1231", "1114", "1312", "1213",
"3112"}; /* Representation set A and C (EN Table 1) */
static const char *EANsetB[10] = {"1123", "1222", "2212", "1141", "2311", "1321", "4111", "2131", "3121",
"2113"}; /* Representation set B (EN Table 1) */
static const char *UPCParity0[10] = {
/* Number set for UPC-E symbol (EN Table 4) */
"BBBAAA", "BBABAA", "BBAABA", "BBAAAB", "BABBAA", "BAABBA", "BAAABB",
"BABABA", "BABAAB", "BAABAB"
};
char upc_check(char source[])
{ /* Calculate the correct check digit for a UPC barcode */
static const char *UPCParity1[10] = {
/* Not covered by BS EN 797:1995 */
"AAABBB", "AABABB", "AABBAB", "AABBBA", "ABAABB", "ABBAAB", "ABBBAA",
"ABABAB", "ABABBA", "ABBABA"
};
static const char *EAN2Parity[4] = {
/* Number sets for 2-digit add-on (EN Table 6) */
"AA", "AB", "BA", "BB"
};
static const char *EAN5Parity[10] = {
/* Number set for 5-digit add-on (EN Table 7) */
"BBAAA", "BABAA", "BAABA", "BAAAB", "ABBAA", "AABBA", "AAABB", "ABABA",
"ABAAB", "AABAB"
};
static const char *EAN13Parity[10] = {
/* Left hand of the EAN-13 symbol (EN Table 3) */
"AAAAA", "ABABB", "ABBAB", "ABBBA", "BAABB", "BBAAB", "BBBAA", "BABAB",
"BABBA", "BBABA"
};
static const char *EANsetA[10] = {
/* Representation set A and C (EN Table 1) */
"3211", "2221", "2122", "1411", "1132", "1231", "1114", "1312", "1213","3112"
};
static const char *EANsetB[10] = {
/* Representation set B (EN Table 1) */
"1123", "1222", "2212", "1141", "2311", "1321", "4111", "2131", "3121", "2113"
};
/* Calculate the correct check digit for a UPC barcode */
char upc_check(char source[]) {
unsigned int i, count, check_digit;
count = 0;
@ -69,12 +94,14 @@ char upc_check(char source[])
}
check_digit = 10 - (count % 10);
if (check_digit == 10) { check_digit = 0; }
if (check_digit == 10) {
check_digit = 0;
}
return itoc(check_digit);
}
void upca_draw(char source[], char dest[])
{ /* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */
/* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */
void upca_draw(char source[], char dest[]) {
unsigned int i, half_way;
half_way = strlen(source) / 2;
@ -82,10 +109,8 @@ void upca_draw(char source[], char dest[])
/* start character */
concat(dest, "111");
for(i = 0; i <= strlen(source); i++)
{
if (i == half_way)
{
for (i = 0; i <= strlen(source); i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverts right hand characters */
concat(dest, "11111");
@ -98,8 +123,8 @@ void upca_draw(char source[], char dest[])
concat(dest, "111");
}
void upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ /* Make a UPC A barcode when we haven't been given the check digit */
/* Make a UPC A barcode when we haven't been given the check digit */
void upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int length;
char gtin[15];
@ -111,8 +136,8 @@ void upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
ustrcpy(symbol->text, (unsigned char*) gtin);
}
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ /* UPC E is a zero-compressed version of UPC A */
/* UPC E is a zero-compressed version of UPC A */
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int i, num_system;
char emode, equivalent[12], check_digit, parity[8], temp[8];
char hrt[9];
@ -120,17 +145,20 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* Two number systems can be used - system 0 and system 1 */
if (ustrlen(source) == 7) {
switch (source[0]) {
case '0': num_system = 0; break;
case '1': num_system = 1; break;
default: num_system = 0; source[0] = '0'; break;
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
}
}
else {
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
@ -142,13 +170,14 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
for (i = 0; i < 11; i++) {
equivalent[i] = '0';
}
if(num_system == 1) { equivalent[0] = temp[0]; }
if (num_system == 1) {
equivalent[0] = temp[0];
}
equivalent[1] = source[0];
equivalent[2] = source[1];
equivalent[11] = '\0';
switch(emode)
{
switch (emode) {
case '0':
case '1':
case '2':
@ -209,8 +238,10 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
for (i = 0; i <= ustrlen(source); i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest); break;
case 'B': lookup(NEON, EANsetB, source[i], dest); break;
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
case 'B': lookup(NEON, EANsetB, source[i], dest);
break;
}
}
@ -222,15 +253,13 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
ustrcpy(symbol->text, (unsigned char*) hrt);
}
void add_on(unsigned char source[], char dest[], int mode)
{ /* EAN-2 and EAN-5 add-on codes */
/* EAN-2 and EAN-5 add-on codes */
void add_on(unsigned char source[], char dest[], int mode) {
char parity[6];
unsigned int i, code_type;
/* If an add-on then append with space */
if (mode != 0)
{
if (mode != 0) {
concat(dest, "9");
}
@ -238,18 +267,14 @@ void add_on(unsigned char source[], char dest[], int mode)
concat(dest, "112");
/* Determine EAN2 or EAN5 add-on */
if(ustrlen(source) == 2)
{
if (ustrlen(source) == 2) {
code_type = EAN2;
}
else
{
} else {
code_type = EAN5;
}
/* Calculate parity for EAN2 */
if(code_type == EAN2)
{
if (code_type == EAN2) {
int code_value, parity_bit;
code_value = (10 * ctoi(source[0])) + ctoi(source[1]);
@ -257,12 +282,10 @@ void add_on(unsigned char source[], char dest[], int mode)
strcpy(parity, EAN2Parity[parity_bit]);
}
if(code_type == EAN5)
{
if (code_type == EAN5) {
int values[6], parity_sum, parity_bit;
for(i = 0; i < 6; i++)
{
for (i = 0; i < 6; i++) {
values[i] = ctoi(source[i]);
}
@ -273,26 +296,24 @@ void add_on(unsigned char source[], char dest[], int mode)
strcpy(parity, EAN5Parity[parity_bit]);
}
for(i = 0; i < ustrlen(source); i++)
{
for (i = 0; i < ustrlen(source); i++) {
switch (parity[i]) {
case 'A': lookup(NEON, EANsetA, source[i], dest); break;
case 'B': lookup(NEON, EANsetB, source[i], dest); break;
case 'A': lookup(NEON, EANsetA, source[i], dest);
break;
case 'B': lookup(NEON, EANsetB, source[i], dest);
break;
}
/* Glyph separator */
if(i != (ustrlen(source) - 1))
{
if (i != (ustrlen(source) - 1)) {
concat(dest, "11");
}
}
}
/* ************************ EAN-13 ****************** */
char ean_check(char source[])
{ /* Calculate the correct check digit for a EAN-13 barcode */
/* Calculate the correct check digit for a EAN-13 barcode */
char ean_check(char source[]) {
int i;
unsigned int h, count, check_digit;
@ -307,12 +328,13 @@ char ean_check(char source[])
}
}
check_digit = 10 - (count % 10);
if (check_digit == 10) { check_digit = 0; }
if (check_digit == 10) {
check_digit = 0;
}
return itoc(check_digit);
}
void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
{
void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int length, i, half_way;
char parity[6];
char gtin[15];
@ -334,21 +356,16 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* start character */
concat(dest, "111");
length = strlen(gtin);
for(i = 1; i <= length; i++)
{
if (i == half_way)
{
for (i = 1; i <= length; i++) {
if (i == half_way) {
/* middle character - separates manufacturer no. from product no. */
/* also inverses right hand characters */
concat(dest, "11111");
}
if(((i > 1) && (i < 7)) && (parity[i - 2] == 'B'))
{
if (((i > 1) && (i < 7)) && (parity[i - 2] == 'B')) {
lookup(NEON, EANsetB, gtin[i], dest);
}
else
{
} else {
lookup(NEON, EANsetA, gtin[i], dest);
}
}
@ -359,8 +376,8 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
ustrcpy(symbol->text, (unsigned char*) gtin);
}
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ /* Make an EAN-8 barcode when we haven't been given the check digit */
/* Make an EAN-8 barcode when we haven't been given the check digit */
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* EAN-8 is basically the same as UPC-A but with fewer digits */
int length;
char gtin[10];
@ -373,18 +390,18 @@ void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
ustrcpy(symbol->text, (unsigned char*) gtin);
}
char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
{
/* For ISBN(13) only */
char isbn13_check(unsigned char source[]) {
unsigned int i, weight, sum, check, h;
sum = 0;
weight = 1;
h = ustrlen(source) - 1;
for(i = 0; i < h; i++)
{
for (i = 0; i < h; i++) {
sum += ctoi(source[i]) * weight;
if(weight == 1) weight = 3; else weight = 1;
if (weight == 1) weight = 3;
else weight = 1;
}
check = sum % 10;
@ -393,8 +410,8 @@ char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
return itoc(check);
}
char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
{
/* For ISBN(10) and SBN only */
char isbn_check(unsigned char source[]) {
unsigned int i, weight, sum, check, h;
char check_char;
@ -402,20 +419,21 @@ char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
weight = 1;
h = ustrlen(source) - 1;
for(i = 0; i < h; i++)
{
for (i = 0; i < h; i++) {
sum += ctoi(source[i]) * weight;
weight++;
}
check = sum % 11;
check_char = itoc(check);
if(check == 10) { check_char = 'X'; }
if (check == 10) {
check_char = 'X';
}
return check_char;
}
int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char dest[]) /* Make an EAN-13 barcode from an SBN or ISBN */
{
/* Make an EAN-13 barcode from an SBN or ISBN */
int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char dest[]) {
int i, error_number;
char check_digit;
@ -427,24 +445,20 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
}
/* Input must be 9, 10 or 13 characters */
if(((src_len < 9) || (src_len > 13)) || ((src_len > 10) && (src_len < 13)))
{
if (((src_len < 9) || (src_len > 13)) || ((src_len > 10) && (src_len < 13))) {
strcpy(symbol->errtxt, "Input wrong length");
return ZINT_ERROR_TOO_LONG;
}
if(src_len == 13) /* Using 13 character ISBN */
{
if (src_len == 13) /* Using 13 character ISBN */ {
if (!(((source[0] == '9') && (source[1] == '7')) &&
((source[2] == '8') || (source[2] == '9'))))
{
((source[2] == '8') || (source[2] == '9')))) {
strcpy(symbol->errtxt, "Invalid ISBN");
return ZINT_ERROR_INVALID_DATA;
}
check_digit = isbn13_check(source);
if (source[src_len - 1] != check_digit)
{
if (source[src_len - 1] != check_digit) {
strcpy(symbol->errtxt, "Incorrect ISBN check");
return ZINT_ERROR_INVALID_CHECK;
}
@ -453,16 +467,13 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
ean13(symbol, source, dest);
}
if(src_len == 10) /* Using 10 digit ISBN */
{
if (src_len == 10) /* Using 10 digit ISBN */ {
check_digit = isbn_check(source);
if(check_digit != source[src_len - 1])
{
if (check_digit != source[src_len - 1]) {
strcpy(symbol->errtxt, "Incorrect ISBN check");
return ZINT_ERROR_INVALID_CHECK;
}
for(i = 13; i > 0; i--)
{
for (i = 13; i > 0; i--) {
source[i] = source[i - 3];
}
source[0] = '9';
@ -473,26 +484,22 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
ean13(symbol, source, dest);
}
if(src_len == 9) /* Using 9 digit SBN */
{
if (src_len == 9) /* Using 9 digit SBN */ {
/* Add leading zero */
for(i = 10; i > 0; i--)
{
for (i = 10; i > 0; i--) {
source[i] = source[i - 1];
}
source[0] = '0';
/* Verify check digit */
check_digit = isbn_check(source);
if(check_digit != source[ustrlen(source) - 1])
{
if (check_digit != source[ustrlen(source) - 1]) {
strcpy(symbol->errtxt, "Incorrect SBN check");
return ZINT_ERROR_INVALID_CHECK;
}
/* Convert to EAN-13 number */
for(i = 13; i > 0; i--)
{
for (i = 13; i > 0; i--) {
source[i] = source[i - 3];
}
source[0] = '9';
@ -506,8 +513,8 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int
return 0;
}
void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsigned char local_source[]) {
/* Add leading zeroes to EAN and UPC strings */
void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsigned char local_source[]) {
unsigned char first_part[20], second_part[20], zfirst_part[20], zsecond_part[20];
int with_addon = 0;
int first_len = 0, second_len = 0, zfirst_len = 0, zsecond_len = 0, i, h;
@ -542,17 +549,31 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
}
/* Calculate target lengths */
if(second_len <= 5) { zsecond_len = 5; }
if(second_len <= 2) { zsecond_len = 2; }
if(second_len == 0) { zsecond_len = 0; }
if (second_len <= 5) {
zsecond_len = 5;
}
if (second_len <= 2) {
zsecond_len = 2;
}
if (second_len == 0) {
zsecond_len = 0;
}
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
if(first_len <= 12) { zfirst_len = 12; }
if(first_len <= 7) { zfirst_len = 7; }
if (first_len <= 12) {
zfirst_len = 12;
}
if (first_len <= 7) {
zfirst_len = 7;
}
if (second_len == 0) {
if(first_len <= 5) { zfirst_len = 5; }
if(first_len <= 2) { zfirst_len = 2; }
if (first_len <= 5) {
zfirst_len = 5;
}
if (first_len <= 2) {
zfirst_len = 2;
}
}
break;
case BARCODE_UPCA:
@ -561,11 +582,17 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
break;
case BARCODE_UPCE:
case BARCODE_UPCE_CC:
if(first_len == 7) { zfirst_len = 7; }
if(first_len <= 6) { zfirst_len = 6; }
if (first_len == 7) {
zfirst_len = 7;
}
if (first_len <= 6) {
zfirst_len = 6;
}
break;
case BARCODE_ISBNX:
if(first_len <= 9) { zfirst_len = 9; }
if (first_len <= 9) {
zfirst_len = 9;
}
break;
}
@ -588,9 +615,8 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
}
}
int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
{
/* splits string to parts before and after '+' parts */
int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
unsigned char first_part[20] = {0}, second_part[20] = {0}, dest[1000] = {0};
unsigned char local_source[20] = {0};
unsigned int latch, reader, writer, with_addon;
@ -620,7 +646,6 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
}
/* Add leading zeroes */
ustrcpy(local_source, (unsigned char *) "");
if (symbol->symbology == BARCODE_ISBNX) {
@ -629,9 +654,10 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
ean_leading_zeroes(symbol, source, local_source);
for(reader = 0; reader <= ustrlen(local_source); reader++)
{
if(source[reader] == '+') { with_addon = TRUE; }
for (reader = 0; reader <= ustrlen(local_source); reader++) {
if (source[reader] == '+') {
with_addon = TRUE;
}
}
reader = 0;
@ -658,22 +684,25 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
strcpy((char*) first_part, (char*) local_source);
}
switch(symbol->symbology)
{
switch (symbol->symbology) {
case BARCODE_EANX:
switch(ustrlen(first_part))
{
case 2: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, first_part); break;
case 5: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, first_part); break;
case 7: ean8(symbol, first_part, (char*)dest); break;
case 12: ean13(symbol, first_part, (char*)dest); break;
default: strcpy(symbol->errtxt, "Invalid length input"); return ZINT_ERROR_TOO_LONG;
switch (ustrlen(first_part)) {
case 2: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
break;
case 5: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
break;
case 7: ean8(symbol, first_part, (char*) dest);
break;
case 12: ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "Invalid length input");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_EANX_CC:
switch(ustrlen(first_part))
{ /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
switch (ustrlen(first_part)) { /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
case 7: set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 67);
set_module(symbol, symbol->rows + 1, 0);
@ -684,7 +713,8 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
ean8(symbol, first_part, (char*)dest); break;
ean8(symbol, first_part, (char*) dest);
break;
case 12:set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
@ -695,8 +725,10 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
ean13(symbol, first_part, (char*)dest); break;
default: strcpy(symbol->errtxt, "Invalid length EAN input"); return ZINT_ERROR_TOO_LONG;
ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "Invalid length EAN input");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCA:
@ -758,8 +790,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
break;
}
switch(ustrlen(second_part))
{
switch (ustrlen(second_part)) {
case 0: break;
case 2:
add_on(second_part, (char*) dest, 1);
@ -801,7 +832,3 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len)
}
return error_number;
}

View File

@ -1,7 +1,7 @@
/* zint.h - definitions for libzint
libzint - the open source barcode library
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions