Commit d1fb6340 authored by unknown's avatar unknown

Just adding support for a "minor" version number.


storage/archive/archive_reader.c:
  Print minor information version.
storage/archive/archive_test.c:
  Fixed test
storage/archive/azio.c:
  Added support for "minor" version.
storage/archive/azlib.h:
  Added information for minor information.
parent af23ddf6
...@@ -41,9 +41,10 @@ int main(int argc, char *argv[]) ...@@ -41,9 +41,10 @@ int main(int argc, char *argv[])
} }
printf("Version %u\n", reader_handle.version); printf("Version %u\n", reader_handle.version);
printf("\tStart position %llu\n", (unsigned long long)reader_handle.start);
if (reader_handle.version > 2) if (reader_handle.version > 2)
{ {
printf("\tMinor version %u\n", reader_handle.minor_version);
printf("\tStart position %llu\n", (unsigned long long)reader_handle.start);
printf("\tBlock size %u\n", reader_handle.block_size); printf("\tBlock size %u\n", reader_handle.block_size);
printf("\tRows %llu\n", reader_handle.rows); printf("\tRows %llu\n", reader_handle.rows);
printf("\tAutoincrement %llu\n", reader_handle.auto_increment); printf("\tAutoincrement %llu\n", reader_handle.auto_increment);
......
...@@ -94,7 +94,7 @@ int main(int argc, char *argv[]) ...@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
azflush(&reader_handle, Z_SYNC_FLUSH); azflush(&reader_handle, Z_SYNC_FLUSH);
assert(reader_handle.rows == TEST_LOOP_NUM); assert(reader_handle.rows == TEST_LOOP_NUM);
assert(reader_handle.auto_increment == 0); assert(reader_handle.auto_increment == 0);
assert(reader_handle.check_point == 61); assert(reader_handle.check_point == 62);
assert(reader_handle.forced_flushes == 1); assert(reader_handle.forced_flushes == 1);
assert(reader_handle.dirty == AZ_STATE_SAVED); assert(reader_handle.dirty == AZ_STATE_SAVED);
...@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) ...@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
azflush(&writer_handle, Z_SYNC_FLUSH); azflush(&writer_handle, Z_SYNC_FLUSH);
assert(writer_handle.rows == TEST_LOOP_NUM); assert(writer_handle.rows == TEST_LOOP_NUM);
assert(writer_handle.auto_increment == 4); assert(writer_handle.auto_increment == 4);
assert(writer_handle.check_point == 61); assert(writer_handle.check_point == 62);
assert(writer_handle.forced_flushes == 2); assert(writer_handle.forced_flushes == 2);
assert(writer_handle.dirty == AZ_STATE_SAVED); assert(writer_handle.dirty == AZ_STATE_SAVED);
...@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) ...@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
azflush(&reader_handle, Z_SYNC_FLUSH); azflush(&reader_handle, Z_SYNC_FLUSH);
assert(reader_handle.rows == 102); assert(reader_handle.rows == 102);
assert(reader_handle.auto_increment == 4); assert(reader_handle.auto_increment == 4);
assert(reader_handle.check_point == 1255); assert(reader_handle.check_point == 1256);
assert(reader_handle.forced_flushes == 4); assert(reader_handle.forced_flushes == 4);
assert(reader_handle.dirty == AZ_STATE_SAVED); assert(reader_handle.dirty == AZ_STATE_SAVED);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
static int const az_magic[2] = {0xfe, 0x03}; /* az magic header */ static int const az_magic[3] = {0xfe, 0x03, 0x01}; /* az magic header */
/* gzip flag byte */ /* gzip flag byte */
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
...@@ -69,6 +69,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) ...@@ -69,6 +69,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
s->transparent = 0; s->transparent = 0;
s->mode = 'r'; s->mode = 'r';
s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */ s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */
s->version = (unsigned char)az_magic[2]; /* minor version */
/* /*
We do our own version of append by nature. We do our own version of append by nature.
...@@ -155,12 +156,14 @@ void write_header(azio_stream *s) ...@@ -155,12 +156,14 @@ void write_header(azio_stream *s)
s->start = AZHEADER_SIZE + AZMETA_BUFFER_SIZE; s->start = AZHEADER_SIZE + AZMETA_BUFFER_SIZE;
s->block_size= AZ_BUFSIZE; s->block_size= AZ_BUFSIZE;
s->version = (unsigned char)az_magic[1]; s->version = (unsigned char)az_magic[1];
s->minor_version = (unsigned char)az_magic[2];
/* Write a very simple .az header: */ /* Write a very simple .az header: */
memset(buffer, 0, AZHEADER_SIZE + AZMETA_BUFFER_SIZE); memset(buffer, 0, AZHEADER_SIZE + AZMETA_BUFFER_SIZE);
*(ptr + AZ_MAGIC_POS)= az_magic[0]; *(ptr + AZ_MAGIC_POS)= az_magic[0];
*(ptr + AZ_VERSION_POS)= (unsigned char)s->version; *(ptr + AZ_VERSION_POS)= (unsigned char)s->version;
*(ptr + AZ_MINOR_VERSION_POS)= (unsigned char)s->minor_version;
*(ptr + AZ_BLOCK_POS)= (unsigned char)(s->block_size/1024); /* Reserved for block size */ *(ptr + AZ_BLOCK_POS)= (unsigned char)(s->block_size/1024); /* Reserved for block size */
*(ptr + AZ_STRATEGY_POS)= (unsigned char)Z_DEFAULT_STRATEGY; /* Compression Type */ *(ptr + AZ_STRATEGY_POS)= (unsigned char)Z_DEFAULT_STRATEGY; /* Compression Type */
...@@ -314,6 +317,7 @@ void read_header(azio_stream *s, unsigned char *buffer) ...@@ -314,6 +317,7 @@ void read_header(azio_stream *s, unsigned char *buffer)
if (buffer[0] == az_magic[0] && buffer[1] == az_magic[1]) if (buffer[0] == az_magic[0] && buffer[1] == az_magic[1])
{ {
s->version= (unsigned int)buffer[AZ_VERSION_POS]; s->version= (unsigned int)buffer[AZ_VERSION_POS];
s->minor_version= (unsigned int)buffer[AZ_MINOR_VERSION_POS];
s->block_size= 1024 * buffer[AZ_BLOCK_POS]; s->block_size= 1024 * buffer[AZ_BLOCK_POS];
s->start= (unsigned long long)uint8korr(buffer + AZ_START_POS); s->start= (unsigned long long)uint8korr(buffer + AZ_START_POS);
s->rows= (unsigned long long)uint8korr(buffer + AZ_ROW_POS); s->rows= (unsigned long long)uint8korr(buffer + AZ_ROW_POS);
......
...@@ -51,22 +51,23 @@ extern "C" { ...@@ -51,22 +51,23 @@ extern "C" {
+ sizeof(unsigned int) + sizeof(unsigned int) \ + sizeof(unsigned int) + sizeof(unsigned int) \
+ sizeof(unsigned char) + sizeof(unsigned char)
#define AZHEADER_SIZE 20 #define AZHEADER_SIZE 21
#define AZ_MAGIC_POS 0 #define AZ_MAGIC_POS 0
#define AZ_VERSION_POS 1 #define AZ_VERSION_POS 1
#define AZ_BLOCK_POS 2 #define AZ_MINOR_VERSION_POS 2
#define AZ_STRATEGY_POS 3 #define AZ_BLOCK_POS 3
#define AZ_FRM_POS 4 #define AZ_STRATEGY_POS 4
#define AZ_META_POS 8 #define AZ_FRM_POS 5
#define AZ_START_POS 12 #define AZ_META_POS 9
#define AZ_ROW_POS 20 #define AZ_START_POS 13
#define AZ_FLUSH_POS 28 #define AZ_ROW_POS 21
#define AZ_CHECK_POS 36 #define AZ_FLUSH_POS 29
#define AZ_AUTOINCREMENT_POS 44 #define AZ_CHECK_POS 37
#define AZ_LONGEST_POS 52 #define AZ_AUTOINCREMENT_POS 45
#define AZ_SHORTEST_POS 56 #define AZ_LONGEST_POS 53
#define AZ_DIRTY_POS 60 #define AZ_SHORTEST_POS 57
#define AZ_DIRTY_POS 61
/* /*
...@@ -210,6 +211,7 @@ typedef struct azio_stream { ...@@ -210,6 +211,7 @@ typedef struct azio_stream {
int back; /* one character push-back */ int back; /* one character push-back */
int last; /* true if push-back is last character */ int last; /* true if push-back is last character */
unsigned char version; /* Version */ unsigned char version; /* Version */
unsigned char minor_version; /* Version */
unsigned int block_size; /* Block Size */ unsigned int block_size; /* Block Size */
unsigned long long check_point; /* Last position we checked */ unsigned long long check_point; /* Last position we checked */
unsigned long long forced_flushes; /* Forced Flushes */ unsigned long long forced_flushes; /* Forced Flushes */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment