MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / ReadLittleBytes

Function ReadLittleBytes

include/bmpread/bmpread.c:126–142  ·  view source on GitHub ↗

Reads up to 4 little-endian bytes from fp and stores the result in the * uint32_t pointed to by dest in the host's byte order. Returns 0 on EOF or * nonzero on success. */

Source from the content-addressed store, hash-verified

124 * nonzero on success.
125 */
126static int ReadLittleBytes(uint32_t * dest, int bytes, FILE * fp)
127{
128 uint32_t shift = 0;
129
130 *dest = 0;
131
132 while(bytes--)
133 {
134 int byte;
135 if((byte = fgetc(fp)) == EOF) return 0;
136
137 *dest += (uint32_t)byte << shift;
138 shift += 8;
139 }
140
141 return 1;
142}
143
144/* Reads a little-endian uint32_t from fp and stores the result in *dest in the
145 * host's byte order. Returns 0 on EOF or nonzero on success.

Callers 2

ReadLittleInt32Function · 0.85
ReadLittleUint16Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected