filehash/ffdb_hash.c
unsigned int
_ffdb_hget_header(ffdb_htab_t *hashp, unsigned int page_size)
{
  unsigned num_copied, i, newchksum;
  unsigned char *hdr_dest;

  num_copied = 0;
  i = 0;

  hdr_dest = (unsigned char *)&hashp->hdr;
  
  /* 
   * XXX
   * This should not be printing to stderr on a "normal" error case.
   */
  lseek(hashp->fp, 0, SEEK_SET);
  num_copied = read(hashp->fp, hdr_dest, sizeof(ffdb_hashhdr_t));
  if (num_copied != sizeof(ffdb_hashhdr_t)) {
    fprintf(stderr, "Fatal error : hash could not retrieve header");
    return 0;
  }

  /* Now I need compare checksum value */
  newchksum = 0;
  newchksum = __ffdb_crc32_checksum (newchksum, hdr_dest,
				     sizeof(ffdb_hashhdr_t) - sizeof(unsigned int));

  if (hashp->mborder == LITTLE_ENDIAN)
    _ffdb_swap_header(hashp);

  if (newchksum != hashp->hdr.chksum) {
    fprintf (stderr, "Hash Meta Data Checksum error!!!!!! 0x%x != 0x%x (retrieved)\n", newchksum, hashp->hdr.chksum);
    exit (1);
  }

#if 0
  if (hashp->hdr.lorder == LITTLE_ENDIAN) 
    fprintf (stderr, "Info: Data are stored in little endian format.\n");
  else
    fprintf (stderr, "Info: Data are stored in big endian format.\n");
#endif

  return num_copied;
}
/**
 * Functions to get/put hash header.  We access the file directly.
 */
Functions to get/put hash header.  We access the file directly.
Functions to get / put hash header . We access the file directly .
unsigned int
_ffdb_hget_header(ffdb_htab_t *hashp, unsigned int page_size)
{
  unsigned num_copied, i, newchksum;
  unsigned char *hdr_dest;
  num_copied = 0;
  i = 0;
  hdr_dest = (unsigned char *)&hashp->hdr;
  lseek(hashp->fp, 0, SEEK_SET);
  num_copied = read(hashp->fp, hdr_dest, sizeof(ffdb_hashhdr_t));
  if (num_copied != sizeof(ffdb_hashhdr_t)) {
    fprintf(stderr, "Fatal error : hash could not retrieve header");
    return 0;
  }
  newchksum = 0;
  newchksum = __ffdb_crc32_checksum (newchksum, hdr_dest,
				     sizeof(ffdb_hashhdr_t) - sizeof(unsigned int));
  if (hashp->mborder == LITTLE_ENDIAN)
    _ffdb_swap_header(hashp);
  if (newchksum != hashp->hdr.chksum) {
    fprintf (stderr, "Hash Meta Data Checksum error!!!!!! 0x%x != 0x%x (retrieved)\n", newchksum, hashp->hdr.chksum);
    exit (1);
  }
#if 0
  if (hashp->hdr.lorder == LITTLE_ENDIAN) 
    fprintf (stderr, "Info: Data are stored in little endian format.\n");
  else
    fprintf (stderr, "Info: Data are stored in big endian format.\n");
#endif
  return num_copied;
}
unsigned int _ffdb_hget_header ( ffdb_htab_t * hashp , unsigned int page_size ) { unsigned num_copied , i , newchksum ; unsigned char * hdr_dest ; num_copied = 0 ; i = 0 ; hdr_dest = ( unsigned char * ) & hashp -> hdr ; lseek ( hashp -> fp , 0 , SEEK_SET ) ; num_copied = read ( hashp -> fp , hdr_dest , sizeof ( ffdb_hashhdr_t ) ) ; if ( num_copied != sizeof ( ffdb_hashhdr_t ) ) { fprintf ( stderr , " " ) ; return 0 ; } newchksum = 0 ; newchksum = __ffdb_crc32_checksum ( newchksum , hdr_dest , sizeof ( ffdb_hashhdr_t ) - sizeof ( unsigned int ) ) ; if ( hashp -> mborder == LITTLE_ENDIAN ) _ffdb_swap_header ( hashp ) ; if ( newchksum != hashp -> hdr . chksum ) { fprintf ( stderr , " \n " , newchksum , hashp -> hdr . chksum ) ; exit ( 1 ) ; } #if 0 if ( hashp -> hdr . lorder == LITTLE_ENDIAN ) fprintf ( stderr , " \n " ) ; else fprintf ( stderr , " \n " ) ; #endif return num_copied ; }
Functions to get/put hash header.
Functions to get / put hash header .
/* 
   * XXX
   * This should not be printing to stderr on a "normal" error case.
   */ /* Now I need compare checksum value */