+0.2
+ - Rewrite Makefile.
+ - Documentation update.
+ - Exclude double include of header files.
+ - Layout cahnges. Place return value in front of function name.
+ - 80 character per line.
+ - Print version number before usage.
+ - Tests
+
+2006-02-06 Stefan Schmidt <stefan@datenfreihafen.org>
+
+
0.1
- Initial release.
- INSTALL, README, TODO, CREDITS, Makefile, LICENSE and CHANGELOG files
Cliff Hones for the RS coding.
-Jan Luebbe for writing the manual page.
+Jan Luebbe <jluebbe@lasnet.de> for writing the manual page and maintaining
+the debian package.
+
+Daniel Willman <alphaone@totalueberwachung.de> for maintaining the gentoo
+ebuild.
+To install this software you need the following libraries installed:
+- libpopt
+- zlib
+
Installing iec16022 is really simple. Just do a 'make' and 'make install'.
+
In standard configuration the binary will be installed in /usr/local/bin. You
-can change this behavior in the Makefile via DESTDIR.
+can change the prefix and DESTDIR in the Makefile.
INSTALL=/usr/bin/install
GZIP=/bin/gzip
-DESTDIR=/usr/local
-
-prefix=$(DESTDIR)
+prefix=/usr/local
bindir=$(prefix)/bin
mandir=$(prefix)/share/man
-all:
- $(CC) -o iec16022 iec16022.c -DLIB image.c reedsol.c iec16022ecc200.c -lz -lpopt
+CFLAGS=-Wall
+
+.PHONY: test clean
+
+all: iec16022 manpage
+
+iec16022: iec16022ecc200.o image.o iec16022.c
+ $(CC) -c iec16022.c
+ $(CC) -o iec16022 $(CFLAGS) reedsol.o iec16022.o image.o iec16022ecc200.o -lz -lpopt
+
+manpage: iec16022.1
$(GZIP) -f --best < iec16022.1 > iec16022.1.gz
install: all
- $(INSTALL) -m 755 iec16022 $(bindir)
- $(INSTALL) -m 644 iec16022.1.gz $(mandir)/man1
+ $(INSTALL) -d -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
+ $(INSTALL) -m 755 iec16022 $(DESTDIR)$(bindir)
+ $(INSTALL) -m 644 iec16022.1.gz $(DESTDIR)$(mandir)/man1
+
+test: iec16022
+ cd test; ./testsuite.sh
+
+iec16022ecc200.o: iec16022ecc200.c iec16022ecc200.h reedsol.o
+ $(CC) -c iec16022ecc200.c
+
+image.o: image.c image.h
+ $(CC) -c image.c
+reedsol.o: reedsol.c reedsol.h
+ $(CC) -DLIB -c reedsol.c
clean:
- rm -f iec16022
- rm -f iec16022.1.gz
+ rm -f iec16022 iec16022.1.gz *.o
With iec16022 you can produce 2d barcodes. Also known as Data Matrix. These
-barcodes are defined in ISO IEC16022.
+barcodes are defined in ISO/IEC 16022.
The code was originally written by Andrews & Arnold Ltd. You can download this
code from http://aa.gg/free/.
-- Set textwidth to 80.
- Fix compiler warnings.
+- Test on 64bit, powerpc, arm, etc. Anyone?
+- Test stamp feature. Anyone?
- Get ISO standard to verify code.
-.\" Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH IEC16022 1 "December 28, 2005"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh disable hyphenation
-.\" .hy enable hyphenation
-.\" .ad l left justify
-.\" .ad b justify to both left and right margins
-.\" .nf disable filling
-.\" .fi enable filling
-.\" .br insert line break
-.\" .sp <n> insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
+.TH iec16022 1 2006-01-14 "iec16022 0.1"
.SH NAME
iec16022 \- program to generate 2d barcodes
.SH SYNOPSIS
.TP
.B \-\-usage
Show short overview of options.
+.SH EXAMPLE
+To produce a datamatrix barcode for foobar in PNG format you need the following
+arguments:
+.TP
+.B iec16022 -f PNG -c foobar -o foobar.png
.SH AUTHOR
iec16022 was written by Adrian Kennard, Andrews & Arnold Ltd.
.PP
*
*/
+#define IEC16022_VERSION "0.2"
#include <stdio.h>
#include <stdlib.h>
#include "iec16022ecc200.h"
// simple checked response malloc
-void *
-safemalloc (int n)
+void * safemalloc (int n)
{
void *p = malloc (n);
if (!p)
}
// hex dump - bottom left pixel first
-void
-dumphex (unsigned char *grid, int W, int H, unsigned char p)
+void dumphex (unsigned char *grid, int W, int H, unsigned char p)
{
int c = 0,
y;
printf ("\n");
}
-int
-main (int argc, const char *argv[])
+int main (int argc, const char *argv[])
{
char c;
int W = 0,
{
"infile", 'i', POPT_ARG_STRING, &infile, 0, "Barcode file", "filename"},
{
- "outfile", 'o', POPT_ARG_STRING, &outfile, 0, "Output filename", "filename"},
+ "outfile", 'o', POPT_ARG_STRING, &outfile, 0, "Output filename", \
+ "filename"},
{
- "encoding", 'e', POPT_ARG_STRING, &encoding, 0, "Encoding template", "[CTXEAB]* for ecc200 or 11/27/41/37/128/256"},
+ "encoding", 'e', POPT_ARG_STRING, &encoding, 0, "Encoding template", \
+ "[CTXEAB]* for ecc200 or 11/27/41/37/128/256"},
{
- "format", 'f', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_STRING, &format, 0, "Output format", "Text/EPS/PNG/Bin/Hex/Stamp"},
- POPT_AUTOHELP {
+ "format", 'f', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_STRING, &format, 0, \
+ "Output format", "Text/EPS/PNG/Bin/Hex/Stamp"},
+ POPT_AUTOHELP {
NULL, 0, 0, NULL, 0}
};
optCon = poptGetContext (NULL, argc, argv, optionsTable, 0);
if ((c = poptGetNextOpt (optCon)) < -1)
{
/* an error occurred during option processing */
- fprintf (stderr, "%s: %s\n", poptBadOption (optCon, POPT_BADOPTION_NOALIAS), poptStrerror (c));
+ fprintf (stderr, "%s: %s\n", poptBadOption (optCon, \
+ POPT_BADOPTION_NOALIAS), poptStrerror (c));
return 1;
}
barcode = (char *) poptGetArg (optCon);
if (poptPeekArg (optCon) || !barcode && !infile || barcode && infile)
{
- poptPrintUsage (optCon, stderr, 0);
+ fprintf (stderr, "Version: %s\n", IEC16022_VERSION);
+ poptPrintUsage (optCon, stderr, 0);
return -1;
}
if (outfile && !freopen (outfile, "w", stdout))
else
ecc = 0;
}
- if (ecc && ecc != 50 && ecc != 80 && ecc != 100 && ecc != 140 || ecc == 50 && W < 11 || ecc == 80 && W < 13
- || ecc == 100 && W < 13 || ecc == 140 && W < 17)
+ if (ecc && ecc != 50 && ecc != 80 && ecc != 100 && ecc != 140 || \
+ ecc == 50 && W < 11 || ecc == 80 && W < 13 || ecc == 100 \
+ && W < 13 || ecc == 140 && W < 17)
{
fprintf (stderr, "ECC%03d invalid for %dx%d\n", ecc, W, H);
return 1;
else
{ // auto size
if (!eccstr)
- ecc = 200; // default is even sizes only unless explicit ecc set to force odd sizes
+ // default is even sizes only unless explicit ecc set to force odd
+ // sizes
+ ecc = 200;
}
if (tolower (*format) == 's')
else
{
int n;
- for (n = 0; n < barcodelen && (barcode[n] == ' ' || isdigit (barcode[n]) || isupper (barcode[n])); n++);
+ for (n = 0; n < barcodelen && (barcode[n] == ' ' || \
+ isdigit (barcode[n]) || isupper (barcode[n])); n++);
if (n < barcodelen)
fprintf (stderr, "Has invalid characters for a stamp\n");
else
- { // Generate simplistic encoding rules as used by the windows app
+ {
+ // Generate simplistic encoding rules as used by the windows app
// TBA - does not always match the windows app...
n = 0;
encoding = safemalloc (barcodelen + 1);
// ASCII
while (1)
{
- if (n == barcodelen || n + 3 <= barcodelen && (!isdigit (barcode[n]) || !isdigit (barcode[n + 1])))
+ if (n == barcodelen || n + 3 <= barcodelen && (!isdigit \
+ (barcode[n]) || !isdigit (barcode[n + 1])))
break;
encoding[n++] = 'A';
- if (n < barcodelen && isdigit (barcode[n - 1]) && isdigit (barcode[n]))
+ if (n < barcodelen && isdigit (barcode[n - 1]) && isdigit \
+ (barcode[n]))
encoding[n++] = 'A';
}
// C40
fprintf (stderr, "Not done odd sizes yet, sorry\n");
} else
{ // even sizes
- grid = iec16022ecc200 (&W, &H, &encoding, barcodelen, barcode, &len, &maxlen, &ecclen);
+ grid = iec16022ecc200 (&W, &H, &encoding, barcodelen, barcode, &len, \
+ &maxlen, &ecclen);
}
// output
{
case 'i': // info
printf ("Size : %dx%d\n", W, H);
- printf ("Encoded : %d of %d bytes with %d bytes of ecc\n", len, maxlen, ecclen);
+ printf ("Encoded : %d of %d bytes with %d bytes of ecc\n", len, maxlen, \
+ ecclen);
printf ("Barcode : %s\n", barcode);
printf ("Encoding: %s\n", encoding);
break;
}
break;
case 'e': // EPS
- printf ("%%!PS-Adobe-3.0 EPSF-3.0\n" "%%%%Creator: IEC16022 barcode/stamp generator\n" "%%%%BarcodeData: %s\n"
- "%%%%BarcodeSize: %dx%d\n" "%%%%BarcodeFormat: ECC200\n" "%%%%DocumentData: Clean7Bit\n" "%%%%LanguageLevel: 1\n"
- "%%%%Pages: 1\n" "%%%%BoundingBox: 0 0 %d %d\n" "%%%%EndComments\n" "%%%%Page: 1 1\n" "%d %d 1[1 0 0 1 -1 -1]{<\n",
+ printf ("%%!PS-Adobe-3.0 EPSF-3.0\n"
+ "%%%%Creator: IEC16022 barcode/stamp generator\n"
+ "%%%%BarcodeData: %s\n" "%%%%BarcodeSize: %dx%d\n"
+ "%%%%BarcodeFormat: ECC200\n" "%%%%DocumentData: Clean7Bit\n"
+ "%%%%LanguageLevel: 1\n" "%%%%Pages: 1\n"
+ "%%%%BoundingBox: 0 0 %d %d\n" "%%%%EndComments\n"
+ "%%%%Page: 1 1\n" "%d %d 1[1 0 0 1 -1 -1]{<\n",
barcode, W, H, W + 2, H + 2, W, H);
dumphex (grid, W, H, 0xFF);
printf (">}image\n");
t = *gmtime (&now);
temp[46] = 0;
v = atoi (temp + 36);
- printf ("%%!PS-Adobe-3.0 EPSF-3.0\n" "%%%%Creator: IEC16022 barcode/stamp generator\n" "%%%%BarcodeData: %s\n"
- "%%%%BarcodeSize: %dx%d\n" "%%%%DocumentData: Clean7Bit\n" "%%%%LanguageLevel: 1\n"
- "%%%%Pages: 1\n" "%%%%BoundingBox: 0 0 190 80\n" "%%%%EndComments\n" "%%%%Page: 1 1\n"
- "10 dict begin/f{findfont exch scalefont setfont}bind def/rm/rmoveto load def/m/moveto load def/rl/rlineto load def\n"
- "/l/lineto load def/cp/closepath load def/c{dup stringwidth pop -2 div 0 rmoveto show}bind def\n"
- "gsave 72 25.4 div dup scale 0 0 m 67 0 rl 0 28 rl -67 0 rl cp clip 1 setgray fill 0 setgray 0.5 0 translate 0.3 setlinewidth\n"
- "32 32 1[2 0 0 2 0 -11]{<\n", barcode, W, H);
+ printf ("%%!PS-Adobe-3.0 EPSF-3.0\n"
+ "%%%%Creator: IEC16022 barcode/stamp generator\n"
+ "%%%%BarcodeData: %s\n" "%%%%BarcodeSize: %dx%d\n"
+ "%%%%DocumentData: Clean7Bit\n" "%%%%LanguageLevel: 1\n"
+ "%%%%Pages: 1\n" "%%%%BoundingBox: 0 0 190 80\n"
+ "%%%%EndComments\n" "%%%%Page: 1 1\n"
+ "10 dict begin/f{findfont exch scalefont \
+ setfont}bind def/rm/rmoveto load def/m/moveto load \
+ def/rl/rlineto load def\n"
+ "/l/lineto load def/cp/closepath load def/c{dup stringwidth \
+ pop -2 div 0 rmoveto show}bind def\n"
+ "gsave 72 25.4 div dup scale 0 0 m 67 0 rl 0 28 rl -67 0 rl \
+ cp clip 1 setgray fill 0 setgray 0.5 0 translate 0.3 \
+ setlinewidth\n" "32 32 1[2 0 0 2 0 -11]{<\n", barcode, W, H);
dumphex (grid, W, H, 0xFF);
printf (">}image\n"
"3.25/Helvetica-Bold f 8 25.3 m(\\243%d.%02d)c\n"
"2.6/Helvetica f 8 22.3 m(%.4s %.4s)c\n"
"1.5/Helvetica f 8 3.3 m(POST BY)c\n"
"3.3/Helvetica f 8 0.25 m(%02d.%02d.%02d)c\n",
- v / 100, v % 100, temp + 6, temp + 10, t.tm_mday, t.tm_mon + 1, t.tm_year % 100);
+ v / 100, v % 100, temp + 6, temp + 10, t.tm_mday, t.tm_mon + \
+ 1, t.tm_year % 100);
if (c == '1' || c == '2' || c == 'A' || c == 'S')
{
if (c == '2')
- printf ("42 0 m 10 0 rl 0 28 rl -10 0 rl cp 57 0 m 5 0 rl 0 28 rl -5 0 rl cp");
+ printf ("42 0 m 10 0 rl 0 28 rl -10 0 rl cp 57 0 m 5 0 rl 0 \
+ 28 rl -5 0 rl cp");
else
- printf ("42 0 m 5 0 rl 0 28 rl -5 0 rl cp 52 0 m 10 0 rl 0 28 rl -10 0 rl cp");
+ printf ("42 0 m 5 0 rl 0 28 rl -5 0 rl cp 52 0 m 10 0 rl 0 \
+ 28 rl -10 0 rl cp");
printf (" 21 0 m 16 0 rl 0 28 rl -16 0 rl cp fill\n"
- "21.3 0.3 m 15.4 0 rl 0 13 rl -15.4 0 rl cp 1 setgray fill gsave 21.3 0.3 15.4 27.4 rectclip newpath\n");
+ "21.3 0.3 m 15.4 0 rl 0 13 rl -15.4 0 rl cp 1 setgray \
+ fill gsave 21.3 0.3 15.4 27.4 rectclip newpath\n");
switch (c)
{
case '1':
printf
- ("27/Helvetica-Bold f 27 8.7 m(1)show grestore 0 setgray 1.5/Helvetica-Bold f 22 3.3 m(POSTAGE PAID GB)show 1.7/Helvetica f 29 1.5 m(DumbStamp.co.uk)c\n");
+ ("27/Helvetica-Bold f 27 8.7 m(1)show grestore 0 setgray \
+ 1.5/Helvetica-Bold f 22 3.3 m(POSTAGE PAID GB)show \
+ 1.7/Helvetica f 29 1.5 m(DumbStamp.co.uk)c\n");
break;
case '2':
printf
- ("21/Helvetica-Bold f 23.5 13 m(2)1.25 1 scale show grestore 0 setgray 1.5/Helvetica-Bold f 22 3.3 m(POSTAGE PAID GB)show 1.7/Helvetica f 29 1.5 m(DumbStamp.co.uk)c\n");
+ ("21/Helvetica-Bold f 23.5 13 m(2)1.25 1 scale show grestore \
+ 0 setgray 1.5/Helvetica-Bold f 22 3.3 \
+ m(POSTAGE PAID GB)show 1.7/Helvetica f 29 1.5 \
+ m(DumbStamp.co.uk)c\n");
break;
case 'A':
printf
- ("16/Helvetica-Bold f 29 14.75 m 1.1 1 scale(A)c grestore 0 setgray 1.5/Helvetica-Bold f 22 3.3 m(POSTAGE PAID GB)show 1.7/Helvetica f 22 1.5 m(Par Avion)show\n");
+ ("16/Helvetica-Bold f 29 14.75 m 1.1 1 scale(A)c grestore 0 \
+ setgray 1.5/Helvetica-Bold f 22 3.3 m(POSTAGE PAID GB)show \
+ 1.7/Helvetica f 22 1.5 m(Par Avion)show\n");
break;
case 'S':
- printf ("10/Helvetica-Bold f 29 17 m(SU)c grestore 0 setgray 1.5/Helvetica-Bold f 22 1.5 m(POSTAGE PAID GB)show\n");
+ printf ("10/Helvetica-Bold f 29 17 m(SU)c grestore 0 setgray \
+ 1.5/Helvetica-Bold f 22 1.5 m(POSTAGE PAID GB)show\n");
break;
}
printf ("2.3/Helvetica-Bold f 29 10 m(LOYAL MAIL)c\n");
} else if (c == 'P')
{ // Standard Parcels
printf ("21 0 m 41 0 rl 0 28 rl -41 0 rl cp fill\n"
- "37.7 0.3 m 24 0 rl 0 27.4 rl -24 0 rl cp 1 setgray fill gsave 21.3 0.3 16.4 27.4 rectclip newpath\n"
- "22.5/Helvetica-Bold f 37.75 -1.25 m 90 rotate(SP)show grestore 0 setgray\n"
+ "37.7 0.3 m 24 0 rl 0 27.4 rl -24 0 rl cp 1 setgray fill \
+ gsave 21.3 0.3 16.4 27.4 rectclip newpath\n"
+ "22.5/Helvetica-Bold f 37.75 -1.25 m 90 rotate(SP)show \
+ grestore 0 setgray\n"
"3.5/Helvetica-Bold f 49.7 21.5 m(LOYAL MAIL)c\n"
- "2.3/Helvetica-Bold f 49.7 7 m(POSTAGE PAID GB)c\n" "2.6/Helveica f 49.7 4.25 m(DumbStamp.co.uk)c\n");
+ "2.3/Helvetica-Bold f 49.7 7 m(POSTAGE PAID GB)c\n" \
+ "2.6/Helveica f 49.7 4.25 m(DumbStamp.co.uk)c\n");
} else if (c == '3')
printf ("21.15 0.15 40.7 27.7 rectstroke\n"
"21 0 m 41 0 rl 0 5 rl -41 0 rl cp fill\n"
- "0 1 2{0 1 18{dup 1.525 mul 22.9 add 24 3 index 1.525 mul add 3 -1 roll 9 add 29 div 0 360 arc fill}for pop}for\n"
+ "0 1 2{0 1 18{dup 1.525 mul 22.9 add 24 3 index 1.525 mul \
+ add 3 -1 roll 9 add 29 div 0 360 arc fill}for pop}for\n"
"50.5 23.07 m 11.5 0 rl 0 5 rl -11.5 0 rl cp fill\n"
"5.85/Helvetica f 23.7 15.6 m(Loyal Mail)show\n"
- "4.75/Helvetica-Bold f 24 11 m(special)show 4.9/Helvetica f(delivery)show\n"
- "gsave 1 setgray 3.2/Helvetica-Bold f 24 1.6 m(next day)show 26 10.15 m 2 0 rl stroke grestore\n"
- "21.15 9.9 m 53.8 9.9 l stroke 53.8 9.9 0.4 0 360 arc fill\n");
+ "4.75/Helvetica-Bold f 24 11 m(special)show 4.9/Helvetica \
+ f(delivery)show\n"
+ "gsave 1 setgray 3.2/Helvetica-Bold f 24 1.6 \
+ m(next day)show 26 10.15 m 2 0 rl stroke grestore\n"
+ "21.15 9.9 m 53.8 9.9 l stroke 53.8 9.9 0.4 0 360 \
+ arc fill\n");
printf ("end grestore\n");
}
break;
};
// simple checked response malloc
-static void *
-safemalloc (int n)
+static void * safemalloc (int n)
{
void *p = malloc (n);
if (!p)
}
// Annex M placement alorithm low level
-static void
-ecc200placementbit (int *array, int NR, int NC, int r, int c, int p, char b)
+static void ecc200placementbit (int *array, int NR, int NC, int r, int c, \
+ int p, char b)
{
if (r < 0)
{
array[r * NC + c] = (p << 3) + b;
}
-static void
-ecc200placementblock (int *array, int NR, int NC, int r, int c, int p)
+static void ecc200placementblock (int *array, int NR, int NC, int r, \
+ int c, int p)
{
ecc200placementbit (array, NR, NC, r - 2, c - 2, p, 7);
ecc200placementbit (array, NR, NC, r - 2, c - 1, p, 6);
ecc200placementbit (array, NR, NC, r - 0, c - 0, p, 0);
}
-static void
-ecc200placementcornerA (int *array, int NR, int NC, int p)
+static void ecc200placementcornerA (int *array, int NR, int NC, int p)
{
ecc200placementbit (array, NR, NC, NR - 1, 0, p, 7);
ecc200placementbit (array, NR, NC, NR - 1, 1, p, 6);
ecc200placementbit (array, NR, NC, 3, NC - 1, p, 0);
}
-static void
-ecc200placementcornerB (int *array, int NR, int NC, int p)
+static void ecc200placementcornerB (int *array, int NR, int NC, int p)
{
ecc200placementbit (array, NR, NC, NR - 3, 0, p, 7);
ecc200placementbit (array, NR, NC, NR - 2, 0, p, 6);
ecc200placementbit (array, NR, NC, 1, NC - 1, p, 0);
}
-static void
-ecc200placementcornerC (int *array, int NR, int NC, int p)
+static void ecc200placementcornerC (int *array, int NR, int NC, int p)
{
ecc200placementbit (array, NR, NC, NR - 3, 0, p, 7);
ecc200placementbit (array, NR, NC, NR - 2, 0, p, 6);
ecc200placementbit (array, NR, NC, 3, NC - 1, p, 0);
}
-static void
-ecc200placementcornerD (int *array, int NR, int NC, int p)
+static void ecc200placementcornerD (int *array, int NR, int NC, int p)
{
ecc200placementbit (array, NR, NC, NR - 1, 0, p, 7);
ecc200placementbit (array, NR, NC, NR - 1, NC - 1, p, 6);
}
// Annex M placement alorithm main function
-static void
-ecc200placement (int *array, int NR, int NC)
+static void ecc200placement (int *array, int NR, int NC)
{
int r,
c,
}
// calculate and append ecc code, and if necessary interleave
-static void
-ecc200 (unsigned char *binary, int bytes, int datablock, int rsblock)
+static void ecc200 (unsigned char *binary, int bytes, int datablock, \
+ int rsblock)
{
int blocks = (bytes + 2) / datablock,
b;
}
}
-// perform encoding for ecc200, source s len sl, to target t len tl, using optional encoding control string e
-// return 1 if OK, 0 if failed. Does all necessary padding to tl
-char
-ecc200encode (unsigned char *t, int tl, unsigned char *s, int sl, char *encoding, int *lenp)
+/*
+ * perform encoding for ecc200, source s len sl, to target t len tl, using
+ * optional encoding control string e return 1 if OK, 0 if failed. Does all
+ * necessary padding to tl
+ */
+
+char ecc200encode (unsigned char *t, int tl, unsigned char *s, int sl, \
+ char *encoding, int *lenp)
{
char enc = 'a'; // start in ASCII encoding mode
int tp = 0,
while (sp < sl && tp < tl)
{
char newenc = enc; // suggest new encoding
- if (tl - tp <= 1 && (enc == 'c' || enc == 't') || tl - tp <= 2 && enc == 'x')
+ if (tl - tp <= 1 && (enc == 'c' || enc == 't') || tl - tp <= 2 && enc \
+ == 'x')
enc = 'a'; // auto revert to ASCII
newenc = tolower (encoding[sp]);
switch (newenc)
out[p++] = (w - s3);
} else
{
- fprintf (stderr, "Could not encode 0x%02X, should not happen\n", c);
+ fprintf (stderr, "Could not encode 0x%02X, should \
+ not happen\n", c);
return 0;
}
}
}
if (tp > tl || sp < sl)
return 0; // did not fit
- //for (tp = 0; tp < tl; tp++) fprintf (stderr, "%02X ", t[tp]); fprintf (stderr, "\n");
+ /*
+ * for (tp = 0; tp < tl; tp++) fprintf (stderr, "%02X ", t[tp]); \
+ * fprintf (stderr, "\n");
+ */
return 1; // OK
}
0, 1, 1, 1, 1, 0, // From E_BINARY
};
-// Creates a encoding list (malloc)
-// returns encoding string
-// if lenp not null, target len stored
-// if error, null returned
-// if exact specified, then assumes shortcuts applicable for exact fit in target
-// 1. No unlatch to return to ASCII for last encoded byte after C40 or Text or X12
-// 2. No unlatch to return to ASCII for last 1 or 2 encoded bytes after EDIFACT
-// 3. Final C40 or text encoding exactly in last 2 bytes can have a shift 0 to pad to make a tripple
-// Only use the encoding from an exact request if the len matches the target, otherwise free the result and try again with exact=0
-static char *
-encmake (int l, unsigned char *s, int *lenp, char exact)
+/*
+ * Creates a encoding list (malloc)
+ * returns encoding string
+ * if lenp not null, target len stored
+ * if error, null returned
+ * if exact specified, then assumes shortcuts applicable for exact fit
+ * in target
+ * 1. No unlatch to return to ASCII for last encoded byte after C40 or
+ * Text or X12
+ * 2. No unlatch to return to ASCII for last 1 or 2 encoded bytes after
+ * EDIFACT
+ * 3. Final C40 or text encoding exactly in last 2 bytes can have a shift
+ * 0 to pad to make a tripple
+ * Only use the encoding from an exact request if the len matches the target,
+ * otherwise free the result and try again with exact=0
+ */
+
+static char * encmake (int l, unsigned char *s, int *lenp, char exact)
{
char *encoding = 0;
int p = l;
char e;
struct
{
- short s; // number of bytes of source that can be encoded in a row at this point using this encoding mode
- short t; // number of bytes of target generated encoding from this point to end if already in this encoding mode
+ // number of bytes of source that can be encoded in a row at this point
+ // using this encoding mode
+ short s;
+ // number of bytes of target generated encoding from this point to end if
+ // already in this encoding mode
+ short t;
} enc[MAXBARCODE][E_MAX];
memset (&enc, 0, sizeof (enc));
if (!l)
bl = 0;
if (p + sl < l)
for (e = 0; e < E_MAX; e++)
- if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + switchcost[E_ASCII][e]) < bl || !bl))
+ if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + \
+ switchcost[E_ASCII][e]) < bl || !bl))
{
bl = t;
b = e;
}
} while (sub && p + sl < l);
if (exact && sub == 2 && p + sl == l)
- { // special case, can encode last block with shift 0 at end (Is this valid when not end of target buffer?)
+ {
+ // special case, can encode last block with shift 0 at end (Is this
+ // valid when not end of target buffer?)
sub = 0;
tl += 2;
}
bl = 0;
if (p + sl < l)
for (e = 0; e < E_MAX; e++)
- if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + switchcost[E_C40][e]) < bl || !bl))
+ if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + \
+ switchcost[E_C40][e]) < bl || !bl))
{
bl = t;
b = e;
}
if (exact && enc[p + sl][E_ASCII].t == 1 && 1 < bl)
- { // special case, switch to ASCII for last bytes
+ {
+ // special case, switch to ASCII for last bytes
bl = 1;
b = E_ASCII;
}
}
} while (sub && p + sl < l);
if (exact && sub == 2 && p + sl == l)
- { // special case, can encode last block with shift 0 at end (Is this valid when not end of target buffer?)
+ {
+ // special case, can encode last block with shift 0 at end (Is this
+ // valid when not end of target buffer?)
sub = 0;
tl += 2;
}
bl = 0;
if (p + sl < l)
for (e = 0; e < E_MAX; e++)
- if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + switchcost[E_TEXT][e]) < bl || !bl))
+ if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + \
+ switchcost[E_TEXT][e]) < bl || !bl))
{
bl = t;
b = e;
do
{
unsigned char c = s[p + sl++];
- if (c != 13 && c != '*' && c != '>' && c != ' ' && !isdigit (c) && !isupper (c))
+ if (c != 13 && c != '*' && c != '>' && c != ' ' && !isdigit (c) && \
+ !isupper (c))
{
sl = 0;
break;
bl = 0;
if (p + sl < l)
for (e = 0; e < E_MAX; e++)
- if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + switchcost[E_X12][e]) < bl || !bl))
+ if (enc[p + sl][e].t && ((t = enc[p + sl][e].t + \
+ switchcost[E_X12][e]) < bl || !bl))
{
bl = t;
b = e;
}
if (exact && enc[p + sl][E_ASCII].t == 1 && 1 < bl)
- { // special case, switch to ASCII for last bytes
+ {
+ // special case, switch to ASCII for last bytes
bl = 1;
b = E_ASCII;
}
bs = 1;
} else
for (e = 0; e < E_MAX; e++)
- if (e != E_EDIFACT && enc[p + 1][e].t && ((t = 2 + enc[p + 1][e].t + switchcost[E_ASCII][e]) < bl || !bl)) // E_ASCII as allowed for unlatch
+ if (e != E_EDIFACT && enc[p + 1][e].t && ((t = 2 + \
+ enc[p + 1][e].t + switchcost[E_ASCII][e]) \
+ < bl || !bl)) // E_ASCII as allowed for unlatch
{
bs = 1;
bl = t;
bs = 2;
} else
for (e = 0; e < E_MAX; e++)
- if (e != E_EDIFACT && enc[p + 2][e].t && ((t = 3 + enc[p + 2][e].t + switchcost[E_ASCII][e]) < bl || !bl)) // E_ASCII as allowed for unlatch
+ if (e != E_EDIFACT && enc[p + 2][e].t && ((t = 3 + \
+ enc[p + 2][e].t + switchcost[E_ASCII][e]) \
+ < bl || !bl)) // E_ASCII as allowed for unlatch
{
bs = 2;
bl = t;
bs = 3;
} else
for (e = 0; e < E_MAX; e++)
- if (e != E_EDIFACT && enc[p + 3][e].t && ((t = 3 + enc[p + 3][e].t + switchcost[E_ASCII][e]) < bl || !bl)) // E_ASCII as allowed for unlatch
+ if (e != E_EDIFACT && enc[p + 3][e].t && ((t = 3 + \
+ enc[p + 3][e].t + switchcost[E_ASCII][e]) \
+ < bl || !bl)) // E_ASCII as allowed for unlatch
{
bs = 3;
bl = t;
} else
{
for (e = 0; e < E_MAX; e++)
- if (enc[p + 4][e].t && ((t = 3 + enc[p + 4][e].t + switchcost[E_EDIFACT][e]) < bl || !bl))
+ if (enc[p + 4][e].t && ((t = 3 + enc[p + 4][e].t + \
+ switchcost[E_EDIFACT][e]) < bl || !bl))
{
bs = 4;
bl = t;
b = e;
}
- if (exact && enc[p + 4][E_ASCII].t && enc[p + 4][E_ASCII].t <= 2 && (t = 3 + enc[p + 4][E_ASCII].t) < bl)
- { // special case, switch to ASCII for last 1 ot two bytes
+ if (exact && enc[p + 4][E_ASCII].t && enc[p + \
+ 4][E_ASCII].t <= 2 && (t = 3 + enc[p + \
+ 4][E_ASCII].t) < bl)
+ {
+ // special case, switch to ASCII for last 1 ot two bytes
bs = 4;
bl = t;
b = E_ASCII;
bl = 0;
for (e = 0; e < E_MAX; e++)
if (enc[p + 1][e].t
- && ((t = enc[p + 1][e].t + switchcost[E_BINARY][e] + ((e == E_BINARY && enc[p + 1][e].t == 249) ? 1 : 0)) < bl || !bl))
+ && ((t = enc[p + 1][e].t + switchcost[E_BINARY][e] + ((e == \
+ E_BINARY && enc[p + 1][e].t == 249) ? 1 : 0)) \
+ < bl || !bl))
{
bl = t;
b = e;
enc[p][E_BINARY].s = 1;
if (bl && b == E_BINARY)
enc[p][b].s += enc[p + 1][b].s;
- //fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); fprintf (stderr, "\n");
+ /*
+ * fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \
+ * (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \
+ * fprintf (stderr, "\n");
+ */
}
encoding = safemalloc (l + 1);
p = 0;
m = 0;
char b = 0;
for (e = 0; e < E_MAX; e++)
- if (enc[p][e].t && ((t = enc[p][e].t + switchcost[cur][e]) < m || t == m && e == cur || !m))
+ if (enc[p][e].t && ((t = enc[p][e].t + switchcost[cur][e]) < m || \
+ t == m && e == cur || !m))
{
b = e;
m = t;
encoding[p] = 0;
return encoding;
}
+/*
+ * Main encoding function
+ * Returns the grid (malloced) containing the matrix. L corner at 0,0.
+ * Takes suggested size in *Wptr, *Hptr, or 0,0. Fills in actual size.
+ * Takes barcodelen and barcode to be encoded
+ * Note, if *encodingptr is null, then fills with auto picked (malloced)
+ * encoding
+ * If lenp not null, then the length of encoded data before any final
+ * unlatch or pad is stored
+ * If maxp not null, then the max storage of this size code is stored
+ * If eccp not null, then the number of ecc bytes used in this size is
+ * stored
+ * Returns 0 on error (writes to stderr with details).
+ */
-// Main encoding function
-// Returns the grid (malloced) containing the matrix. L corner at 0,0.
-// Takes suggested size in *Wptr, *Hptr, or 0,0. Fills in actual size.
-// Takes barcodelen and barcode to be encoded
-// Note, if *encodingptr is null, then fills with auto picked (malloced) encoding
-// If lenp not null, then the length of encoded data before any final unlatch or pad is stored
-// If maxp not null, then the max storage of this size code is stored
-// If eccp not null, then the number of ecc bytes used in this size is stored
-// Returns 0 on error (writes to stderr with details).
-unsigned char *
-iec16022ecc200 (int *Wptr, int *Hptr, char **encodingptr, int barcodelen, unsigned char *barcode, int *lenp, int *maxp, int *eccp)
+unsigned char * iec16022ecc200 (int *Wptr, int *Hptr, char **encodingptr, \
+ int barcodelen, unsigned char *barcode, \
+ int *lenp, int *maxp, int *eccp)
{
unsigned char binary[3000]; // encoded raw data and ecc to place in barcode
int W = 0,
// encoding
if (W)
{ // known size
- for (matrix = ecc200matrix; matrix->W && (matrix->W != W || matrix->H != H); matrix++);
+ for (matrix = ecc200matrix; matrix->W && (matrix->W != W || \
+ matrix->H != H); matrix++);
if (!matrix->W)
{
fprintf (stderr, "Invalid size %dx%d\n", W, H);
if (encoding)
{ // find one that fits chosen encoding
for (matrix = ecc200matrix; matrix->W; matrix++)
- if (ecc200encode (binary, matrix->bytes, barcode, barcodelen, encoding, 0))
+ if (ecc200encode (binary, matrix->bytes, barcode, barcodelen, \
+ encoding, 0))
break;
} else
{
int len;
char *e;
e = encmake (barcodelen, barcode, &len, 1);
- for (matrix = ecc200matrix; matrix->W && matrix->bytes != len; matrix++);
+ for (matrix = ecc200matrix; matrix->W && matrix->bytes != len; \
+ matrix++);
if (e && !matrix->W)
{ // try for non exact fit
free (e);
e = encmake (barcodelen, barcode, &len, 0);
- for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; matrix++);
+ for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; \
+ matrix++);
}
encoding = e;
}
W = matrix->W;
H = matrix->H;
}
- if (!ecc200encode (binary, matrix->bytes, barcode, barcodelen, encoding, lenp))
+ if (!ecc200encode (binary, matrix->bytes, barcode, barcodelen, \
+ encoding, lenp))
{
fprintf (stderr, "Barcode too long for %dx%d\n", W, H);
return 0;
int v = places[(NR - y - 1) * NC + x];
//fprintf (stderr, "%4d", v);
if (v == 1 || v > 7 && (binary[(v >> 3) - 1] & (1 << (v & 7))))
- grid[(1 + y + 2 * (y / (matrix->FH - 2))) * W + 1 + x + 2 * (x / (matrix->FW - 2))] = 1;
+ grid[(1 + y + 2 * (y / (matrix->FH - 2))) * W + 1 + x + 2 * \
+ (x / (matrix->FW - 2))] = 1;
}
//fprintf (stderr, "\n");
}
*/
-unsigned char *
-iec16022ecc200 (int *Wptr, int *Hptr, char **encodingptr, int barcodelen, \
- unsigned char *barcode, int *lenp,int *maxp,int *eccp);
+#ifndef __IEC16022ECC200_H
+#define __IEC16022ECC200_H
+
+unsigned char * iec16022ecc200 (int *Wptr, int *Hptr, char **encodingptr, \
+ int barcodelen, unsigned char *barcode, \
+ int *lenp,int *maxp,int *eccp);
#define MAXBARCODE 3116
+#endif /* __IEC16022ECC200_H */
0x09, 0x04, 0x12, //%
};
-Image *
-ImageNew (int w, int h, int c)
+Image * ImageNew (int w, int h, int c)
{ // create a new blank image
Image *i;
if (!w || !h)
return i;
}
-void
-ImageFree (Image * i)
+void ImageFree (Image * i)
{ // free an image
if (i)
{
}
Private;
-static
-LZWFlush (Private * p)
+static LZWFlush (Private * p)
{ // flush this block
write (p->fh, p->block, *p->block + 1);
*p->block = 0;
}
-static
-LZWOut (Private * p, short v)
+static LZWOut (Private * p, short v)
{ // output a value
p->blockv |= (v << p->blockb);
p->blockb += p->lzwbits;
}
}
-static
-LZWClear (Private * p)
+static LZWClear (Private * p)
{
int c;
p->lzwbits = p->colbits + 1;
for (c = 0; c < p->cols; c++)
{
p->lzw[p->cols][c] = c; // links to literal entries
- memset (&p->lzw[c], -1, p->cols * 2); // links from literals, dead ends initially
+ // links from literals, dead ends initially
+ memset (&p->lzw[c], -1, p->cols * 2);
}
}
-static
-ImageStart (Private * p)
+static ImageStart (Private * p)
{
unsigned char b = p->colbits;
write (p->fh, &b, 1);
LZWOut (p, p->cols); // clear code
}
-static
-ImageEnd (Private * p)
+static ImageEnd (Private * p)
{
LZWOut (p, p->lzwcode); // last prefix
LZWOut (p, p->cols + 1); // end code
if (p->blockb)
- p->block[++*p->block] = p->blockv; // last partial byte
+ p->block[++*p->block] = p->blockv; // last partial byte
LZWFlush (p);
}
-static
-ImageOut (Private * p, unsigned char c)
+static ImageOut (Private * p, unsigned char c)
{
short next = p->lzw[p->lzwcode][c];
if (next == -1)
}
// write GIF image
-void
-ImageWriteGif (Image * i, int fh, int back, int trans, char *comment)
+void ImageWriteGif (Image * i, int fh, int back, int trans, char *comment)
{
struct strPrivate p;
p.fh = fh;
- for (p.colbits = 2, p.cols = 4; p.cols < i->C; p.cols *= 2, p.colbits++); // count colours, min 4
+ // count colours, min 4
+ for (p.colbits = 2, p.cols = 4; p.cols < i->C; p.cols *= 2, p.colbits++);
{ // headers
char buf[1500];
int n = 0;
write (fh, "\x3B", 1); // trailer
}
-void
-ImageText (Image * i, int x, int y, int col, char *text)
+void ImageText (Image * i, int x, int y, int col, char *text)
{ // writes 8x8 text
if (i && text)
while (*text)
}
}
-void
-ImageSmall (Image * i, int x, int y, int col, char *text)
+void ImageSmall (Image * i, int x, int y, int col, char *text)
{ // writes 4x6 digits
if (i && text)
while (*text)
}
}
-void
-ImageRect (Image * i, int x, int y, int w, int h, int c)
+void ImageRect (Image * i, int x, int y, int w, int h, int c)
{ // fill a box
if (i && w && h)
{
static unsigned int crc_table[256];
/* Make the table for a fast CRC. */
-void
-make_crc_table (void)
+void make_crc_table (void)
{
unsigned int c;
int n,
is the 1's complement of the final running CRC (see the
crc() routine below)). */
-unsigned int
-update_crc (unsigned int crc, unsigned char *buf, int len)
+unsigned int update_crc (unsigned int crc, unsigned char *buf, int len)
{
unsigned int c = crc;
int n;
}
/* Return the CRC of the bytes buf[0..len-1]. */
-unsigned int
-crc (unsigned char *buf, int len)
+unsigned int crc (unsigned char *buf, int len)
{
return update_crc (0xffffffffL, buf, len) ^ 0xffffffffL;
}
-unsigned int
-writecrc (int fh, char *ptr, int len, unsigned int c)
+unsigned int writecrc (int fh, char *ptr, int len, unsigned int c)
{
write (fh, ptr, len);
while (len--)
return c;
}
-void
-writechunk (int fh, char *typ, void *ptr, int len)
+void writechunk (int fh, char *typ, void *ptr, int len)
{
unsigned int v = htonl (len),
crc;
}
#ifndef USEZLIB
-unsigned int
-adlersum (unsigned char *p, int l, unsigned int adler)
+unsigned int adlersum (unsigned char *p, int l, unsigned int adler)
{
unsigned int s1 = (adler & 65535),
s2 = (adler >> 16);
#endif
// write PNG image
-void
-ImageWritePNG (Image * i, int fh, int back, int trans, char *comment)
+void ImageWritePNG (Image * i, int fh, int back, int trans, char *comment)
{
make_crc_table ();
write (fh, "\211PNG\r\n\032\n", 8); // PNG header
unsigned char alpha[256];
int n;
for (n = 0; n < i->C; n++)
- alpha[n] = 255 - (i->Colour[n] >> 24); // 4th palette byte treated as 0=opaque, 255-transparrent
+ // 4th palette byte treated as 0=opaque, 255-transparren
+ alpha[n] = 255 - (i->Colour[n] >> 24);
if (trans >= 0 && trans < i->C)
- alpha[trans] = 0; // manual set of specific transparrent colour
+ // manual set of specific transparrent colour
+ alpha[trans] = 0;
writechunk (fh, "tRNS", alpha, i->C);
}
#ifndef USEZLIB
*
*/
+#ifndef __IMAGE_H
+#define __IMAGE_H
+
typedef unsigned int Colour; // RGB value
// Image object
void ImageSmall(Image *i,int x,int y,int c,char *text); // write 4x6 text
void ImageRect(Image *i,int x,int y,int w,int h,int c); // fill a box
#define ImageWrite ImageWritePNG // default
+
+#endif /* __IMAGE_H */
// 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,
// (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;
// symbol sizes up to 8 bits. Just change the data type of data and res
// to unsigned int * for larger symbols.
-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,
#ifndef LIB
// The following tests the routines with the ISO/IEC 16022 Annexe R data
-int
-main (void)
+int main (void)
{
register int i;
*
*/
+#ifndef __REEDSOL_H
+#define __REEDSOL_H
+
void rs_init_gf(int poly);
void rs_init_code(int nsym, int index);
void rs_encode(int len, unsigned char *data, unsigned char *res);
+#endif /* __REEDSOL_H */
--- /dev/null
+ÿÿÿÿ¿`ï\1aÁ϶mÜ>ý\ 6Ü\1fÏÃð\8a¼N¯·«9\9a\82±¤Ë»¾\83Ð@¨ÄÌEÙù£,Æ<°\17Ü-öb°:Çw×ɪªªªÿÿÿÿ\9fÀ\8eöÊÕï\ f\97¦\91\ 4¸%\8fkûh\8eÔ«-¨\eÛ\12£0ËQ³kâ\1aÛ\1e\80Éôå£ÂÍ~\84\19ögëTåà½\83絪ªªª
\ No newline at end of file
--- /dev/null
+%!PS-Adobe-3.0 EPSF-3.0
+%%Creator: IEC16022 barcode/stamp generator
+%%BarcodeData: Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o
+%%BarcodeSize: 32x32
+%%BarcodeFormat: ECC200
+%%DocumentData: Clean7Bit
+%%LanguageLevel: 1
+%%Pages: 1
+%%BoundingBox: 0 0 34 34
+%%EndComments
+%%Page: 1 1
+32 32 1[1 0 0 1 -1 -1]{<
+00000000 409F10E5 3E304992 23C102F9 23E0303C 0F7543B1 504854C6 657D4E5B 3444417C 2FBF573B 33BA2606 5CD339C3 4FE823D2 099D4FC5 38882836 55555555
+00000000 603F7109 352A10F0 68596EFB 47DA7094 0497712B 54D257E4 24ED5CCF 34AE4C94 1DE524E1 7F360B1A 5C3D3281 7BE60998 14AB1A1F 427C184A 55555555
+>}image
--- /dev/null
+FFFFFFFF BF60EF1A C1CFB66D DC3EFD06 DC1FCFC3 F08ABC4E AFB7AB39 9A82B1A4 CBBBBE83 D040A8C4 CC45D9F9 A32CC63C B017DC2D F662B03A C777D7C9 AAAAAAAA
+FFFFFFFF 9FC08EF6 CAD5EF0F 97A69104 B8258F6B FB688ED4 AB2DA81B DB12A330 CB51B36B E21ADB1E 80C9F4E5 A3C2CD7E 8419F667 EB54E5E0 BD83E7B5 AAAAAAAA
--- /dev/null
+* * * * * * * * * * * * * * * *
+* **** ** ***** **** ** * *
+*** * ** * * * *** * ****
+* * ** ***** ** ** ***
+* * **** * ** ** * ******
+* ** * ***** * *** * *
+*** * ** * ** ** ** ****
+** * ** * * ** ** ** ** * **
+** ** ** * * * * ** **
+* * * ** * ** ** * * ** **
+***** ** ** * * *** ** * *
+* *** * * ** **** ** * **
+* * **** * ** * * * *
+** * * ** * * **** **** ****
+* ******* * *** **** **
+********************************
+* * * * * * * * * * * * * * * *
+** *** *** ***** * ***** * *
+**** ** ** * * ** *** *
+* ** * ***** *** * ** *
+* * ** * ** ** ** ****
+** ** * * *** ** ****** *
+** * * * * * ** *
+** * *** *** *** ***** * **
+* ** * * * * ** ** * *
+* * ***** ** **** * * ** *** *
+**** * * * * **** * ***
+** *** ******* ****** **
+** *** ***** ****** * **
+** *** ***** ** ** ** ** *
+* ****** ** *** **** ** *
+********************************
--- /dev/null
+#!/bin/bash
+
+FAILED=0
+
+../iec16022 -o testsuite-test.text -f Text -c "Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o"
+../iec16022 -o testsuite-test.eps -f EPS -c "Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o"
+../iec16022 -o testsuite-test.png -f PNG -c "Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o"
+../iec16022 -o testsuite-test.bin -f Bin -c "Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o"
+../iec16022 -o testsuite-test.hex -f Hex -c "Aolash3l dee6Ieke OhBohm1C MengaR9m zaHaoQu2 huW3Uer8 ieg7chaJ haiKua1o"
+
+diff -b testsuite-test.text testsuite-example.text && echo "Text test passed" || echo "Text test FAILED" || FAILED=1
+diff -b testsuite-test.eps testsuite-example.eps && echo "EPS test passed" || echo "EPS test FAILED" || FAILED=1
+diff -b testsuite-test.png testsuite-example.png && echo "PNG test passed" || echo "PNG test FAILED" || FAILED=1
+diff -b testsuite-test.bin testsuite-example.bin && echo "Bin test passed" || echo "Bin test FAILED" || FAILED=1
+diff -b testsuite-test.hex testsuite-example.hex && echo "Hex test passed" || echo "Hex test FAILED" || FAILED=1
+
+rm testsuite-test.*
+
+exit $FAILED