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 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 * Changed the output of check/fix to allow a more easily postprocessing
with other tools like awk and sort. with other tools like awk and sort.
* Added the hidden option -G/--gui to enable the output of progress * 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. 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 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 The sync process should stop only if the error could be caused by a disk
corruption. corruption.

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) char* strdechex(void* void_data, unsigned data_len, char* str)
{ {
unsigned char* data = void_data; unsigned char* data = void_data;
unsigned i; unsigned i;
for(i=0;i<data_len;++i) { for(i=0;i<data_len;++i) {
char c0; unsigned b0;
char c1; unsigned b1;
unsigned char b0; unsigned b;
unsigned char b1;
c0 = *str; b0 = strdecset[(unsigned char)str[0]];
if (c0 >= '0' && c0 <= '9') b1 = strdecset[(unsigned char)str[1]];
b0 = c0 - '0';
else if (c0 >= 'a' && c0 <= 'f') b = (b0 << 4) | b1;
b0 = c0 - 'a' + 10;
else if (c0 >= 'A' && c0 <= 'F') if (b > 0xFF)
b0 = c0 - 'A' + 10;
else
return str; return str;
++str;
c1 = *str; data[0] = b;
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[i] = (b0 << 4) | b1; data += 1;
str += 2;
} }
return 0; return 0;