int IOR_Check(const int len, const char *in_buff, char *out_buff)
{
int i;
int x;
int n;
int rts;
i = 0;
if(strncmp(in_buff, "IOR:", 4) == 0) {
i = 4;
}
for(x = 0; i < len; i += 2) {
rts = atox(buff[i]);
if(rts == -1) {
out_buff[x] = 0;
return -1;
}
n = rts * 16;
rts = atox(buff[i+1]);
if(rts == -1) {
out_buff[x] = 0;
return -1;
}
n += rts;
if(n == 0x00) {
out_buff[x] = '_';
} else if(n >= 0x01 && n <= 0x1f){
out_buff[x] = '*';
} else if(n >= 0x20 && n <= 0x7e){
out_buff[x] = n;
} else {
out_buff[x] = '*';
}
x ++;
}
out_buff[x] = 0;
return 0;
}
struct ASCII_TBL {
char a;
int n;
} ascii_tbl[24] = {
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4},
{'5', 5}, {'6', 6}, {'7', 7}, {'8', 8}, {'9', 9},
{'a', 10}, {'b', 11}, {'c', 12}, {'d', 13}, {'e', 14}, {'f', 15},
{'A', 10}, {'B', 11}, {'C', 12}, {'D', 13}, {'E', 14}, {'F', 15},
{' ', -1},
};
int atox(const char a)
{
int i;
for(i = 0; ascii_tbl[i].n != -1; i ++) {
if(ascii_tbl[i].a == a) {
return ascii_tbl[i].n;
}
}
return -1;
}