Changeset 159 for trunk/include


Ignore:
Timestamp:
12/06/09 15:09:01 (15 years ago)
Author:
tim
Message:

began rearranging data parsing. Moved charater set conversion and basic parsing logic into regfi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r158 r159  
    4545#include <unistd.h>
    4646#include <assert.h>
     47#include <iconv.h>
    4748
    4849#include "talloc.h"
     
    250251
    251252
     253typedef struct _regfi_data
     254{
     255  uint32 type;
     256
     257  /* Length of the raw data. */
     258  uint32 size;
     259
     260  /* This is always present, representing the raw data cell contents. */
     261  uint8* raw;
     262
     263  /* Represents the length of the interpreted value. Meaning is type-specific.*/
     264  uint32 interpreted_size;
     265
     266  /* These items represent interpreted versions of the raw attribute above.
     267   * Only use the appropriate member according to the type field. 
     268   * In the event of an unknown type, use only the raw field.
     269   */
     270  union _regfi_data_interpreted
     271  {
     272    uint8* none; /* */
     273    uint8* string;
     274    uint8* expand_string;
     275    uint8* binary; /* */
     276    uint32 dword;
     277    uint32 dword_be;
     278    uint8* link;
     279    uint8** multiple_string;
     280    uint64 qword;
     281
     282    /* The following are treated as binary currently, but this may change in
     283     * the future as the formats become better understood.
     284     */
     285    uint8* resource_list;
     286    uint8* full_resource_descriptor;
     287    uint8* resource_requirements_list;
     288  } interpreted;
     289} REGFI_DATA;
     290
     291
    252292/* Value record */
    253293typedef struct
     
    256296  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
    257297
    258   uint8* data;
     298  REGFI_DATA* data;     /* XXX: deprecated */
     299
    259300  char*  valuename;
    260301  uint16 name_length;
    261302  uint32 hbin_off;      /* offset from beginning of this hbin block */
    262303 
    263   uint32 data_size;
    264   uint32 data_off;      /* offset of data cell (virtual) */
     304  uint32 data_size;     /* As reported in the VK record.  May be different than
     305                         * That obtained while parsing the data cell itself. */
     306  uint32 data_off;      /* Offset of data cell (virtual) */
    265307  uint32 type;
    266308  uint8  magic[REGFI_CELL_MAGIC_SIZE];
     
    423465  void_stack* key_positions;
    424466  REGFI_NK_REC* cur_key;
     467  const char* string_encoding;
    425468  uint32 cur_subkey;
    426469  uint32 cur_value;
     
    446489
    447490
     491
    448492/******************************************************************************/
    449493/*                         Main iterator API                                  */
     
    462506 */
    463507char*                 regfi_get_messages(REGFI_FILE* file);
     508
    464509void                  regfi_set_message_mask(REGFI_FILE* file, uint16 mask);
    465510
    466 REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* fh);
     511
     512/* regfi_iterator_new: Creates a new iterator for the provided registry file.
     513 *
     514 * Arguments:
     515 *   file            -- The opened registry file the iterator should be
     516 *                      created for.
     517 *   output_encoding -- An integer representing the output string encoding.
     518 *                      These integers currently map to a specific set of
     519 *                      iconv(3) encodings.
     520 *                      The following values are currently accepted:
     521 *                      0 - default (currently US-ASCII//TRANSLIT)
     522 *                      1 - US-ASCII//TRANSLIT
     523 *                      2 - UTF-8//TRANSLIT
     524 *
     525 *                      XXX: This encoding only applies to specific data
     526 *                           strings currently, but should apply to key
     527 *                           names and value names in the future.
     528 *
     529 * Returns:
     530 *   A newly allocated REGFI_ITERATOR. Must be free()d with regfi_iterator_free.
     531 */
     532REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* file,
     533                                         uint32 output_encoding);
    467534void                  regfi_iterator_free(REGFI_ITERATOR* i);
    468535bool                  regfi_iterator_down(REGFI_ITERATOR* i);
     
    487554                                                const char* value_name);
    488555
    489 REGFI_DATA*           regfi_iterator_cur_data(REGFI_ITERATOR* i);
     556REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i,
     557                                                const REGFI_VK_REC* value);
    490558
    491559
     
    512580                                          range_list* used_ranges,
    513581                                          bool strict);
     582bool                  regfi_interpret_data(REGFI_FILE* file,
     583                                           const char* string_encoding,
     584                                           uint32 type, REGFI_DATA* data);
     585void                  regfi_free_data(REGFI_DATA* data);
    514586
    515587/* These are cached so return values don't need to be freed. */
     
    599671REGFI_VK_REC*         regfi_copy_vk(const REGFI_VK_REC* vk);
    600672int32                 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset);
     673int32                 regfi_conv_charset(const char* output_charset,
     674                                         uint8* input, char* output,
     675                                         uint32 input_len, uint32 output_max);
     676REGFI_DATA*           regfi_buffer_to_data(REGFI_BUFFER raw_data);
    601677
    602678#endif  /* _REGFI_H */
Note: See TracChangeset for help on using the changeset viewer.