Changeset 32 for trunk/test


Ignore:
Timestamp:
07/16/05 19:16:17 (19 years ago)
Author:
tim
Message:

Added key name retrieval to test utility

Code formatting changes to regfio.c

Added type<->string mapping functions to regfio library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/lib-regfio.c

    r31 r32  
    7474  }
    7575
     76  /* Cut trailing slash */ 
     77  if(buf[buf_len-buf_left-2] == '/')
     78    buf[buf_len-buf_left-2] = '\0';
     79
    7680  return buf;
    7781}
    7882
    7983
    80 void printKeyTree(REGF_FILE* f,  void_stack* nk_stack)
     84void printKeyList(REGF_NK_REC* nk, char* prefix)
     85{
     86  unsigned int i;
     87  const char* str_type;
     88 
     89  for(i=0; i < nk->num_values; i++)
     90  {
     91    str_type = type_val2str(nk->values[i].type);
     92    printf("%s/%s:%s=\n", prefix, nk->values[i].valuename, str_type);
     93  }
     94}
     95
     96
     97void printKeyTree(REGF_FILE* f, void_stack* nk_stack)
    8198{
    8299  REGF_NK_REC* cur;
     
    84101  char* path;
    85102
    86   while((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
     103  if((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
    87104  {
    88     if((sub = regfio_fetch_subkey(f, cur)) != NULL)
     105    printf("%s:KEY\n", cur->keyname);
     106    while((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL)
    89107    {
    90       path = getStackPath(nk_stack);
    91       if(path != NULL)
     108      if((sub = regfio_fetch_subkey(f, cur)) != NULL)
    92109      {
    93         printf("%s%s:KEY\n", path, sub->keyname);
    94         free(path);
     110        void_stack_push(nk_stack, sub);
     111        path = getStackPath(nk_stack);
     112        if(path != NULL)
     113        {
     114          printKeyList(cur, path);
     115          printf("%s:KEY\n", path);
     116          free(path);
     117        }
    95118      }
    96       void_stack_push(nk_stack, sub);
    97     }
    98     else
    99     {
    100       cur = void_stack_pop(nk_stack);
    101       /* XXX: This is just a shallow free.  Need to write deep free
    102        * routines to replace the Samba code for this.
    103        */
    104       if(cur != NULL)
    105         free(cur);
     119      else
     120      {
     121        cur = void_stack_pop(nk_stack);
     122        /* XXX: This is just a shallow free.  Need to write deep free
     123         * routines to replace the Samba code for this.
     124         */
     125        if(cur != NULL)
     126          free(cur);
     127      }
    106128    }
    107129  }
Note: See TracChangeset for help on using the changeset viewer.