diff --git a/backend/bc412.c b/backend/bc412.c index e61203b2..8bf694f9 100644 --- a/backend/bc412.c +++ b/backend/bc412.c @@ -32,10 +32,10 @@ /* A little information about this symbology can be found at * https://barcodeguide.seagullscientific.com/Content/Symbologies/BC412.htm - * + * * Partial specification at * https://www.wdfxw.net/doc80487518.htm - * + * * Checked against the encoder at * https://www.barcodesoft.com/en/semi/semi-t1-95-bc-412-code */ @@ -72,26 +72,26 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt char dest[293]; /* 2 + (36 * 8) + 3 */ char *d = dest; int error_number = 0; - + if ((length < 7) || (length > 18)) { strcpy(symbol->errtxt, "790: Input wrong length (should be between 7 and 18 characters)"); return ZINT_ERROR_TOO_LONG; } to_upper(source, length); - + padded_source[0] = source[0]; padded_source[1] = '0'; - + for (i = 2; i <= length; i++) { padded_source[i] = source[i - 1]; } padded_source[length + 1] = 0; - + if (!is_sane_lookup(BROMINE, 35, padded_source, length + 1, posns)) { strcpy(symbol->errtxt, "791: Invalid character in data (alphanumerics only, excluding the letter \"O\")"); return ZINT_ERROR_INVALID_DATA; } - + for (i = 0; i <= length; i++) { if (i % 2) { counter_even += posns[i]; @@ -99,38 +99,38 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt counter_odd += posns[i]; } } - + counter_odd %= 35; counter_even %= 35; - + /* Check digit */ check_sum = counter_odd + (2 * counter_even); check_sum %= 35; check_sum *= 17; check_sum %= 35; - + if (symbol->debug & ZINT_DEBUG_PRINT) { printf("BC412 check: %c\n", BROMINE[check_sum]); } - + padded_source[1] = BROMINE[check_sum]; posns[1] = check_sum; - + /* Start character */ memcpy(d, "12", 2); d += 2; - + for (i = 0; i <= length; i++, d += 8) { memcpy(d, BC412Table[posns[i]], 8); } - + /* Stop character */ memcpy(d, "111", 3); d += 3; - + expand(symbol, dest, d - dest); ustrcpy(symbol->text, padded_source); - + if (symbol->output_options & COMPLIANT_HEIGHT) { /* SEMI T1-95 Table 1 "Module" (Character) Height 2mm ± 0.025mm, using Module Spacing 0.12mm ± 0.025mm as X-dimension */ @@ -140,7 +140,7 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt /* Using compliant height as default as no backwards compatibility to consider */ (void) set_height(symbol, 0.0f, stripf(2.0f / 0.12f), 0.0f, 1 /*no_errtxt*/); } - + return error_number; } diff --git a/backend/channel_precalcs.h b/backend/channel_precalcs.h index de134a10..f1e6ebf7 100644 --- a/backend/channel_precalcs.h +++ b/backend/channel_precalcs.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -27,7 +27,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef Z_CHANNEL_PRECALCS_H +#define Z_CHANNEL_PRECALCS_H /* Channel code precalculated values to avoid excessive looping */ /* To generate uncomment CHANNEL_GENERATE_PRECALCS define and run "backend/tests/test_channel -f generate -g" */ @@ -104,3 +107,6 @@ static channel_precalc channel_precalcs8[] = { { 7504623, { 1, 1, 3, 4, 3, 1, 1, 1, }, { 5, 2, 1, 1, 1, 1, 1, 3, }, { 8, 8, 8, 6, 3, 1, 1, }, { 8, 4, 3, 3, 3, 3, 3, }, }, { 7623744, { 3, 1, 1, 2, 2, 1, 2, 3, }, { 5, 2, 1, 1, 1, 2, 1, 2, }, { 8, 6, 6, 6, 5, 4, 4, }, { 8, 4, 3, 3, 3, 3, 2, }, }, }; + +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_CHANNEL_PRECALCS_H */ diff --git a/backend/codablock.c b/backend/codablock.c index 198e1cdd..becfbecd 100644 --- a/backend/codablock.c +++ b/backend/codablock.c @@ -1,4 +1,4 @@ -/* codablock.c - Handles Codablock-F and Codablock-E */ +/* codablock.c - Handles Codablock-F */ /* libzint - the open source barcode library Copyright (C) 2016-2022 Harald Oehlmann @@ -30,62 +30,60 @@ */ /* SPDX-License-Identifier: BSD-3-Clause */ -#include -#include -#include #include "common.h" #include "code128.h" +#include +#include +#include #define uchar unsigned char /* FTab C128 flags - may be added */ -#define CodeA 1 -#define CodeB 2 -#define CodeC 4 -#define CEnd 8 -#define CShift 16 -#define CFill 32 +#define CodeA 1 +#define CodeB 2 +#define CodeC 4 +#define CEnd 8 +#define CShift 16 +#define CFill 32 #define CodeFNC1 64 #define CodeFNC4 128 -#define ZTNum (CodeA+CodeB+CodeC) -#define ZTFNC1 (CodeA+CodeB+CodeC+CodeFNC1) +#define ZTNum (CodeA + CodeB + CodeC) +#define ZTFNC1 (CodeA + CodeB + CodeC + CodeFNC1) /* ASCII-Extension for Codablock-F */ -#define aFNC1 (uchar)(128) -#define aFNC2 (uchar)(129) -#define aFNC3 (uchar)(130) -#define aFNC4 (uchar)(131) -#define aCodeA (uchar)(132) -#define aCodeB (uchar)(133) -#define aCodeC (uchar)(134) -#define aShift (uchar)(135) +#define aFNC1 ((uchar) 128) +#define aFNC2 ((uchar) 129) +#define aFNC3 ((uchar) 130) +#define aFNC4 ((uchar) 131) +#define aCodeA ((uchar) 132) +#define aCodeB ((uchar) 133) +#define aCodeC ((uchar) 134) +#define aShift ((uchar) 135) /* Code F Analysing-Chart */ -typedef struct sCharacterSetTable -{ - int CharacterSet; /* Still possible character sets for actual*/ - int AFollowing; /* Still following Characters in Charset A */ - int BFollowing; /* Still following Characters in Charset B */ - int CFollowing; /* Still following Characters in Charset C */ +typedef struct sCharacterSetTable { + int CharacterSet; /* Still possible character sets for actual*/ + int AFollowing; /* Still following Characters in Charset A */ + int BFollowing; /* Still following Characters in Charset B */ + int CFollowing; /* Still following Characters in Charset C */ } CharacterSetTable; /* Find the possible Code-128 Character sets for a character * The result is an or of CodeA, CodeB, CodeC, CodeFNC1, CodeFNC4 depending on the * possible Code 128 character sets. */ -static int GetPossibleCharacterSet(unsigned char C) -{ - if (C<='\x1f') /* Control chars */ +static int GetPossibleCharacterSet(unsigned char C) { + if (C <= '\x1f') /* Control chars */ return CodeA; if (z_isdigit(C)) - return ZTNum; /* ZTNum=CodeA+CodeB+CodeC */ - if (C==aFNC1) /* FNC1s (GS1) not used */ - return ZTFNC1; /* ZTFNC1=CodeA+CodeB+CodeC+CodeFNC1 */ /* Not reached */ - if (C==aFNC4) + return ZTNum; /* ZTNum=CodeA+CodeB+CodeC */ + if (C == aFNC1) /* FNC1s (GS1) not used */ + return ZTFNC1; /* ZTFNC1=CodeA+CodeB+CodeC+CodeFNC1 */ /* Not reached */ + if (C == aFNC4) return (CodeA | CodeB | CodeFNC4); - if (C>='\x60' && C<='\x7f') /* 60 to 127 */ + if (C >= '\x60' && C <= '\x7f') /* 60 to 127 */ return CodeB; - return CodeA+CodeB; + return CodeA + CodeB; } /* Create a Table with the following information for each Data character: @@ -97,55 +95,46 @@ static int GetPossibleCharacterSet(unsigned char C) * int CFollowing The number of characters encodable in CodeC if we * start here. */ -static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength) -{ +static void CreateCharacterSetTable(CharacterSetTable T[], unsigned char *data, const int dataLength) { int charCur; int runChar; /* Treat the Data backwards */ - charCur=dataLength-1; - T[charCur].CharacterSet=GetPossibleCharacterSet(data[charCur]); - T[charCur].AFollowing=((T[charCur].CharacterSet & CodeA)==0)?0:1; - T[charCur].BFollowing=((T[charCur].CharacterSet & CodeB)==0)?0:1; - T[charCur].CFollowing=0; - - for (charCur--;charCur>=0;charCur--) - { - T[charCur].CharacterSet=GetPossibleCharacterSet(data[charCur]); - T[charCur].AFollowing= - ((T[charCur].CharacterSet & CodeA)==0)?0:T[charCur+1].AFollowing+1; - T[charCur].BFollowing= - ((T[charCur].CharacterSet & CodeB)==0)?0:T[charCur+1].BFollowing+1; - T[charCur].CFollowing=0; + charCur = dataLength - 1; + T[charCur].CharacterSet = GetPossibleCharacterSet(data[charCur]); + T[charCur].AFollowing = ((T[charCur].CharacterSet & CodeA) == 0) ? 0 : 1; + T[charCur].BFollowing = ((T[charCur].CharacterSet & CodeB) == 0) ? 0 : 1; + T[charCur].CFollowing = 0; + for (charCur--; charCur >= 0; charCur--) { + T[charCur].CharacterSet = GetPossibleCharacterSet(data[charCur]); + T[charCur].AFollowing = ((T[charCur].CharacterSet & CodeA) == 0) ? 0 : T[charCur + 1].AFollowing + 1; + T[charCur].BFollowing = ((T[charCur].CharacterSet & CodeB) == 0) ? 0 : T[charCur + 1].BFollowing + 1; + T[charCur].CFollowing = 0; } /* Find the CodeC-chains */ - for (charCur=0;charCur=dataLength) + if (runChar >= dataLength) break; /* Only a Number may follow */ - if (T[runChar].CharacterSet==ZTNum) - T[charCur].CFollowing+=2; + if (T[runChar].CharacterSet == ZTNum) + T[charCur].CFollowing += 2; else break; } ++runChar; - } while (runChar0 && runChar 0 && runChar < charCur + T[charCur].CFollowing) { + if (T[runChar].CharacterSet != ZTFNC1) { /* NOT FNC1 */ - digitCount+=2; + digitCount += 2; runChar++; } runChar++; @@ -184,74 +170,66 @@ static int RemainingDigits(CharacterSetTable *T, int charCur,int emptyColumns) * pSet Output of the character sets used, allocated by me. * Return value Resulting row count */ - -static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength, - int * pRows, int * pUseColumns, int * pSet, int * pFillings) -{ - int useColumns; /* Usable Characters per line */ - int fillings = 0; /* Number of filling characters */ +static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength, int *pRows, + int *pUseColumns, int *pSet, int *pFillings) { + int useColumns; /* Usable Characters per line */ + int fillings = 0; /* Number of filling characters */ int rowsCur; int runChar; - int emptyColumns; /* Number of codes still empty in line. */ - int emptyColumns2; /* Alternative emptyColumns to compare */ - int CPaires; /* Number of digit pairs which may fit in the line */ - int characterSetCur; /* Current Character Set */ - int isFNC4; /* Set if current character FNC4 */ + int emptyColumns; /* Number of codes still empty in line. */ + int emptyColumns2; /* Alternative emptyColumns to compare */ + int CPaires; /* Number of digit pairs which may fit in the line */ + int characterSetCur; /* Current Character Set */ + int isFNC4; /* Set if current character FNC4 */ - useColumns=*pUseColumns; + useColumns = *pUseColumns; /* >>> Loop until rowsCur <= 44 */ do { - int charCur=0; - memset(pSet,0,dataLength*sizeof(int)); - rowsCur=0; + int charCur = 0; + memset(pSet, 0, sizeof(int) * dataLength); + rowsCur = 0; /* >>> Line Loop */ - do{ + do { /* >> Start Character */ - emptyColumns=useColumns; /* Remained place in Line */ + emptyColumns = useColumns; /* Remained place in Line */ /* >>Choose in Set A or B */ /* (C is changed as an option later on) */ - pSet[charCur]=characterSetCur= - (T[charCur].AFollowing > T[charCur].BFollowing) - ? CodeA : CodeB; + pSet[charCur] = characterSetCur = (T[charCur].AFollowing > T[charCur].BFollowing) ? CodeA : CodeB; /* >> Test on Numeric Mode C */ - CPaires=RemainingDigits(T,charCur, emptyColumns); - if (CPaires>=4) - { + CPaires = RemainingDigits(T, charCur, emptyColumns); + if (CPaires >= 4) { /* 4 Digits in Numeric compression ->OK */ /* > May an odd start find more ? */ /* Skip leading 's */ /* Typical structure : 12... */ /* Test if numeric after one isn't better.*/ - runChar=charCur; - emptyColumns2=emptyColumns; - while (T[runChar].CharacterSet==ZTFNC1) /* FNC1s (GS1) not used */ - { + runChar = charCur; + emptyColumns2 = emptyColumns; + while (T[runChar].CharacterSet == ZTFNC1) { /* FNC1s (GS1) not used */ ++runChar; /* Not reached */ --emptyColumns2; } - if (CPaires>=RemainingDigits(T,runChar+1,emptyColumns2-1)) - { + if (CPaires >= RemainingDigits(T, runChar + 1, emptyColumns2 - 1)) { /* Start odd is not better */ /* We start in C */ - pSet[charCur]=characterSetCur=CodeC; + pSet[charCur] = characterSetCur = CodeC; /* Increment charCur */ - if (T[charCur].CharacterSet!=ZTFNC1) - ++charCur; /* 2 Num.Digits */ + if (T[charCur].CharacterSet != ZTFNC1) + ++charCur; /* 2 Num.Digits */ } } ++charCur; --emptyColumns; /* >> Following characters */ - while(emptyColumns>0 && charCur 0 && charCur < dataLength) { isFNC4 = (T[charCur].CharacterSet & CodeFNC4); - switch(characterSetCur){ + switch (characterSetCur) { case CodeA: case CodeB: /* >> Check switching to CodeC */ @@ -260,105 +238,94 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const * - 4 real Digits will fit in line * - an odd Start will not be better */ - if (T[charCur].CharacterSet==ZTNum - && (CPaires=RemainingDigits(T,charCur, emptyColumns-1))>=4 - && CPaires > RemainingDigits(T,charCur+1,emptyColumns-2)) - { + if (T[charCur].CharacterSet == ZTNum + && (CPaires = RemainingDigits(T, charCur, emptyColumns - 1)) >= 4 + && CPaires > RemainingDigits(T, charCur + 1, emptyColumns - 2)) { /* > Change to C */ - pSet[charCur]=characterSetCur=CodeC; - charCur+=2; /* 2 Digit */ - emptyColumns-=2; /* 12 */ - } else if (characterSetCur==CodeA) - { - if (T[charCur].AFollowing == 0 || (isFNC4 && T[charCur].AFollowing == 1)) - { + pSet[charCur] = characterSetCur = CodeC; + charCur += 2; /* 2 Digit */ + emptyColumns -= 2; /* 12 */ + } else if (characterSetCur == CodeA) { + if (T[charCur].AFollowing == 0 || (isFNC4 && T[charCur].AFollowing == 1)) { /* Must change to B */ - if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2)) - { + if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2)) { /* Can't switch: */ - pSet[charCur-1]|=CEnd+CFill; - emptyColumns=0; - }else{ + pSet[charCur - 1] |= CEnd + CFill; + emptyColumns = 0; + } else { /* or ? */ - if (T[charCur].BFollowing == 1 || (isFNC4 && T[charCur].BFollowing == 2)) - { - /* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" as - given in Table B.1 and Table B.2 */ + if (T[charCur].BFollowing == 1 || (isFNC4 && T[charCur].BFollowing == 2)) { + /* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" + as given in Table B.1 and Table B.2 */ if (isFNC4) { /* So skip FNC4 and shift value instead */ --emptyColumns; ++charCur; } - pSet[charCur]|=CShift; + pSet[charCur] |= CShift; } else { - pSet[charCur]|=CodeB; + pSet[charCur] |= CodeB; characterSetCur = CodeB; } - emptyColumns-=2; + emptyColumns -= 2; ++charCur; } } else if (isFNC4 && emptyColumns == 1) { /* Can't fit extended ASCII on same line */ - pSet[charCur-1]|=CEnd+CFill; - emptyColumns=0; - }else{ + pSet[charCur - 1] |= CEnd + CFill; + emptyColumns = 0; + } else { --emptyColumns; ++charCur; } } else { /* Last possibility : CodeB */ - if (T[charCur].BFollowing == 0 || (isFNC4 && T[charCur].BFollowing == 1)) - { + if (T[charCur].BFollowing == 0 || (isFNC4 && T[charCur].BFollowing == 1)) { /* Must change to A */ - if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2)) - { + if (emptyColumns == 1 || (isFNC4 && emptyColumns == 2)) { /* Can't switch: */ - pSet[charCur-1]|=CEnd+CFill; - emptyColumns=0; + pSet[charCur - 1] |= CEnd + CFill; + emptyColumns = 0; } else { /* or ? */ - if (T[charCur].AFollowing == 1 || (isFNC4 && T[charCur].AFollowing == 2)) - { - /* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" as - given in Table B.1 and Table B.2 */ + if (T[charCur].AFollowing == 1 || (isFNC4 && T[charCur].AFollowing == 2)) { + /* Note using order "FNC4 shift char" (same as CODE128) not "shift FNC4 char" + as given in Table B.1 and Table B.2 */ if (isFNC4) { /* So skip FNC4 and shift value instead */ --emptyColumns; ++charCur; } - pSet[charCur]|=CShift; + pSet[charCur] |= CShift; } else { - pSet[charCur]|=CodeA; + pSet[charCur] |= CodeA; characterSetCur = CodeA; } - emptyColumns-=2; + emptyColumns -= 2; ++charCur; } } else if (isFNC4 && emptyColumns == 1) { /* Can't fit extended ASCII on same line */ - pSet[charCur-1]|=CEnd+CFill; - emptyColumns=0; - }else{ + pSet[charCur - 1] |= CEnd + CFill; + emptyColumns = 0; + } else { --emptyColumns; ++charCur; } } break; case CodeC: - if(T[charCur].CFollowing>0) - { - charCur+=(T[charCur].CharacterSet==ZTFNC1)?1:2; + if (T[charCur].CFollowing > 0) { + charCur += (T[charCur].CharacterSet == ZTFNC1) ? 1 : 2; emptyColumns--; - }else{ + } else { /* Must change to A or B */ - if (emptyColumns==1) - { + if (emptyColumns == 1) { /* Can't switch: */ - pSet[charCur-1]|=CEnd+CFill; - emptyColumns=0; - }else{ + pSet[charCur - 1] |= CEnd + CFill; + emptyColumns = 0; + } else { /* or ?*/ - characterSetCur=pSet[charCur]= - (T[charCur].AFollowing > T[charCur].BFollowing) - ?CodeA:CodeB; - emptyColumns-=2; + characterSetCur = pSet[charCur] + = (T[charCur].AFollowing > T[charCur].BFollowing) ? CodeA : CodeB; + emptyColumns -= 2; ++charCur; } } @@ -367,28 +334,24 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const } /* while */ /* > End of Codeline */ - pSet[charCur-1]|=CEnd; + pSet[charCur - 1] |= CEnd; ++rowsCur; - } while (charCur44) { + if (rowsCur > 44) { ++useColumns; if (useColumns > 62) { return ZINT_ERROR_TOO_LONG; @@ -397,32 +360,31 @@ static int Columns2Rows(struct zint_symbol *symbol, CharacterSetTable *T, const rowsCur = 2; fillings += useColumns; } - } while(rowsCur>44); + } while (rowsCur > 44); if (symbol->debug & ZINT_DEBUG_PRINT) { - printf(" -> out: rowsCur <%i>, useColumns <%i>, fillings <%i>\n",rowsCur,useColumns,fillings); + printf(" -> out: rowsCur <%i>, useColumns <%i>, fillings <%i>\n", rowsCur, useColumns, fillings); } - *pUseColumns=useColumns; - *pRows=rowsCur; - *pFillings=fillings; + *pUseColumns = useColumns; + *pRows = rowsCur; + *pFillings = fillings; return 0; } /* Find columns if row count is given. */ -static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength, - int * pRows, int * pUseColumns, int * pSet, int * pFillings) -{ +static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const int dataLength, int *pRows, + int *pUseColumns, int *pSet, int *pFillings) { int rowsCur; - int rowsRequested; /* Number of requested rows */ + int rowsRequested; /* Number of requested rows */ int columnsRequested; /* Number of requested columns (if any) */ int fillings; int useColumns; - int testColumns; /* To enter into Width2Rows */ + int testColumns; /* To enter into Width2Rows */ int testListSize = 0; int pTestList[62 + 1]; int *pBackupSet = (int *) z_alloca(sizeof(int) * dataLength); - rowsRequested=*pRows; + rowsRequested = *pRows; columnsRequested = *pUseColumns >= 4 ? *pUseColumns : 0; if (symbol->debug & ZINT_DEBUG_PRINT) { @@ -433,7 +395,7 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const testColumns = columnsRequested; } else { /* First guess */ - testColumns=dataLength/rowsRequested; + testColumns = dataLength / rowsRequested; if (testColumns > 62) testColumns = 62; else if (testColumns < 4) @@ -444,17 +406,17 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const int errorCur; pTestList[testListSize] = testColumns; testListSize++; - useColumns=testColumns; /* Make a copy because it may be modified */ + useColumns = testColumns; /* Make a copy because it may be modified */ errorCur = Columns2Rows(symbol, T, dataLength, &rowsCur, &useColumns, pSet, &fillings); if (errorCur != 0) return errorCur; - if (rowsCur<=rowsRequested) { + if (rowsCur <= rowsRequested) { /* Less or exactly line number found */ /* check if column count below already tested or at smallest/requested */ int fInTestList = (rowsCur == 2 || testColumns == 4 || testColumns == columnsRequested); int posCur; - for (posCur = 0; posCur < testListSize && ! fInTestList; posCur++) { - if ( pTestList[posCur] == testColumns-1 ) + for (posCur = 0; posCur < testListSize && !fInTestList; posCur++) { + if (pTestList[posCur] == testColumns - 1) fInTestList = 1; } if (fInTestList) { @@ -465,18 +427,18 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const rowsCur = rowsRequested; } /* Exit with actual */ - *pFillings=fillings; - *pRows=rowsCur; + *pFillings = fillings; + *pRows = rowsCur; *pUseColumns = useColumns; return 0; } /* > Test more rows (shorter CDB) */ - memcpy(pBackupSet,pSet,dataLength*sizeof(int)); + memcpy(pBackupSet, pSet, sizeof(int) * dataLength); --testColumns; } else { /* > Too many rows */ /* > Test less rows (longer code) */ - memcpy(pBackupSet,pSet,dataLength*sizeof(int)); + memcpy(pBackupSet, pSet, sizeof(int) * dataLength); if (++testColumns > 62) { return ZINT_ERROR_TOO_LONG; } @@ -486,23 +448,22 @@ static int Rows2Columns(struct zint_symbol *symbol, CharacterSetTable *T, const /* Print a character in character set A */ -static void A2C128_A(uchar **ppOutPos,uchar c) -{ - uchar * pOutPos = *ppOutPos; - switch(c){ - case aCodeB: *pOutPos=100; break; - case aFNC4: *pOutPos=101; break; - case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */ - case aFNC2: *pOutPos=97; break; /* FNC2s (Message Append) not used */ /* Not reached */ - case aFNC3: *pOutPos=96; break; - case aCodeC: *pOutPos=99; break; - case aShift: *pOutPos=98; break; +static void A2C128_A(uchar **ppOutPos, uchar c) { + uchar *pOutPos = *ppOutPos; + switch (c) { + case aCodeB: *pOutPos = 100; break; + case aFNC4: *pOutPos = 101; break; + case aFNC1: *pOutPos = 102; break; /* FNC1s (GS1) not used */ /* Not reached */ + case aFNC2: *pOutPos = 97; break; /* FNC2s (Message Append) not used */ /* Not reached */ + case aFNC3: *pOutPos = 96; break; + case aCodeC: *pOutPos = 99; break; + case aShift: *pOutPos = 98; break; default: /* +++ HaO 13.11.98 c>' ' && c < '\x1F' corrected */ - if(c>=' ' && c<='_') - *pOutPos=(uchar)(c-' '); + if (c >= ' ' && c <= '_') + *pOutPos = (uchar) (c - ' '); else - *pOutPos=(uchar)(c+64); + *pOutPos = (uchar) (c + 64); break; } (*ppOutPos)++; @@ -510,65 +471,60 @@ static void A2C128_A(uchar **ppOutPos,uchar c) /* Output c in Set B */ -static void A2C128_B(uchar **ppOutPos,uchar c) -{ - uchar * pOutPos = *ppOutPos; - switch(c){ - case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */ - case aFNC2: *pOutPos=97; break; /* FNC2s (Message Append) not used */ /* Not reached */ - case aFNC3: *pOutPos=96; break; - case aFNC4: *pOutPos=100; break; - case aCodeA: *pOutPos=101; break; - case aCodeC: *pOutPos=99; break; - case aShift: *pOutPos=98; break; - default: *pOutPos=(uchar)(c-' '); break; +static void A2C128_B(uchar **ppOutPos, uchar c) { + uchar *pOutPos = *ppOutPos; + switch (c) { + case aFNC1: *pOutPos = 102; break; /* FNC1s (GS1) not used */ /* Not reached */ + case aFNC2: *pOutPos = 97; break; /* FNC2s (Message Append) not used */ /* Not reached */ + case aFNC3: *pOutPos = 96; break; + case aFNC4: *pOutPos = 100; break; + case aCodeA: *pOutPos = 101; break; + case aCodeC: *pOutPos = 99; break; + case aShift: *pOutPos = 98; break; + default: *pOutPos = (uchar) (c - ' '); break; } ++(*ppOutPos); } /* Output c1, c2 in Set C */ -static void A2C128_C(uchar **ppOutPos,uchar c1,uchar c2) -{ - uchar * pOutPos = *ppOutPos; - switch(c1){ - case aFNC1: *pOutPos=102; break; /* FNC1s (GS1) not used */ /* Not reached */ - case aCodeB: *pOutPos=100; break; - case aCodeA: *pOutPos=101; break; - default: *pOutPos=(char)(10 * (c1- '0') + (c2 - '0'));break; +static void A2C128_C(uchar **ppOutPos, uchar c1, uchar c2) { + uchar *pOutPos = *ppOutPos; + switch (c1) { + case aFNC1: *pOutPos = 102; break; /* FNC1s (GS1) not used */ /* Not reached */ + case aCodeB: *pOutPos = 100; break; + case aCodeA: *pOutPos = 101; break; + default: *pOutPos = (uchar) (10 * (c1 - '0') + (c2 - '0')); break; } (*ppOutPos)++; } /* Output a character in Characterset */ -static void ASCIIZ128(uchar **ppOutPos, int CharacterSet,uchar c1, uchar c2) -{ - if (CharacterSet==CodeA) - A2C128_A(ppOutPos,c1); - else if(CharacterSet==CodeB) - A2C128_B(ppOutPos,c1); +static void ASCIIZ128(uchar **ppOutPos, int CharacterSet, uchar c1, uchar c2) { + if (CharacterSet == CodeA) + A2C128_A(ppOutPos, c1); + else if (CharacterSet == CodeB) + A2C128_B(ppOutPos, c1); else - A2C128_C(ppOutPos,c1,c2); + A2C128_C(ppOutPos, c1, c2); } /* XLate Tables D.2, D.3 and F.1 of Codablock-F Specification and call output */ -static void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet) -{ - switch (CharacterSet){ +static void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet) { + switch (CharacterSet) { case CodeA: /* Row # Indicators and Data Check Characters K1/K2 for CodeA and CodeB are the same */ case CodeB: - if (Sum<=31) - A2C128_B(ppOutPos, (uchar)(Sum+96)); - else if(Sum<=47) - A2C128_B(ppOutPos, (uchar)Sum); + if (Sum <= 31) + A2C128_B(ppOutPos, (uchar) (Sum + 96)); + else if (Sum <= 47) + A2C128_B(ppOutPos, (uchar) Sum); else - A2C128_B(ppOutPos, (uchar)(Sum+10)); + A2C128_B(ppOutPos, (uchar) (Sum + 10)); break; case CodeC: - A2C128_C(ppOutPos - ,(char)(Sum/10+'0') ,(uchar)(Sum%10+'0')); + A2C128_C(ppOutPos, (uchar) (Sum / 10 + '0'), (uchar) (Sum % 10 + '0')); break; } } @@ -580,8 +536,8 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int int error_number; int rows, columns, useColumns; int fillings; - int Sum1,Sum2; - uchar * pOutPos; + int Sum1, Sum2; + uchar *pOutPos; int rowCur; int characterSetCur; int emptyColumns; @@ -591,6 +547,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int unsigned char *data; int *pSet; uchar *pOutput; + /* Suppresses clang-analyzer-core.VLASize warning */ assert(length > 0); @@ -621,7 +578,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int } /* option_2: (usable data) columns: <= 0: automatic, 9..67 (min 9 == 4 data, max 67 == 62 data) */ columns = symbol->option_2; - if ( ! (columns <= 0 || (columns >= 9 && columns <= 67)) ) { + if (!(columns <= 0 || (columns >= 9 && columns <= 67))) { strcpy(symbol->errtxt, "411: Columns parameter not in 0, 9..67"); return ZINT_ERROR_INVALID_OPTION; } @@ -635,11 +592,10 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int } /* Replace all Codes>127 with Code-128 */ for (charCur = 0; charCur < length; charCur++) { - if (source[charCur]>127) - { + if (source[charCur] > 127) { data[dataLength] = aFNC4; dataLength++; - data[dataLength] = (unsigned char)(source[charCur]&127); + data[dataLength] = (unsigned char) (source[charCur] & 127); } else data[dataLength] = source[charCur]; dataLength++; @@ -648,7 +604,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int /* Build character set table */ T = (CharacterSetTable *) z_alloca(sizeof(CharacterSetTable) * dataLength); pSet = (int *) z_alloca(sizeof(int) * dataLength); - CreateCharacterSetTable(T,data,dataLength); + CreateCharacterSetTable(T, data, dataLength); /* Find final row and column count */ /* nor row nor column count given */ @@ -666,7 +622,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int } /* There are 5 Codewords for Organisation Start(2),row(1),CheckSum,Stop */ useColumns = columns - 5; - if ( rows > 0 ) { + if (rows > 0) { /* row count given */ error_number = Rows2Columns(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings); } else { @@ -690,30 +646,30 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int if (symbol->debug & ZINT_DEBUG_PRINT) { /* start a new level of local variables */ int DPos; printf("\nData:"); - for (DPos=0 ; DPos< dataLength ; DPos++) - fputc(data[DPos],stdout); + for (DPos = 0; DPos < dataLength; DPos++) + fputc(data[DPos], stdout); printf("\n Set:"); - for (DPos=0 ; DPos< dataLength ; DPos++) { - switch (pSet[DPos]&(CodeA+CodeB+CodeC)) { - case CodeA: fputc('A',stdout); break; - case CodeB: fputc('B',stdout); break; - case CodeC: fputc('C',stdout); break; - default: fputc('.',stdout); break; + for (DPos = 0; DPos < dataLength; DPos++) { + switch (pSet[DPos] & (CodeA + CodeB + CodeC)) { + case CodeA: fputc('A', stdout); break; + case CodeB: fputc('B', stdout); break; + case CodeC: fputc('C', stdout); break; + default: fputc('.', stdout); break; } } printf("\nFNC1:"); - for (DPos=0 ; DPos< dataLength ; DPos++) - fputc((pSet[DPos]&CodeFNC1)==0?'.':'X',stdout); + for (DPos = 0; DPos < dataLength; DPos++) + fputc((pSet[DPos] & CodeFNC1) == 0 ? '.' : 'X', stdout); printf("\n END:"); - for (DPos=0 ; DPos< dataLength ; DPos++) - fputc((pSet[DPos]&CEnd)==0?'.':'X',stdout); + for (DPos = 0; DPos < dataLength; DPos++) + fputc((pSet[DPos] & CEnd) == 0 ? '.' : 'X', stdout); printf("\nShif:"); - for (DPos=0 ; DPos< dataLength ; DPos++) - fputc((pSet[DPos]&CShift)==0?'.':'X',stdout); + for (DPos = 0; DPos < dataLength; DPos++) + fputc((pSet[DPos] & CShift) == 0 ? '.' : 'X', stdout); printf("\nFILL:"); - for (DPos=0 ; DPos< dataLength ; DPos++) - fputc((pSet[DPos]&CFill)==0?'.':'X',stdout); - fputc('\n',stdout); + for (DPos = 0; DPos < dataLength; DPos++) + fputc((pSet[DPos] & CFill) == 0 ? '.' : 'X', stdout); + fputc('\n', stdout); printf("K1 %d, K2 %d\n", Sum1, Sum2); } @@ -723,13 +679,12 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int /* The C128 column count contains Start (2CW), Row ID, Checksum, Stop */ pOutput = (unsigned char *) z_alloca(columns * rows); pOutPos = pOutput; - charCur=0; + charCur = 0; /* >> Loop over rows */ - for (rowCur=0 ; rowCur=dataLength) - { + for (rowCur = 0; rowCur < rows; rowCur++) { + if (charCur >= dataLength) { /* >> Empty line with StartA, aCodeB, row #, and then filler aCodeC aCodeB etc */ - *pOutPos='\x67'; + *pOutPos = '\x67'; pOutPos++; *pOutPos = 100; /* aCodeB */ pOutPos++; @@ -739,35 +694,33 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int if (rowCur == rows - 1) { emptyColumns -= 2; } - while (emptyColumns>0) - { - if(characterSetCur==CodeC) - { - A2C128_C(&pOutPos,aCodeB,'\0'); - characterSetCur=CodeB; - }else{ - A2C128_B(&pOutPos,aCodeC); - characterSetCur=CodeC; + while (emptyColumns > 0) { + if (characterSetCur == CodeC) { + A2C128_C(&pOutPos, aCodeB, '\0'); + characterSetCur = CodeB; + } else { + A2C128_B(&pOutPos, aCodeC); + characterSetCur = CodeC; } --emptyColumns; } - }else{ + } else { /* >> Normal Line */ /* > Startcode */ - switch (pSet[charCur] & (CodeA+CodeB+CodeC)){ + switch (pSet[charCur] & (CodeA + CodeB + CodeC)) { case CodeA: *pOutPos = '\x67'; pOutPos++; *pOutPos = '\x62'; pOutPos++; - characterSetCur=CodeA; + characterSetCur = CodeA; break; case CodeB: *pOutPos = '\x67'; pOutPos++; *pOutPos = '\x64'; pOutPos++; - characterSetCur=CodeB; + characterSetCur = CodeB; break; case CodeC: default: @@ -775,87 +728,77 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int pOutPos++; *pOutPos = '\x63'; pOutPos++; - characterSetCur=CodeC; + characterSetCur = CodeC; break; } /* > Set F1 */ /* In first line : # of rows */ SumASCII(&pOutPos, rowCur == 0 ? rows - 2 : rowCur + 42, characterSetCur); /* >>> Data */ - emptyColumns=useColumns; + emptyColumns = useColumns; /* >> Character loop */ - while (emptyColumns > 0 && charCur < dataLength) - { + while (emptyColumns > 0 && charCur < dataLength) { /* ? Change character set */ - if (emptyColumns < useColumns) - { - if ((pSet[charCur]&CodeA)!=0) - { + if (emptyColumns < useColumns) { + if ((pSet[charCur] & CodeA) != 0) { /* Change to A */ - ASCIIZ128(&pOutPos,characterSetCur,aCodeA,'\0'); + ASCIIZ128(&pOutPos, characterSetCur, aCodeA, '\0'); --emptyColumns; - characterSetCur=CodeA; - } else if ((pSet[charCur]&CodeB)!=0) - { + characterSetCur = CodeA; + } else if ((pSet[charCur] & CodeB) != 0) { /* Change to B */ - ASCIIZ128(&pOutPos,characterSetCur,aCodeB,'\0'); + ASCIIZ128(&pOutPos, characterSetCur, aCodeB, '\0'); --emptyColumns; - characterSetCur=CodeB; - } else if ((pSet[charCur]&CodeC)!=0) - { + characterSetCur = CodeB; + } else if ((pSet[charCur] & CodeC) != 0) { /* Change to C */ - ASCIIZ128(&pOutPos,characterSetCur,aCodeC,'\0'); + ASCIIZ128(&pOutPos, characterSetCur, aCodeC, '\0'); --emptyColumns; - characterSetCur=CodeC; + characterSetCur = CodeC; } } - if ((pSet[charCur]&CShift)!=0) - { + if ((pSet[charCur] & CShift) != 0) { /* >> Shift it and put out the shifted character */ - ASCIIZ128(&pOutPos,characterSetCur,aShift,'\0'); - emptyColumns-=2; - characterSetCur=(characterSetCur==CodeB)?CodeA:CodeB; - ASCIIZ128(&pOutPos,characterSetCur,data[charCur],'\0'); - characterSetCur=(characterSetCur==CodeB)?CodeA:CodeB; - }else{ + ASCIIZ128(&pOutPos, characterSetCur, aShift, '\0'); + emptyColumns -= 2; + characterSetCur = (characterSetCur == CodeB) ? CodeA : CodeB; + ASCIIZ128(&pOutPos, characterSetCur, data[charCur], '\0'); + characterSetCur = (characterSetCur == CodeB) ? CodeA : CodeB; + } else { /* Normal Character */ - if (characterSetCur==CodeC) - { - if (data[charCur]==aFNC1) /* FNC1s (GS1) not used */ - A2C128_C(&pOutPos,aFNC1,'\0'); /* Not reached */ - else - { + if (characterSetCur == CodeC) { + if (data[charCur] == aFNC1) /* FNC1s (GS1) not used */ + A2C128_C(&pOutPos, aFNC1, '\0'); /* Not reached */ + else { A2C128_C(&pOutPos, data[charCur], - (uchar) (charCur + 1 < dataLength ? data[charCur + 1] : 0)); + (uchar) (charCur + 1 < dataLength ? data[charCur + 1] : 0)); ++charCur; /* We need this here to get the good index */ /* for the termination flags in Set. */ } - }else - ASCIIZ128(&pOutPos,characterSetCur,data[charCur],'\0'); + } else + ASCIIZ128(&pOutPos, characterSetCur, data[charCur], '\0'); --emptyColumns; } /* >> End Criteria */ - if ((pSet[charCur] & CFill) || (pSet[charCur] & CEnd)) - { + if ((pSet[charCur] & CFill) || (pSet[charCur] & CEnd)) { /* Fill Line but leave space for checks in last line */ if (rowCur == rows - 1) { emptyColumns -= 2; } - while(emptyColumns>0) - { - switch(characterSetCur){ + while (emptyColumns > 0) { + switch (characterSetCur) { case CodeC: - A2C128_C(&pOutPos,aCodeB,'\0'); - characterSetCur=CodeB; + A2C128_C(&pOutPos, aCodeB, '\0'); + characterSetCur = CodeB; break; case CodeB: - A2C128_B(&pOutPos,aCodeC); - characterSetCur=CodeC; + A2C128_B(&pOutPos, aCodeC); + characterSetCur = CodeC; break; case CodeA: - A2C128_A(&pOutPos,aCodeC); - characterSetCur=CodeC; + A2C128_A(&pOutPos, aCodeC); + characterSetCur = CodeC; break; } --emptyColumns; @@ -863,27 +806,25 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int } ++charCur; } /* Loop over characters */ - } /* if filling-Line / normal */ + } /* if filling-Line / normal */ /* Add checksum in last line */ - if (rowCur == rows - 1) - { - SumASCII(&pOutPos,Sum1,characterSetCur); - SumASCII(&pOutPos,Sum2,characterSetCur); + if (rowCur == rows - 1) { + SumASCII(&pOutPos, Sum1, characterSetCur); + SumASCII(&pOutPos, Sum2, characterSetCur); } /* Add Code 128 checksum */ { int Sum = pOutput[columns * rowCur] % 103; int Pos = 1; - for ( ; Pos < useColumns+3 ; Pos++) - { + for (; Pos < useColumns + 3; Pos++) { Sum = (Sum + pOutput[columns * rowCur + Pos] * Pos) % 103; } - *pOutPos=(uchar)Sum; + *pOutPos = (uchar) Sum; pOutPos++; } /* Add end character */ - *pOutPos=106; + *pOutPos = 106; pOutPos++; } /* End Lineloop */ @@ -891,13 +832,11 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int /* Dump the output to the screen */ printf("\nCode 128 Code Numbers:\n"); - { /* start a new level of local variables */ + { /* start a new level of local variables */ int DPos, DPos2; - for (DPos=0 ; DPos< rows ; DPos++) - { - for (DPos2=0 ; DPos2 < columns ; DPos2++) - { - printf("%3d ",(int)(pOutput[DPos*columns+DPos2])); + for (DPos = 0; DPos < rows; DPos++) { + for (DPos2 = 0; DPos2 < columns; DPos2++) { + printf("%3d ", (int) (pOutput[DPos * columns + DPos2])); } printf("\n"); } @@ -929,7 +868,7 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int min_row_height = 8.0f; } error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, - 0.0f, 0 /*no_errtxt*/); + 0.0f, 0 /*no_errtxt*/); } else { (void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/); } diff --git a/backend/code1.h b/backend/code1.h index 99ade65d..5f9ad231 100644 --- a/backend/code1.h +++ b/backend/code1.h @@ -1,8 +1,7 @@ /* code1.h - Lookup info for USS Code One */ - /* libzint - the open source barcode library - Copyright (C) 2009-2021 Robin Stuart + Copyright (C) 2009-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,7 +28,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef Z_CODE1_H +#define Z_CODE1_H static const char c40_shift[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -59,39 +61,39 @@ static const char text_value[] = { 22, 23, 24, 25, 26, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 27, 28, 29, 30, 31 }; -static const unsigned short int c1_height[] = { +static const unsigned short c1_height[] = { 16, 22, 28, 40, 52, 70, 104, 148 }; -static const unsigned short int c1_width[] = { +static const unsigned short c1_width[] = { 18, 22, 32, 42, 54, 76, 98, 134 }; -static const unsigned short int c1_data_length[] = { +static const unsigned short c1_data_length[] = { 10, 19, 44, 91, 182, 370, 732, 1480 }; -static const unsigned short int c1_ecc_length[] = { +static const unsigned short c1_ecc_length[] = { 10, 16, 26, 44, 70, 140, 280, 560 }; -static const unsigned short int c1_blocks[] = { +static const unsigned short c1_blocks[] = { 1, 1, 1, 1, 1, 2, 4, 8 }; -static const unsigned short int c1_data_blocks[] = { +static const unsigned short c1_data_blocks[] = { 10, 19, 44, 91, 182, 185, 183, 185 }; -static const unsigned short int c1_ecc_blocks[] = { +static const unsigned short c1_ecc_blocks[] = { 10, 16, 26, 44, 70, 70, 70, 70 }; -static const unsigned short int c1_grid_width[] = { +static const unsigned short c1_grid_width[] = { 4, 5, 7, 9, 12, 17, 22, 30 }; -static const unsigned short int c1_grid_height[] = { +static const unsigned short c1_grid_height[] = { 5, 7, 10, 15, 21, 30, 46, 68 }; @@ -101,3 +103,6 @@ static const unsigned short int c1_grid_height[] = { #define C1_TEXT 4 #define C1_EDI 5 #define C1_BYTE 6 + +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_CODE1_H */ diff --git a/backend/code128.h b/backend/code128.h index 93336241..1d9f1474 100644 --- a/backend/code128.h +++ b/backend/code128.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 - 2021 Robin Stuart + Copyright (C) 2020-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -27,10 +27,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ -#ifndef CODE128_H -#define CODE128_H +#ifndef Z_CODE128_H +#define Z_CODE128_H #ifdef __cplusplus extern "C" { @@ -63,4 +63,5 @@ INTERNAL_DATA_EXTERN const char C128Table[107][6]; } #endif /* __cplusplus */ -#endif /* CODE128_H */ +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_CODE128_H */ diff --git a/backend/code16k.c b/backend/code16k.c index 14c15420..82605fff 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -1,8 +1,7 @@ /* code16k.c - Handles Code 16k stacked symbology */ - /* libzint - the open source barcode library - Copyright (C) 2008 - 2021 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,16 +28,16 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ /* Updated to comply with BS EN 12323:2005 */ /* Code 16k can hold up to 77 characters or 154 numbers */ -#include -#include #include "common.h" #include "code128.h" +#include +#include /* Note using C128Table with extra entry at 106 (Triple Shift) for C16KTable */ @@ -413,3 +412,5 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len return error_number; } + +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/code49.h b/backend/code49.h index f781a9e7..1eba383d 100644 --- a/backend/code49.h +++ b/backend/code49.h @@ -1,8 +1,7 @@ /* code49.h - Code 49 Tables */ - /* libzint - the open source barcode library - Copyright (C) 2009-2021 Robin Stuart + Copyright (C) 2009-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,7 +28,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef Z_CODE49_H +#define Z_CODE49_H /* This data set taken from ANSI/AIM-BC6-2000, 4th April 2000 */ @@ -72,7 +74,7 @@ static const char c49_table4[8][4] = { {'O','E','O','E'}, {'E','O','O','E'}, {'O','O','O','O'}, {'E','E','E','E'} }; -static const unsigned short int c49_even_bitpattern[] = { +static const unsigned short c49_even_bitpattern[] = { /* Appendix E - Code 49 Encodation Patterns (Even Symbol Character Parity) */ 0xBE5C, 0xC16E, 0x86DC, 0xC126, 0x864C, 0x9EDC, 0xC726, 0x9E4C, 0xDF26, 0x82CC, 0x8244, 0x8ECC, 0xC322, 0x8E44, 0xBECC, 0xCF22, 0xBE44, 0xC162, 0x86C4, 0xC762, @@ -317,7 +319,7 @@ static const unsigned short int c49_even_bitpattern[] = { 0xCF2E }; -static const unsigned short int c49_odd_bitpattern[] = { +static const unsigned short c49_odd_bitpattern[] = { /* Appendix E - Code 49 Encodation Patterns (Odd Symbol Character Parity) */ 0xC940, 0xF250, 0xECA0, 0xFB28, 0xE5A0, 0xF968, 0xDB40, 0xF6D0, 0xFDB4, 0xC4A0, 0xF128, 0x9940, 0xE650, 0xF994, 0xDCA0, 0xF728, 0xFDCA, 0x8B40, 0xE2D0, 0xCDA0, @@ -561,3 +563,6 @@ static const unsigned short int c49_odd_bitpattern[] = { 0x990E, 0x8B0E, 0x8906, 0xBB0E, 0xB906, 0x9B06, 0x9902, 0xA2FC, 0xD37E, 0xD13E, 0xAEFC }; + +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_CODE49_H */ diff --git a/backend/composite.h b/backend/composite.h index c202322d..ed2b5398 100644 --- a/backend/composite.h +++ b/backend/composite.h @@ -1,8 +1,7 @@ /* composite.c - Tables for UCC.EAN Composite Symbols */ - /* libzint - the open source barcode library - Copyright (C) 2008 - 2020 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,10 +28,13 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef Z_COMPOSITE_H +#define Z_COMPOSITE_H /* CC-A component coefficients from ISO/IEC 24728:2006 Annex F */ -static const unsigned short int ccaCoeffs[30] = { +static const unsigned short ccaCoeffs[30] = { /* k = 4 */ 522, 568, 723, 809, @@ -138,3 +140,6 @@ static const UINT pwr928[69][7] = { { 231, 54, 222, 565, 282, 130, 192, }, { 462, 108, 445, 202, 564, 260, 384, }, }; + +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_COMPOSITE_H */ diff --git a/backend/dllversion.c b/backend/dllversion.c index 62b02698..7e353547 100644 --- a/backend/dllversion.c +++ b/backend/dllversion.c @@ -1,8 +1,7 @@ /* Sed: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/versions.asp */ - /* libzint - the open source barcode library - Copyright (C) 2008 - 2021 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,7 +28,8 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + #if defined (_WIN32) && (defined(_USRDLL) || defined(DLL_EXPORT) || defined(PIC)) #include #include @@ -40,14 +40,13 @@ extern "C" { #endif -__declspec(dllexport) HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi); +__declspec(dllexport) HRESULT DllGetVersion(DLLVERSIONINFO2 *pdvi); #ifdef __cplusplus } #endif -HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi) -{ +HRESULT DllGetVersion(DLLVERSIONINFO2 *pdvi) { if (!pdvi || (sizeof(*pdvi) != pdvi->info1.cbSize)) return (E_INVALIDARG); @@ -64,4 +63,5 @@ HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi) #else /* https://stackoverflow.com/a/26541331 Suppresses gcc warning ISO C forbids an empty translation unit */ typedef int make_iso_compilers_happy; +/* vim: set ts=4 sw=4 et : */ #endif /* _WIN32 */ diff --git a/backend/dmatrix.h b/backend/dmatrix.h index b11ed544..de444585 100644 --- a/backend/dmatrix.h +++ b/backend/dmatrix.h @@ -75,11 +75,11 @@ static const char dm_text_value[] = { }; /* Position in option array [symbol option value - 1] -// The position in the option array is by increasing total data codewords with square first -// The last comment value is the total data codewords value. -// The index of this array is the --vers parameter value -1 and is given as first comment value */ + The position in the option array is by increasing total data codewords with square first + The last comment value is the total data codewords value. + The index of this array is the --vers parameter value -1 and is given as first comment value */ -static const unsigned short int dm_intsymbol[] = { +static const unsigned short dm_intsymbol[] = { /* Standard DM */ 0, /* 1: 10x10 , 3*/ 1, /* 2: 12x12 , 5*/ 3, /* 3: 14x14 , 8*/ 5, /* 4: 16x16 , 12*/ 7, /* 5: 18x18 , 18*/ 9, /* 6: 20x20 , 22*/ 12, /* 7: 22x22 , 30*/ 15, /* 8: 24x24 , 36*/ @@ -122,7 +122,7 @@ static const char dm_isDMRE[] = { /* Horizontal matrix size */ -static const unsigned short int dm_matrixH[] = { +static const unsigned short dm_matrixH[] = { /* 0*/ 10, /* 10x10 , 3*/ 12, /* 12x12 , 5 */ 8, /* 8x18 , 5*/ 14, /* 14x14 , 8*/ /* 4*/ 8, /* 8x32 , 10*/ 16, /* 16x16 , 12*/ 12, /* 12x26 , 16*/ 18, /* 18x18 , 18*/ /* 8*/ 8, /* 8x48 , 18*/ 20, /* 20x20 , 22*/ 12, /* 12x36 , 22*/ 8, /* 8x64 , 24*/ @@ -139,7 +139,7 @@ static const unsigned short int dm_matrixH[] = { /* Vertical matrix sizes */ -static const unsigned short int dm_matrixW[] = { +static const unsigned short dm_matrixW[] = { /* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */ /* 4*/ 32, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */ /* 8*/ 48, /* 8x48 */ 20, /* 20x20 */ 36, /* 12x36 */ 64, /* 8x64 */ @@ -157,7 +157,7 @@ static const unsigned short int dm_matrixW[] = { /* Horizontal submodule size (including subfinder) */ -static const unsigned short int dm_matrixFH[] = { +static const unsigned short dm_matrixFH[] = { /* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 8, /* 8x18 */ 14, /* 14x14 */ /* 4*/ 8, /* 8x32 */ 16, /* 16x16 */ 12, /* 12x26 */ 18, /* 18x18 */ /* 8*/ 8, /* 8x48 */ 20, /* 20x20 */ 12, /* 12x36 */ 8, /* 8x64 */ @@ -174,7 +174,7 @@ static const unsigned short int dm_matrixFH[] = { /* Vertical submodule size (including subfinder) */ -static const unsigned short int dm_matrixFW[] = { +static const unsigned short dm_matrixFW[] = { /* 0*/ 10, /* 10x10 */ 12, /* 12x12 */ 18, /* 8x18 */ 14, /* 14x14 */ /* 4*/ 16, /* 8x32 */ 16, /* 16x16 */ 26, /* 12x26 */ 18, /* 18x18 */ /* 8*/ 24, /* 8x48 */ 20, /* 20x20 */ 18, /* 12x36 */ 16, /* 8x64 */ @@ -191,7 +191,7 @@ static const unsigned short int dm_matrixFW[] = { /* Total Data Codewords */ -static const unsigned short int dm_matrixbytes[] = { +static const unsigned short dm_matrixbytes[] = { /* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */ /* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */ /* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */ @@ -208,7 +208,7 @@ static const unsigned short int dm_matrixbytes[] = { /* Data Codewords per RS-Block */ -static const unsigned short int dm_matrixdatablock[] = { +static const unsigned short dm_matrixdatablock[] = { /* 0*/ 3, /* 10x10 */ 5, /* 12x12 */ 5, /* 8x18 */ 8, /* 14x14 */ /* 4*/ 10, /* 8x32 */ 12, /* 16x16 */ 16, /* 12x26 */ 18, /* 18x18 */ /* 8*/ 18, /* 8x48 */ 22, /* 20x20 */ 22, /* 12x36 */ 24, /* 8x64 */ @@ -225,7 +225,7 @@ static const unsigned short int dm_matrixdatablock[] = { /* ECC Codewords per RS-Block */ -static const unsigned short int dm_matrixrsblock[] = { +static const unsigned short dm_matrixrsblock[] = { /* 0*/ 5, /* 10x10 */ 7, /* 12x12 */ 7, /* 8x18 */ 10, /* 14x14 */ /* 4*/ 11, /* 8x32 */ 12, /* 16x16 */ 14, /* 12x26 */ 14, /* 18x18 */ /* 8*/ 15, /* 8x48 */ 18, /* 20x20 */ 18, /* 12x36 */ 18, /* 8x64 */ diff --git a/backend/dmatrix_trace.h b/backend/dmatrix_trace.h index 32ea562f..52329986 100644 --- a/backend/dmatrix_trace.h +++ b/backend/dmatrix_trace.h @@ -1,8 +1,7 @@ /* dmatrix_trace.h - Trace routines for DM_COMPRESSION algorithm */ - /* libzint - the open source barcode library - Copyright (C) 2021 Robin Stuart + Copyright (C) 2021-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,7 +28,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef Z_DMATRIX_TRACE_H #define Z_DMATRIX_TRACE_H @@ -151,4 +150,5 @@ static void DM_TRACE_NotAddEdge(const unsigned char *source, const int length, s } #endif /* DM_TRACE */ +/* vim: set ts=4 sw=4 et : */ #endif /* Z_DMATRIX_TRACE_H */ diff --git a/backend/eci.h b/backend/eci.h index 12cf0f5f..272aad28 100644 --- a/backend/eci.h +++ b/backend/eci.h @@ -1,5 +1,5 @@ -/* eci.c - Extended Channel Interpretations to Unicode tables - +/* eci.c - Extended Channel Interpretations to Unicode tables */ +/* libzint - the open source barcode library Copyright (C) 2009-2022 Robin Stuart @@ -28,6 +28,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef Z_ECI_H #define Z_ECI_H diff --git a/backend/general_field.h b/backend/general_field.h index b43ac588..f4b3af7c 100644 --- a/backend/general_field.h +++ b/backend/general_field.h @@ -27,6 +27,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef Z_GENERAL_FIELD_H #define Z_GENERAL_FIELD_H diff --git a/backend/gs1.h b/backend/gs1.h index dfa7c539..9e3857f7 100644 --- a/backend/gs1.h +++ b/backend/gs1.h @@ -1,5 +1,4 @@ /* gs1.h - Verifies GS1 data */ - /* libzint - the open source barcode library Copyright (C) 2009-2022 Robin Stuart @@ -29,6 +28,8 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ + #ifndef Z_GS1_H #define Z_GS1_H diff --git a/backend/imail.c b/backend/imail.c index 7e234614..cac921e4 100644 --- a/backend/imail.c +++ b/backend/imail.c @@ -1,8 +1,7 @@ /* imail.c - Handles Intelligent Mail (aka OneCode) for USPS */ - /* libzint - the open source barcode library - Copyright (C) 2008 - 2021 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,14 +28,14 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ /* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence" is Copyright (C) 2006 United States Postal Service */ -#include #include "common.h" #include "large.h" +#include #define SODIUM_MNS_F (IS_NUM_F | IS_MNS_F) /* SODIUM "0123456789-" */ @@ -187,7 +186,7 @@ static const unsigned short AppxD_II[78] = { 0x0801, 0x1002, 0x1001, 0x0802, 0x0404, 0x0208, 0x0110, 0x00A0 }; -static const unsigned short int AppxD_IV[130] = { +static const unsigned short AppxD_IV[130] = { /* Appendix D Table IV - Bar-to-Character Mapping (reverse lookup) */ 67, 6, 78, 16, 86, 95, 34, 40, 45, 113, 117, 121, 62, 87, 18, 104, 41, 76, 57, 119, 115, 72, 97, 2, 127, 26, 105, 35, 122, 52, 114, 7, 24, 82, 68, 63, 94, 44, 77, 112, 70, 100, 39, 30, 107, @@ -255,7 +254,7 @@ INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int unsigned short usps_crc; unsigned int codeword[10]; unsigned short characters[10]; - short int bar_map[130]; + short bar_map[130]; int zip_len, len; if (length > 32) { @@ -453,3 +452,5 @@ INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int symbol->width = read - 1; return error_number; } + +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/iso3166.h b/backend/iso3166.h index 0a5b221a..fda673b3 100644 --- a/backend/iso3166.h +++ b/backend/iso3166.h @@ -3,7 +3,7 @@ */ /* libzint - the open source barcode library - Copyright (C) 2021 Robin Stuart + Copyright (C) 2021-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -30,9 +30,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ISO3166_H -#define ISO3166_H +#ifndef Z_ISO3166_H +#define Z_ISO3166_H /* Whether ISO 3166-1 numeric */ static int iso3166_numeric(int cc) { @@ -85,4 +86,4 @@ static int iso3166_alpha2(const char *cc) { return codes[cc_int >> 3] & (1 << (cc_int & 0x7)) ? 1 : 0; } -#endif /* ISO3166_H */ +#endif /* Z_ISO3166_H */ diff --git a/backend/maxicode.h b/backend/maxicode.h index 2d224597..f280a607 100644 --- a/backend/maxicode.h +++ b/backend/maxicode.h @@ -1,8 +1,7 @@ /* maxicode.h - Handles Maxicode */ - /* libzint - the open source barcode library - Copyright (C) 2008-2017 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,41 +28,45 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ -static const unsigned short int MaxiGrid[] = { +#ifndef Z_MAXICODE_H +#define Z_MAXICODE_H + +static const unsigned short MaxiGrid[] = { /* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */ /* 30 x 33 data grid */ - 122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0, - 124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0, + 122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0, + 124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0, 126, 125, 132, 131, 138, 137, 144, 143, 150, 149, 156, 155, 162, 161, 168, 167, 174, 173, 180, 179, 186, 185, 192, 191, 198, 197, 204, 203, 819, 818, - 284, 283, 278, 277, 272, 271, 266, 265, 260, 259, 254, 253, 248, 247, 242, 241, 236, 235, 230, 229, 224, 223, 218, 217, 212, 211, 206, 205, 820, 0, + 284, 283, 278, 277, 272, 271, 266, 265, 260, 259, 254, 253, 248, 247, 242, 241, 236, 235, 230, 229, 224, 223, 218, 217, 212, 211, 206, 205, 820, 0, 286, 285, 280, 279, 274, 273, 268, 267, 262, 261, 256, 255, 250, 249, 244, 243, 238, 237, 232, 231, 226, 225, 220, 219, 214, 213, 208, 207, 822, 821, - 288, 287, 282, 281, 276, 275, 270, 269, 264, 263, 258, 257, 252, 251, 246, 245, 240, 239, 234, 233, 228, 227, 222, 221, 216, 215, 210, 209, 823, 0, + 288, 287, 282, 281, 276, 275, 270, 269, 264, 263, 258, 257, 252, 251, 246, 245, 240, 239, 234, 233, 228, 227, 222, 221, 216, 215, 210, 209, 823, 0, 290, 289, 296, 295, 302, 301, 308, 307, 314, 313, 320, 319, 326, 325, 332, 331, 338, 337, 344, 343, 350, 349, 356, 355, 362, 361, 368, 367, 825, 824, - 292, 291, 298, 297, 304, 303, 310, 309, 316, 315, 322, 321, 328, 327, 334, 333, 340, 339, 346, 345, 352, 351, 358, 357, 364, 363, 370, 369, 826, 0, + 292, 291, 298, 297, 304, 303, 310, 309, 316, 315, 322, 321, 328, 327, 334, 333, 340, 339, 346, 345, 352, 351, 358, 357, 364, 363, 370, 369, 826, 0, 294, 293, 300, 299, 306, 305, 312, 311, 318, 317, 324, 323, 330, 329, 336, 335, 342, 341, 348, 347, 354, 353, 360, 359, 366, 365, 372, 371, 828, 827, - 410, 409, 404, 403, 398, 397, 392, 391, 80, 79, 0, 0, 14, 13, 38, 37, 3, 0, 45, 44, 110, 109, 386, 385, 380, 379, 374, 373, 829, 0, - 412, 411, 406, 405, 400, 399, 394, 393, 82, 81, 41, 0, 16, 15, 40, 39, 4, 0, 0, 46, 112, 111, 388, 387, 382, 381, 376, 375, 831, 830, - 414, 413, 408, 407, 402, 401, 396, 395, 84, 83, 42, 0, 0, 0, 0, 0, 6, 5, 48, 47, 114, 113, 390, 389, 384, 383, 378, 377, 832, 0, - 416, 415, 422, 421, 428, 427, 104, 103, 56, 55, 17, 0, 0, 0, 0, 0, 0, 0, 21, 20, 86, 85, 434, 433, 440, 439, 446, 445, 834, 833, - 418, 417, 424, 423, 430, 429, 106, 105, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 23, 22, 88, 87, 436, 435, 442, 441, 448, 447, 835, 0, - 420, 419, 426, 425, 432, 431, 108, 107, 60, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 90, 89, 438, 437, 444, 443, 450, 449, 837, 836, - 482, 481, 476, 475, 470, 469, 49, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 54, 53, 464, 463, 458, 457, 452, 451, 838, 0, - 484, 483, 478, 477, 472, 471, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 466, 465, 460, 459, 454, 453, 840, 839, - 486, 485, 480, 479, 474, 473, 52, 51, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 43, 468, 467, 462, 461, 456, 455, 841, 0, - 488, 487, 494, 493, 500, 499, 98, 97, 62, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 92, 91, 506, 505, 512, 511, 518, 517, 843, 842, - 490, 489, 496, 495, 502, 501, 100, 99, 64, 63, 0, 0, 0, 0, 0, 0, 0, 0, 29, 28, 94, 93, 508, 507, 514, 513, 520, 519, 844, 0, - 492, 491, 498, 497, 504, 503, 102, 101, 66, 65, 18, 0, 0, 0, 0, 0, 0, 0, 19, 30, 96, 95, 510, 509, 516, 515, 522, 521, 846, 845, - 560, 559, 554, 553, 548, 547, 542, 541, 74, 73, 33, 0, 0, 0, 0, 0, 0, 11, 68, 67, 116, 115, 536, 535, 530, 529, 524, 523, 847, 0, - 562, 561, 556, 555, 550, 549, 544, 543, 76, 75, 0, 0, 8, 7, 36, 35, 12, 0, 70, 69, 118, 117, 538, 537, 532, 531, 526, 525, 849, 848, - 564, 563, 558, 557, 552, 551, 546, 545, 78, 77, 0, 34, 10, 9, 26, 25, 0, 0, 72, 71, 120, 119, 540, 539, 534, 533, 528, 527, 850, 0, + 410, 409, 404, 403, 398, 397, 392, 391, 80, 79, 0, 0, 14, 13, 38, 37, 3, 0, 45, 44, 110, 109, 386, 385, 380, 379, 374, 373, 829, 0, + 412, 411, 406, 405, 400, 399, 394, 393, 82, 81, 41, 0, 16, 15, 40, 39, 4, 0, 0, 46, 112, 111, 388, 387, 382, 381, 376, 375, 831, 830, + 414, 413, 408, 407, 402, 401, 396, 395, 84, 83, 42, 0, 0, 0, 0, 0, 6, 5, 48, 47, 114, 113, 390, 389, 384, 383, 378, 377, 832, 0, + 416, 415, 422, 421, 428, 427, 104, 103, 56, 55, 17, 0, 0, 0, 0, 0, 0, 0, 21, 20, 86, 85, 434, 433, 440, 439, 446, 445, 834, 833, + 418, 417, 424, 423, 430, 429, 106, 105, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 23, 22, 88, 87, 436, 435, 442, 441, 448, 447, 835, 0, + 420, 419, 426, 425, 432, 431, 108, 107, 60, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 90, 89, 438, 437, 444, 443, 450, 449, 837, 836, + 482, 481, 476, 475, 470, 469, 49, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 54, 53, 464, 463, 458, 457, 452, 451, 838, 0, + 484, 483, 478, 477, 472, 471, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 466, 465, 460, 459, 454, 453, 840, 839, + 486, 485, 480, 479, 474, 473, 52, 51, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 43, 468, 467, 462, 461, 456, 455, 841, 0, + 488, 487, 494, 493, 500, 499, 98, 97, 62, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 92, 91, 506, 505, 512, 511, 518, 517, 843, 842, + 490, 489, 496, 495, 502, 501, 100, 99, 64, 63, 0, 0, 0, 0, 0, 0, 0, 0, 29, 28, 94, 93, 508, 507, 514, 513, 520, 519, 844, 0, + 492, 491, 498, 497, 504, 503, 102, 101, 66, 65, 18, 0, 0, 0, 0, 0, 0, 0, 19, 30, 96, 95, 510, 509, 516, 515, 522, 521, 846, 845, + 560, 559, 554, 553, 548, 547, 542, 541, 74, 73, 33, 0, 0, 0, 0, 0, 0, 11, 68, 67, 116, 115, 536, 535, 530, 529, 524, 523, 847, 0, + 562, 561, 556, 555, 550, 549, 544, 543, 76, 75, 0, 0, 8, 7, 36, 35, 12, 0, 70, 69, 118, 117, 538, 537, 532, 531, 526, 525, 849, 848, + 564, 563, 558, 557, 552, 551, 546, 545, 78, 77, 0, 34, 10, 9, 26, 25, 0, 0, 72, 71, 120, 119, 540, 539, 534, 533, 528, 527, 850, 0, 566, 565, 572, 571, 578, 577, 584, 583, 590, 589, 596, 595, 602, 601, 608, 607, 614, 613, 620, 619, 626, 625, 632, 631, 638, 637, 644, 643, 852, 851, - 568, 567, 574, 573, 580, 579, 586, 585, 592, 591, 598, 597, 604, 603, 610, 609, 616, 615, 622, 621, 628, 627, 634, 633, 640, 639, 646, 645, 853, 0, + 568, 567, 574, 573, 580, 579, 586, 585, 592, 591, 598, 597, 604, 603, 610, 609, 616, 615, 622, 621, 628, 627, 634, 633, 640, 639, 646, 645, 853, 0, 570, 569, 576, 575, 582, 581, 588, 587, 594, 593, 600, 599, 606, 605, 612, 611, 618, 617, 624, 623, 630, 629, 636, 635, 642, 641, 648, 647, 855, 854, - 728, 727, 722, 721, 716, 715, 710, 709, 704, 703, 698, 697, 692, 691, 686, 685, 680, 679, 674, 673, 668, 667, 662, 661, 656, 655, 650, 649, 856, 0, + 728, 727, 722, 721, 716, 715, 710, 709, 704, 703, 698, 697, 692, 691, 686, 685, 680, 679, 674, 673, 668, 667, 662, 661, 656, 655, 650, 649, 856, 0, 730, 729, 724, 723, 718, 717, 712, 711, 706, 705, 700, 699, 694, 693, 688, 687, 682, 681, 676, 675, 670, 669, 664, 663, 658, 657, 652, 651, 858, 857, - 732, 731, 726, 725, 720, 719, 714, 713, 708, 707, 702, 701, 696, 695, 690, 689, 684, 683, 678, 677, 672, 671, 666, 665, 660, 659, 654, 653, 859, 0, + 732, 731, 726, 725, 720, 719, 714, 713, 708, 707, 702, 701, 696, 695, 690, 689, 684, 683, 678, 677, 672, 671, 666, 665, 660, 659, 654, 653, 859, 0, 734, 733, 740, 739, 746, 745, 752, 751, 758, 757, 764, 763, 770, 769, 776, 775, 782, 781, 788, 787, 794, 793, 800, 799, 806, 805, 812, 811, 861, 860, - 736, 735, 742, 741, 748, 747, 754, 753, 760, 759, 766, 765, 772, 771, 778, 777, 784, 783, 790, 789, 796, 795, 802, 801, 808, 807, 814, 813, 862, 0, + 736, 735, 742, 741, 748, 747, 754, 753, 760, 759, 766, 765, 772, 771, 778, 777, 784, 783, 790, 789, 796, 795, 802, 801, 808, 807, 814, 813, 862, 0, 738, 737, 744, 743, 750, 749, 756, 755, 762, 761, 768, 767, 774, 773, 780, 779, 786, 785, 792, 791, 798, 797, 804, 803, 810, 809, 816, 815, 864, 863 }; @@ -102,3 +105,5 @@ static const char maxiSymbolChar[256] = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36 }; +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_MAXICODE_H */ diff --git a/backend/medical.c b/backend/medical.c index 0d057844..0566bb33 100644 --- a/backend/medical.c +++ b/backend/medical.c @@ -1,5 +1,4 @@ /* medical.c - Handles 1 track and 2 track pharmacode and Codabar */ - /* libzint - the open source barcode library Copyright (C) 2008-2022 Robin Stuart @@ -29,9 +28,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ -#include #include "common.h" +#include INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length); diff --git a/backend/output.h b/backend/output.h index be5e51b7..ca356ccf 100644 --- a/backend/output.h +++ b/backend/output.h @@ -1,7 +1,7 @@ -/* output.h - Common routines for raster/vector - +/* output.h - Common routines for raster/vector */ +/* libzint - the open source barcode library - Copyright (C) 2020 - 2021 Robin Stuart + Copyright (C) 2020-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -28,7 +28,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef Z_OUTPUT_H #define Z_OUTPUT_H @@ -52,4 +52,5 @@ INTERNAL void out_upcean_split_text(int upceanflag, unsigned char text[], } #endif /* __cplusplus */ +/* vim: set ts=4 sw=4 et : */ #endif /* Z_OUTPUT_H */ diff --git a/backend/pdf417.h b/backend/pdf417.h index 13154443..139e55cc 100644 --- a/backend/pdf417.h +++ b/backend/pdf417.h @@ -1,5 +1,4 @@ /* pdf417.h - PDF417 tables and coefficients declarations */ - /* libzint - the open source barcode library Copyright (C) 2008-2022 Robin Stuart @@ -30,6 +29,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ /* See "pdf417_tabs.h" for table definitions */ diff --git a/backend/pdf417_tabs.h b/backend/pdf417_tabs.h index bf85a3da..0cb42cd1 100644 --- a/backend/pdf417_tabs.h +++ b/backend/pdf417_tabs.h @@ -1,5 +1,4 @@ /* pdf417_tabs.h - PDF417 tables and coefficients */ - /* libzint - the open source barcode library Copyright (C) 2008-2022 Robin Stuart @@ -30,6 +29,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ /* this file contains the character table, the pre-calculated coefficients and the codeword patterns taken from lines 416 to 454 of pdf417.frm */ diff --git a/backend/postal.c b/backend/postal.c index bf909aed..2e919c2b 100644 --- a/backend/postal.c +++ b/backend/postal.c @@ -145,7 +145,7 @@ static int postnet_enc(struct zint_symbol *symbol, const unsigned char source[], strcpy(symbol->errtxt, "480: Input too long (38 character maximum)"); return ZINT_ERROR_TOO_LONG; } - + if (symbol->symbology == BARCODE_CEPNET) { if (length != 8) { strcpy(symbol->errtxt, "780: Input is wrong length (should be 8 digits)"); diff --git a/backend/reedsol.h b/backend/reedsol.h index 5b6163ec..066ccaa8 100644 --- a/backend/reedsol.h +++ b/backend/reedsol.h @@ -1,7 +1,10 @@ /* - This is a simple Reed-Solomon encoder (C) Cliff Hones 2004 +*/ +/* + libzint - the open source barcode library + Copyright (C) 2009-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,7 +32,7 @@ SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef Z_REEDSOL_H #define Z_REEDSOL_H @@ -72,4 +75,5 @@ INTERNAL void rs_uint_free(rs_uint_t *rs_uint); } #endif /* __cplusplus */ +/* vim: set ts=4 sw=4 et : */ #endif /* Z_REEDSOL_H */ diff --git a/backend/reedsol_logs.h b/backend/reedsol_logs.h index c902c07e..baaf98dc 100644 --- a/backend/reedsol_logs.h +++ b/backend/reedsol_logs.h @@ -1,7 +1,7 @@ -/* reedsol_logs.h - Log and antilog tables for Reed-Solomon - +/* reedsol_logs.h - Log and antilog tables for Reed-Solomon */ +/* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -28,10 +28,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ -#ifndef REEDSOL_LOGS_H -#define REEDSOL_LOGS_H +#ifndef Z_REEDSOL_LOGS_H +#define Z_REEDSOL_LOGS_H /* Static log/antilog tables for prime polys of up to degree 8 (> 8 too large so generated at runtime instead). * Antilog tables doubled to avoid mod. */ @@ -261,4 +261,5 @@ static const unsigned char alog_0x163[510] = { 0x4C, 0x98, 0x53, 0xA6, 0x2F, 0x5E, 0xBC, 0x1B, 0x36, 0x6C, 0xD8, 0xD3, 0xC5, 0xE9, 0xB1, }; -#endif /* REEDSOL_LOGS_H */ +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_REEDSOL_LOGS_H */ diff --git a/backend/rss.h b/backend/rss.h index 5676a572..72b4894b 100644 --- a/backend/rss.h +++ b/backend/rss.h @@ -1,8 +1,7 @@ /* rss.h - Data tables for Reduced Space Symbology */ - /* libzint - the open source barcode library - Copyright (C) 2007 - 2020 Robin Stuart + Copyright (C) 2007-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,10 +28,13 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef Z_RSS_H +#define Z_RSS_H /* RSS-14 Tables */ -static const unsigned short int g_sum_table[9] = { +static const unsigned short g_sum_table[9] = { 0, 161, 961, 2015, 2715, 0, 336, 1036, 1516 }; @@ -77,7 +79,7 @@ static const char checksum_weight[32] = { }; /* RSS Limited Tables */ -static const unsigned short int t_even_ltd[7] = { +static const unsigned short t_even_ltd[7] = { 28, 728, 6454, 203, 2408, 1, 16632 }; @@ -196,11 +198,11 @@ static const char finder_pattern_ltd[1246] = { }; /* RSS Expanded Tables */ -static const unsigned short int g_sum_exp[5] = { +static const unsigned short g_sum_exp[5] = { 0, 348, 1388, 2948, 3988 }; -static const unsigned short int t_even_exp[5] = { +static const unsigned short t_even_exp[5] = { 4, 20, 52, 104, 204 }; @@ -220,7 +222,7 @@ static const char widest_even_exp[5] = { 2, 4, 5, 6, 8 }; -static const unsigned short int checksum_weight_exp[184] = { +static const unsigned short checksum_weight_exp[184] = { /* Table 14 */ 1, 3, 9, 27, 81, 32, 96, 77, 20, 60, 180, 118, 143, 7, 21, 63, @@ -290,3 +292,5 @@ static const char weight_rows[210] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20 }; +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_RSS_H */ diff --git a/backend/telepen.c b/backend/telepen.c index e6a526bf..f4315e52 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -1,8 +1,7 @@ /* telepen.c - Handles Telepen and Telepen numeric */ - /* libzint - the open source barcode library - Copyright (C) 2008-2021 Robin Stuart + Copyright (C) 2008-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,15 +28,15 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ /* Telepen Barcode Symbology information and History (BSiH) https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */ #define SODIUM_X_F (IS_NUM_F | IS_UX__F | IS_LX__F) /* SODIUM "0123456789Xx" */ -#include #include "common.h" +#include static const char TeleTable[128][16] = { { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" }, @@ -74,6 +73,7 @@ static const char TeleTable[128][16] = { { "31111111111111" }, { "111311111113" }, { "131111111113" }, {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}, }; + /* Generated by "backend/tests/test_telepen -f generate_lens -g" */ static const char TeleLens[128] = { 8, 10, 8, 10, 10, 8, 8, 12, 8, 10, 8, 10, 10, 10, 10, 12, @@ -224,3 +224,5 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int ustrcpy(symbol->text, temp); return error_number; } + +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/tif_lzw.h b/backend/tif_lzw.h index 61c99674..06ce722a 100644 --- a/backend/tif_lzw.h +++ b/backend/tif_lzw.h @@ -1,7 +1,7 @@ -/* tif_lzw.h - LZW compression for TIFF - +/* tif_lzw.h - LZW compression for TIFF */ +/* libzint - the open source barcode library - Copyright (C) 2021 Robin Stuart + Copyright (C) 2021-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -28,10 +28,10 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ -#ifndef TIF_LZW_H -#define TIF_LZW_H +#ifndef Z_TIF_LZW_H +#define Z_TIF_LZW_H /* * Adapted from TIFF Library 4.2.0 libtiff/tif_lzw.c */ @@ -370,4 +370,5 @@ static void tif_lzw_init(tif_lzw_state *sp) { sp->enc_hashtab = NULL; } -#endif /* TIF_LZW_H */ +/* vim: set ts=4 sw=4 et : */ +#endif /* Z_TIF_LZW_H */ diff --git a/backend/tools/gen_iso3166_h.php b/backend/tools/gen_iso3166_h.php index da7d7baa..d0d3cf6a 100644 --- a/backend/tools/gen_iso3166_h.php +++ b/backend/tools/gen_iso3166_h.php @@ -2,13 +2,14 @@ /* Generate ISO 3166 include "backend/iso3166.h" for "backend/gs1.c" */ /* libzint - the open source barcode library - Copyright (C) 2021 + Copyright (C) 2021-2022 Robin Stuart */ +/* SPDX-License-Identifier: BSD-3-Clause */ + /* To create "backend/iso3166.h" (from project directory): * * php backend/tools/gen_iso3166_h.php > backend/iso3166.h */ -/* vim: set ts=4 sw=4 et : */ $basename = basename(__FILE__); $dirname = dirname(__FILE__); @@ -122,7 +123,7 @@ if ($print_copyright) { print <<<'EOD' /* libzint - the open source barcode library - Copyright (C) 2021 Robin Stuart + Copyright (C) 2021-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -149,6 +150,7 @@ print <<<'EOD' OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* SPDX-License-Identifier: BSD-3-Clause */ EOD; @@ -156,8 +158,8 @@ EOD; if ($print_h_guard) { print <<<'EOD' -#ifndef ISO3166_H -#define ISO3166_H +#ifndef Z_ISO3166_H +#define Z_ISO3166_H EOD; } @@ -219,7 +221,9 @@ EOD; if ($print_h_guard) { print <<<'EOD' -#endif /* ISO3166_H */ +#endif /* Z_ISO3166_H */ EOD; } + +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/zintconfig.h b/backend/zintconfig.h index 20a18bcc..dbeebfe3 100644 --- a/backend/zintconfig.h +++ b/backend/zintconfig.h @@ -1,7 +1,7 @@ -/* zintconfig.h - the configured options and settings for libzint - +/* zintconfig.h - the configured options and settings for libzint */ +/* libzint - the open source barcode library - Copyright (C) 2021 Robin Stuart + Copyright (C) 2021-2022 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -28,7 +28,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* vim: set ts=4 sw=4 et : */ +/* SPDX-License-Identifier: BSD-3-Clause */ #ifndef ZINTCONFIG_H #define ZINTCONFIG_H @@ -38,4 +38,5 @@ #define ZINT_VERSION_RELEASE 1 #define ZINT_VERSION_BUILD 9 +/* vim: set ts=4 sw=4 et : */ #endif /* ZINTCONFIG_H */