Faster load of the content file.

This commit is contained in:
Andrea Mazzoleni 2011-06-22 20:55:54 +02:00
parent 132ccef591
commit 7f400289b8
4 changed files with 35 additions and 27 deletions

View file

@ -3,7 +3,7 @@ SnapRAID HISTORY
1.5 2011/6
==========
* In the configuration file extra space are ignored.
* Ignores extra spaces in the configuration file.
* Changed the output of check/fix to allow a more easily postprocessing
with other tools like awk and sort.
* Added the hidden option -G/--gui to enable the output of progress

2
TODO
View file

@ -3,7 +3,7 @@ SnapRAID TODO
This is a list of possible TODO items for SnapRAID. The order is not relevant.
* If a file cannot be synched, for example because it was changing, of it
* If a file cannot be synched, for example because it was changing, or it
the file name cannot be supported, it's better to do not stop the sync process.
The sync process should stop only if the error could be caused by a disk
corruption.

View file

@ -311,7 +311,7 @@ void state_read(struct snapraid_state* state)
tag = s;
s = strtoken(s);
if (strcmp(tag, "blk") == 0 || strcmp(tag, "inv") == 0) {
char* pos;
char* hash;

56
util.c
View file

@ -125,40 +125,48 @@ void strenchex(char* str, const void* void_data, unsigned data_len)
}
}
static unsigned strdecset[256] =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
char* strdechex(void* void_data, unsigned data_len, char* str)
{
unsigned char* data = void_data;
unsigned i;
for(i=0;i<data_len;++i) {
char c0;
char c1;
unsigned char b0;
unsigned char b1;
unsigned b0;
unsigned b1;
unsigned b;
c0 = *str;
if (c0 >= '0' && c0 <= '9')
b0 = c0 - '0';
else if (c0 >= 'a' && c0 <= 'f')
b0 = c0 - 'a' + 10;
else if (c0 >= 'A' && c0 <= 'F')
b0 = c0 - 'A' + 10;
else
b0 = strdecset[(unsigned char)str[0]];
b1 = strdecset[(unsigned char)str[1]];
b = (b0 << 4) | b1;
if (b > 0xFF)
return str;
++str;
c1 = *str;
if (c1 >= '0' && c1 <= '9')
b1 = c1 - '0';
else if (c1 >= 'a' && c1 <= 'f')
b1 = c1 - 'a' + 10;
else if (c1 >= 'A' && c1 <= 'F')
b1 = c1 - 'A' + 10;
else
return str;
++str;
data[0] = b;
data[i] = (b0 << 4) | b1;
data += 1;
str += 2;
}
return 0;