Changeset 166 for trunk/lib


Ignore:
Timestamp:
12/15/09 22:18:05 (14 years ago)
Author:
tim
Message:

fixed a bug in big data parsing
broke up some of REGFI_FILE initialization
started added more regfi API documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfi.c

    r165 r166  
    12711271
    12721272
    1273 /*******************************************************************
    1274  * Open the registry file and then read in the REGF block to get the
    1275  * first hbin offset.
    1276  *******************************************************************/
     1273/******************************************************************************
     1274 ******************************************************************************/
    12771275REGFI_FILE* regfi_open(const char* filename)
     1276{
     1277  REGFI_FILE* ret_val;
     1278  int fd;
     1279
     1280  /* open an existing file */
     1281  if ((fd = open(filename, REGFI_OPEN_FLAGS)) == -1)
     1282  {
     1283    /* fprintf(stderr, "regfi_open: failure to open %s (%s)\n", filename, strerror(errno));*/
     1284    return NULL;
     1285  }
     1286
     1287  ret_val = regfi_alloc(fd);
     1288
     1289  if(ret_val == NULL)
     1290    close(fd);
     1291
     1292  return ret_val;
     1293}
     1294
     1295
     1296/******************************************************************************
     1297 ******************************************************************************/
     1298REGFI_FILE* regfi_alloc(int fd)
    12781299{
    12791300  struct stat sbuf;
     
    12811302  REGFI_HBIN* hbin = NULL;
    12821303  uint32 hbin_off, file_length, cache_secret;
    1283   int fd;
    12841304  bool rla;
    12851305
    1286   /* open an existing file */
    1287   if ((fd = open(filename, REGFI_OPEN_FLAGS)) == -1)
    1288   {
    1289     /* fprintf(stderr, "regfi_open: failure to open %s (%s)\n", filename, strerror(errno));*/
    1290     return NULL;
    1291   }
    1292  
    12931306  /* Determine file length.  Must be at least big enough
    12941307   * for the header and one hbin.
     
    13001313    return NULL;
    13011314
    1302   /* read in an existing file */
     1315  /* Read file header */
    13031316  if ((rb = regfi_parse_regf(fd, true)) == NULL)
    13041317  {
    1305     /* fprintf(stderr, "regfi_open: Failed to read initial REGF block\n"); */
    1306     close(fd);
     1318    /* fprintf(stderr, "regfi_alloc: Failed to read initial REGF block\n"); */
    13071319    return NULL;
    13081320  }
     
    13121324  if(rb->hbins == NULL)
    13131325  {
    1314     /* fprintf(stderr, "regfi_open: Failed to create HBIN list.\n"); */
    1315     close(fd);
     1326    /* fprintf(stderr, "regfi_alloc: Failed to create HBIN list.\n"); */
    13161327    talloc_free(rb);
    13171328    return NULL;
     
    13501361/******************************************************************************
    13511362 ******************************************************************************/
    1352 int regfi_close(REGFI_FILE *file)
     1363int regfi_close(REGFI_FILE* file)
    13531364{
    13541365  int fd;
     
    13611372  file->fd = -1;
    13621373
    1363   range_list_free(file->hbins);
    1364 
    1365   if(file->sk_cache != NULL)
    1366     lru_cache_destroy(file->sk_cache);
     1374  regfi_free(file);
     1375
     1376  return close(fd);
     1377}
     1378
     1379
     1380/******************************************************************************
     1381 ******************************************************************************/
     1382void regfi_free(REGFI_FILE *file)
     1383{
     1384  if(file->last_message != NULL)
     1385    free(last_message);
    13671386
    13681387  talloc_free(file);
    1369   return close(fd);
    13701388}
    13711389
     
    20772095
    20782096
    2079 /*******************************************************************
     2097/******************************************************************************
    20802098 * Convert from UTF-16LE to specified character set.
    20812099 * On error, returns a negative errno code.
    2082  *******************************************************************/
     2100 *****************************************************************************/
    20832101int32 regfi_conv_charset(const char* input_charset, const char* output_charset,
    20842102                         uint8* input, char* output,
     
    29012919                                       uint16 num_chunks, bool strict)
    29022920{
    2903   uint32 cell_length, chunk_offset, data_left;
     2921  uint32 cell_length, chunk_offset;
    29042922  range_list* ret_val;
    29052923  uint16 i;
     
    29112929    goto fail;
    29122930 
    2913   for(i=0; (i<num_chunks) && (data_left>0); i++)
     2931  for(i=0; i<num_chunks; i++)
    29142932  {
    29152933    chunk_offset = offsets[i]+REGFI_REGF_SIZE;
Note: See TracChangeset for help on using the changeset viewer.