libdmtx 0.7.8.7
libdmtx is a software library that enables programs to read and write Data Matrix barcodes of the modern ECC200 variety.
Loading...
Searching...
No Matches
dmtxencodec40textx12.c File Reference

libdmtx - Data Matrix Encoding/Decoding Library Copyright 2011 Mike Laughton. More...

#include <assert.h>
#include "dmtx.h"
#include "dmtxstatic.h"

Go to the source code of this file.

Macros

#define CHKERR
 
#define CHKSIZE
 
#define CHKPASS
 
#define RETURN_IF_FAIL
 

Functions

static void encodeNextChunkCTX (DmtxEncodeStream *stream, int sizeIdxRequest)
 
static void appendValuesCTX (DmtxEncodeStream *stream, DmtxByteList *valueList)
 
static void appendUnlatchCTX (DmtxEncodeStream *stream)
 
static void completeIfDoneCTX (DmtxEncodeStream *stream, int sizeIdxRequest)
 Complete C40/Text/X12 encoding if it matches a known end-of-symbol condition.
 
static void completePartialC40Text (DmtxEncodeStream *stream, DmtxByteList *valueList, int sizeIdxRequest)
 The remaining values can exist in 3 possible cases:
 
static void completePartialX12 (DmtxEncodeStream *stream, DmtxByteList *valueList, int sizeIdxRequest)
 Partial chunks are not valid in X12.
 
static DmtxBoolean partialX12ChunkRemains (DmtxEncodeStream *stream)
 Return DmtxTrue 1 or 2 X12 values remain, otherwise DmtxFalse.
 
static void pushCTXValues (DmtxByteList *valueList, DmtxByte inputValue, int targetScheme, DmtxPassFail *passFail, int fnc1)
 
static DmtxBoolean isCTX (int scheme)
 
static void shiftValueListBy3 (DmtxByteList *list, DmtxPassFail *passFail)
 

Detailed Description

libdmtx - Data Matrix Encoding/Decoding Library Copyright 2011 Mike Laughton.

All rights reserved. Copyright 2012-2016 Vadim A. Misbakh-Soloviov. All rights reserved.

See LICENSE file in the main project directory for full terms of use and distribution.

Contact: Vadim A. Misbakh-Soloviov dmtx@.nosp@m.mva..nosp@m.name Mike Laughton mike@.nosp@m.drag.nosp@m.onfly.nosp@m.logi.nosp@m.c.com

C40/Text/X12 encoding rules

Definition in file dmtxencodec40textx12.c.

Macro Definition Documentation

◆ CHKERR

#define CHKERR
Value:
{ \
if (stream->status != DmtxStatusEncoding) { \
return; \
} \
}
@ DmtxStatusEncoding
Definition dmtx.h:80

Definition at line 23 of file dmtxencodec40textx12.c.

◆ CHKPASS

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) { \
streamMarkFatal(stream, DmtxErrorUnknown); \
return; \
} \
}
#define DmtxFail
Definition dmtx.h:44
@ DmtxErrorUnknown
Definition dmtxstatic.h:394

Definition at line 40 of file dmtxencodec40textx12.c.

◆ CHKSIZE

#define CHKSIZE
Value:
{ \
if (sizeIdx == DmtxUndefined) { \
streamMarkInvalid(stream, DmtxErrorUnknown); \
return; \
} \
}
#define DmtxUndefined
Definition dmtx.h:40

Definition at line 31 of file dmtxencodec40textx12.c.

◆ RETURN_IF_FAIL

#define RETURN_IF_FAIL
Value:
{ \
if (*passFail == DmtxFail) \
return; \
}

Definition at line 49 of file dmtxencodec40textx12.c.

Function Documentation

◆ appendUnlatchCTX()

static void appendUnlatchCTX ( DmtxEncodeStream * stream)
static

Definition at line 175 of file dmtxencodec40textx12.c.

◆ appendValuesCTX()

static void appendValuesCTX ( DmtxEncodeStream * stream,
DmtxByteList * valueList )
static

Definition at line 141 of file dmtxencodec40textx12.c.

◆ completeIfDoneCTX()

static void completeIfDoneCTX ( DmtxEncodeStream * stream,
int sizeIdxRequest )
static

Complete C40/Text/X12 encoding if it matches a known end-of-symbol condition.

Term Trip Symbol Codeword Cond Size Remain Sequence


(a) 3 2 Special case

  • - UNLATCH [PAD]

Definition at line 203 of file dmtxencodec40textx12.c.

◆ completePartialC40Text()

static void completePartialC40Text ( DmtxEncodeStream * stream,
DmtxByteList * valueList,
int sizeIdxRequest )
static

The remaining values can exist in 3 possible cases:

a) 1 C40/Text/X12 remaining == 1 data b) 2 C40/Text/X12 remaining == 1 shift + 1 data c) 2 C40/Text/X12 remaining == 1 data + 1 data

To distinguish between cases (b) and (c), encode the final input value to C40/Text/X12 in a temporary location and check the resulting length. If it expands to multiple values it represents (b); otherwise it is (c). This accounts for both shift and upper shift conditions.

Note that in cases (a) and (c) the final C40/Text/X12 value encoded in the previous chunk may have been a shift value, but this will be ignored by the decoder due to the implicit shift to ASCII. <– what if symbol is much larger though?

Term Value Symbol Codeword Cond Count Remain Sequence


(b) C40 2 2 C40+C40+0 (d) ASCII 1 1 ASCII (implicit unlatch) (c) ASCII 1 2 UNLATCH ASCII

  • - UNLATCH (finish ASCII)

Definition at line 252 of file dmtxencodec40textx12.c.

◆ completePartialX12()

static void completePartialX12 ( DmtxEncodeStream * stream,
DmtxByteList * valueList,
int sizeIdxRequest )
static

Partial chunks are not valid in X12.

Encode using ASCII instead, using an implied unlatch if there is exactly one ascii codeword and one symbol codeword remaining. Otherwise use explicit unlatch.

Definition at line 345 of file dmtxencodec40textx12.c.

◆ encodeNextChunkCTX()

static void encodeNextChunkCTX ( DmtxEncodeStream * stream,
int sizeIdxRequest )
static

Definition at line 59 of file dmtxencodec40textx12.c.

◆ isCTX()

static DmtxBoolean isCTX ( int scheme)
static

Definition at line 562 of file dmtxencodec40textx12.c.

◆ partialX12ChunkRemains()

static DmtxBoolean partialX12ChunkRemains ( DmtxEncodeStream * stream)
static

Return DmtxTrue 1 or 2 X12 values remain, otherwise DmtxFalse.

Definition at line 405 of file dmtxencodec40textx12.c.

◆ pushCTXValues()

static void pushCTXValues ( DmtxByteList * valueList,
DmtxByte inputValue,
int targetScheme,
DmtxPassFail * passFail,
int fnc1 )
static

Definition at line 450 of file dmtxencodec40textx12.c.

◆ shiftValueListBy3()

static void shiftValueListBy3 ( DmtxByteList * list,
DmtxPassFail * passFail )
static

Definition at line 579 of file dmtxencodec40textx12.c.