Changeset 40
- Timestamp:
- 07/31/05 12:52:57 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/reglookup.c
r39 r40 29 29 30 30 31 /* Globals, influenced by command line parameters */ 32 bool print_verbose = false; 33 bool print_security = false; 34 bool path_filter_enabled = false; 35 bool type_filter_enabled = false; 36 char* path_filter = NULL; 37 int type_filter; 38 char* registry_file = NULL; 39 40 31 41 void bailOut(int code, char* message) 32 42 { … … 131 141 void printValue(REGF_VK_REC* vk, char* prefix) 132 142 { 133 const char* str_type; 134 135 str_type = type_val2str(vk->type); 136 printf("%s/%s:%s=\n", prefix, vk->valuename, str_type); 143 if(!type_filter_enabled || (vk->type == type_filter)) 144 printf("%s/%s:%s=\n", prefix, vk->valuename, type_val2str(vk->type)); 137 145 } 138 146 … … 154 162 char* path; 155 163 char* val_path; 164 int key_type = type_str2val("KEY"); 156 165 157 166 if((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL) … … 161 170 162 171 if(strlen(path) > 0) 163 printf("%s%s:KEY\n", prefix, path); 164 printValueList(cur, path); 172 if(!type_filter_enabled || (key_type == type_filter)) 173 printf("%s%s:KEY\n", prefix, path); 174 if(!type_filter_enabled || (key_type != type_filter)) 175 printValueList(cur, path); 165 176 while((cur = (REGF_NK_REC*)void_stack_cur(nk_stack)) != NULL) 166 177 { … … 174 185 val_path = (char*)malloc(strlen(prefix)+strlen(path)+1); 175 186 sprintf(val_path, "%s%s", prefix, path); 176 printf("%s:KEY\n", val_path); 177 printValueList(sub, val_path); 187 if(!type_filter_enabled || (key_type == type_filter)) 188 printf("%s:KEY\n", val_path); 189 if(!type_filter_enabled || (key_type != type_filter)) 190 printValueList(sub, val_path); 178 191 free(val_path); 179 192 free(path); … … 275 288 { 276 289 fprintf(stderr, "Usage: readreg [-v] [-s]" 277 " [- f <PREFIX_FILTER>] [-t <TYPE_FILTER>]"290 " [-p <PATH_FILTER>] [-t <TYPE_FILTER>]" 278 291 " <REGISTRY_FILE>\n"); 279 292 /* XXX: replace version string with Subversion property? */ … … 282 295 fprintf(stderr, "\t-v\t sets verbose mode.\n"); 283 296 fprintf(stderr, "\t-s\t prints security descriptors.\n"); 284 fprintf(stderr, "\t- f\t restrictsoutput to elements below this path.\n");285 fprintf(stderr, "\t-t\t restrict results to aspecific data type.\n");297 fprintf(stderr, "\t-p\t restrict output to elements below this path.\n"); 298 fprintf(stderr, "\t-t\t restrict results to this specific data type.\n"); 286 299 fprintf(stderr, "\n"); 287 300 } 288 289 /* Globals, influenced by command line parameters */290 bool print_verbose = false;291 bool print_security = false;292 bool prefix_filter_enabled = false;293 bool type_filter_enabled = false;294 char* prefix_filter = NULL;295 char* type_filter = NULL;296 char* registry_file = NULL;297 301 298 302 … … 315 319 for(argi = 1; argi < argc; argi++) 316 320 { 317 if (strcmp("- f", argv[argi]) == 0)321 if (strcmp("-p", argv[argi]) == 0) 318 322 { 319 323 if(++argi > argc) 320 324 { 321 325 usage(); 322 bailOut(1, "ERROR: '- f' option requires parameter.\n");323 } 324 if((p refix_filter = strdup(argv[argi])) == NULL)326 bailOut(1, "ERROR: '-p' option requires parameter.\n"); 327 } 328 if((path_filter = strdup(argv[argi])) == NULL) 325 329 bailOut(2, "ERROR: Memory allocation problem.\n"); 326 330 327 p refix_filter_enabled = true;331 path_filter_enabled = true; 328 332 } 329 333 else if (strcmp("-t", argv[argi]) == 0) … … 334 338 bailOut(1, "ERROR: '-t' option requires parameter.\n"); 335 339 } 336 if((prefix_filter = strdup(argv[argi])) == NULL) 337 bailOut(2, "ERROR: Memory allocation problem.\n"); 340 if((type_filter = type_str2val(argv[argi])) == 0) 341 { 342 fprintf(stderr, "ERROR: Invalid type specified: %s.\n", argv[argi]); 343 bailOut(1, ""); 344 } 338 345 339 346 type_filter_enabled = true; … … 368 375 if(void_stack_push(nk_stack, root)) 369 376 { 370 path_stack = path2Stack(p refix_filter);377 path_stack = path2Stack(path_filter); 371 378 if(void_stack_size(path_stack) < 1) 372 379 printKeyTree(f, nk_stack, "");
Note: See TracChangeset
for help on using the changeset viewer.