Make compile with MSVC6 (no C99 compatibility)

This commit is contained in:
Harald Oehlmann 2016-07-28 10:32:46 +02:00
parent 804ca24aca
commit 3939a1ae54
9 changed files with 118 additions and 15 deletions

View File

@ -36,6 +36,10 @@
#include "common.h" #include "common.h"
#include "bmp.h" /* Bitmap header structure */ #include "bmp.h" /* Bitmap header structure */
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
#define SSET "0123456789ABCDEF" #define SSET "0123456789ABCDEF"
@ -46,6 +50,8 @@ int bmp_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
unsigned int data_size; unsigned int data_size;
unsigned char *bitmap_file_start, *bmp_posn; unsigned char *bitmap_file_start, *bmp_posn;
FILE *bmp_file; FILE *bmp_file;
bitmap_file_header_t file_header;
bitmap_info_header_t info_header;
switch (rotate_angle) { switch (rotate_angle) {
case 0: case 0:
@ -184,9 +190,6 @@ int bmp_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
data_size = symbol->bitmap_height * row_size; data_size = symbol->bitmap_height * row_size;
symbol->bitmap_byte_length = data_size; symbol->bitmap_byte_length = data_size;
bitmap_file_header_t file_header;
bitmap_info_header_t info_header;
file_header.header_field = 0x4d42; // "BM" file_header.header_field = 0x4d42; // "BM"
file_header.file_size = sizeof(bitmap_file_header_t) + sizeof(bitmap_info_header_t) + data_size; file_header.file_size = sizeof(bitmap_file_header_t) + sizeof(bitmap_info_header_t) + data_size;
file_header.reserved = 0; file_header.reserved = 0;

View File

@ -36,14 +36,23 @@
extern "C" { extern "C" {
#endif #endif
#include <stdint.h> #ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
typedef struct bitmap_file_header { typedef struct bitmap_file_header {
uint16_t header_field; uint16_t header_field;
uint32_t file_size; uint32_t file_size;
uint32_t reserved; uint32_t reserved;
uint32_t data_offset; uint32_t data_offset;
} __attribute__((__packed__ )) bitmap_file_header_t; }
#ifdef __GNUC__
__attribute__((__packed__ ))
#endif
bitmap_file_header_t;
typedef struct bitmap_info_header { typedef struct bitmap_info_header {
uint32_t header_size; uint32_t header_size;
@ -57,7 +66,11 @@ extern "C" {
int32_t vert_res; int32_t vert_res;
uint32_t colours; uint32_t colours;
uint32_t important_colours; uint32_t important_colours;
} __attribute__((__packed__ )) bitmap_info_header_t; }
#ifdef __GNUC__
__attribute__((__packed__ ))
#endif
bitmap_info_header_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,4 +1,4 @@
/* maxipng.h - Shapes for Maxicode output to PNG file */ /* maxihex.h - Shapes for Maxicode output to PNG file */
/* /*
libzint - the open source barcode library libzint - the open source barcode library

View File

@ -35,7 +35,11 @@
#include <string.h> #include <string.h>
#include "common.h" #include "common.h"
#include "pcx.h" /* PCX header structure */ #include "pcx.h" /* PCX header structure */
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
#define SSET "0123456789ABCDEF" #define SSET "0123456789ABCDEF"
@ -45,11 +49,16 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
int row, column, i, colour; int row, column, i, colour;
int run_count; int run_count;
FILE *pcx_file; FILE *pcx_file;
pcx_header_t header;
#ifdef _MSC_VER
char* rotated_bitmap;
unsigned char* rle_row;
#endif
#ifndef _MSC_VER #ifndef _MSC_VER
char rotated_bitmap[image_height * image_width]; char rotated_bitmap[image_height * image_width];
#else #else
char* rotated_bitmap = (char *) _alloca((image_height * image_width) * sizeof(char)); rotated_bitmap = (char *) _alloca((image_height * image_width) * sizeof(char));
#endif /* _MSC_VER */ #endif /* _MSC_VER */
switch (rotate_angle) { switch (rotate_angle) {
@ -68,7 +77,7 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
#ifndef _MSC_VER #ifndef _MSC_VER
unsigned char rle_row[symbol->bitmap_width]; unsigned char rle_row[symbol->bitmap_width];
#else #else
unsignd char* rle_row = (unsigned char *) _alloca((symbol->bitmap_width * 6) * sizeof(unsigned char)); rle_row = (unsigned char *) _alloca((symbol->bitmap_width * 6) * sizeof(unsigned char));
#endif /* _MSC_VER */ #endif /* _MSC_VER */
/* sort out colour options */ /* sort out colour options */
@ -137,7 +146,6 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width
break; break;
} }
pcx_header_t header;
header.manufacturer = 10; // ZSoft header.manufacturer = 10; // ZSoft
header.version = 5; // Version 3.0 header.version = 5; // Version 3.0

View File

@ -36,7 +36,12 @@
extern "C" { extern "C" {
#endif #endif
#include <stdint.h> #ifdef _MSC_VER
#include <windows.h>
#include "stdint_msvc.h"
#else
#include <stdint.h>
#endif
typedef struct pcx_header { typedef struct pcx_header {
uint8_t manufacturer; uint8_t manufacturer;
@ -57,7 +62,11 @@ extern "C" {
uint16_t horiz_screen_size; uint16_t horiz_screen_size;
uint16_t vert_screen_size; uint16_t vert_screen_size;
uint8_t filler[54]; uint8_t filler[54];
} __attribute__((__packed__ )) pcx_header_t; }
#ifdef __GNUC__
__attribute__((__packed__ ))
#endif
pcx_header_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

52
backend/stdint_msvc.h Normal file
View File

@ -0,0 +1,52 @@
/* stdint_msvc.h - definitions for libzint
libzint - the open source barcode library
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#ifndef STDINT_MSVC_H
#define STDINT_MSVC_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef _MSC_VER
typedef BYTE uint8_t;
typedef WORD uint16_t;
typedef DWORD uint32_t;
typedef INT32 int32_t;
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STDINT_MSVC_H */

View File

@ -53,6 +53,7 @@ SOURCES += qrencode/bitstream.c \
} }
HEADERS += ../backend/aztec.h \ HEADERS += ../backend/aztec.h \
../backend/bmp.h \
../backend/code49.h \ ../backend/code49.h \
../backend/common.h \ ../backend/common.h \
../backend/composite.h \ ../backend/composite.h \
@ -63,17 +64,20 @@ HEADERS += ../backend/aztec.h \
../backend/hanxin.h \ ../backend/hanxin.h \
../backend/large.h \ ../backend/large.h \
../backend/maxicode.h \ ../backend/maxicode.h \
../backend/maxipng.h \ ../backend/maxihex.h \
../backend/pcx.h \
../backend/pdf417.h \ ../backend/pdf417.h \
../backend/reedsol.h \ ../backend/reedsol.h \
../backend/rss.h \ ../backend/rss.h \
../backend/sjis.h \ ../backend/sjis.h \
../backend/stdint_msvc.h \
../backend/zint.h \ ../backend/zint.h \
qzint.h qzint.h
SOURCES += ../backend/2of5.c \ SOURCES += ../backend/2of5.c \
../backend/auspost.c \ ../backend/auspost.c \
../backend/aztec.c \ ../backend/aztec.c \
../backend/bmp.c \
../backend/code.c \ ../backend/code.c \
../backend/code128.c \ ../backend/code128.c \
../backend/code16k.c \ ../backend/code16k.c \
@ -89,10 +93,12 @@ SOURCES += ../backend/2of5.c \
../backend/library.c \ ../backend/library.c \
../backend/maxicode.c \ ../backend/maxicode.c \
../backend/medical.c \ ../backend/medical.c \
../backend/pcx.c \
../backend/pdf417.c \ ../backend/pdf417.c \
../backend/plessey.c \ ../backend/plessey.c \
../backend/postal.c \ ../backend/postal.c \
../backend/ps.c \ ../backend/ps.c \
../backend/raster.c \
../backend/reedsol.c \ ../backend/reedsol.c \
../backend/render.c \ ../backend/render.c \
../backend/rss.c \ ../backend/rss.c \

View File

@ -29,7 +29,7 @@ HEADERS += ../backend/aztec.h \
../backend/gs1.h \ ../backend/gs1.h \
../backend/large.h \ ../backend/large.h \
../backend/maxicode.h \ ../backend/maxicode.h \
../backend/maxipng.h \ ../backend/maxihex.h \
../backend/ms_stdint.h \ ../backend/ms_stdint.h \
../backend/pdf417.h \ ../backend/pdf417.h \
../backend/qr.h \ ../backend/qr.h \

View File

@ -100,6 +100,10 @@ SOURCE=..\..\backend\aztec.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\backend\bmp.c
# End Source File
# Begin Source File
SOURCE=..\..\backend\code.c SOURCE=..\..\backend\code.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -176,6 +180,10 @@ SOURCE=..\..\backend\medical.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\backend\pcx.c
# End Source File
# Begin Source File
SOURCE=..\..\backend\pdf417.c SOURCE=..\..\backend\pdf417.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -200,6 +208,10 @@ SOURCE=..\..\backend\qr.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\backend\raster.c
# End Source File
# Begin Source File
SOURCE=..\..\backend\reedsol.c SOURCE=..\..\backend\reedsol.c
# End Source File # End Source File
# Begin Source File # Begin Source File