Changeset 78 for trunk/lib


Ignore:
Timestamp:
01/15/07 10:22:47 (18 years ago)
Author:
tim
Message:

beginning process of rewriting regfio interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfio.c

    r77 r78  
    2929
    3030/* Registry types mapping */
    31 const unsigned int regfio_num_reg_types = 12;
    32 static const char* regfio_type_names[] =
     31const unsigned int regfi_num_reg_types = 12;
     32static const char* regfi_type_names[] =
    3333  {"NONE", "SZ", "EXPAND_SZ", "BINARY", "DWORD", "DWORD_BE", "LINK",
    3434   "MULTI_SZ", "RSRC_LIST", "RSRC_DESC", "RSRC_REQ_LIST", "QWORD"};
     
    3636
    3737/* Returns NULL on error */
    38 const char* regfio_type_val2str(unsigned int val)
     38const char* regfi_type_val2str(unsigned int val)
    3939{
    4040  if(val == REG_KEY)
    4141    return "KEY";
    4242 
    43   if(val >= regfio_num_reg_types)
     43  if(val >= regfi_num_reg_types)
    4444    return NULL;
    4545 
    46   return regfio_type_names[val];
     46  return regfi_type_names[val];
    4747}
    4848
    4949
    5050/* Returns -1 on error */
    51 int regfio_type_str2val(const char* str)
     51int regfi_type_str2val(const char* str)
    5252{
    5353  int i;
     
    5656    return REG_KEY;
    5757
    58   for(i=0; i < regfio_num_reg_types; i++)
    59     if (strcmp(regfio_type_names[i], str) == 0)
     58  for(i=0; i < regfi_num_reg_types; i++)
     59    if (strcmp(regfi_type_names[i], str) == 0)
    6060      return i;
    6161
     
    6969/* Security descriptor parsing functions  */
    7070
    71 const char* regfio_ace_type2str(uint8 type)
     71const char* regfi_ace_type2str(uint8 type)
    7272{
    7373  static const char* map[7]
     
    8989 *   http://msdn2.microsoft.com/en-us/library/aa772242.aspx
    9090 */
    91 char* regfio_ace_flags2str(uint8 flags)
     91char* regfi_ace_flags2str(uint8 flags)
    9292{
    9393  static const char* flag_map[32] =
     
    147147
    148148
    149 char* regfio_ace_perms2str(uint32 perms)
     149char* regfi_ace_perms2str(uint32 perms)
    150150{
    151151  uint32 i, p;
     
    226226
    227227
    228 char* regfio_sid2str(DOM_SID* sid)
     228char* regfi_sid2str(DOM_SID* sid)
    229229{
    230230  uint32 i, size = MAXSUBAUTHS*11 + 24;
     
    248248
    249249
    250 char* regfio_get_acl(SEC_ACL* acl)
     250char* regfi_get_acl(SEC_ACL* acl)
    251251{
    252252  uint32 i, extra, size = 0;
     
    263263  for (i = 0; i < acl->num_aces && !failed; i++)
    264264  {
    265     sid_str = regfio_sid2str(&acl->ace[i].trustee);
    266     type_str = regfio_ace_type2str(acl->ace[i].type);
    267     perms_str = regfio_ace_perms2str(acl->ace[i].info.mask);
    268     flags_str = regfio_ace_flags2str(acl->ace[i].flags);
     265    sid_str = regfi_sid2str(&acl->ace[i].trustee);
     266    type_str = regfi_ace_type2str(acl->ace[i].type);
     267    perms_str = regfi_ace_perms2str(acl->ace[i].info.mask);
     268    flags_str = regfi_ace_flags2str(acl->ace[i].flags);
    269269   
    270270    if(flags_str != NULL && perms_str != NULL
     
    307307
    308308
    309 char* regfio_get_sacl(SEC_DESC *sec_desc)
     309char* regfi_get_sacl(SEC_DESC *sec_desc)
    310310{
    311311  if (sec_desc->sacl)
    312     return regfio_get_acl(sec_desc->sacl);
     312    return regfi_get_acl(sec_desc->sacl);
    313313  else
    314314    return NULL;
     
    316316
    317317
    318 char* regfio_get_dacl(SEC_DESC *sec_desc)
     318char* regfi_get_dacl(SEC_DESC *sec_desc)
    319319{
    320320  if (sec_desc->dacl)
    321     return regfio_get_acl(sec_desc->dacl);
     321    return regfi_get_acl(sec_desc->dacl);
    322322  else
    323323    return NULL;
     
    325325
    326326
    327 char* regfio_get_owner(SEC_DESC *sec_desc)
    328 {
    329   return regfio_sid2str(sec_desc->owner_sid);
    330 }
    331 
    332 
    333 char* regfio_get_group(SEC_DESC *sec_desc)
    334 {
    335   return regfio_sid2str(sec_desc->grp_sid);
     327char* regfi_get_owner(SEC_DESC *sec_desc)
     328{
     329  return regfi_sid2str(sec_desc->owner_sid);
     330}
     331
     332
     333char* regfi_get_group(SEC_DESC *sec_desc)
     334{
     335  return regfi_sid2str(sec_desc->grp_sid);
    336336}
    337337
     
    13681368 first hbin offset.
    13691369*******************************************************************/
    1370 REGF_FILE* regfio_open( const char *filename )
     1370REGF_FILE* regfi_open( const char *filename )
    13711371{
    13721372  REGF_FILE *rb;
     
    13821382  /*    if ( !(rb->mem_ctx = talloc_init( "read_regf_block" )) )
    13831383    {
    1384     regfio_close( rb );
     1384    regfi_close( rb );
    13851385    return NULL;
    13861386    }
     
    13911391
    13921392  if ( (rb->fd = open(filename, flags)) == -1 ) {
    1393     /* DEBUG(0,("regfio_open: failure to open %s (%s)\n", filename, strerror(errno)));*/
    1394     regfio_close( rb );
     1393    /* DEBUG(0,("regfi_open: failure to open %s (%s)\n", filename, strerror(errno)));*/
     1394    regfi_close( rb );
    13951395    return NULL;
    13961396  }
     
    13991399       
    14001400  if ( !read_regf_block( rb ) ) {
    1401     /* DEBUG(0,("regfio_open: Failed to read initial REGF block\n"));*/
    1402     regfio_close( rb );
     1401    /* DEBUG(0,("regfi_open: Failed to read initial REGF block\n"));*/
     1402    regfi_close( rb );
    14031403    return NULL;
    14041404  }
     
    14121412/*******************************************************************
    14131413 *******************************************************************/
    1414 static void regfio_mem_free( REGF_FILE *file )
     1414static void regfi_mem_free( REGF_FILE *file )
    14151415{
    14161416  /* free any zalloc()'d memory */
     
    14241424/*******************************************************************
    14251425 *******************************************************************/
    1426 int regfio_close( REGF_FILE *file )
     1426int regfi_close( REGF_FILE *file )
    14271427{
    14281428  int fd;
    14291429
    1430   regfio_mem_free( file );
     1430  regfi_mem_free( file );
    14311431
    14321432  /* nothing to do if there is no open file */
     
    14471447 on my experience.  --jerry
    14481448*******************************************************************/
    1449 REGF_NK_REC* regfio_rootkey( REGF_FILE *file )
     1449REGF_NK_REC* regfi_rootkey( REGF_FILE *file )
    14501450{
    14511451  REGF_NK_REC *nk;
     
    14591459               
    14601460  if ( !(nk = (REGF_NK_REC*)zalloc(sizeof(REGF_NK_REC) )) ) {
    1461     /*DEBUG(0,("regfio_rootkey: zalloc() failed!\n"));*/
     1461    /*DEBUG(0,("regfi_rootkey: zalloc() failed!\n"));*/
    14621462    return NULL;
    14631463  }
     
    14921492       
    14931493  if ( !found ) {
    1494     /*DEBUG(0,("regfio_rootkey: corrupt registry file ?  No root key record located\n"));*/
     1494    /*DEBUG(0,("regfi_rootkey: corrupt registry file ?  No root key record located\n"));*/
    14951495    return NULL;
    14961496  }
     
    15101510 NK record.  Remember that offsets are from the *first* HBIN block.
    15111511*******************************************************************/
    1512 REGF_NK_REC* regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk )
     1512REGF_NK_REC* regfi_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk )
    15131513{
    15141514  REGF_NK_REC *subkey;
     
    15291529    return NULL;
    15301530  }
    1531        
     1531 
    15321532  nk_offset = nk->subkeys.hashes[nk->subkey_index].nk_off;
    15331533  if(!prs_set_offset(&hbin->ps,
Note: See TracChangeset for help on using the changeset viewer.