#include "RIV_Varios.h"
//////////////////////////////////
unsigned long CRIV_Varios::read_32u(FILE *fp)
{
unsigned char b0,b1,b2,b3; // bytes from file
b0 = getc(fp);
b1 = getc(fp);
b2 = getc(fp);
b3 = getc(fp);
return (unsigned long)((((((b3<<8)|b2)<<8)|b1)<<8)|b0);
}
// Similarly for writing to file
// Other routines need to be written for 16 bit (signed/unsigned)
//////////////////////////////////
//////////////////////////////////
unsigned int CRIV_Varios::read_16u(FILE *fp)
{
unsigned char b0,b1; // bytes from file
b0 = getc(fp);
b1 = getc(fp);
return (unsigned int)((b1<<8)|b0);
}
//////////////////////////////////
//////////////////////////////////
int CRIV_Varios::Byte_2_Hex(char Byte_Entrada, char *Char_Salida)
{
char aux_char;
aux_char = Byte_Entrada;
aux_char = aux_char & 0x0000000F;
if (aux_char <= 0x9)
{
Char_Salida[1] = ( aux_char ) + 0x30;
}
else
{
Char_Salida[1] = aux_char + 0x37;
}
aux_char = Byte_Entrada;
aux_char = aux_char >> 4;
aux_char = aux_char & 0x0000000F;
if (aux_char <= 0x9)
{
Char_Salida[0] = aux_char + 0x30;
}
else
{
Char_Salida[0] = aux_char + 0x37;
}
return (0);
}
//////////////////////////////////