int main(int argc, const char * argv[]) { if (argc == 2) { struct mbdb_file *test = ParseMBDBFile((char*)argv[1]); for (int index = 0; index < test->record_count; index++) { struct mbdb_record *record = &(test->record[index]); if (record->domain.name.length) { printf("%s\n",record->domain.name.string); } if (record->path.name.length) { printf("\tFile Name: %s\n",record->path.name.string); } if (record->path.name.string != NULL) { struct mbdb_file_name *file_name = FindFileForFromManifestRecord(record); if (file_name->has_file) { printf("\tHash Name: "); hashprint(file_name->name); } } } } else { printf("please provide the path to a Manifest.mbdb file. They can be found at: /Users/*/Library/Application Support/MobileSync/Backup/<UDID>/Manifest.mbdb\n"); printf("usage: ./mb2parse <path to Manifest.mbdb>\n"); } return 0; }
int main (int argc, char **argv) { Exec_Name = basename (argv[0]); char *default_dictionary = DEFAULT_DICTNAME; char *user_dictionary = NULL; hashset *hashset = new_hashset (); yy_flex_debug = false; bool x = false; bool xx = false; // Scan the arguments and set flags. opterr = false; for (;;) { int option = getopt (argc, argv, "nxyd:@:"); if (option == EOF) break; switch (option) { char optopt_string[16]; // used in default: case 'd': user_dictionary = optarg; break; case 'n': default_dictionary = NULL; break; case 'x': if(x) xx = true; x = true; break; case 'y': yy_flex_debug = true; break; case '@': set_debugflags (optarg); if (strpbrk (optarg, "@y")) yy_flex_debug = true; break; default : sprintf (optopt_string, "-%c", optopt); print_error (optopt_string, "invalid option"); Exit_Status = 2; break; } } // Load the dictionaries into the hash table. load_dictionary (default_dictionary, hashset); load_dictionary (user_dictionary, hashset); if(hashsetload(hashset) == 0){ fprintf(stderr, "%s: dictionary is empty\n", argv[0]); free_hashset(hashset); Exit_Status = 2; return Exit_Status; } if(x) hashprint(hashset); if(xx) { hashprintmore(hashset); free_hashset(hashset); return Exit_Status; } // Read and do spell checking on each of the files. if (optind >= argc) { yyin = stdin; spellcheck (STDIN_NAME, hashset); }else { for (int fileix = optind; fileix < argc; ++fileix) { DEBUGF ('m', "argv[%d] = \"%s\"\n", fileix, argv[fileix]); char *filename = argv[fileix]; if (strcmp (filename, STDIN_NAME) == 0) { yyin = stdin; spellcheck (STDIN_NAME, hashset); }else { yyin = open_infile (filename); if (yyin == NULL) continue; spellcheck (filename, hashset); fclose (yyin); } } } yylex_destroy (); free_hashset(hashset); return Exit_Status; }