diff --git a/backend/common.c b/backend/common.c index 9cf3a56d..e7ed58a6 100644 --- a/backend/common.c +++ b/backend/common.c @@ -23,7 +23,7 @@ #include #include "common.h" -const int ustrlen(unsigned char data[]) { +int ustrlen(unsigned char data[]) { /* Local replacement for strlen() with unsigned char strings */ int i; for (i=0;data[i];i++); diff --git a/backend/common.h b/backend/common.h index 04602988..52bc9117 100644 --- a/backend/common.h +++ b/backend/common.h @@ -41,7 +41,7 @@ extern "C" { #endif /* __cplusplus */ -extern const int ustrlen(unsigned char source[]); +extern 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[]); diff --git a/backend/library.c b/backend/library.c index 7476f587..edb18759 100644 --- a/backend/library.c +++ b/backend/library.c @@ -67,11 +67,30 @@ struct zint_symbol *ZBarcode_Create() return symbol; } - -int ZBarcode_Delete(struct zint_symbol *symbol) +void ZBarcode_Clear(struct zint_symbol *symbol) { + int i, j; + + for(i = 0; i < symbol->rows; i++) { + for(j = 0; j < symbol->width; j++) { + unset_module(symbol, i, j); + } + } + symbol->rows = 0; + symbol->width = 0; + symbol->text[0] = '\0'; + symbol->errtxt[0] = '\0'; + if (symbol->bitmap != NULL) + free(symbol->bitmap); + symbol->bitmap_width = 0; + symbol->bitmap_height = 0; +} + +void ZBarcode_Delete(struct zint_symbol *symbol) +{ + if (symbol->bitmap != NULL) + free(symbol->bitmap); free(symbol); - return 0; } extern int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */ diff --git a/backend/postal.c b/backend/postal.c index 15d4971f..5e046e19 100644 --- a/backend/postal.c +++ b/backend/postal.c @@ -366,7 +366,7 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) char height_pattern[50], localstr[13]; unsigned int loopey; int writer, i, h; - int error_number, zeroes; + int error_number, /* zeroes; */ strcpy(height_pattern, ""); error_number = 0; @@ -383,9 +383,10 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) } /* Add leading zeroes */ - zeroes = 11 - length; + /* zeroes = 11 - length; memset(localstr, '0', zeroes); - strcpy(localstr + zeroes, (char *)source); + strcpy(localstr + zeroes, (char *)source);*/ + strcpy(localstr, (char *)source); /* Encode data */ for (i = 0; i < 11; i++) { diff --git a/backend/zint.h b/backend/zint.h index a6b1fda7..b917c376 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -178,7 +178,8 @@ struct zint_symbol { #endif ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void); -ZINT_EXTERN int ZBarcode_Delete(struct zint_symbol *symbol); +ZINT_EXTERN void ZBarcode_Clear(struct zint_symbol *symbol); +ZINT_EXTERN void ZBarcode_Delete(struct zint_symbol *symbol); ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input, int length); ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename); @@ -187,7 +188,7 @@ ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned c ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle); ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle); -ZINT_EXTERN int ZBarcide_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle); +ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle); ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle); ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);