commit a54f6b2ea6a23e215015714d42c7f1da1115b5da
parent 438b6f72400f3f992e4ab73fe21aab763b98ae53
Author: Frederic Cambus <fred@statdns.com>
Date: Mon, 2 Jul 2018 11:52:24 +0200
Rename some fields in the input struct
Diffstat:
8 files changed, 101 insertions(+), 101 deletions(-)
diff --git a/include/ansilove.h b/include/ansilove.h
@@ -17,8 +17,8 @@
#include <stdint.h>
struct input {
- unsigned char *data;
- size_t size;
+ unsigned char *buffer;
+ size_t length;
char *fext;
};
diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c
@@ -91,10 +91,10 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
ansi_buffer = malloc(sizeof (struct ansiChar));
// ANSi interpreter
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
- current_character = inputFile->data[loop];
- next_character = inputFile->data[loop + 1];
+ current_character = inputFile->buffer[loop];
+ next_character = inputFile->buffer[loop + 1];
if (column == 80)
{
@@ -129,13 +129,13 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
{
for (ansi_sequence_loop = 0; ansi_sequence_loop < 14; ansi_sequence_loop++)
{
- ansi_sequence_character = inputFile->data[loop + 2 + ansi_sequence_loop];
+ ansi_sequence_character = inputFile->buffer[loop + 2 + ansi_sequence_loop];
// cursor position
if (ansi_sequence_character == 'H' || ansi_sequence_character == 'f')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// create sequence content array
seqArrayCount = explode(&seqArray, ';', seqGrab);
@@ -163,7 +163,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'A')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -179,7 +179,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'B')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -195,7 +195,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'C')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -214,7 +214,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'D')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's content length
int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -253,7 +253,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'J')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// convert grab to an integer
int32_t eraseDisplayInt = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -280,7 +280,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (ansi_sequence_character == 'm')
{
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->data + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
// create sequence content array
seqArrayCount = explode(&seqArray, ';', seqGrab);
diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c
@@ -17,7 +17,7 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
gdImagePtr canvas;
// create ADF instance
- canvas = gdImageCreate(640, (((inputFile->size - 192 - 4096 -1) / 2) / 80) * 16);
+ canvas = gdImageCreate(640, (((inputFile->length - 192 - 4096 -1) / 2) / 80) * 16);
// error output
if (!canvas) {
@@ -35,9 +35,9 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
for (loop = 0; loop < 16; loop++)
{
index = (adf_colors[loop] * 3) + 1;
- gdImageColorAllocate(canvas, (inputFile->data[index] << 2 | inputFile->data[index] >> 4),
- (inputFile->data[index + 1] << 2 | inputFile->data[index + 1] >> 4),
- (inputFile->data[index + 2] << 2 | inputFile->data[index + 2] >> 4));
+ gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
+ (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
+ (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
}
gdImageColorAllocate(canvas, 0, 0, 0);
@@ -47,7 +47,7 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
uint32_t character, attribute, foreground, background;
loop = 192 + 4096 + 1;
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
if (column == 80)
{
@@ -55,13 +55,13 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
row++;
}
- character = inputFile->data[loop];
- attribute = inputFile->data[loop+1];
+ character = inputFile->buffer[loop];
+ attribute = inputFile->buffer[loop+1];
background = (attribute & 240) >> 4;
foreground = attribute & 15;
- drawchar(canvas, inputFile->data+193, 8, 16, column, row, background, foreground, character);
+ drawchar(canvas, inputFile->buffer+193, 8, 16, column, row, background, foreground, character);
column++;
loop += 2;
diff --git a/src/loaders/binary.c b/src/loaders/binary.c
@@ -14,7 +14,7 @@
int ansilove_binary(struct input *inputFile, struct output *outputFile)
{
// binary files must have an even size
- if (inputFile->size % 2) {
+ if (inputFile->length % 2) {
fprintf(stderr, "\nBinary file is not valid.\n");
return -1;
}
@@ -30,7 +30,7 @@ int ansilove_binary(struct input *inputFile, struct output *outputFile)
// allocate buffer image memory
canvas = gdImageCreate(outputFile->columns * outputFile->bits,
- ((inputFile->size / 2) / outputFile->columns * fontData.height));
+ ((inputFile->length / 2) / outputFile->columns * fontData.height));
if (!canvas) {
perror("Error, can't allocate buffer image memory");
@@ -53,7 +53,7 @@ int ansilove_binary(struct input *inputFile, struct output *outputFile)
uint32_t character, attribute, background, foreground;
uint32_t loop = 0, column = 0, row = 0;
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
if (column == outputFile->columns)
{
@@ -61,8 +61,8 @@ int ansilove_binary(struct input *inputFile, struct output *outputFile)
row++;
}
- character = inputFile->data[loop];
- attribute = inputFile->data[loop+1];
+ character = inputFile->buffer[loop];
+ attribute = inputFile->buffer[loop+1];
background = (attribute & 240) >> 4;
foreground = (attribute & 15);
diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c
@@ -14,7 +14,7 @@
int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
{
// extract relevant part of the IDF header, 16-bit endian unsigned short
- int32_t x2 = (inputFile->data[9] << 8) + inputFile->data[8];
+ int32_t x2 = (inputFile->buffer[9] << 8) + inputFile->buffer[8];
// libgd image pointers
gdImagePtr canvas;
@@ -32,14 +32,14 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
int16_t idf_data, idf_data_length;
- while (loop < inputFile->size - 4096 - 48)
+ while (loop < inputFile->length - 4096 - 48)
{
- memcpy(&idf_data, inputFile->data+loop, 2);
+ memcpy(&idf_data, inputFile->buffer+loop, 2);
// RLE compressed data
if (idf_data == 1)
{
- memcpy(&idf_data_length, inputFile->data+loop+2, 2);
+ memcpy(&idf_data_length, inputFile->buffer+loop+2, 2);
idf_sequence_length = idf_data_length & 255;
@@ -55,8 +55,8 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
return -1;
}
- idf_buffer[i] = inputFile->data[loop + 4];
- idf_buffer[i+1] = inputFile->data[loop + 5];
+ idf_buffer[i] = inputFile->buffer[loop + 4];
+ idf_buffer[i+1] = inputFile->buffer[loop + 5];
i += 2;
}
loop += 4;
@@ -73,8 +73,8 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
}
// normal character
- idf_buffer[i] = inputFile->data[loop];
- idf_buffer[i+1] = inputFile->data[loop + 1];
+ idf_buffer[i] = inputFile->buffer[loop];
+ idf_buffer[i+1] = inputFile->buffer[loop + 1];
i += 2;
}
loop += 2;
@@ -93,10 +93,10 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
// process IDF palette
for (loop = 0; loop < 16; loop++)
{
- index = (loop * 3) + inputFile->size - 48;
- colors[loop] = gdImageColorAllocate(canvas, (inputFile->data[index] << 2 | inputFile->data[index] >> 4),
- (inputFile->data[index + 1] << 2 | inputFile->data[index + 1] >> 4),
- (inputFile->data[index + 2] << 2 | inputFile->data[index + 2] >> 4));
+ index = (loop * 3) + inputFile->length - 48;
+ colors[loop] = gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
+ (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
+ (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
}
// render IDF
@@ -117,7 +117,7 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
background = (attribute & 240) >> 4;
foreground = attribute & 15;
- drawchar(canvas, inputFile->data+(inputFile->size - 48 - 4096), 8, 16, column, row, colors[background], colors[foreground], character);
+ drawchar(canvas, inputFile->buffer+(inputFile->length - 48 - 4096), 8, 16, column, row, colors[background], colors[foreground], character);
column++;
}
diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c
@@ -47,10 +47,10 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
loop = 0;
structIndex = 0;
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
- current_character = inputFile->data[loop];
- next_character = inputFile->data[loop+1];
+ current_character = inputFile->buffer[loop];
+ next_character = inputFile->buffer[loop+1];
if (column == 80)
{
@@ -84,12 +84,12 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
if (current_character == 64 && next_character == 88)
{
// set graphics rendition
- background = inputFile->data[loop+2];
- foreground = inputFile->data[loop+3];
+ background = inputFile->buffer[loop+2];
+ foreground = inputFile->buffer[loop+3];
loop += 3;
}
else if (current_character == 64 && next_character == 67 &&
- inputFile->data[loop+2] == 'L' && inputFile->data[loop+3] == 'S')
+ inputFile->buffer[loop+2] == 'L' && inputFile->buffer[loop+3] == 'S')
{
// erase display
column = 0;
@@ -100,18 +100,18 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
loop += 4;
}
- else if (current_character == 64 && next_character == 80 && inputFile->data[loop+2] == 'O'
- && inputFile->data[loop+3] == 'S' && inputFile->data[loop+4] == ':')
+ else if (current_character == 64 && next_character == 80 && inputFile->buffer[loop+2] == 'O'
+ && inputFile->buffer[loop+3] == 'S' && inputFile->buffer[loop+4] == ':')
{
// cursor position
- if (inputFile->data[loop+6] == '@')
+ if (inputFile->buffer[loop+6] == '@')
{
- column = ((inputFile->data[loop+5])-48)-1;
+ column = ((inputFile->buffer[loop+5])-48)-1;
loop += 5;
}
else
{
- column = (10 * ((inputFile->data[loop+5])-48) + (inputFile->data[loop+6])-48)-1;
+ column = (10 * ((inputFile->buffer[loop+5])-48) + (inputFile->buffer[loop+6])-48)-1;
loop += 6;
}
}
diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c
@@ -25,8 +25,8 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
gdImagePtr canvas;
// extract tundra header
- tundra_version = inputFile->data[0];
- memcpy(&tundra_header, inputFile->data+1, 8);
+ tundra_version = inputFile->buffer[0];
+ memcpy(&tundra_header, inputFile->buffer+1, 8);
// need to add check for "TUNDRA24" string in the header
if (tundra_version != 24) {
@@ -38,7 +38,7 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
uint32_t character, background = 0, foreground = 0;
uint32_t loop = 9, column = 0, row = 1;
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
if (column == 80)
{
@@ -46,38 +46,38 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
row++;
}
- character = inputFile->data[loop];
+ character = inputFile->buffer[loop];
if (character == 1)
{
row =
- (inputFile->data[loop + 1] << 24) + (inputFile->data[loop + 2] << 16) +
- (inputFile->data[loop + 3] << 8) + inputFile->data[loop+4];
+ (inputFile->buffer[loop + 1] << 24) + (inputFile->buffer[loop + 2] << 16) +
+ (inputFile->buffer[loop + 3] << 8) + inputFile->buffer[loop+4];
column =
- (inputFile->data[loop + 5] << 24) + (inputFile->data[loop + 6] << 16) +
- (inputFile->data[loop + 7] << 8) + inputFile->data[loop+8];
+ (inputFile->buffer[loop + 5] << 24) + (inputFile->buffer[loop + 6] << 16) +
+ (inputFile->buffer[loop + 7] << 8) + inputFile->buffer[loop+8];
loop += 8;
}
if (character == 2)
{
- character = inputFile->data[loop + 1];
+ character = inputFile->buffer[loop + 1];
loop += 5;
}
if (character == 4)
{
- character = inputFile->data[loop + 1];
+ character = inputFile->buffer[loop + 1];
loop += 5;
}
if (character == 6)
{
- character = inputFile->data[loop + 1];
+ character = inputFile->buffer[loop + 1];
loop += 9;
}
@@ -102,7 +102,7 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
loop = 9;
- while (loop < inputFile->size)
+ while (loop < inputFile->length)
{
if (column == 80)
{
@@ -110,17 +110,17 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
row++;
}
- character = inputFile->data[loop];
+ character = inputFile->buffer[loop];
if (character == 1)
{
row =
- (inputFile->data[loop + 1] << 24) + (inputFile->data[loop + 2] << 16) +
- (inputFile->data[loop + 3] << 8) + inputFile->data[loop + 4];
+ (inputFile->buffer[loop + 1] << 24) + (inputFile->buffer[loop + 2] << 16) +
+ (inputFile->buffer[loop + 3] << 8) + inputFile->buffer[loop + 4];
column =
- (inputFile->data[loop + 5] << 24) + (inputFile->data[loop + 6] << 16) +
- (inputFile->data[loop + 7] << 8) + inputFile->data[loop + 8];
+ (inputFile->buffer[loop + 5] << 24) + (inputFile->buffer[loop + 6] << 16) +
+ (inputFile->buffer[loop + 7] << 8) + inputFile->buffer[loop + 8];
loop += 8;
}
@@ -128,20 +128,20 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
if (character == 2)
{
foreground =
- (inputFile->data[loop + 3] << 16) + (inputFile->data[loop + 4] << 8) +
- inputFile->data[loop + 5];
+ (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
+ inputFile->buffer[loop + 5];
- character = inputFile->data[loop+1];
+ character = inputFile->buffer[loop+1];
loop += 5;
}
if (character == 4)
{
- background = (inputFile->data[loop + 3] << 16) + (inputFile->data[loop + 4] << 8) +
- inputFile->data[loop+5];
+ background = (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
+ inputFile->buffer[loop+5];
- character = inputFile->data[loop+1];
+ character = inputFile->buffer[loop+1];
loop += 5;
}
@@ -149,14 +149,14 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
if (character == 6)
{
foreground =
- (inputFile->data[loop + 3] << 16) + (inputFile->data[loop + 4] << 8) +
- inputFile->data[loop+5];
+ (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
+ inputFile->buffer[loop+5];
background =
- (inputFile->data[loop + 7] << 16) + (inputFile->data[loop + 8] << 8) +
- inputFile->data[loop+9];
+ (inputFile->buffer[loop + 7] << 16) + (inputFile->buffer[loop + 8] << 8) +
+ inputFile->buffer[loop+9];
- character = inputFile->data[loop+1];
+ character = inputFile->buffer[loop+1];
loop += 9;
}
diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c
@@ -16,15 +16,15 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
const unsigned char *font_data;
unsigned char *font_data_xbin = NULL;
- if (strncmp((char *)inputFile->data, "XBIN\x1a", 5) != 0) {
+ if (strncmp((char *)inputFile->buffer, "XBIN\x1a", 5) != 0) {
fputs("\nNot an XBin.\n\n", stderr);
return -1;
}
- int32_t xbin_width = (inputFile->data[6] << 8) + inputFile->data[5];
- int32_t xbin_height = (inputFile->data[8] << 8) + inputFile->data[7];
- int32_t xbin_fontsize = inputFile->data[9];
- int32_t xbin_flags = inputFile->data[10];
+ int32_t xbin_width = (inputFile->buffer[6] << 8) + inputFile->buffer[5];
+ int32_t xbin_height = (inputFile->buffer[8] << 8) + inputFile->buffer[7];
+ int32_t xbin_fontsize = inputFile->buffer[9];
+ int32_t xbin_flags = inputFile->buffer[10];
gdImagePtr canvas;
@@ -50,9 +50,9 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
{
index = (loop * 3) + offset;
- colors[loop] = gdImageColorAllocate(canvas, (inputFile->data[index] << 2 | inputFile->data[index] >> 4),
- (inputFile->data[index + 1] << 2 | inputFile->data[index + 1] >> 4),
- (inputFile->data[index + 2] << 2 | inputFile->data[index + 2] >> 4));
+ colors[loop] = gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
+ (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
+ (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
}
offset += 48;
@@ -75,7 +75,7 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
perror("Memory error");
return -1;
}
- memcpy(font_data_xbin, inputFile->data+offset, (xbin_fontsize * numchars));
+ memcpy(font_data_xbin, inputFile->buffer+offset, (xbin_fontsize * numchars));
font_data = font_data_xbin;
@@ -91,10 +91,10 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
// read compressed xbin
if ((xbin_flags & 4) == 4) {
- while (offset < inputFile->size && row != xbin_height)
+ while (offset < inputFile->length && row != xbin_height)
{
- int32_t ctype = inputFile->data[offset] & 0xC0;
- int32_t counter = (inputFile->data[offset] & 0x3F) + 1;
+ int32_t ctype = inputFile->buffer[offset] & 0xC0;
+ int32_t counter = (inputFile->buffer[offset] & 0x3F) + 1;
character = -1;
attribute = -1;
@@ -103,36 +103,36 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
while (counter--) {
// none
if (ctype == 0) {
- character = inputFile->data[offset];
- attribute = inputFile->data[offset + 1];
+ character = inputFile->buffer[offset];
+ attribute = inputFile->buffer[offset + 1];
offset += 2;
}
// char
else if (ctype == 0x40) {
if (character == -1) {
- character = inputFile->data[offset];
+ character = inputFile->buffer[offset];
offset++;
}
- attribute = inputFile->data[offset];
+ attribute = inputFile->buffer[offset];
offset++;
}
// attr
else if (ctype == 0x80) {
if (attribute == -1) {
- attribute = inputFile->data[offset];
+ attribute = inputFile->buffer[offset];
offset++;
}
- character = inputFile->data[offset];
+ character = inputFile->buffer[offset];
offset++;
}
// both
else {
if (character == -1) {
- character = inputFile->data[offset];
+ character = inputFile->buffer[offset];
offset++;
}
if (attribute == -1) {
- attribute = inputFile->data[offset];
+ attribute = inputFile->buffer[offset];
offset++;
}
}
@@ -154,7 +154,7 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
}
// read uncompressed xbin
else {
- while (offset < inputFile->size && row != xbin_height)
+ while (offset < inputFile->length && row != xbin_height)
{
if (column == xbin_width)
{
@@ -162,8 +162,8 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
row++;
}
- character = inputFile->data[offset];
- attribute = inputFile->data[offset+1];
+ character = inputFile->buffer[offset];
+ attribute = inputFile->buffer[offset+1];
background = (attribute & 240) >> 4;
foreground = attribute & 15;