/* * include needed system headers */ #include /* include standard i/o library */ #include /* include standard library */ #include /* include string library */ #include /* include unix standard library */ #include /* */ #include /* */ #include /* */ #include /* error simbol definitions */ #include /* system time definitions */ #include /* math library */ /** * Read nbytes at position p of buffer, and fill value */ void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value) { char bytes[4]; int i; for(i=0; i<*nbytes; i++) { bytes[i] = *(buffer+(*p)-1+i); } if(*nbytes == 1) *value = 0x000000ff & bytes[0]; if(*nbytes == 2) *value = ((bytes[0]<<8)&0x0000ff00) | (bytes[1]&0x000000ff); if(*nbytes == 4) *value = ((bytes[0]<<24)&0xff000000) | ((bytes[1]<<16)&0x00ff0000) | ((bytes[2]<<8)&0x0000ff00) | (bytes[3]&0x000000ff); *p += *nbytes; return; }