mirror of
https://github.com/theclashingfritz/soft2scene.git
synced 2025-12-30 07:29:31 -06:00
A load of progress.
This commit is contained in:
106
BinaryFile.cpp
106
BinaryFile.cpp
@@ -3,9 +3,17 @@
|
||||
#include "BinaryFile.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
BinaryFile::BinaryFile(const char *fname) {
|
||||
filestream.open(fname, std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
#include <zlib.h>
|
||||
|
||||
BinaryFile::BinaryFile() {
|
||||
|
||||
}
|
||||
|
||||
BinaryFile::BinaryFile(const char *fname) : filepath(fname) {
|
||||
filestream.open(filepath, std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc);
|
||||
if (!filestream.is_open()) {
|
||||
std::cerr << "File Error: " << strerror(errno) << std::endl;
|
||||
}
|
||||
@@ -17,12 +25,106 @@ BinaryFile::~BinaryFile() {
|
||||
}
|
||||
}
|
||||
|
||||
CompressedBinaryFile::CompressedBinaryFile() {
|
||||
|
||||
}
|
||||
|
||||
CompressedBinaryFile::CompressedBinaryFile(const char *fname) : BinaryFile(fname) {
|
||||
|
||||
}
|
||||
|
||||
CompressedBinaryFile::~CompressedBinaryFile() {
|
||||
if (filestream.is_open()) {
|
||||
compress_file();
|
||||
filestream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CompressedBinaryFile::compress_file() {
|
||||
filestream.seekg(0, std::ios::end);
|
||||
size_t length = filestream.tellg();
|
||||
filestream.seekg(0, std::ios::beg);
|
||||
|
||||
char *inbuffer = new char[length + 1];
|
||||
|
||||
// Read file
|
||||
filestream.read(inbuffer, length);
|
||||
filestream.close();
|
||||
|
||||
// Reopen the file.
|
||||
filestream.open(filepath, std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc);
|
||||
|
||||
const size_t BUFSIZE = 128 * 1024;
|
||||
uint8_t temp_buffer[BUFSIZE];
|
||||
|
||||
size_t buffer_pos = 0;
|
||||
size_t buffer_size = BUFSIZE + 1;
|
||||
char *buffer = (char *)malloc(sizeof(char) * buffer_size);
|
||||
memset(buffer, 0, buffer_size);
|
||||
|
||||
// Compress our file data.
|
||||
{
|
||||
z_stream strm;
|
||||
strm.zalloc = 0;
|
||||
strm.zfree = 0;
|
||||
strm.next_in = (Bytef *)inbuffer;
|
||||
strm.avail_in = length;
|
||||
strm.next_out = temp_buffer;
|
||||
strm.avail_out = BUFSIZE;
|
||||
|
||||
deflateInit(&strm, Z_BEST_COMPRESSION);
|
||||
|
||||
while (strm.avail_in != 0) {
|
||||
int res = deflate(&strm, Z_NO_FLUSH);
|
||||
assert(res == Z_OK);
|
||||
if (strm.avail_out == 0) {
|
||||
buffer_size += BUFSIZE;
|
||||
buffer = (char *)realloc(buffer, sizeof(char) * buffer_size);
|
||||
memcpy(buffer + buffer_pos, temp_buffer, BUFSIZE);
|
||||
buffer_pos += BUFSIZE;
|
||||
|
||||
strm.next_out = temp_buffer;
|
||||
strm.avail_out = BUFSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
int deflate_res = Z_OK;
|
||||
while (deflate_res == Z_OK) {
|
||||
if (strm.avail_out == 0) {
|
||||
buffer_size += BUFSIZE;
|
||||
buffer = (char *)realloc(buffer, sizeof(char) * buffer_size);
|
||||
memcpy(buffer + buffer_pos, temp_buffer, BUFSIZE);
|
||||
buffer_pos += BUFSIZE;
|
||||
|
||||
strm.next_out = temp_buffer;
|
||||
strm.avail_out = BUFSIZE;
|
||||
}
|
||||
deflate_res = deflate(&strm, Z_FINISH);
|
||||
}
|
||||
assert(deflate_res == Z_STREAM_END);
|
||||
|
||||
if (strm.avail_out > 0) {
|
||||
size_t write_size = BUFSIZE - strm.avail_out;
|
||||
if (buffer_pos + write_size >= buffer_size) {
|
||||
buffer_size += write_size;
|
||||
buffer = (char *)realloc(buffer, sizeof(char) * buffer_size);
|
||||
}
|
||||
memcpy(buffer + buffer_pos, temp_buffer, write_size);
|
||||
buffer_pos += write_size;
|
||||
buffer[buffer_pos] = 0;
|
||||
}
|
||||
|
||||
// Reallocate to the EXACT size we need and want.
|
||||
buffer_size = buffer_pos;
|
||||
buffer = (char *)realloc(buffer, sizeof(char) * buffer_size);
|
||||
|
||||
deflateEnd(&strm);
|
||||
}
|
||||
|
||||
// Write the compressed buffer to our file.
|
||||
filestream.write(buffer, buffer_size);
|
||||
|
||||
// Free our buffer!
|
||||
free(buffer);
|
||||
}
|
||||
31
BinaryFile.h
31
BinaryFile.h
@@ -5,14 +5,21 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
class BinaryFile;
|
||||
class CompressedBinaryFile;
|
||||
|
||||
class BinaryFile {
|
||||
friend class CompressedBinaryFile;
|
||||
|
||||
public:
|
||||
BinaryFile();
|
||||
BinaryFile(const char *fname);
|
||||
virtual ~BinaryFile();
|
||||
|
||||
@@ -69,11 +76,17 @@ class BinaryFile {
|
||||
}
|
||||
|
||||
protected:
|
||||
// Stream we use for working on the data.
|
||||
std::fstream filestream;
|
||||
|
||||
private:
|
||||
// Filepath used to opening our file stream.
|
||||
std::string filepath;
|
||||
};
|
||||
|
||||
class CompressedBinaryFile : public BinaryFile {
|
||||
public:
|
||||
CompressedBinaryFile();
|
||||
CompressedBinaryFile(const char *fname);
|
||||
virtual ~CompressedBinaryFile();
|
||||
|
||||
@@ -119,6 +132,20 @@ class CompressedBinaryFile : public BinaryFile {
|
||||
return write(cval.uval);
|
||||
}
|
||||
|
||||
std::ostream& write(const char *str) {
|
||||
assert(str != nullptr);
|
||||
return filestream.write(str, strlen(str));
|
||||
}
|
||||
|
||||
std::ostream& write(char *const &str) {
|
||||
assert(str != nullptr);
|
||||
return filestream.write(str, strlen(str));
|
||||
}
|
||||
|
||||
std::ostream& write(const std::string &str) {
|
||||
return filestream.write(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
std::ostream &write(const Vector3f &value) {
|
||||
write(value.x);
|
||||
write(value.y);
|
||||
@@ -166,8 +193,6 @@ class CompressedBinaryFile : public BinaryFile {
|
||||
}
|
||||
return *stream;
|
||||
}
|
||||
|
||||
// Direct types to write compressed.
|
||||
|
||||
virtual std::ostream &write_uint32(const uint32_t &value) {
|
||||
return write(value);
|
||||
@@ -176,4 +201,6 @@ class CompressedBinaryFile : public BinaryFile {
|
||||
virtual std::ostream &write_uint64(const uint64_t &value) {
|
||||
return write(value);
|
||||
}
|
||||
|
||||
void compress_file();
|
||||
};
|
||||
@@ -35,6 +35,14 @@ Constraint::Type Constraint::get_type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
void Constraint::set_active(bool is_active) {
|
||||
active = is_active;
|
||||
}
|
||||
|
||||
bool Constraint::get_active() {
|
||||
return active;
|
||||
}
|
||||
|
||||
void Constraint::set_passive_element(Element *element) {
|
||||
assert(element != nullptr);
|
||||
passive_element = element;
|
||||
@@ -100,6 +108,7 @@ PositionLimits *Constraint::get_position_limits() {
|
||||
|
||||
void Constraint::write(BinaryFile &file) {
|
||||
file.write(type);
|
||||
file.write(active);
|
||||
file.write(passive_element_index);
|
||||
file.write(active_elements_count);
|
||||
assert(active_element_indicies != nullptr);
|
||||
|
||||
@@ -16,6 +16,7 @@ class Constraint {
|
||||
SCALE,
|
||||
POSITION_LIMIT,
|
||||
ROTATION_LIMIT,
|
||||
UP_VCT,
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -23,6 +24,9 @@ class Constraint {
|
||||
~Constraint();
|
||||
|
||||
Type get_type();
|
||||
|
||||
void set_active(bool is_active);
|
||||
bool get_active();
|
||||
|
||||
void set_passive_element(Element *element);
|
||||
Element *get_passive_element();
|
||||
@@ -47,6 +51,9 @@ class Constraint {
|
||||
private:
|
||||
// The type of constraint this is, INVALID means there is no valid type set.
|
||||
Type type = INVALID;
|
||||
|
||||
// If the constraint is activated.
|
||||
bool active = true;
|
||||
|
||||
// The 'passive' element, This is the target of the constraint and what the constraints, well constrain.
|
||||
Element *passive_element = nullptr;
|
||||
|
||||
239
Element.cpp
239
Element.cpp
@@ -17,6 +17,10 @@ Element::~Element() {
|
||||
delete mesh_info;
|
||||
mesh_info = nullptr;
|
||||
}
|
||||
if (node) {
|
||||
delete node;
|
||||
node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Element::set_parent(Element *new_parent) {
|
||||
@@ -86,6 +90,22 @@ bool Element::get_visibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
void Element::set_as_joint(bool is_joint) {
|
||||
joint = is_joint;
|
||||
}
|
||||
|
||||
bool Element::is_joint() {
|
||||
return joint;
|
||||
}
|
||||
|
||||
void Element::prepare_joint_linklist_node() {
|
||||
node = new JointLinkListNode;
|
||||
}
|
||||
|
||||
JointLinkListNode *Element::get_joint_linklist_node() {
|
||||
return node;
|
||||
}
|
||||
|
||||
void Element::prepare_children(uint32_t amount) {
|
||||
// If we already HAVE children. Then release the buffer.
|
||||
if (children) {
|
||||
@@ -127,19 +147,19 @@ uint64_t Element::get_flags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
void Element::set_array_position(SIZE index) {
|
||||
void Element::set_array_position(int64_t index) {
|
||||
array_index = index;
|
||||
}
|
||||
|
||||
SIZE Element::get_array_position() {
|
||||
int64_t Element::get_array_position() {
|
||||
return array_index;
|
||||
}
|
||||
|
||||
void Element::set_parent_position(SIZE index) {
|
||||
void Element::set_parent_position(int64_t index) {
|
||||
parent_index = index;
|
||||
}
|
||||
|
||||
SIZE Element::get_parent_position() {
|
||||
int64_t Element::get_parent_position() {
|
||||
return parent_index;
|
||||
}
|
||||
|
||||
@@ -149,11 +169,11 @@ void Element::prepare_children_indicies() {
|
||||
children_indexes = nullptr;
|
||||
}
|
||||
|
||||
children_indexes = new SIZE[children_count + 1];
|
||||
memset(children_indexes, NULL, sizeof(SIZE) * children_count);
|
||||
children_indexes = new int64_t[children_count + 1];
|
||||
memset(children_indexes, NULL, sizeof(int64_t) * children_count);
|
||||
}
|
||||
|
||||
SIZE *Element::get_children_indicies() {
|
||||
int64_t *Element::get_children_indicies() {
|
||||
return children_indexes;
|
||||
}
|
||||
|
||||
@@ -166,6 +186,7 @@ void Element::write(BinaryFile &file) {
|
||||
file.write(rot);
|
||||
file.write(scale);
|
||||
file.write(visibility);
|
||||
file.write(joint);
|
||||
file.write(array_index);
|
||||
file.write(parent_index);
|
||||
file.write(children_count);
|
||||
@@ -177,6 +198,9 @@ void Element::write(BinaryFile &file) {
|
||||
assert(mesh_info != nullptr);
|
||||
mesh_info->write(file);
|
||||
}
|
||||
if (joint) {
|
||||
node->write(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,26 +235,6 @@ MeshInfo::~MeshInfo() {
|
||||
delete[] v_coords;
|
||||
v_coords = nullptr;
|
||||
}
|
||||
if (u_scales) {
|
||||
delete[] u_scales;
|
||||
u_scales = nullptr;
|
||||
}
|
||||
if (v_scales) {
|
||||
delete[] v_scales;
|
||||
v_scales = nullptr;
|
||||
}
|
||||
if (u_offsets) {
|
||||
delete[] u_offsets;
|
||||
u_offsets = nullptr;
|
||||
}
|
||||
if (v_offsets) {
|
||||
delete[] v_offsets;
|
||||
v_offsets = nullptr;
|
||||
}
|
||||
if (texture_names) {
|
||||
delete[] texture_names;
|
||||
texture_names = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MeshInfo::set_triangle_count(uint32_t new_triangle_count) {
|
||||
@@ -241,6 +245,14 @@ uint32_t MeshInfo::get_triangle_count() {
|
||||
return triangle_count;
|
||||
}
|
||||
|
||||
void MeshInfo::set_material_id(uint32_t id) {
|
||||
material_id = id;
|
||||
}
|
||||
|
||||
uint32_t MeshInfo::get_material_id() {
|
||||
return material_id;
|
||||
}
|
||||
|
||||
void MeshInfo::prepare_control_vertices(uint32_t new_vertices_count) {
|
||||
// If we already HAVE control vertices. Then release the buffer.
|
||||
if (control_vertices) {
|
||||
@@ -335,8 +347,7 @@ uint32_t MeshInfo::get_normals_count() {
|
||||
return normals_count;
|
||||
}
|
||||
|
||||
void MeshInfo::prepare_uvs_and_textures(uint32_t new_uv_coords_count, uint32_t new_uv_scales_count, uint32_t new_uv_offsets_count,
|
||||
uint32_t new_texture_names_count, uint32_t new_texture_count) {
|
||||
void MeshInfo::prepare_uv_coords(uint32_t new_uv_coords_count) {
|
||||
// Free arrays if they're already allocated.
|
||||
if (u_coords) {
|
||||
delete[] u_coords;
|
||||
@@ -346,33 +357,9 @@ void MeshInfo::prepare_uvs_and_textures(uint32_t new_uv_coords_count, uint32_t n
|
||||
delete[] v_coords;
|
||||
v_coords = nullptr;
|
||||
}
|
||||
if (u_scales) {
|
||||
delete[] u_scales;
|
||||
u_scales = nullptr;
|
||||
}
|
||||
if (v_scales) {
|
||||
delete[] v_scales;
|
||||
v_scales = nullptr;
|
||||
}
|
||||
if (u_offsets) {
|
||||
delete[] u_offsets;
|
||||
u_offsets = nullptr;
|
||||
}
|
||||
if (v_offsets) {
|
||||
delete[] v_offsets;
|
||||
v_offsets = nullptr;
|
||||
}
|
||||
if (texture_names) {
|
||||
delete[] texture_names;
|
||||
texture_names = nullptr;
|
||||
}
|
||||
|
||||
// Store our counts.
|
||||
uv_coords_count = new_uv_coords_count;
|
||||
uv_scales_count = new_uv_scales_count;
|
||||
uv_offsets_count = new_uv_offsets_count;
|
||||
texture_names_count = new_texture_names_count;
|
||||
texture_count = new_texture_count;
|
||||
|
||||
// Allocate arrays for uv coordinates.
|
||||
u_coords = new float[uv_coords_count + 1];
|
||||
@@ -380,30 +367,6 @@ void MeshInfo::prepare_uvs_and_textures(uint32_t new_uv_coords_count, uint32_t n
|
||||
|
||||
v_coords = new float[uv_coords_count + 1];
|
||||
memset(v_coords, 0, sizeof(float) * uv_coords_count);
|
||||
|
||||
// Allocate arrays of texture info.
|
||||
u_scales = new float[uv_scales_count + 1];
|
||||
memset(u_scales, 0, sizeof(float) * uv_scales_count);
|
||||
|
||||
v_scales = new float[uv_scales_count + 1];
|
||||
memset(v_scales, 0, sizeof(float) * uv_scales_count);
|
||||
|
||||
u_offsets = new float[uv_offsets_count + 1];
|
||||
memset(u_offsets, 0, sizeof(float) * uv_offsets_count);
|
||||
|
||||
v_offsets = new float[uv_offsets_count + 1];
|
||||
memset(v_offsets, 0, sizeof(float) * uv_offsets_count);
|
||||
|
||||
texture_names = new char *[texture_names_count + 1];
|
||||
memset(texture_names, 0, sizeof(char *) * texture_names_count);
|
||||
}
|
||||
|
||||
int32_t &MeshInfo::get_u_repeat() {
|
||||
return u_repeat;
|
||||
}
|
||||
|
||||
int32_t &MeshInfo::get_v_repeat() {
|
||||
return v_repeat;
|
||||
}
|
||||
|
||||
float *MeshInfo::get_u_coords() {
|
||||
@@ -414,35 +377,9 @@ float *MeshInfo::get_v_coords() {
|
||||
return v_coords;
|
||||
}
|
||||
|
||||
float *MeshInfo::get_u_scale() {
|
||||
return u_scales;
|
||||
}
|
||||
|
||||
float *MeshInfo::get_v_scale() {
|
||||
return v_scales;
|
||||
}
|
||||
|
||||
float *MeshInfo::get_u_offset() {
|
||||
return u_offsets;
|
||||
}
|
||||
|
||||
float *MeshInfo::get_v_offset() {
|
||||
return v_offsets;
|
||||
}
|
||||
|
||||
void MeshInfo::set_texture_name(uint32_t index, const char *name) {
|
||||
// Don't allow a buffer overflow!
|
||||
if (index >= texture_names_count) { return; }
|
||||
|
||||
texture_names[index] = (char *)name;
|
||||
}
|
||||
|
||||
char **MeshInfo::get_texture_names() {
|
||||
return texture_names;
|
||||
}
|
||||
|
||||
void MeshInfo::write(BinaryFile &file) {
|
||||
file.write(triangle_count);
|
||||
file.write(material_id);
|
||||
file.write(control_vertices_count);
|
||||
for (uint32_t i = 0; i < control_vertices_count; i++) {
|
||||
Vector4d &control_vertex = control_vertices[i];
|
||||
@@ -463,8 +400,6 @@ void MeshInfo::write(BinaryFile &file) {
|
||||
Vector4d &normal = normals[i];
|
||||
file.write(normal);
|
||||
}
|
||||
file.write(u_repeat);
|
||||
file.write(v_repeat);
|
||||
file.write(uv_coords_count);
|
||||
for (uint32_t i = 0; i < uv_coords_count; i++) {
|
||||
float &u_coord = u_coords[i];
|
||||
@@ -472,26 +407,80 @@ void MeshInfo::write(BinaryFile &file) {
|
||||
file.write(u_coord);
|
||||
file.write(v_coord);
|
||||
}
|
||||
file.write(uv_scales_count);
|
||||
for (uint32_t i = 0; i < uv_scales_count; i++) {
|
||||
float &u_scale = u_scales[i];
|
||||
float &v_scale = v_scales[i];
|
||||
file.write(u_scale);
|
||||
file.write(v_scale);
|
||||
}
|
||||
|
||||
|
||||
JointLinkListNode::~JointLinkListNode() {
|
||||
if (next) {
|
||||
delete[] next;
|
||||
next = nullptr;
|
||||
}
|
||||
file.write(uv_offsets_count);
|
||||
for (uint32_t i = 0; i < uv_offsets_count; i++) {
|
||||
float &u_offset = u_offsets[i];
|
||||
float &v_offset = v_offsets[i];
|
||||
file.write(u_offset);
|
||||
file.write(v_offset);
|
||||
if (next_indicies) {
|
||||
delete[] next_indicies;
|
||||
next_indicies = nullptr;
|
||||
}
|
||||
file.write(texture_count);
|
||||
file.write(texture_names_count);
|
||||
for (uint32_t i = 0; i < texture_names_count; i++) {
|
||||
char *&texture_name = texture_names[i];
|
||||
if (texture_name == nullptr) { continue; }
|
||||
file.write_uint64(strlen(texture_name));
|
||||
file.write(texture_name);
|
||||
}
|
||||
|
||||
|
||||
void JointLinkListNode::prepare_next() {
|
||||
// Free arrays if they're already allocated.
|
||||
if (next) {
|
||||
delete[] next;
|
||||
next = nullptr;
|
||||
}
|
||||
|
||||
next = new Element *[next_count + 1];
|
||||
memset(next, 0, sizeof(Element *) * next_count);
|
||||
}
|
||||
|
||||
Element **JointLinkListNode::get_next() {
|
||||
return next;
|
||||
}
|
||||
|
||||
void JointLinkListNode::set_next_count(SIZE count) {
|
||||
next_count = count;
|
||||
}
|
||||
|
||||
SIZE JointLinkListNode::get_next_count() {
|
||||
return next_count;
|
||||
}
|
||||
|
||||
void JointLinkListNode::set_previous(Element *element) {
|
||||
previous = element;
|
||||
}
|
||||
|
||||
Element *JointLinkListNode::get_previous() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
void JointLinkListNode::prepare_next_indicies() {
|
||||
// Free arrays if they're already allocated.
|
||||
if (next_indicies) {
|
||||
delete[] next_indicies;
|
||||
next_indicies = nullptr;
|
||||
}
|
||||
|
||||
next_indicies = new int64_t[next_count + 1];
|
||||
memset(next_indicies, 0, sizeof(int64_t) * next_count);
|
||||
}
|
||||
|
||||
int64_t *JointLinkListNode::get_next_indicies() {
|
||||
return next_indicies;
|
||||
}
|
||||
|
||||
void JointLinkListNode::set_previous_index(int64_t index) {
|
||||
previous_index = index;
|
||||
}
|
||||
|
||||
int64_t JointLinkListNode::get_previous_index() {
|
||||
return previous_index;
|
||||
}
|
||||
|
||||
void JointLinkListNode::write(BinaryFile &file) {
|
||||
file.write(next_count);
|
||||
for (SIZE i = 0; i < next_count; i++) {
|
||||
int64_t next_index = next_indicies[i];
|
||||
file.write(next_index);
|
||||
}
|
||||
file.write(previous_index);
|
||||
}
|
||||
92
Element.h
92
Element.h
@@ -14,6 +14,9 @@ class MeshInfo {
|
||||
|
||||
void set_triangle_count(uint32_t new_triangle_count);
|
||||
uint32_t get_triangle_count();
|
||||
|
||||
void set_material_id(uint32_t id);
|
||||
uint32_t get_material_id();
|
||||
|
||||
void prepare_control_vertices(uint32_t new_vertices_count);
|
||||
Vector4d *get_control_vertices();
|
||||
@@ -31,29 +34,19 @@ class MeshInfo {
|
||||
Vector4d *get_normals();
|
||||
uint32_t get_normals_count();
|
||||
|
||||
void prepare_uvs_and_textures(uint32_t new_uv_coords_count, uint32_t new_uv_scales_count, uint32_t new_uv_offsets_count,
|
||||
uint32_t new_texture_names_count, uint32_t new_texture_count);
|
||||
|
||||
int32_t &get_u_repeat();
|
||||
int32_t &get_v_repeat();
|
||||
void prepare_uv_coords(uint32_t new_uv_coords_count);
|
||||
|
||||
float *get_u_coords();
|
||||
float *get_v_coords();
|
||||
|
||||
float *get_u_scale();
|
||||
float *get_v_scale();
|
||||
|
||||
float *get_u_offset();
|
||||
float *get_v_offset();
|
||||
|
||||
void set_texture_name(uint32_t index, const char *name);
|
||||
char **get_texture_names();
|
||||
|
||||
void write(BinaryFile &file);
|
||||
|
||||
private:
|
||||
// Total amount of triangles.
|
||||
uint32_t triangle_count = 0;
|
||||
|
||||
// Index of our Material in the global array.
|
||||
uint32_t material_id = 0;
|
||||
|
||||
// Control Verticies
|
||||
Vector4d *control_vertices = nullptr;
|
||||
@@ -73,26 +66,43 @@ class MeshInfo {
|
||||
Vector4d *normals = nullptr;
|
||||
uint32_t normals_count = 0;
|
||||
|
||||
// UVs
|
||||
int32_t u_repeat = 0;
|
||||
int32_t v_repeat = 0;
|
||||
|
||||
// UV Coords
|
||||
float *u_coords = nullptr;
|
||||
float *v_coords = nullptr;
|
||||
uint32_t uv_coords_count = 0;
|
||||
};
|
||||
|
||||
float *u_scales = nullptr;
|
||||
float *v_scales = nullptr;
|
||||
uint32_t uv_scales_count = 0;
|
||||
class JointLinkListNode {
|
||||
public:
|
||||
JointLinkListNode() {};
|
||||
~JointLinkListNode();
|
||||
|
||||
float *u_offsets = nullptr;
|
||||
float *v_offsets = nullptr;
|
||||
uint32_t uv_offsets_count = 0;
|
||||
void prepare_next();
|
||||
Element **get_next();
|
||||
|
||||
uint32_t texture_count = 0;
|
||||
void set_next_count(SIZE count);
|
||||
SIZE get_next_count();
|
||||
|
||||
char **texture_names = nullptr;
|
||||
uint32_t texture_names_count = 0;
|
||||
void set_previous(Element *element);
|
||||
Element *get_previous();
|
||||
|
||||
void prepare_next_indicies();
|
||||
int64_t *get_next_indicies();
|
||||
|
||||
void set_previous_index(int64_t index);
|
||||
int64_t get_previous_index();
|
||||
|
||||
void write(BinaryFile &file);
|
||||
|
||||
private:
|
||||
Element **next = nullptr;
|
||||
SIZE next_count = 0;
|
||||
|
||||
Element *previous = nullptr;
|
||||
|
||||
// Read/Write
|
||||
int64_t *next_indicies = nullptr;
|
||||
int64_t previous_index = -1;
|
||||
};
|
||||
|
||||
// This class is a replacement for the root in Softimage which is Model for some reason.
|
||||
@@ -124,6 +134,12 @@ class Element {
|
||||
void set_visibility(bool new_visibility);
|
||||
bool get_visibility();
|
||||
|
||||
void set_as_joint(bool is_joint);
|
||||
bool is_joint();
|
||||
|
||||
void prepare_joint_linklist_node();
|
||||
JointLinkListNode *get_joint_linklist_node();
|
||||
|
||||
void prepare_children(uint32_t amount);
|
||||
void set_child(uint32_t index, Element* child);
|
||||
Element *get_child(uint32_t index);
|
||||
@@ -140,14 +156,14 @@ class Element {
|
||||
void set_flags(uint64_t nflags);
|
||||
uint64_t get_flags();
|
||||
|
||||
void set_array_position(SIZE index);
|
||||
SIZE get_array_position();
|
||||
void set_array_position(int64_t index);
|
||||
int64_t get_array_position();
|
||||
|
||||
void set_parent_position(SIZE index);
|
||||
SIZE get_parent_position();
|
||||
void set_parent_position(int64_t index);
|
||||
int64_t get_parent_position();
|
||||
|
||||
void prepare_children_indicies();
|
||||
SIZE *get_children_indicies();
|
||||
int64_t *get_children_indicies();
|
||||
|
||||
void write(BinaryFile &file);
|
||||
|
||||
@@ -174,17 +190,23 @@ class Element {
|
||||
// Visibility (Visible by default)
|
||||
bool visibility = true;
|
||||
|
||||
// If our Element is infact a joint!
|
||||
bool joint = false;
|
||||
|
||||
// Our joint link list node, We only have this if we are infact a joint.
|
||||
JointLinkListNode *node = nullptr;
|
||||
|
||||
// Write/Read Info
|
||||
// Used for resolving children and parents of Element array.
|
||||
|
||||
uint64_t flags = 0;
|
||||
|
||||
// Used to resolve position in Element array.
|
||||
SIZE array_index = 0;
|
||||
int64_t array_index = 0;
|
||||
|
||||
// Position of parent in Element array.
|
||||
SIZE parent_index = 0;
|
||||
int64_t parent_index = 0;
|
||||
|
||||
// Array of indexes to all of our children.
|
||||
SIZE *children_indexes = nullptr;
|
||||
int64_t *children_indexes = nullptr;
|
||||
};
|
||||
198
Material.cpp
Normal file
198
Material.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
#include "Material.h"
|
||||
|
||||
|
||||
Material::Material() : name("") {
|
||||
|
||||
}
|
||||
|
||||
Material::Material(const char *material_name) : name(material_name) {
|
||||
|
||||
}
|
||||
|
||||
Material::~Material() {
|
||||
if (textures) {
|
||||
delete[] textures;
|
||||
textures = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Material::Material(const Material &other) {
|
||||
set_name(other.get_name());
|
||||
set_shade_model(other.get_shade_model());
|
||||
set_diffuse_source(other.get_diffuse_source());
|
||||
set_transparency_source(other.get_transparency_source());
|
||||
set_static_blur(other.has_static_blur());
|
||||
set_ambieance(other.get_ambieance());
|
||||
set_diffuse(other.get_diffuse());
|
||||
set_specular(other.get_specular());
|
||||
set_specular_decay(other.get_specular_decay());
|
||||
set_reflection(other.get_reflection());
|
||||
set_refractive_index(other.get_refractive_index());
|
||||
set_transparency(other.get_transparency());
|
||||
set_blur_decay(other.get_blur_decay());
|
||||
set_blur_width(other.get_blur_width());
|
||||
|
||||
set_texture_count(other.get_texture_count());
|
||||
Texture *textures = prepare_textures();
|
||||
Texture *other_textures = other.get_textures();
|
||||
for (auto i = 0; i < texture_count; i++) {
|
||||
textures[i] = other_textures[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Material::set_name(std::string new_name) {
|
||||
name = new_name;
|
||||
}
|
||||
|
||||
std::string Material::get_name() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
void Material::set_shade_model(Material::ShadingModel model) {
|
||||
shade_model = model;
|
||||
}
|
||||
|
||||
Material::ShadingModel Material::get_shade_model() const {
|
||||
return shade_model;
|
||||
}
|
||||
|
||||
void Material::set_diffuse_source(Material::ComponentSource source) {
|
||||
diffuse_source = source;
|
||||
}
|
||||
|
||||
Material::ComponentSource Material::get_diffuse_source() const {
|
||||
return diffuse_source;
|
||||
}
|
||||
|
||||
void Material::set_transparency_source(Material::ComponentSource source) {
|
||||
transparency_source = source;
|
||||
}
|
||||
|
||||
Material::ComponentSource Material::get_transparency_source() const {
|
||||
return transparency_source;
|
||||
}
|
||||
|
||||
void Material::set_static_blur(bool blur) {
|
||||
static_blur = blur;
|
||||
}
|
||||
|
||||
bool Material::has_static_blur() const {
|
||||
return static_blur;
|
||||
}
|
||||
|
||||
void Material::set_ambieance(Vector3f &amb) {
|
||||
ambieance = amb;
|
||||
}
|
||||
|
||||
Vector3f Material::get_ambieance() const {
|
||||
return ambieance;
|
||||
}
|
||||
|
||||
void Material::set_diffuse(Vector3f &diff) {
|
||||
diffuse = diff;
|
||||
}
|
||||
|
||||
Vector3f Material::get_diffuse() const {
|
||||
return diffuse;
|
||||
}
|
||||
|
||||
void Material::set_specular(Vector3f &spec) {
|
||||
specular = spec;
|
||||
}
|
||||
|
||||
Vector3f Material::get_specular() const {
|
||||
return specular;
|
||||
}
|
||||
|
||||
void Material::set_specular_decay(float decay) {
|
||||
specular_decay = decay;
|
||||
}
|
||||
|
||||
float Material::get_specular_decay() const {
|
||||
return specular_decay;
|
||||
}
|
||||
|
||||
void Material::set_reflection(float value) {
|
||||
reflection = value;
|
||||
}
|
||||
|
||||
float Material::get_reflection() const {
|
||||
return reflection;
|
||||
}
|
||||
|
||||
void Material::set_refractive_index(float index) {
|
||||
refractive_index = index;
|
||||
}
|
||||
|
||||
float Material::get_refractive_index() const {
|
||||
return refractive_index;
|
||||
}
|
||||
|
||||
void Material::set_transparency(float value) {
|
||||
transparency = value;
|
||||
}
|
||||
|
||||
float Material::get_transparency() const {
|
||||
return transparency;
|
||||
}
|
||||
|
||||
void Material::set_blur_decay(float decay) {
|
||||
blur_decay = decay;
|
||||
}
|
||||
|
||||
float Material::get_blur_decay() const {
|
||||
return blur_decay;
|
||||
}
|
||||
|
||||
void Material::set_blur_width(float width) {
|
||||
blur_width = width;
|
||||
}
|
||||
|
||||
float Material::get_blur_width() const {
|
||||
return blur_width;
|
||||
}
|
||||
|
||||
void Material::set_texture_count(uint32_t count) {
|
||||
texture_count = count;
|
||||
}
|
||||
|
||||
uint32_t Material::get_texture_count() const {
|
||||
return texture_count;
|
||||
}
|
||||
|
||||
Texture *Material::prepare_textures() {
|
||||
if (textures) {
|
||||
delete[] textures;
|
||||
textures = nullptr;
|
||||
}
|
||||
textures = new Texture[texture_count + 1];
|
||||
return textures;
|
||||
}
|
||||
|
||||
Texture *Material::get_textures() const {
|
||||
return textures;
|
||||
}
|
||||
|
||||
void Material::write(BinaryFile &file) {
|
||||
file.write_uint64(name.size());
|
||||
file.write(name);
|
||||
file.write(shade_model);
|
||||
file.write(diffuse_source);
|
||||
file.write(transparency_source);
|
||||
file.write(ambieance);
|
||||
file.write(diffuse);
|
||||
file.write(specular);
|
||||
file.write(specular_decay);
|
||||
file.write(reflection);
|
||||
file.write(refractive_index);
|
||||
file.write(transparency);
|
||||
file.write(blur_decay);
|
||||
file.write(blur_width);
|
||||
file.write(static_blur);
|
||||
|
||||
file.write(texture_count);
|
||||
for (auto i = 0; i < texture_count; i++) {
|
||||
Texture &texture = textures[i];
|
||||
texture.write(file);
|
||||
}
|
||||
}
|
||||
136
Material.h
Normal file
136
Material.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "BinaryFile.h"
|
||||
#include "Texture.h"
|
||||
#include "Types.h"
|
||||
|
||||
class Material {
|
||||
public:
|
||||
enum ShadingModel : uint8_t {
|
||||
CONSTANT = 1,
|
||||
LAMBERT = 3,
|
||||
PHONG = 4,
|
||||
BLINN = 5,
|
||||
SHADOW = 6,
|
||||
VERTEX_COLOR = 7,
|
||||
};
|
||||
|
||||
enum ComponentSource : uint8_t {
|
||||
MATERIAL = 1,
|
||||
VERTICIES = 2,
|
||||
BOTH = 3,
|
||||
};
|
||||
|
||||
Material();
|
||||
Material(const char *material_name);
|
||||
~Material();
|
||||
|
||||
Material(const Material &other);
|
||||
|
||||
void set_name(std::string new_name);
|
||||
std::string get_name() const;
|
||||
|
||||
void set_shade_model(ShadingModel model);
|
||||
ShadingModel get_shade_model() const;
|
||||
|
||||
void set_diffuse_source(ComponentSource source);
|
||||
ComponentSource get_diffuse_source() const;
|
||||
|
||||
void set_transparency_source(ComponentSource source);
|
||||
ComponentSource get_transparency_source() const;
|
||||
|
||||
void set_static_blur(bool blur);
|
||||
bool has_static_blur() const;
|
||||
|
||||
void set_ambieance(Vector3f &amb);
|
||||
Vector3f get_ambieance() const;
|
||||
|
||||
void set_diffuse(Vector3f &diff);
|
||||
Vector3f get_diffuse() const;
|
||||
|
||||
void set_specular(Vector3f &spec);
|
||||
Vector3f get_specular() const;
|
||||
|
||||
void set_specular_decay(float decay);
|
||||
float get_specular_decay() const;
|
||||
|
||||
void set_reflection(float value);
|
||||
float get_reflection() const;
|
||||
|
||||
void set_refractive_index(float index);
|
||||
float get_refractive_index() const;
|
||||
|
||||
void set_transparency(float value);
|
||||
float get_transparency() const;
|
||||
|
||||
void set_blur_decay(float decay);
|
||||
float get_blur_decay() const;
|
||||
|
||||
void set_blur_width(float width);
|
||||
float get_blur_width() const;
|
||||
|
||||
void set_texture_count(uint32_t count);
|
||||
uint32_t get_texture_count() const;
|
||||
Texture *prepare_textures();
|
||||
Texture *get_textures() const;
|
||||
|
||||
void write(BinaryFile &file);
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
// Shading Model of the material.
|
||||
//
|
||||
// Notes:
|
||||
// SAA_materialGetShadingModel returns SAA_SHM_VERTEXCOLOR if the material diffuse and / or transparency is not from material.
|
||||
// This is to ensure compatibility with existing plug-ins that rely on this functionality.
|
||||
//
|
||||
// SAA_materialSetShadingModel can accept SAA_SHM_VERTEXCOLOR as the given shading model but it will emulate the old behavior
|
||||
// by affecting the material as such:
|
||||
// set both diffuse and transparency sources to Vertex
|
||||
// set shading model to Constant
|
||||
ShadingModel shade_model = CONSTANT;
|
||||
|
||||
ComponentSource diffuse_source = MATERIAL;
|
||||
|
||||
ComponentSource transparency_source = MATERIAL;
|
||||
|
||||
// Enables or disables static blur.
|
||||
bool static_blur = false;
|
||||
|
||||
// RGB color value for surface areas shaded with ambient light on Lambert-, Blinn-, or Phong-shaded models.
|
||||
Vector3f ambieance = { 0.0f };
|
||||
|
||||
// RGB color value for surface areas that are diffusely illuminated.
|
||||
Vector3f diffuse = { 0.0f };
|
||||
|
||||
// RGB color value for the specular highlight on a Phong- or Blinn-shaded model.
|
||||
Vector3f specular = { 0.0f };
|
||||
|
||||
// Controls the spread of the specular decay over the model surface (for Phong and Blinn-shaded models).
|
||||
// Values range from 0 to 300.
|
||||
float specular_decay = 0.0f;
|
||||
|
||||
// A value from 0 to 1: a value of 1 represents complete reflectivity.
|
||||
float reflection = 0.0f;
|
||||
|
||||
// Controls the bending of light rays through a transparent material.
|
||||
float refractive_index = 0.0f;
|
||||
|
||||
// A value from 0 to 1: a value of 1 represents complete transparency.
|
||||
float transparency = 0.0f;
|
||||
|
||||
float blur_decay = 0.0f;
|
||||
float blur_width = 0.0f;
|
||||
|
||||
// Textures
|
||||
uint32_t texture_count = 0;
|
||||
Texture *textures = nullptr;
|
||||
|
||||
// Temporaries
|
||||
private:
|
||||
// This only exists for sanity purposes in soft2scene. It's not needed otherwise.
|
||||
bool initialized = false;
|
||||
};
|
||||
107
Texture.cpp
Normal file
107
Texture.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "Texture.h"
|
||||
|
||||
Texture::Texture() : filepath("") {
|
||||
|
||||
}
|
||||
|
||||
Texture::Texture(const char *path) : filepath(path) {
|
||||
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
|
||||
}
|
||||
|
||||
void Texture::set_filepath(std::string path) {
|
||||
filepath = path;
|
||||
}
|
||||
|
||||
std::string &Texture::get_filepath() {
|
||||
return filepath;
|
||||
}
|
||||
|
||||
void Texture::set_u_scale(float scale) {
|
||||
u_scale = scale;
|
||||
}
|
||||
|
||||
float Texture::get_u_scale() {
|
||||
return u_scale;
|
||||
}
|
||||
|
||||
void Texture::set_v_scale(float scale) {
|
||||
v_scale = scale;
|
||||
}
|
||||
|
||||
float Texture::get_v_scale() {
|
||||
return v_scale;
|
||||
}
|
||||
|
||||
void Texture::set_u_offset(float offset) {
|
||||
u_offset = offset;
|
||||
}
|
||||
|
||||
float Texture::get_u_offset() {
|
||||
return u_offset;
|
||||
}
|
||||
|
||||
void Texture::set_v_offset(float offset) {
|
||||
v_offset = offset;
|
||||
}
|
||||
|
||||
float Texture::get_v_offset() {
|
||||
return v_offset;
|
||||
}
|
||||
|
||||
void Texture::set_u_repeat(int32_t repeat) {
|
||||
u_repeat = repeat;
|
||||
}
|
||||
|
||||
int32_t Texture::get_u_repeat() {
|
||||
return u_repeat;
|
||||
}
|
||||
|
||||
void Texture::set_v_repeat(int32_t repeat) {
|
||||
v_repeat = repeat;
|
||||
}
|
||||
|
||||
int32_t Texture::get_v_repeat() {
|
||||
return v_repeat;
|
||||
}
|
||||
|
||||
void Texture::set_transparency(float value) {
|
||||
transparency = value;
|
||||
}
|
||||
|
||||
float Texture::get_transparency() {
|
||||
return transparency;
|
||||
}
|
||||
|
||||
void Texture::set_uv_swap(bool swap) {
|
||||
uv_swap = swap;
|
||||
}
|
||||
|
||||
bool Texture::get_uv_swap() {
|
||||
return uv_swap;
|
||||
}
|
||||
|
||||
void Texture::set_uv_wrap(bool wrap) {
|
||||
uv_wrap = wrap;
|
||||
}
|
||||
|
||||
bool Texture::get_uv_wrap() {
|
||||
return uv_wrap;
|
||||
}
|
||||
|
||||
void Texture::write(BinaryFile &file) {
|
||||
file.write_uint64(filepath.size());
|
||||
file.write(filepath);
|
||||
file.write(uv_swap);
|
||||
file.write(uv_wrap);
|
||||
file.write(u_scale);
|
||||
file.write(v_scale);
|
||||
file.write(u_offset);
|
||||
file.write(v_offset);
|
||||
file.write(u_repeat);
|
||||
file.write(v_repeat);
|
||||
file.write(transparency);
|
||||
}
|
||||
66
Texture.h
Normal file
66
Texture.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "BinaryFile.h"
|
||||
#include "Types.h"
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
Texture();
|
||||
Texture(const char *path);
|
||||
~Texture();
|
||||
|
||||
void set_filepath(std::string path);
|
||||
std::string &get_filepath();
|
||||
|
||||
void set_u_scale(float scale);
|
||||
float get_u_scale();
|
||||
|
||||
void set_v_scale(float scale);
|
||||
float get_v_scale();
|
||||
|
||||
void set_u_offset(float offset);
|
||||
float get_u_offset();
|
||||
|
||||
void set_v_offset(float offset);
|
||||
float get_v_offset();
|
||||
|
||||
void set_u_repeat(int32_t repeat);
|
||||
int32_t get_u_repeat();
|
||||
|
||||
void set_v_repeat(int32_t repeat);
|
||||
int32_t get_v_repeat();
|
||||
|
||||
void set_transparency(float value);
|
||||
float get_transparency();
|
||||
|
||||
void set_uv_swap(bool swap);
|
||||
bool get_uv_swap();
|
||||
|
||||
void set_uv_wrap(bool wrap);
|
||||
bool get_uv_wrap();
|
||||
|
||||
void write(BinaryFile &file);
|
||||
|
||||
private:
|
||||
std::string filepath;
|
||||
|
||||
float u_scale = 0.0f;
|
||||
float v_scale = 0.0f;
|
||||
|
||||
float u_offset = 0.0f;
|
||||
float v_offset = 0.0f;
|
||||
|
||||
int32_t u_repeat = 1;
|
||||
int32_t v_repeat = 1;
|
||||
|
||||
// Controls the transparency effect of the Effect Value Alpha Channel and RGB Intensity options. Values range from -1 to 1.
|
||||
float transparency = 1.0f;
|
||||
|
||||
// If true, the U and V directions of the texture coordinates are exchanged.
|
||||
bool uv_swap = false;
|
||||
|
||||
// Controls whether a texture is wrapped around the UV seams (where the UV coordinates wrap from 1 back to 0).
|
||||
bool uv_wrap = false;
|
||||
};
|
||||
157
Utilities.cpp
Normal file
157
Utilities.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
#include "Utilities.h"
|
||||
|
||||
int verbose = 3;
|
||||
FILE *log_file = nullptr;
|
||||
|
||||
// General
|
||||
|
||||
void safe_exit(int code) {
|
||||
// Close the log for debugging.
|
||||
if (log_file) {
|
||||
fflush(log_file);
|
||||
fclose(log_file);
|
||||
log_file = nullptr;
|
||||
}
|
||||
|
||||
exit(code);
|
||||
}
|
||||
|
||||
int *MakeIndexMap(int *indices, int num_indices, int map_size) {
|
||||
int i, j;
|
||||
|
||||
// Allocate map array
|
||||
int *map = new int[map_size];
|
||||
|
||||
if (map != NULL) {
|
||||
for (i = 0; i < map_size; i++) {
|
||||
j = 0;
|
||||
int found = 0;
|
||||
while (j < num_indices) {
|
||||
if (indices[j] == i) {
|
||||
map[i] = j;
|
||||
lfprintf(log_file, "map[%d] = %d\n", 2, i, map[i]);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (!found) {
|
||||
lfprintf(log_file, "WARNING: Orphan vertex (%d)\n", 2, i);
|
||||
// default to -1 for now
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(log_file, "Not enough memory for index map...\n");
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
// SAA
|
||||
|
||||
char *GetName(SAA_Scene *scene, SAA_Elem *element) {
|
||||
int name_len = 0;
|
||||
|
||||
// Get the name
|
||||
SAA_elementGetNameLength(scene, element, &name_len);
|
||||
char* name = new char[++name_len];
|
||||
SAA_elementGetName(scene, element, name_len, name);
|
||||
name[--name_len] = 0;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
char *GetPrefix(SAA_Scene *scene, SAA_Elem *element) {
|
||||
int prefix_len = 0;
|
||||
|
||||
// Get the prefix
|
||||
SAA_elementGetPrefixLength(scene, element, &prefix_len);
|
||||
char* prefix = new char[++prefix_len];
|
||||
SAA_elementGetPrefix(scene, element, prefix_len, prefix);
|
||||
prefix[--prefix_len] = 0;
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
char *GetFullName(SAA_Scene *scene, SAA_Elem *element) {
|
||||
char *prefix = GetPrefix(scene, element);
|
||||
char *name = GetName(scene, element);
|
||||
|
||||
// Construct the full name from both the prefix and name.
|
||||
size_t name_len = strlen(name);
|
||||
size_t prefix_len = strlen(prefix);
|
||||
int fullname_len = name_len + prefix_len + 1;
|
||||
char *fullname = new char[fullname_len + 1];
|
||||
strncpy_s(fullname, fullname_len, prefix, prefix_len);
|
||||
strncpy_s(fullname + prefix_len + 1, fullname_len - prefix_len, name, name_len);
|
||||
fullname[prefix_len] = '-';
|
||||
|
||||
delete[] name;
|
||||
delete[] prefix;
|
||||
|
||||
return fullname;
|
||||
}
|
||||
|
||||
char *GetTextureName(SAA_Scene *scene, SAA_Elem *texture) {
|
||||
char *name = nullptr;
|
||||
int filename_len = 0;
|
||||
|
||||
// Get the textures name.
|
||||
SAA_texture2DGetPicNameLength(scene, texture, &filename_len);
|
||||
|
||||
if (filename_len) {
|
||||
filename_len += 5;
|
||||
char *filename = new char[filename_len];
|
||||
memset(filename, 0, filename_len);
|
||||
SAA_texture2DGetPicName(scene, texture, filename_len, filename);
|
||||
|
||||
char *tmpName = NULL;
|
||||
tmpName = strrchr(filename, '/');
|
||||
if (tmpName) {
|
||||
tmpName++;
|
||||
name = new char[strlen(tmpName) + 5];
|
||||
strcpy_s(name, strlen(tmpName) + 5, tmpName);
|
||||
|
||||
delete[] filename;
|
||||
} else {
|
||||
name = filename;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we are not being passed a NULL image, an empty image string or
|
||||
// the default image created by egg2soft
|
||||
if ((name != nullptr) && strlen(name) && (strstr(name, "noIcon") == nullptr)) {
|
||||
return name;
|
||||
} else {
|
||||
fprintf(log_file, "Warning: GetTextureName received NULL name.\n");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
char *GetTextureFilepath(SAA_Scene *scene, SAA_Elem *texture) {
|
||||
char *filepath = nullptr;
|
||||
int filepath_len = 0;
|
||||
|
||||
// Get the textures name.
|
||||
SAA_texture2DGetPicNameLength(scene, texture, &filepath_len);
|
||||
|
||||
if (filepath_len) {
|
||||
filepath_len += 5;
|
||||
filepath = new char[filepath_len];
|
||||
memset(filepath, 0, filepath_len);
|
||||
SAA_texture2DGetPicName(scene, texture, filepath_len, filepath);
|
||||
int err = strcat_s(filepath, filepath_len, ".pic");
|
||||
}
|
||||
|
||||
// make sure we are not being passed a NULL image, an empty image string or
|
||||
// the default image created by egg2soft
|
||||
if ((filepath != nullptr) && strlen(filepath) && (strstr(filepath, "noIcon") == nullptr)) {
|
||||
return filepath;
|
||||
} else {
|
||||
fprintf(log_file, "Warning: GetTextureFilepath received NULL filepath.\n");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
136
Utilities.h
Normal file
136
Utilities.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#pragma once
|
||||
|
||||
#include <SAA.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "Element.h"
|
||||
#include "Types.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define dprintf(format, ...) printf(format, __VA_ARGS__);
|
||||
#else
|
||||
#define dprintf(format, ...)
|
||||
#endif
|
||||
|
||||
#define lprintf(format, verbose_level, ...) if (verbose >= verbose_level) { printf(format, __VA_ARGS__); }
|
||||
#define lfprintf(file, format, verbose_level, ...) if (verbose >= verbose_level) { fprintf(file, format, __VA_ARGS__); }
|
||||
|
||||
extern int verbose;
|
||||
extern FILE *log_file;
|
||||
|
||||
// General
|
||||
|
||||
void safe_exit(int code);
|
||||
int *MakeIndexMap(int *indices, int num_indices, int map_size);
|
||||
|
||||
|
||||
// General (Templates)
|
||||
|
||||
template <typename T, typename S>
|
||||
void ArrayRemove(T *&arr, size_t index, S &size) {
|
||||
for (S i = index; i < size - 1; i++) {
|
||||
arr[i] = arr[i + 1];
|
||||
}
|
||||
size--;
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
void ArrayRemove(T **&arr, size_t index, S &size) {
|
||||
for (S i = index; i < size - 1; i++) {
|
||||
arr[i] = arr[i + 1];
|
||||
}
|
||||
size--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all duplicates in the array and return a index map. (The index map is for mapping the old indicies to the new ones.)
|
||||
*/
|
||||
template <typename T, typename S>
|
||||
S *RemoveDuplicates(T *&arr, S &size) {
|
||||
// Allocate and initialize our index map.
|
||||
S *index_map = new S[size + 1];
|
||||
memset(index_map, 0, size);
|
||||
|
||||
for (S i = 0; i < size; i++) {
|
||||
T &item = arr[i];
|
||||
index_map[i] = i;
|
||||
for (S j = i + 1; j < size; j++) {
|
||||
if (memcmp(&item, &arr[j], sizeof(T)) == 0) {
|
||||
ArrayRemove(arr, j, size);
|
||||
index_map[j] = i;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index_map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all duplicates in the array and return a index map. (The index map is for mapping the old indicies to the new ones.)
|
||||
*/
|
||||
template <typename T, typename S>
|
||||
S *RemoveDuplicates(T **arr, S &size) {
|
||||
// Allocate and initialize our index map.
|
||||
S *index_map = new S[size + 1];
|
||||
memset(index_map, 0, size);
|
||||
|
||||
for (S i = 0; i < size; i++) {
|
||||
T *&item = arr[i];
|
||||
index_map[i] = i;
|
||||
for (S j = i + 1; j < size; j++) {
|
||||
if (item == arr[j]) {
|
||||
ArrayRemove(arr, j, size);
|
||||
index_map[j] = i;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index_map;
|
||||
}
|
||||
|
||||
// SAA
|
||||
|
||||
char *GetName(SAA_Scene *scene, SAA_Elem *element);
|
||||
char *GetPrefix(SAA_Scene *scene, SAA_Elem *element);
|
||||
char *GetFullName(SAA_Scene *scene, SAA_Elem *element);
|
||||
char *GetTextureName(SAA_Scene *scene, SAA_Elem *texture);
|
||||
char *GetTextureFilepath(SAA_Scene *scene, SAA_Elem *texture);
|
||||
|
||||
/**
|
||||
* Remove all duplicates in the array and return a index map. (The index map is for mapping the old indicies to the new ones.)
|
||||
*/
|
||||
template <typename S>
|
||||
S *RemoveDuplicates(SAA_Scene *scene, SAA_Elem *&arr, S &size) {
|
||||
// Allocate and initialize our index map.
|
||||
S *index_map = new S[size + 1];
|
||||
memset(index_map, 0, size);
|
||||
|
||||
for (S i = 0; i < size; i++) {
|
||||
SAA_Elem &item = arr[i];
|
||||
index_map[i] = i;
|
||||
char *name1 = GetName(scene, &item);
|
||||
|
||||
for (S j = i + 1; j < size; j++) {
|
||||
SAA_Elem &item2 = arr[j];
|
||||
char *name2 = GetName(scene, &item2);
|
||||
|
||||
if (memcmp(&item, &item2, sizeof(SAA_Elem)) == 0 && strcmp(name1, name2) == 0) {
|
||||
char *elem_name = GetName(scene, arr);
|
||||
printf("DEBUG: Removing duplicate element %s from array.\n", elem_name);
|
||||
|
||||
ArrayRemove(arr, j, size);
|
||||
index_map[j] = i;
|
||||
j--;
|
||||
}
|
||||
|
||||
delete[] name2;
|
||||
}
|
||||
|
||||
delete[] name1;
|
||||
}
|
||||
|
||||
return index_map;
|
||||
}
|
||||
799
soft2scene.cpp
799
soft2scene.cpp
File diff suppressed because it is too large
Load Diff
@@ -75,8 +75,8 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>D:\Softimage\SDK_4.0\SAAPHIRE\h;C:\Program Files\Microsoft SDKs\Windows\v7.1\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\Softimage\SDK_4.0\SAAPHIRE\dso;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\Softimage\SDK_4.0\SAAPHIRE\h;C:\Program Files\Microsoft SDKs\Windows\v7.1\include;D:\Softimage\SoftTools\soft2scene\zlib\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\Softimage\SDK_4.0\SAAPHIRE\dso;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;D:\Softimage\SoftTools\soft2scene\zlib\lib\Debug;$(LibraryPath)</LibraryPath>
|
||||
<CopyLocalProjectReference>false</CopyLocalProjectReference>
|
||||
<CopyLocalDebugSymbols>false</CopyLocalDebugSymbols>
|
||||
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
|
||||
@@ -85,8 +85,8 @@
|
||||
<TargetName>lib$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>D:\Softimage\SDK_4.0\SAAPHIRE\h;C:\Program Files\Microsoft SDKs\Windows\v7.1\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\Softimage\SDK_4.0\SAAPHIRE\dso;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>D:\Softimage\SDK_4.0\SAAPHIRE\h;C:\Program Files\Microsoft SDKs\Windows\v7.1\include;D:\Softimage\SoftTools\soft2scene\zlib\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\Softimage\SDK_4.0\SAAPHIRE\dso;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;D:\Softimage\SoftTools\soft2scene\zlib\lib\Release;$(LibraryPath)</LibraryPath>
|
||||
<CopyLocalProjectReference>false</CopyLocalProjectReference>
|
||||
<CopyLocalDebugSymbols>false</CopyLocalDebugSymbols>
|
||||
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
|
||||
@@ -106,7 +106,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SAA.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>SAA.lib;zlibstaticd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateMapFile>true</GenerateMapFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -126,7 +126,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SAA.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>SAA.lib;zlibstatic.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<GenerateMapFile>true</GenerateMapFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -162,13 +162,19 @@
|
||||
<ClCompile Include="BinaryFile.cpp" />
|
||||
<ClCompile Include="Constraint.cpp" />
|
||||
<ClCompile Include="Element.cpp" />
|
||||
<ClCompile Include="Material.cpp" />
|
||||
<ClCompile Include="soft2scene.cpp" />
|
||||
<ClCompile Include="Texture.cpp" />
|
||||
<ClCompile Include="Utilities.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BinaryFile.h" />
|
||||
<ClInclude Include="Constraint.h" />
|
||||
<ClInclude Include="Element.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="Texture.h" />
|
||||
<ClInclude Include="Types.h" />
|
||||
<ClInclude Include="Utilities.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -27,6 +27,15 @@
|
||||
<ClCompile Include="Constraint.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utilities.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Material.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Texture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Element.h">
|
||||
@@ -41,5 +50,14 @@
|
||||
<ClInclude Include="Constraint.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utilities.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Material.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Texture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
9446
zlib/include/crc32.h
Normal file
9446
zlib/include/crc32.h
Normal file
File diff suppressed because it is too large
Load Diff
380
zlib/include/deflate.h
Normal file
380
zlib/include/deflate.h
Normal file
@@ -0,0 +1,380 @@
|
||||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef DEFLATE_H
|
||||
#define DEFLATE_H
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
|
||||
the crc code when it is not needed. For shared libraries, gzip encoding
|
||||
should be left enabled. */
|
||||
#ifndef NO_GZIP
|
||||
# define GZIP
|
||||
#endif
|
||||
|
||||
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
|
||||
the cost of a larger memory footprint */
|
||||
/* #define LIT_MEM */
|
||||
|
||||
/* ===========================================================================
|
||||
* Internal compression state.
|
||||
*/
|
||||
|
||||
#define LENGTH_CODES 29
|
||||
/* number of length codes, not counting the special END_BLOCK code */
|
||||
|
||||
#define LITERALS 256
|
||||
/* number of literal bytes 0..255 */
|
||||
|
||||
#define L_CODES (LITERALS+1+LENGTH_CODES)
|
||||
/* number of Literal or Length codes, including the END_BLOCK code */
|
||||
|
||||
#define D_CODES 30
|
||||
/* number of distance codes */
|
||||
|
||||
#define BL_CODES 19
|
||||
/* number of codes used to transfer the bit lengths */
|
||||
|
||||
#define HEAP_SIZE (2*L_CODES+1)
|
||||
/* maximum heap size */
|
||||
|
||||
#define MAX_BITS 15
|
||||
/* All codes must not exceed MAX_BITS bits */
|
||||
|
||||
#define Buf_size 16
|
||||
/* size of bit buffer in bi_buf */
|
||||
|
||||
#define INIT_STATE 42 /* zlib header -> BUSY_STATE */
|
||||
#ifdef GZIP
|
||||
# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */
|
||||
#endif
|
||||
#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */
|
||||
#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */
|
||||
#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */
|
||||
#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */
|
||||
#define BUSY_STATE 113 /* deflate -> FINISH_STATE */
|
||||
#define FINISH_STATE 666 /* stream complete */
|
||||
/* Stream status */
|
||||
|
||||
|
||||
/* Data structure describing a single value and its code string. */
|
||||
typedef struct ct_data_s {
|
||||
union {
|
||||
ush freq; /* frequency count */
|
||||
ush code; /* bit string */
|
||||
} fc;
|
||||
union {
|
||||
ush dad; /* father node in Huffman tree */
|
||||
ush len; /* length of bit string */
|
||||
} dl;
|
||||
} FAR ct_data;
|
||||
|
||||
#define Freq fc.freq
|
||||
#define Code fc.code
|
||||
#define Dad dl.dad
|
||||
#define Len dl.len
|
||||
|
||||
typedef struct static_tree_desc_s static_tree_desc;
|
||||
|
||||
typedef struct tree_desc_s {
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
const static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} FAR tree_desc;
|
||||
|
||||
typedef ush Pos;
|
||||
typedef Pos FAR Posf;
|
||||
typedef unsigned IPos;
|
||||
|
||||
/* A Pos is an index in the character window. We use short instead of int to
|
||||
* save space in the various tables. IPos is used only for parameter passing.
|
||||
*/
|
||||
|
||||
typedef struct internal_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
int status; /* as the name implies */
|
||||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
ulg pending; /* nb of bytes in the pending buffer */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
gz_headerp gzhead; /* gzip header information to write */
|
||||
ulg gzindex; /* where in extra, name, or comment */
|
||||
Byte method; /* can only be DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
/* used by deflate.c: */
|
||||
|
||||
uInt w_size; /* LZ77 window size (32K by default) */
|
||||
uInt w_bits; /* log2(w_size) (8..16) */
|
||||
uInt w_mask; /* w_size - 1 */
|
||||
|
||||
Bytef *window;
|
||||
/* Sliding window. Input bytes are read into the second half of the window,
|
||||
* and move to the first half later to keep a dictionary of at least wSize
|
||||
* bytes. With this organization, matches are limited to a distance of
|
||||
* wSize-MAX_MATCH bytes, but this ensures that IO is always
|
||||
* performed with a length multiple of the block size. Also, it limits
|
||||
* the window size to 64K, which is quite useful on MSDOS.
|
||||
* To do: use the user input buffer as sliding window.
|
||||
*/
|
||||
|
||||
ulg window_size;
|
||||
/* Actual size of window: 2*wSize, except when the user input buffer
|
||||
* is directly used as sliding window.
|
||||
*/
|
||||
|
||||
Posf *prev;
|
||||
/* Link to older string with same hash index. To limit the size of this
|
||||
* array to 64K, this link is maintained only for the last 32K strings.
|
||||
* An index in this array is thus a window index modulo 32K.
|
||||
*/
|
||||
|
||||
Posf *head; /* Heads of the hash chains or NIL. */
|
||||
|
||||
uInt ins_h; /* hash index of string to be inserted */
|
||||
uInt hash_size; /* number of elements in hash table */
|
||||
uInt hash_bits; /* log2(hash_size) */
|
||||
uInt hash_mask; /* hash_size-1 */
|
||||
|
||||
uInt hash_shift;
|
||||
/* Number of bits by which ins_h must be shifted at each input
|
||||
* step. It must be such that after MIN_MATCH steps, the oldest
|
||||
* byte no longer takes part in the hash key, that is:
|
||||
* hash_shift * MIN_MATCH >= hash_bits
|
||||
*/
|
||||
|
||||
long block_start;
|
||||
/* Window position at the beginning of the current output block. Gets
|
||||
* negative when the window is moved backwards.
|
||||
*/
|
||||
|
||||
uInt match_length; /* length of best match */
|
||||
IPos prev_match; /* previous match */
|
||||
int match_available; /* set if previous match exists */
|
||||
uInt strstart; /* start of string to insert */
|
||||
uInt match_start; /* start of matching string */
|
||||
uInt lookahead; /* number of valid bytes ahead in window */
|
||||
|
||||
uInt prev_length;
|
||||
/* Length of the best match at previous step. Matches not greater than this
|
||||
* are discarded. This is used in the lazy match evaluation.
|
||||
*/
|
||||
|
||||
uInt max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this
|
||||
* length. A higher limit improves compression ratio but degrades the
|
||||
* speed.
|
||||
*/
|
||||
|
||||
uInt max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly
|
||||
* smaller than this value. This mechanism is used only for compression
|
||||
* levels >= 4.
|
||||
*/
|
||||
# define max_insert_length max_lazy_match
|
||||
/* Insert new strings in the hash table only if the match length is not
|
||||
* greater than this length. This saves time but degrades compression.
|
||||
* max_insert_length is used only for compression levels <= 3.
|
||||
*/
|
||||
|
||||
int level; /* compression level (1..9) */
|
||||
int strategy; /* favor or force Huffman coding*/
|
||||
|
||||
uInt good_match;
|
||||
/* Use a faster search when the previous match is longer than this */
|
||||
|
||||
int nice_match; /* Stop searching when current match exceeds this */
|
||||
|
||||
/* used by trees.c: */
|
||||
/* Didn't use ct_data typedef below to suppress compiler warning */
|
||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
||||
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
||||
|
||||
struct tree_desc_s l_desc; /* desc. for literal tree */
|
||||
struct tree_desc_s d_desc; /* desc. for distance tree */
|
||||
struct tree_desc_s bl_desc; /* desc. for bit length tree */
|
||||
|
||||
ush bl_count[MAX_BITS+1];
|
||||
/* number of codes at each bit length for an optimal tree */
|
||||
|
||||
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
|
||||
int heap_len; /* number of elements in the heap */
|
||||
int heap_max; /* element of largest frequency */
|
||||
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
|
||||
* The same heap array is used to build all trees.
|
||||
*/
|
||||
|
||||
uch depth[2*L_CODES+1];
|
||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
#ifdef LIT_MEM
|
||||
# define LIT_BUFS 5
|
||||
ushf *d_buf; /* buffer for distances */
|
||||
uchf *l_buf; /* buffer for literals/lengths */
|
||||
#else
|
||||
# define LIT_BUFS 4
|
||||
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||
#endif
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
* limiting lit_bufsize to 64K:
|
||||
* - frequencies can be kept in 16 bit counters
|
||||
* - if compression is not successful for the first block, all input
|
||||
* data is still in the window so we can still emit a stored block even
|
||||
* when input comes from standard input. (This can also be done for
|
||||
* all blocks if lit_bufsize is not greater than 32K.)
|
||||
* - if compression is not successful for a file smaller than 64K, we can
|
||||
* even emit a stored file instead of a stored block (saving 5 bytes).
|
||||
* This is applicable only for zip (not gzip or zlib).
|
||||
* - creating new Huffman trees less frequently may not provide fast
|
||||
* adaptation to changes in the input data statistics. (Take for
|
||||
* example a binary file with poorly compressible code followed by
|
||||
* a highly compressible string table.) Smaller buffer sizes give
|
||||
* fast adaptation but have of course the overhead of transmitting
|
||||
* trees more frequently.
|
||||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
uInt sym_next; /* running index in symbol buffer */
|
||||
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
uInt matches; /* number of string matches in current block */
|
||||
uInt insert; /* bytes at end of window left to insert */
|
||||
|
||||
#ifdef ZLIB_DEBUG
|
||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
|
||||
#endif
|
||||
|
||||
ush bi_buf;
|
||||
/* Output buffer. bits are inserted starting at the bottom (least
|
||||
* significant bits).
|
||||
*/
|
||||
int bi_valid;
|
||||
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
||||
* are always zero.
|
||||
*/
|
||||
int bi_used;
|
||||
/* Last number of used bits when going to a byte boundary.
|
||||
*/
|
||||
|
||||
ulg high_water;
|
||||
/* High water mark offset in window for initialized bytes -- bytes above
|
||||
* this are set to zero in order to avoid memory check warnings when
|
||||
* longest match routines access bytes past the input. This is then
|
||||
* updated to the new high water mark.
|
||||
*/
|
||||
|
||||
} FAR deflate_state;
|
||||
|
||||
/* Output a byte on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
|
||||
|
||||
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||
/* Minimum amount of lookahead, except at the end of the input file.
|
||||
* See deflate.c for comments about the MIN_MATCH+1.
|
||||
*/
|
||||
|
||||
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
|
||||
/* In order to simplify the code, particularly on 16 bit machines, match
|
||||
* distances are limited to MAX_DIST instead of WSIZE.
|
||||
*/
|
||||
|
||||
#define WIN_INIT MAX_MATCH
|
||||
/* Number of bytes after end of data in window to initialize in order to avoid
|
||||
memory checker errors from longest match routines */
|
||||
|
||||
/* in trees.c */
|
||||
void ZLIB_INTERNAL _tr_init(deflate_state *s);
|
||||
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
|
||||
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_align(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
#ifndef ZLIB_DEBUG
|
||||
/* Inline versions of _tr_tally for speed: */
|
||||
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
extern uch ZLIB_INTERNAL _length_code[];
|
||||
extern uch ZLIB_INTERNAL _dist_code[];
|
||||
#else
|
||||
extern const uch ZLIB_INTERNAL _length_code[];
|
||||
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||
#endif
|
||||
|
||||
#ifdef LIT_MEM
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->sym_next] = 0; \
|
||||
s->l_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->d_buf[s->sym_next] = dist; \
|
||||
s->l_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||
s->sym_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
flush = _tr_tally(s, distance, length)
|
||||
#endif
|
||||
|
||||
#endif /* DEFLATE_H */
|
||||
215
zlib/include/gzguts.h
Normal file
215
zlib/include/gzguts.h
Normal file
@@ -0,0 +1,215 @@
|
||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||
* Copyright (C) 2004-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
# ifndef _LARGEFILE_SOURCE
|
||||
# define _LARGEFILE_SOURCE 1
|
||||
# endif
|
||||
# undef _FILE_OFFSET_BITS
|
||||
# undef _TIME_BITS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
# endif
|
||||
# ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
#ifdef STDC
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_C_SOURCE
|
||||
# define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
# include <io.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(WIDECHAR)
|
||||
# define WIDECHAR
|
||||
#endif
|
||||
|
||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||
# define NO_GZCOMPRESS
|
||||
#endif
|
||||
|
||||
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
# if !defined(NO_vsnprintf) && \
|
||||
(defined(MSDOS) || defined(__TURBOC__) || defined(__SASC) || \
|
||||
defined(VMS) || defined(__OS400) || defined(__MVS__))
|
||||
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
||||
but for now we just assume it doesn't. */
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef WIN32
|
||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||
# ifndef vsnprintf
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
# endif
|
||||
# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
|
||||
/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
|
||||
# ifndef NO_snprintf
|
||||
# define NO_snprintf
|
||||
# endif
|
||||
# ifndef NO_vsnprintf
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* unlike snprintf (which is required in C99), _snprintf does not guarantee
|
||||
null termination of the result -- however this is only used in gzlib.c where
|
||||
the result is assured to fit in the space provided */
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* since "static" is used to mean two completely different things in C, we
|
||||
define "local" for the non-static meaning of "static", for readability
|
||||
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||
|
||||
/* gz* functions always use library allocation functions */
|
||||
#ifndef STDC
|
||||
extern voidp malloc(uInt size);
|
||||
extern void free(voidpf ptr);
|
||||
#endif
|
||||
|
||||
/* get errno and strerror definition */
|
||||
#if defined UNDER_CE
|
||||
# include <windows.h>
|
||||
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||
#else
|
||||
# ifndef NO_STRERROR
|
||||
# include <errno.h>
|
||||
# define zstrerror() strerror(errno)
|
||||
# else
|
||||
# define zstrerror() "stdio error (consult errno)"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||
#endif
|
||||
|
||||
/* default memLevel */
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
|
||||
/* default i/o buffer size -- double this for output when reading (this and
|
||||
twice this must be able to fit in an unsigned type) */
|
||||
#define GZBUFSIZE 8192
|
||||
|
||||
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||
#define GZ_NONE 0
|
||||
#define GZ_READ 7247
|
||||
#define GZ_WRITE 31153
|
||||
#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
|
||||
|
||||
/* values for gz_state how */
|
||||
#define LOOK 0 /* look for a gzip header */
|
||||
#define COPY 1 /* copy input directly */
|
||||
#define GZIP 2 /* decompress a gzip stream */
|
||||
|
||||
/* internal gzip file state data structure */
|
||||
typedef struct {
|
||||
/* exposed contents for gzgetc() macro */
|
||||
struct gzFile_s x; /* "x" for exposed */
|
||||
/* x.have: number of bytes available at x.next */
|
||||
/* x.next: next output data to deliver or write */
|
||||
/* x.pos: current position in uncompressed data */
|
||||
/* used for both reading and writing */
|
||||
int mode; /* see gzip modes above */
|
||||
int fd; /* file descriptor */
|
||||
char *path; /* path or fd for error messages */
|
||||
unsigned size; /* buffer size, zero if not allocated yet */
|
||||
unsigned want; /* requested buffer size, default is GZBUFSIZE */
|
||||
unsigned char *in; /* input buffer (double-sized when writing) */
|
||||
unsigned char *out; /* output buffer (double-sized when reading) */
|
||||
int direct; /* 0 if processing gzip, 1 if transparent */
|
||||
/* just for reading */
|
||||
int how; /* 0: get header, 1: copy, 2: decompress */
|
||||
z_off64_t start; /* where the gzip data started, for rewinding */
|
||||
int eof; /* true if end of input file reached */
|
||||
int past; /* true if read requested past end */
|
||||
/* just for writing */
|
||||
int level; /* compression level */
|
||||
int strategy; /* compression strategy */
|
||||
int reset; /* true if a reset is pending after a Z_FINISH */
|
||||
/* seek request */
|
||||
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||
int seek; /* true if seek request pending */
|
||||
/* error information */
|
||||
int err; /* error code */
|
||||
char *msg; /* error message */
|
||||
/* zlib inflate or deflate stream */
|
||||
z_stream strm; /* stream structure in-place (not a pointer) */
|
||||
} gz_state;
|
||||
typedef gz_state FAR *gz_statep;
|
||||
|
||||
/* shared functions */
|
||||
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
|
||||
#if defined UNDER_CE
|
||||
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||
#endif
|
||||
|
||||
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
11
zlib/include/inffast.h
Normal file
11
zlib/include/inffast.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-2003, 2010 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
|
||||
94
zlib/include/inffixed.h
Normal file
94
zlib/include/inffixed.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by makefixed().
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications.
|
||||
It is part of the implementation of this library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
static const code lenfix[512] = {
|
||||
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
|
||||
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
|
||||
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
|
||||
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
|
||||
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
|
||||
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
|
||||
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
|
||||
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
|
||||
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
|
||||
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
|
||||
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
|
||||
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
|
||||
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
|
||||
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
|
||||
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
|
||||
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
|
||||
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
|
||||
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
|
||||
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
|
||||
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
|
||||
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
|
||||
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
|
||||
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
|
||||
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
|
||||
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
|
||||
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
|
||||
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
|
||||
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
|
||||
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
|
||||
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
|
||||
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
|
||||
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
|
||||
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
|
||||
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
|
||||
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
|
||||
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
|
||||
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
|
||||
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
|
||||
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
|
||||
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
|
||||
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
|
||||
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
|
||||
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
|
||||
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
|
||||
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
|
||||
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
|
||||
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
|
||||
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
|
||||
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
|
||||
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
|
||||
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
|
||||
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
|
||||
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
|
||||
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
|
||||
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
|
||||
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
|
||||
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
|
||||
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
|
||||
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
|
||||
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
|
||||
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
|
||||
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
|
||||
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
|
||||
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
|
||||
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
|
||||
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
|
||||
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
|
||||
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
|
||||
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
|
||||
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
|
||||
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
|
||||
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
|
||||
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
|
||||
{0,9,255}
|
||||
};
|
||||
|
||||
static const code distfix[32] = {
|
||||
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
|
||||
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
|
||||
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
|
||||
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
|
||||
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
|
||||
{22,5,193},{64,5,0}
|
||||
};
|
||||
126
zlib/include/inflate.h
Normal file
126
zlib/include/inflate.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/* inflate.h -- internal inflate state definition
|
||||
* Copyright (C) 1995-2019 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
|
||||
the crc code when it is not needed. For shared libraries, gzip decoding
|
||||
should be left enabled. */
|
||||
#ifndef NO_GZIP
|
||||
# define GUNZIP
|
||||
#endif
|
||||
|
||||
/* Possible inflate modes between inflate() calls */
|
||||
typedef enum {
|
||||
HEAD = 16180, /* i: waiting for magic header */
|
||||
FLAGS, /* i: waiting for method and flags (gzip) */
|
||||
TIME, /* i: waiting for modification time (gzip) */
|
||||
OS, /* i: waiting for extra flags and operating system (gzip) */
|
||||
EXLEN, /* i: waiting for extra length (gzip) */
|
||||
EXTRA, /* i: waiting for extra bytes (gzip) */
|
||||
NAME, /* i: waiting for end of file name (gzip) */
|
||||
COMMENT, /* i: waiting for end of comment (gzip) */
|
||||
HCRC, /* i: waiting for header crc (gzip) */
|
||||
DICTID, /* i: waiting for dictionary check value */
|
||||
DICT, /* waiting for inflateSetDictionary() call */
|
||||
TYPE, /* i: waiting for type bits, including last-flag bit */
|
||||
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
||||
STORED, /* i: waiting for stored size (length and complement) */
|
||||
COPY_, /* i/o: same as COPY below, but only first time in */
|
||||
COPY, /* i/o: waiting for input or output to copy stored block */
|
||||
TABLE, /* i: waiting for dynamic block table lengths */
|
||||
LENLENS, /* i: waiting for code length code lengths */
|
||||
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
||||
LEN_, /* i: same as LEN below, but only first time in */
|
||||
LEN, /* i: waiting for length/lit/eob code */
|
||||
LENEXT, /* i: waiting for length extra bits */
|
||||
DIST, /* i: waiting for distance code */
|
||||
DISTEXT, /* i: waiting for distance extra bits */
|
||||
MATCH, /* o: waiting for output space to copy string */
|
||||
LIT, /* o: waiting for output space to write literal */
|
||||
CHECK, /* i: waiting for 32-bit check value */
|
||||
LENGTH, /* i: waiting for 32-bit length (gzip) */
|
||||
DONE, /* finished check, done -- remain here until reset */
|
||||
BAD, /* got a data error -- remain here until reset */
|
||||
MEM, /* got an inflate() memory error -- remain here until reset */
|
||||
SYNC /* looking for synchronization bytes to restart inflate() */
|
||||
} inflate_mode;
|
||||
|
||||
/*
|
||||
State transitions between above modes -
|
||||
|
||||
(most modes can go to BAD or MEM on error -- not shown for clarity)
|
||||
|
||||
Process header:
|
||||
HEAD -> (gzip) or (zlib) or (raw)
|
||||
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
|
||||
HCRC -> TYPE
|
||||
(zlib) -> DICTID or TYPE
|
||||
DICTID -> DICT -> TYPE
|
||||
(raw) -> TYPEDO
|
||||
Read deflate blocks:
|
||||
TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
|
||||
STORED -> COPY_ -> COPY -> TYPE
|
||||
TABLE -> LENLENS -> CODELENS -> LEN_
|
||||
LEN_ -> LEN
|
||||
Read deflate codes in fixed or dynamic block:
|
||||
LEN -> LENEXT or LIT or TYPE
|
||||
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
||||
LIT -> LEN
|
||||
Process trailer:
|
||||
CHECK -> LENGTH -> DONE
|
||||
*/
|
||||
|
||||
/* State maintained between inflate() calls -- approximately 7K bytes, not
|
||||
including the allocated sliding window, which is up to 32K bytes. */
|
||||
struct inflate_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
int last; /* true if processing last block */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||
bit 2 true to validate check value */
|
||||
int havedict; /* true if dictionary provided */
|
||||
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||
-1 if raw or no header yet */
|
||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||
unsigned long check; /* protected copy of check value */
|
||||
unsigned long total; /* protected copy of output count */
|
||||
gz_headerp head; /* where to save gzip header information */
|
||||
/* sliding window */
|
||||
unsigned wbits; /* log base 2 of requested window size */
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||
/* bit accumulator */
|
||||
unsigned long hold; /* input bit accumulator */
|
||||
unsigned bits; /* number of bits in hold */
|
||||
/* for string and stored block copying */
|
||||
unsigned length; /* literal or length of data to copy */
|
||||
unsigned offset; /* distance back to copy string from */
|
||||
/* for table and code decoding */
|
||||
unsigned extra; /* extra bits needed */
|
||||
/* fixed and dynamic code tables */
|
||||
code const FAR *lencode; /* starting table for length/literal codes */
|
||||
code const FAR *distcode; /* starting table for distance codes */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
/* dynamic table building */
|
||||
unsigned ncode; /* number of code length code lengths */
|
||||
unsigned nlen; /* number of length code lengths */
|
||||
unsigned ndist; /* number of distance code lengths */
|
||||
unsigned have; /* number of code lengths in lens[] */
|
||||
code FAR *next; /* next available space in codes[] */
|
||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
code codes[ENOUGH]; /* space for code tables */
|
||||
int sane; /* if false, allow invalid distance too far */
|
||||
int back; /* bits back of last unprocessed length/lit */
|
||||
unsigned was; /* initial length of match */
|
||||
};
|
||||
62
zlib/include/inftrees.h
Normal file
62
zlib/include/inftrees.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2005, 2010 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* Structure for decoding tables. Each entry provides either the
|
||||
information needed to do the operation requested by the code that
|
||||
indexed that table entry, or it provides a pointer to another
|
||||
table that indexes more bits of the code. op indicates whether
|
||||
the entry is a pointer to another table, a literal, a length or
|
||||
distance, an end-of-block, or an invalid code. For a table
|
||||
pointer, the low four bits of op is the number of index bits of
|
||||
that table. For a length or distance, the low four bits of op
|
||||
is the number of extra bits to get after the code. bits is
|
||||
the number of bits in this code or part of the code to drop off
|
||||
of the bit buffer. val is the actual byte to output in the case
|
||||
of a literal, the base length or distance, or the offset from
|
||||
the current table to the next table. Each entry is four bytes. */
|
||||
typedef struct {
|
||||
unsigned char op; /* operation, extra bits, table bits */
|
||||
unsigned char bits; /* bits in this part of the code */
|
||||
unsigned short val; /* offset in table or code value */
|
||||
} code;
|
||||
|
||||
/* op values as set by inflate_table():
|
||||
00000000 - literal
|
||||
0000tttt - table link, tttt != 0 is the number of table index bits
|
||||
0001eeee - length or distance, eeee is the number of extra bits
|
||||
01100000 - end of block
|
||||
01000000 - invalid code
|
||||
*/
|
||||
|
||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||
codes. These values were found by exhaustive searches using the program
|
||||
examples/enough.c found in the zlib distribution. The arguments to that
|
||||
program are the number of symbols, the initial root table size, and the
|
||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
||||
initial root table size (9 or 6) is found in the fifth argument of the
|
||||
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||
changed, then these maximum sizes would be need to be recalculated and
|
||||
updated. */
|
||||
#define ENOUGH_LENS 852
|
||||
#define ENOUGH_DISTS 592
|
||||
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||
|
||||
/* Type of code to build for inflate_table() */
|
||||
typedef enum {
|
||||
CODES,
|
||||
LENS,
|
||||
DISTS
|
||||
} codetype;
|
||||
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work);
|
||||
128
zlib/include/trees.h
Normal file
128
zlib/include/trees.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* header created automatically with -DGEN_TREES_H */
|
||||
|
||||
local const ct_data static_ltree[L_CODES+2] = {
|
||||
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
|
||||
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
|
||||
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
|
||||
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
|
||||
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
|
||||
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
|
||||
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
|
||||
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
|
||||
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
|
||||
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
|
||||
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
|
||||
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
|
||||
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
|
||||
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
|
||||
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
|
||||
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
|
||||
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
|
||||
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
|
||||
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
|
||||
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
|
||||
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
|
||||
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
|
||||
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
|
||||
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
|
||||
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
|
||||
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
|
||||
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
|
||||
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
|
||||
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
|
||||
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
|
||||
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
|
||||
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
|
||||
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
|
||||
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
|
||||
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
|
||||
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
|
||||
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
|
||||
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
|
||||
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
|
||||
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
|
||||
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
|
||||
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
|
||||
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
|
||||
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
|
||||
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
|
||||
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
|
||||
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
|
||||
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
|
||||
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
|
||||
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
|
||||
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
|
||||
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
|
||||
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
|
||||
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
|
||||
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
|
||||
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
|
||||
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
|
||||
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
|
||||
};
|
||||
|
||||
local const ct_data static_dtree[D_CODES] = {
|
||||
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
|
||||
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
|
||||
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
|
||||
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
|
||||
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
|
||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||
};
|
||||
|
||||
const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
|
||||
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||
};
|
||||
|
||||
local const int base_length[LENGTH_CODES] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
|
||||
64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||
};
|
||||
|
||||
local const int base_dist[D_CODES] = {
|
||||
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
|
||||
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
|
||||
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
546
zlib/include/zconf.h
Normal file
546
zlib/include/zconf.h
Normal file
@@ -0,0 +1,546 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
/* #undef Z_PREFIX */
|
||||
/* #undef Z_HAVE_UNISTD_H */
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols and init macros */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# define adler32_z z_adler32_z
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define crc32_combine_gen z_crc32_combine_gen
|
||||
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||
# define crc32_combine_op z_crc32_combine_op
|
||||
# define crc32_z z_crc32_z
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateGetDictionary z_deflateGetDictionary
|
||||
# define deflateInit z_deflateInit
|
||||
# define deflateInit2 z_deflateInit2
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflateUsed z_deflateUsed
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzfread z_gzfread
|
||||
# define gzfwrite z_gzfwrite
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit z_inflateBackInit
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCodesUsed z_inflateCodesUsed
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit z_inflateInit
|
||||
# define inflateInit2 z_inflateInit2
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateValidate z_inflateValidate
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# define uncompress2 z_uncompress2
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef z_const
|
||||
# ifdef ZLIB_CONST
|
||||
# define z_const const
|
||||
# else
|
||||
# define z_const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
# ifdef _WIN64
|
||||
typedef unsigned long long z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
#else
|
||||
# define z_longlong long long
|
||||
# if defined(NO_SIZE_T)
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
# elif defined(STDC)
|
||||
# include <stddef.h>
|
||||
typedef size_t z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# undef z_longlong
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# if defined(__WATCOMC__) || defined(__GO32__) || \
|
||||
(defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#elif defined(__MINGW32__)
|
||||
# define z_off64_t long long
|
||||
#elif defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
#elif defined(__GO32__)
|
||||
# define z_off64_t offset_t
|
||||
#else
|
||||
# define z_off64_t z_off_t
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
1953
zlib/include/zlib.h
Normal file
1953
zlib/include/zlib.h
Normal file
File diff suppressed because it is too large
Load Diff
257
zlib/include/zutil.h
Normal file
257
zlib/include/zutil.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZUTIL_H
|
||||
#define ZUTIL_H
|
||||
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#if defined(STDC) && !defined(Z_SOLO)
|
||||
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* since "static" is used to mean two completely different things in C, we
|
||||
define "local" for the non-static meaning of "static", for readability
|
||||
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned long
|
||||
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned long long
|
||||
# elif (ULONG_LONG_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned long long
|
||||
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||
# define Z_U8 unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
#if MAX_WBITS < 9 || MAX_WBITS > 15
|
||||
# error MAX_WBITS must be in 9..15
|
||||
#endif
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||
# define OS_CODE 0x00
|
||||
# ifndef Z_SOLO
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 1
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 2
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#ifdef __370__
|
||||
# if __TARGET_LIB__ < 0x20000000
|
||||
# define OS_CODE 4
|
||||
# elif __TARGET_LIB__ < 0x40000000
|
||||
# define OS_CODE 11
|
||||
# else
|
||||
# define OS_CODE 8
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 5
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 6
|
||||
# if defined(M_I86) && !defined(Z_SOLO)
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MACOS)
|
||||
# define OS_CODE 7
|
||||
#endif
|
||||
|
||||
#if defined(__acorn) || defined(__riscos)
|
||||
# define OS_CODE 13
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define OS_CODE 10
|
||||
#endif
|
||||
|
||||
#ifdef _BEOS_
|
||||
# define OS_CODE 16
|
||||
#endif
|
||||
|
||||
#ifdef __TOS_OS400__
|
||||
# define OS_CODE 18
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define OS_CODE 19
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||
#pragma warn -8004
|
||||
#pragma warn -8008
|
||||
#pragma warn -8066
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#ifndef Z_LARGE64
|
||||
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
|
||||
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
|
||||
#endif
|
||||
|
||||
/* common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 3 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#if defined(pyr) || defined(Z_SOLO)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
|
||||
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
|
||||
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef ZLIB_DEBUG
|
||||
# include <stdio.h>
|
||||
extern int ZLIB_INTERNAL z_verbose;
|
||||
extern void ZLIB_INTERNAL z_error(char *m);
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
#ifndef Z_SOLO
|
||||
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
||||
unsigned size);
|
||||
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
||||
#endif
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
/* Reverse the bytes in a 32-bit value */
|
||||
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||
|
||||
#endif /* ZUTIL_H */
|
||||
Reference in New Issue
Block a user