mirror of
https://git.code.sf.net/p/zint/code
synced 2026-02-02 08:45:58 +00:00
Merge Windows platform patches by tgotic
This commit is contained in:
86
backend/Makefile.mingw
Normal file
86
backend/Makefile.mingw
Normal file
@@ -0,0 +1,86 @@
|
||||
# Linux makefile for libzint
|
||||
#
|
||||
# make compiles with QR Code support
|
||||
# make libzint_noqr compiles without QR Code support
|
||||
# make install copies to /usr/local/lib
|
||||
# make uninstall removes library
|
||||
# make clean cleans up a previous compilation and any object or editor files
|
||||
#
|
||||
|
||||
ZINT_VERSION:=-DZINT_VERSION=\"2.1.3\"
|
||||
|
||||
|
||||
CC:= gcc
|
||||
AR:= ar rc
|
||||
RANLIB:= ranlib
|
||||
INCLUDE:= -I/mingw/include
|
||||
CFLAGS:= -D_WIN32 -O2 -fms-extensions -mms-bitfields -fno-exceptions -fomit-frame-pointer -Wall
|
||||
|
||||
prefix := /mingw
|
||||
includedir := $(prefix)/include
|
||||
libdir := $(prefix)/lib
|
||||
bindir := $(prefix)/bin
|
||||
DESTDIR :=
|
||||
APP:=zint
|
||||
DLL:=$(APP).dll
|
||||
STATLIB:=lib$(APP).a
|
||||
|
||||
COMMON_OBJ:= common.o png.o library.o ps.o large.o reedsol.o gs1.o svg.o
|
||||
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
||||
POSTAL_OBJ:= postal.o auspost.o imail.o
|
||||
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o
|
||||
|
||||
LIB_OBJ:= $(COMMON_OBJ) $(ONEDIM_OBJ) $(TWODIM_OBJ) $(POSTAL_OBJ)
|
||||
DLL_OBJ:= $(LIB_OBJ:.o=.lo) dllversion.lo
|
||||
|
||||
ifeq ($(NO_QR),true)
|
||||
DEFINES+= -DNO_QR
|
||||
else
|
||||
DEFINES_DLL+= -DQRENCODE_DLL
|
||||
LIBS+= -lqrencode
|
||||
endif
|
||||
|
||||
ifeq ($(NO_PNG),true)
|
||||
DEFINES+= -DNO_PNG
|
||||
else
|
||||
DEFINES_DLL+= -DPNG_DLL -DZLIB_DLL
|
||||
LIBS+= -lpng -lz
|
||||
endif
|
||||
|
||||
LIBS+= -lm
|
||||
|
||||
all: $(DLL) $(STATLIB)
|
||||
|
||||
%.lo:%.c
|
||||
@echo Compiling $< ...
|
||||
$(CC) $(CFLAGS) $(DEFINES) $(DEFINES_DLL) -DDLL_EXPORT -DPIC $(ZINT_VERSION) -c -o $@ $<
|
||||
|
||||
%.o:%.c
|
||||
@echo Compiling $< ...
|
||||
$(CC) $(CFLAGS) $(DEFINES) $(ZINT_VERSION) -c -o $@ $<
|
||||
|
||||
$(DLL):$(DLL_OBJ)
|
||||
@echo Linking $@...
|
||||
o2dll.sh -o $@ $(DLL_OBJ) $(LIBS) #-version-info 2:1:3 -version-number 2:1:3
|
||||
|
||||
$(STATLIB): $(LIB_OBJ)
|
||||
@echo Linking $@...
|
||||
$(AR) $@ $(LIB_OBJ)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
.PHONY: install uninstall clean dist
|
||||
|
||||
install:
|
||||
cp -fp libzint.* $(DESTDIR)$(libdir)
|
||||
cp -fp zint.h $(DESTDIR)$(includedir)/zint.h
|
||||
cp -fp zint.dll $(DESTDIR)$(bindir)
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)$(libdir)/libzint.*
|
||||
rm $(DESTDIR)$(includedir)/zint.h
|
||||
rm $(DESTDIR)$(bindir)/zint.dll
|
||||
|
||||
clean:
|
||||
rm -f *.lib *.dll *.o *.a *~ *.res *.exe *.def *.lo *.bak
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "aztec.h"
|
||||
#include "reedsol.h"
|
||||
@@ -50,10 +53,17 @@ void insert(char binary_string[], int posn, char newbit)
|
||||
int aztec_text_process(unsigned char source[], char binary_string[], int gs1)
|
||||
{ /* Encode input data into a binary string */
|
||||
int i, j, k, bytes;
|
||||
int charmap[ustrlen(source)], typemap[ustrlen(source)], maplength;
|
||||
int curtable, newtable, lasttable, chartype;
|
||||
int blockmap[2][ustrlen(source)], blocks, debug;
|
||||
|
||||
int curtable, newtable, lasttable, chartype, maplength, blocks, debug;
|
||||
#ifndef _MSC_VER
|
||||
int charmap[ustrlen(source)], typemap[ustrlen(source)];
|
||||
int blockmap[2][ustrlen(source)];
|
||||
#else
|
||||
int* charmap = (int*)_alloca(ustrlen(source) * sizeof(int));
|
||||
int* typemap = (int*)_alloca(ustrlen(source) * sizeof(int));
|
||||
int* blockmap[2];
|
||||
blockmap[0] = (int*)_alloca(ustrlen(source) * sizeof(int));
|
||||
blockmap[1] = (int*)_alloca(ustrlen(source) * sizeof(int));
|
||||
#endif
|
||||
/* Lookup input string in encoding table */
|
||||
maplength = 0;
|
||||
debug = 0;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "gs1.h"
|
||||
|
||||
@@ -39,7 +42,7 @@
|
||||
|
||||
#define DPDSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"
|
||||
|
||||
int list[2][170];
|
||||
static int list[2][170];
|
||||
|
||||
/* Code 128 tables checked against ISO/IEC 15417:2007 */
|
||||
|
||||
@@ -582,11 +585,15 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
{ /* Handle EAN-128 (Now known as GS1-128) */
|
||||
int i, j, e_count, values[170], bar_characters, read, total_sum;
|
||||
int error_number, indexchaine, indexliste, sourcelen;
|
||||
char set[170], mode, last_set, reduced[ustrlen(source)];
|
||||
char set[170], mode, last_set;
|
||||
float glyph_count;
|
||||
char dest[1000];
|
||||
int separator_row, linkage_flag;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
char reduced[ustrlen(source)];
|
||||
#else
|
||||
char* reduced = (char*)_alloca(ustrlen(source));
|
||||
#endif
|
||||
error_number = 0;
|
||||
strcpy(dest, "");
|
||||
linkage_flag = 0;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#define CANDB 98
|
||||
#define CANDBB 99
|
||||
|
||||
int list[2][170];
|
||||
static int list[2][170];
|
||||
|
||||
/* EN 12323 Table 1 - "Code 16K" character encodations */
|
||||
static char *C16KTable[107] = {"212222", "222122", "222221", "121223", "121322", "131222", "122213",
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#define SSET "0123456789ABCDEF"
|
||||
|
||||
int ustrlen(unsigned char data[]) {
|
||||
const int ustrlen(unsigned char data[]) {
|
||||
/* Local replacement for strlen() with unsigned char strings */
|
||||
int i;
|
||||
for (i=0;data[i];i++);
|
||||
|
||||
@@ -20,28 +20,45 @@
|
||||
*/
|
||||
|
||||
/* Used in some logic */
|
||||
#ifndef __COMMON_H
|
||||
#define __COMMON_H
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/* The most commonly used set */
|
||||
#define NESET "0123456789"
|
||||
|
||||
#include "zint.h"
|
||||
|
||||
int ustrlen(unsigned char source[]);
|
||||
void ustrcpy(unsigned char target[], unsigned char source[]);
|
||||
void concat(char dest[], char source[]);
|
||||
void uconcat(unsigned char dest[], unsigned char source[]);
|
||||
int ctoi(char source);
|
||||
char itoc(int source);
|
||||
void to_upper(unsigned char source[]);
|
||||
int is_sane(char test_string[], unsigned char source[]);
|
||||
void lookup(char set_string[], char *table[], char data, char dest[]);
|
||||
int posn(char set_string[], char data);
|
||||
void expand(struct zint_symbol *symbol, char data[]);
|
||||
int is_stackable(int symbology);
|
||||
int roundup(float input);
|
||||
int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern const int ustrlen(unsigned char source[]);
|
||||
extern void ustrcpy(unsigned char target[], unsigned char source[]);
|
||||
extern void concat(char dest[], char source[]);
|
||||
extern void uconcat(unsigned char dest[], unsigned char source[]);
|
||||
extern int ctoi(char source);
|
||||
extern char itoc(int source);
|
||||
extern void to_upper(unsigned char source[]);
|
||||
extern int is_sane(char test_string[], unsigned char source[]);
|
||||
extern void lookup(char set_string[], char *table[], char data, char dest[]);
|
||||
extern int posn(char set_string[], char data);
|
||||
extern void expand(struct zint_symbol *symbol, char data[]);
|
||||
extern int is_stackable(int symbology);
|
||||
extern int roundup(float input);
|
||||
extern int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
extern void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __COMMON_H */
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "large.h"
|
||||
#include "composite.h"
|
||||
@@ -330,7 +333,11 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
|
||||
int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
|
||||
{ /* CC-B 2D component */
|
||||
int length, i, binloc;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char data_string[(ustrlen(source) / 8) + 3];
|
||||
#else
|
||||
unsigned char* data_string = (unsigned char*)_alloca((ustrlen(source) / 8) + 3);
|
||||
#endif
|
||||
int chainemc[180], mclength;
|
||||
int k, j, longueur, mccorrection[50], offset;
|
||||
int total, dummy[5];
|
||||
@@ -557,7 +564,11 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
|
||||
int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int ecc_level)
|
||||
{ /* CC-C 2D component - byte compressed PDF417 */
|
||||
int length, i, binloc;
|
||||
unsigned char data_string[(ustrlen(source) / 8) + 4];
|
||||
#ifndef _MSC_VER
|
||||
unsigned char data_string[(ustrlen(source) / 8) + 4];
|
||||
#else
|
||||
unsigned char* data_string = (unsigned char*)_alloca((ustrlen(source) / 8) + 4);
|
||||
#endif
|
||||
int chainemc[1000], mclength, k;
|
||||
int offset, longueur, loop, total, j, mccorrection[520];
|
||||
int c1, c2, c3, dummy[35];
|
||||
@@ -693,14 +704,19 @@ int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int e
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cc_binary_string(struct zint_symbol *symbol, char source[], char binary_string[], int cc_mode, int *cc_width, int *ecc, int lin_width)
|
||||
int cc_binary_string(struct zint_symbol *symbol, const char source[], char binary_string[], int cc_mode, int *cc_width, int *ecc, int lin_width)
|
||||
{ /* Handles all data encodation from section 5 of ISO/IEC 24723 */
|
||||
int encoding_method, read_posn, d1, d2, value, alpha_pad;
|
||||
int i, j, mask, ai_crop, ai_crop_posn, fnc1_latch;
|
||||
long int group_val;
|
||||
int ai90_mode, latch, remainder, binary_length;
|
||||
char date_str[4];
|
||||
char general_field[strlen(source)], general_field_type[strlen(source)];
|
||||
#ifndef _MSC_VER
|
||||
char general_field[strlen(source) + 1], general_field_type[strlen(source) + 1];
|
||||
#else
|
||||
char* general_field = (char*)_alloca(strlen(source) + 1);
|
||||
char* general_field_type = (char*)_alloca(strlen(source) + 1);
|
||||
#endif
|
||||
int target_bitsize;
|
||||
|
||||
encoding_method = 1;
|
||||
@@ -710,7 +726,7 @@ int cc_binary_string(struct zint_symbol *symbol, char source[], char binary_stri
|
||||
fnc1_latch = 0;
|
||||
alpha_pad = 0;
|
||||
ai90_mode = 0;
|
||||
*(ecc) = 0;
|
||||
*ecc = 0;
|
||||
value = 0;
|
||||
target_bitsize = 0;
|
||||
|
||||
@@ -783,7 +799,12 @@ int cc_binary_string(struct zint_symbol *symbol, char source[], char binary_stri
|
||||
|
||||
if (encoding_method == 3) {
|
||||
/* Encodation Method field of "11" - AI 90 */
|
||||
char ninety[strlen(source)], numeric_part[4];
|
||||
#ifndef _MSC_VER
|
||||
char ninety[strlen(source) + 1];
|
||||
#else
|
||||
char* ninety = (char*)_alloca(strlen(source) + 1);
|
||||
#endif
|
||||
char numeric_part[4];
|
||||
int alpha, alphanum, numeric, test1, test2, test3, next_ai_posn;
|
||||
int numeric_value, table3_letter, mask;
|
||||
|
||||
@@ -796,7 +817,7 @@ int cc_binary_string(struct zint_symbol *symbol, char source[], char binary_stri
|
||||
do {
|
||||
ninety[i] = source[i + 2];
|
||||
i++;
|
||||
} while ((source[i + 2] != '[') && ((i + 2) < strlen(source)));
|
||||
} while ((strlen(source) > i + 2) && ('[' != source[i + 2]));
|
||||
ninety[i] = '\0';
|
||||
|
||||
/* Find out if the AI 90 data is alphabetic or numeric or both */
|
||||
@@ -1675,8 +1696,13 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
||||
{
|
||||
int error_number, cc_mode, cc_width, ecc_level;
|
||||
int j, i, k, separator_row;
|
||||
#ifndef _MSC_VER
|
||||
char reduced[ustrlen(source)];
|
||||
char binary_string[10 * ustrlen(source)];
|
||||
#else
|
||||
char* reduced = (char*)_alloca(ustrlen(source) + 1);
|
||||
char* binary_string = (char*)_alloca(20 * (ustrlen(source) + 1));
|
||||
#endif
|
||||
struct zint_symbol *linear;
|
||||
int top_shift, bottom_shift;
|
||||
|
||||
@@ -1762,7 +1788,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
||||
case BARCODE_RSS_EXPSTACK_CC: cc_width = 4; break;
|
||||
}
|
||||
|
||||
strcpy(binary_string, "");
|
||||
memset(binary_string, 0, sizeof(binary_string));
|
||||
|
||||
if(cc_mode < 1 || cc_mode > 3) { cc_mode = 1; }
|
||||
|
||||
@@ -1875,7 +1901,11 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
||||
symbol->rows += linear->rows;
|
||||
ustrcpy(symbol->text, (unsigned char *)linear->text);
|
||||
|
||||
//#ifdef _MSC_VER
|
||||
// free(reduced);
|
||||
// free(binary_string);
|
||||
//#endif
|
||||
ZBarcode_Delete(linear);
|
||||
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
||||
31
backend/dllversion.c
Normal file
31
backend/dllversion.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Sed: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/versions.asp */
|
||||
#if defined (_WIN32) && (defined(_USRDLL) || defined(DLL_EXPORT) || defined(PIC))
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
__declspec(dllexport) HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi)
|
||||
{
|
||||
if (!pdvi || (sizeof(*pdvi) != pdvi->info1.cbSize))
|
||||
return (E_INVALIDARG);
|
||||
|
||||
pdvi->info1.dwMajorVersion = 2;
|
||||
pdvi->info1.dwMinorVersion = 1;
|
||||
pdvi->info1.dwBuildNumber = 3;
|
||||
pdvi->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
|
||||
if (sizeof(DLLVERSIONINFO2) == pdvi->info1.cbSize)
|
||||
pdvi->ullVersion = MAKEDLLVERULL(2, 1, 3, 0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "reedsol.h"
|
||||
#include "common.h"
|
||||
#include "dm200.h"
|
||||
@@ -191,7 +194,7 @@ static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock)
|
||||
|
||||
float dmroundup(float input)
|
||||
{
|
||||
float fraction, output;
|
||||
float fraction, output = 0.0;
|
||||
|
||||
fraction = input - (int)input;
|
||||
if(fraction > 0.01) { output = (input - fraction) + 1.0; } else { output = input; }
|
||||
@@ -358,8 +361,11 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha
|
||||
int text_buffer[6], text_p;
|
||||
int x12_buffer[6], x12_p;
|
||||
int edifact_buffer[8], edifact_p;
|
||||
char binary[2 * inputlen];
|
||||
|
||||
#ifndef _MSC_VER
|
||||
char binary[2 * inputlen];
|
||||
#else
|
||||
char* binary = (char*)_alloca(2 * inputlen);
|
||||
#endif
|
||||
sp = 0;
|
||||
tp = 0;
|
||||
memset(c40_buffer, 0, 6);
|
||||
@@ -813,9 +819,9 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[])
|
||||
int x, y, NC, NR, *places;
|
||||
NC = W - 2 * (W / FW);
|
||||
NR = H - 2 * (H / FH);
|
||||
places = safemalloc(NC * NR * sizeof(int));
|
||||
places = (int*)safemalloc(NC * NR * sizeof(int));
|
||||
ecc200placement(places, NR, NC);
|
||||
grid = safemalloc(W * H);
|
||||
grid = (unsigned char*)safemalloc(W * H);
|
||||
memset(grid, 0, W * H);
|
||||
for (y = 0; y < H; y += FH) {
|
||||
for (x = 0; x < W; x++)
|
||||
|
||||
@@ -23,8 +23,17 @@
|
||||
|
||||
#ifndef __IEC16022ECC200_H
|
||||
#define __IEC16022ECC200_H
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
||||
#define MAXBARCODE 3116
|
||||
|
||||
#define DM_ASCII 1
|
||||
|
||||
@@ -21,10 +21,16 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "dmatrix.h"
|
||||
#include "common.h"
|
||||
|
||||
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
||||
#ifdef _MSC_VER
|
||||
#include "dm200.h"
|
||||
#else
|
||||
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
||||
#endif
|
||||
|
||||
#define B11SET " 0123456789"
|
||||
#define B27SET " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
@@ -36,8 +42,13 @@ void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[
|
||||
int input_length, i;
|
||||
input_length = ustrlen(source);
|
||||
char xor_register[17];
|
||||
#ifndef _MSC_VER
|
||||
char precrc_bitstream[(input_length * 8) + 16];
|
||||
char precrc_bitstream_reversed[(input_length * 8) + 16];
|
||||
#else
|
||||
char* precrc_bitstream = (char*)_alloca((input_length * 8) + 16);
|
||||
char* precrc_bitstream_reversed = (char*)_alloca((input_length * 8) + 16);
|
||||
#endif
|
||||
int machine_cycles;
|
||||
char input_bit, out1, out2, out3;
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "gs1.h"
|
||||
|
||||
/* This code does some checks on the integrity of GS1 data. It is not intended
|
||||
to be bulletproof, nor does it report very accurately what problem was found
|
||||
@@ -257,7 +261,11 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[])
|
||||
{
|
||||
/* Only to keep the compiler happy */
|
||||
#ifndef _MSC_VER
|
||||
char temp[ustrlen(source) + 5];
|
||||
#else
|
||||
char* temp = (char*)_alloca(ustrlen(source) + 5);
|
||||
#endif
|
||||
int error_number, i;
|
||||
|
||||
error_number = gs1_verify(symbol, source, temp);
|
||||
|
||||
@@ -18,6 +18,18 @@
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef __GS1_H
|
||||
#define __GS1_H
|
||||
|
||||
int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[]);
|
||||
int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[]);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[]);
|
||||
extern int ugs1_verify(struct zint_symbol *symbol, unsigned char source[], unsigned char reduced[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GS1_H */
|
||||
@@ -19,9 +19,10 @@
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
#include "large.h"
|
||||
|
||||
static short int BCD[40] = {
|
||||
0, 0, 0, 0,
|
||||
|
||||
@@ -18,13 +18,23 @@
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef __LARGE_H
|
||||
#define __LARGE_H
|
||||
|
||||
void binary_load(short int reg[], char data[]);
|
||||
void binary_add(short int accumulator[], short int input_buffer[]);
|
||||
void binary_subtract(short int accumulator[], short int input_buffer[]);
|
||||
void shiftdown(short int buffer[]);
|
||||
void shiftup(short int buffer[]);
|
||||
short int islarger(short int accum[], short int reg[]);
|
||||
void hex_dump(short int input_buffer[]);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern void binary_load(short int reg[], char data[]);
|
||||
extern void binary_add(short int accumulator[], short int input_buffer[]);
|
||||
extern void binary_subtract(short int accumulator[], short int input_buffer[]);
|
||||
extern void shiftdown(short int buffer[]);
|
||||
extern void shiftup(short int buffer[]);
|
||||
extern short int islarger(short int accum[], short int reg[]);
|
||||
extern void hex_dump(short int input_buffer[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __LARGE_H */
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "gs1.h"
|
||||
#include "sjis.h"
|
||||
@@ -32,7 +35,7 @@ struct zint_symbol *ZBarcode_Create()
|
||||
struct zint_symbol *symbol;
|
||||
int i, j;
|
||||
|
||||
symbol = malloc(sizeof(*symbol));
|
||||
symbol = (struct zint_symbol*)malloc(sizeof(*symbol));
|
||||
if (!symbol) return NULL;
|
||||
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
@@ -386,7 +389,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
|
||||
int input_length;
|
||||
|
||||
input_length = ustrlen(source);
|
||||
#ifndef _MSC_VER
|
||||
unsigned char preprocessed[input_length];
|
||||
#else
|
||||
unsigned char* preprocessed = (unsigned char*)_alloca(input_length + 1);
|
||||
#endif
|
||||
|
||||
if(ustrlen(source) == 0) {
|
||||
strcpy(symbol->errtxt, "No input data");
|
||||
|
||||
BIN
backend/libzint.so.2.1.3
Executable file
BIN
backend/libzint.so.2.1.3
Executable file
Binary file not shown.
@@ -23,8 +23,8 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
#include "micqr.h"
|
||||
#include "reedsol.h"
|
||||
#include "micqr.h"
|
||||
|
||||
#define NUMERIC 1
|
||||
#define ALPHANUM 2
|
||||
|
||||
@@ -113,15 +113,15 @@ void regroupe(int *indexliste)
|
||||
/* 478 */
|
||||
void pdfsmooth(int *indexliste)
|
||||
{
|
||||
int i, this, last, next, length;
|
||||
int i, crnt, last, next, length;
|
||||
|
||||
for(i = 0; i < *(indexliste); i++) {
|
||||
this = liste[1][i];
|
||||
crnt = liste[1][i];
|
||||
length = liste[0][i];
|
||||
if(i != 0) { last = liste[1][i - 1]; } else { last = FALSE; }
|
||||
if(i != *(indexliste) - 1) { next = liste[1][i + 1]; } else { next = FALSE; }
|
||||
|
||||
if(this == NUM) {
|
||||
if(crnt == NUM) {
|
||||
if(i == 0) { /* first block */
|
||||
if(*(indexliste) > 1) { /* and there are others */
|
||||
if((next == TEX) && (length < 8)) { liste[1][i] = TEX;}
|
||||
@@ -143,12 +143,12 @@ void pdfsmooth(int *indexliste)
|
||||
regroupe(indexliste);
|
||||
/* 520 */
|
||||
for(i = 0; i < *(indexliste); i++) {
|
||||
this = liste[1][i];
|
||||
crnt = liste[1][i];
|
||||
length = liste[0][i];
|
||||
if(i != 0) { last = liste[1][i - 1]; } else { last = FALSE; }
|
||||
if(i != *(indexliste) - 1) { next = liste[1][i + 1]; } else { next = FALSE; }
|
||||
|
||||
if((this == TEX) && (i > 0)) { /* not the first */
|
||||
if((crnt == TEX) && (i > 0)) { /* not the first */
|
||||
if(i == *(indexliste) - 1) { /* the last one */
|
||||
if((last == BYT) && (length == 1)) { liste[1][i] = BYT; }
|
||||
} else { /* not the last one */
|
||||
@@ -554,7 +554,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
||||
if(symbol->option_2 < 1) {
|
||||
/* This is a much more simple formula to Grand Zebu's -
|
||||
it does not try to make the symbol square */
|
||||
symbol->option_2 = 0.5 + sqrt((longueur + k) / 3);
|
||||
symbol->option_2 = 0.5 + sqrt((longueur + k) / 3.0);
|
||||
}
|
||||
if(((longueur + k) / symbol->option_2) > 90) {
|
||||
/* stop the symbol from becoming too high */
|
||||
|
||||
@@ -55,7 +55,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
|
||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||
return error_number;
|
||||
}
|
||||
checkptr = calloc (1, ustrlen(source) * 4 + 8);
|
||||
checkptr = (unsigned char *)calloc (1, ustrlen(source) * 4 + 8);
|
||||
|
||||
/* Start character */
|
||||
concat(dest, "31311331");
|
||||
|
||||
@@ -22,9 +22,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifndef NO_PNG
|
||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
||||
#include "maxipng.h" /* Maxicode shapes */
|
||||
#endif /* NO_PNG */
|
||||
|
||||
#include "font.h" /* Font for human readable text */
|
||||
|
||||
#define SSET "0123456789ABCDEF"
|
||||
@@ -43,7 +51,7 @@ static void writepng_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||
fprintf(stderr, "writepng libpng error: %s\n", msg);
|
||||
fflush(stderr);
|
||||
|
||||
graphic = png_get_error_ptr(png_ptr);
|
||||
graphic = (struct mainprog_info_type*)png_get_error_ptr(png_ptr);
|
||||
if (graphic == NULL) { /* we are completely hosed now */
|
||||
fprintf(stderr,
|
||||
"writepng severe error: jmpbuf not recoverable; terminating.\n");
|
||||
@@ -57,7 +65,11 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
||||
{
|
||||
struct mainprog_info_type wpng_info;
|
||||
struct mainprog_info_type *graphic;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char outdata[image_width * 3];
|
||||
#else
|
||||
unsigned char* outdata = (unsigned char*)_alloca(image_width * 3);
|
||||
#endif
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
graphic = &wpng_info;
|
||||
@@ -472,7 +484,11 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
||||
int error_number;
|
||||
int scaler = (int)(2 * symbol->scale);
|
||||
int default_text_posn;
|
||||
#ifndef _MSC_VER
|
||||
unsigned char local_text[ustrlen(symbol->text)];
|
||||
#else
|
||||
unsigned char* local_text = (unsigned char*)_alloca(ustrlen(symbol->text));
|
||||
#endif
|
||||
|
||||
to_latin1(symbol->text, local_text);
|
||||
|
||||
@@ -561,7 +577,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
||||
image_height = scaler * (symbol->height + textoffset + yoffset + yoffset);
|
||||
|
||||
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
||||
printf("Insifficient memory for pixel buffer");
|
||||
printf("Insufficient memory for pixel buffer");
|
||||
return ERROR_ENCODING_PROBLEM;
|
||||
} else {
|
||||
for(i = 0; i < (image_width * image_height); i++) {
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
|
||||
#define BESET "ABCD"
|
||||
@@ -101,8 +104,8 @@ int post_plot(struct zint_symbol *symbol, unsigned char source[])
|
||||
char height_pattern[200];
|
||||
unsigned int loopey;
|
||||
int writer;
|
||||
strcpy(height_pattern, "");
|
||||
int error_number;
|
||||
strcpy(height_pattern, "");
|
||||
|
||||
error_number = 0;
|
||||
|
||||
@@ -503,8 +506,14 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
|
||||
input_length = ustrlen(source);
|
||||
inter_length = input_length * 2;
|
||||
if(inter_length < 20) { inter_length = 20; }
|
||||
#ifndef _MSC_VER
|
||||
char inter[inter_length];
|
||||
char local_source[input_length];
|
||||
char local_source[input_length];
|
||||
#else
|
||||
char* inter = (char*)_alloca(inter_length);
|
||||
char* local_source = (char*)_alloca(inter_length);
|
||||
#endif
|
||||
|
||||
inter_posn = 0;
|
||||
error_number = 0;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ QRcode *encode(int security, int size, const unsigned char *intext, int kanji)
|
||||
int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
||||
{
|
||||
QRcode *code;
|
||||
int errno = 0;
|
||||
/*int errno = 0;*/
|
||||
int i, j;
|
||||
int kanji;
|
||||
|
||||
@@ -89,7 +89,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
||||
|
||||
QRcode_free(code);
|
||||
|
||||
return errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -40,13 +40,13 @@
|
||||
|
||||
#include <stdio.h> // only needed for debug (main)
|
||||
#include <stdlib.h> // only needed for malloc/free
|
||||
|
||||
#include "reedsol.h"
|
||||
static int gfpoly;
|
||||
static int symsize; // in bits
|
||||
static int logmod; // 2**symsize - 1
|
||||
static int rlen;
|
||||
|
||||
static int *log = NULL, *alog = NULL, *rspoly = NULL;
|
||||
static int *logt = NULL, *alog = NULL, *rspoly = NULL;
|
||||
|
||||
// rs_init_gf(poly) initialises the parameters for the Galois Field.
|
||||
// The symbol size is determined from the highest bit set in poly
|
||||
@@ -72,12 +72,12 @@ void rs_init_gf(int poly)
|
||||
|
||||
// Calculate the log/alog tables
|
||||
logmod = (1 << m) - 1;
|
||||
log = (int *)malloc(sizeof(int) * (logmod + 1));
|
||||
logt = (int *)malloc(sizeof(int) * (logmod + 1));
|
||||
alog = (int *)malloc(sizeof(int) * logmod);
|
||||
|
||||
for (p = 1, v = 0; v < logmod; v++) {
|
||||
alog[v] = p;
|
||||
log[p] = v;
|
||||
logt[p] = v;
|
||||
p <<= 1;
|
||||
if (p & b)
|
||||
p ^= poly;
|
||||
@@ -104,10 +104,10 @@ void rs_init_code(int nsym, int index)
|
||||
rspoly[i] = 1;
|
||||
for (k = i - 1; k > 0; k--) {
|
||||
if (rspoly[k])
|
||||
rspoly[k] = alog[(log[rspoly[k]] + index) % logmod];
|
||||
rspoly[k] = alog[(logt[rspoly[k]] + index) % logmod];
|
||||
rspoly[k] ^= rspoly[k - 1];
|
||||
}
|
||||
rspoly[0] = alog[(log[rspoly[0]] + index) % logmod];
|
||||
rspoly[0] = alog[(logt[rspoly[0]] + index) % logmod];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -121,12 +121,12 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
|
||||
m = res[rlen - 1] ^ data[i];
|
||||
for (k = rlen - 1; k > 0; k--) {
|
||||
if (m && rspoly[k])
|
||||
res[k] = res[k - 1] ^ alog[(log[m] + log[rspoly[k]]) % logmod];
|
||||
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
if (m && rspoly[0])
|
||||
res[0] = alog[(log[m] + log[rspoly[0]]) % logmod];
|
||||
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
|
||||
else
|
||||
res[0] = 0;
|
||||
}
|
||||
@@ -141,20 +141,20 @@ void rs_encode_long(int len, unsigned int *data, unsigned int *res)
|
||||
m = res[rlen - 1] ^ data[i];
|
||||
for (k = rlen - 1; k > 0; k--) {
|
||||
if (m && rspoly[k])
|
||||
res[k] = res[k - 1] ^ alog[(log[m] + log[rspoly[k]]) % logmod];
|
||||
res[k] = res[k - 1] ^ alog[(logt[m] + logt[rspoly[k]]) % logmod];
|
||||
else
|
||||
res[k] = res[k - 1];
|
||||
}
|
||||
if (m && rspoly[0])
|
||||
res[0] = alog[(log[m] + log[rspoly[0]]) % logmod];
|
||||
res[0] = alog[(logt[m] + logt[rspoly[0]]) % logmod];
|
||||
else
|
||||
res[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void rs_free()
|
||||
void rs_free(void)
|
||||
{ /* Free memory */
|
||||
free(log);
|
||||
free(logt);
|
||||
free(alog);
|
||||
free(rspoly);
|
||||
rspoly = NULL;
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "large.h"
|
||||
#include "rss.h"
|
||||
@@ -951,7 +954,7 @@ int general_rules(char field[], char type[])
|
||||
|
||||
for(i = 0; i < block_count; i++) {
|
||||
current = block[1][i];
|
||||
next = block[1][i + 1];
|
||||
next = (block[1][i + 1] & 0xFF);
|
||||
|
||||
if((current == ISOIEC) && (i != (block_count - 1))) {
|
||||
if((next == ANY_ENC) && (block[0][i + 1] >= 4)) {
|
||||
@@ -1039,7 +1042,12 @@ int general_rules(char field[], char type[])
|
||||
int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[])
|
||||
{ /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
|
||||
int encoding_method, i, mask, j, read_posn, latch;
|
||||
#ifndef _MSC_VER
|
||||
char general_field[strlen(source)], general_field_type[strlen(source)];
|
||||
#else
|
||||
char* general_field = (char*)_alloca(strlen(source));
|
||||
char* general_field_type = (char*)_alloca(strlen(source));
|
||||
#endif
|
||||
int remainder, d1, d2, value;
|
||||
char padstring[14];
|
||||
|
||||
@@ -1853,13 +1861,18 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
||||
int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
|
||||
{ /* GS1 DataBar Expanded */
|
||||
int i, j, k, l, data_chars, vs[21], group[21], v_odd[21], v_even[21];
|
||||
char binary_string[7 * ustrlen(source)], substring[21][14], latch;
|
||||
char substring[21][14], latch;
|
||||
int char_widths[21][8], checksum, check_widths[8], c_group;
|
||||
int check_char, c_odd, c_even, elements[235], pattern_width, reader, writer;
|
||||
int row, elements_in_sub, special_case_row, left_to_right;
|
||||
int codeblocks, sub_elements[235], stack_rows, current_row, current_block;
|
||||
int separator_row;
|
||||
char reduced[ustrlen(source)];
|
||||
#ifndef _MSC_VER
|
||||
char reduced[ustrlen(source)], binary_string[7 * ustrlen(source)];
|
||||
#else
|
||||
char* reduced = (char*)_alloca(ustrlen(source));
|
||||
char* binary_string = (char*)_alloca(7 * ustrlen(source));
|
||||
#endif
|
||||
|
||||
separator_row = 0;
|
||||
reader=0;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
int svg_plot(struct zint_symbol *symbol)
|
||||
{
|
||||
int i, block_width, latch, r, this_row;
|
||||
float textpos, large_bar_height, preset_height, row_height, row_posn = 0;
|
||||
float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0;
|
||||
FILE *fsvg;
|
||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
||||
float red_ink, green_ink, blue_ink, red_paper, green_paper, blue_paper;
|
||||
|
||||
@@ -159,15 +159,27 @@ struct zint_symbol {
|
||||
#define ERROR_FILE_ACCESS 10
|
||||
#define ERROR_MEMORY 11
|
||||
|
||||
extern struct zint_symbol *ZBarcode_Create();
|
||||
extern int ZBarcode_Delete(struct zint_symbol *symbol);
|
||||
extern int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input);
|
||||
extern int ZBarcode_Print(struct zint_symbol *symbol);
|
||||
extern int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input);
|
||||
extern int ZBarcode_Encode_and_Print_Rotated(struct zint_symbol *symbol, unsigned char *input, int rotate_angle);
|
||||
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_MSC_VER)
|
||||
# if defined (DLL_EXPORT) || defined(PIC) || defined(_USRDLL)
|
||||
# define ZINT_EXTERN __declspec(dllexport)
|
||||
# elif defined(ZINT_DLL)
|
||||
# define ZINT_EXTERN __declspec(dllimport)
|
||||
# else
|
||||
# define ZINT_EXTERN extern
|
||||
# endif
|
||||
#else
|
||||
# define ZINT_EXTERN extern
|
||||
#endif
|
||||
|
||||
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
||||
ZINT_EXTERN int ZBarcode_Delete(struct zint_symbol *symbol);
|
||||
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input);
|
||||
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol);
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input);
|
||||
ZINT_EXTERN int ZBarcode_Encode_and_Print_Rotated(struct zint_symbol *symbol, unsigned char *input, int rotate_angle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
#endif /* ZINT_H */
|
||||
|
||||
Reference in New Issue
Block a user