| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflbits.h" BITS * bits_fget (FILE *file)
Reads a bitstring from the specified file stream. You must have previously written the bitstring using bit_fput (). Returns a newly-created bitmap, or NULL if there was insufficient memory.
{ int block_nbr; /* Bitstring block number */ word comp_size; /* Size of compressed block */ BITBLOCK *block_ptr; /* Points to bitstring block */ BITS *bits; ASSERT (file); bits = bits create (); /* Create a new, empty bitmap */ /* Read bitstring header from file */ fread (&bits-> block_count, sizeof (bits-> block_count), 1, file); fread (&bits-> free_list, sizeof (bits-> free_list), 1, file); /* Read bitstring blocks from file */ for (block_nbr = 0; block_nbr < bits-> block_count; block_nbr++) { block_nbr = alloc_block (bits); if (block_nbr == 0) { bits destroy (bits); return (NULL); } fread (&comp_size, sizeof (comp_size), 1, file); fread (compressed, comp_size, 1, file); block_ptr = bits-> block [block_nbr]; block_ptr-> size = expand block (compressed, (byte *) block_ptr, comp_size); } return (bits); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |