/** * @param db_path Path to DB, which probably does not exist. But it gets passed in because we need * it in a bunch of places. * @param idx_path Path to index file (should be superset of db_path) */ TSK_HDB_INFO *idxonly_open(const TSK_TCHAR *db_path, const TSK_TCHAR *idx_path) { TSK_HDB_BINSRCH_INFO *hdb_binsrch_info = NULL; TSK_TCHAR *ext; TSK_HDB_HTYPE_ENUM htype; hdb_binsrch_info = hdb_binsrch_open(NULL, db_path); if (NULL == hdb_binsrch_info) { return NULL; } hdb_binsrch_info->base.db_type = TSK_HDB_DBTYPE_IDXONLY_ID; // open the index ext = TSTRRCHR(idx_path, _TSK_T('-')); if (ext == NULL) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_HDB_ARG); tsk_error_set_errstr("idxonly_open: invalid file name (no extension): %" PRIttocTSK, idx_path); return NULL; } else if ((TSTRLEN(ext) == 8) && (TSTRICMP(ext, _TSK_T("-md5.idx")) == 0)) { htype = TSK_HDB_HTYPE_MD5_ID; } else if ((TSTRLEN(ext) == 9) && (TSTRICMP(ext, _TSK_T("-sha1.idx")) == 0)) { htype = TSK_HDB_HTYPE_SHA1_ID; } else { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_HDB_ARG); tsk_error_set_errstr("idxonly_open: invalid file name (unknown extension): %" PRIttocTSK, idx_path); return NULL; } if (hdb_binsrch_open_idx((TSK_HDB_INFO*)hdb_binsrch_info, htype)) { return NULL; } if (idxonly_name(hdb_binsrch_info)) { hdb_binsrch_close((TSK_HDB_INFO*)hdb_binsrch_info); return NULL; } hdb_binsrch_info->base.get_db_path = idxonly_get_db_path; hdb_binsrch_info->get_entry = idxonly_getentry; // Before returning, do one final check that we'll be able to open // the index file if (hdb_binsrch_open_idx((TSK_HDB_INFO*)hdb_binsrch_info, hdb_binsrch_info->hash_type)) { hdb_binsrch_close((TSK_HDB_INFO*)hdb_binsrch_info); return NULL; } return (TSK_HDB_INFO*)hdb_binsrch_info; }
TSK_HDB_INFO *nsrl_open(FILE *hDb, const TSK_TCHAR *db_path) { TSK_HDB_BINSRCH_INFO *hdb_binsrch_info = NULL; // get the basic binary-search info struct hdb_binsrch_info = hdb_binsrch_open(hDb, db_path); if (NULL == hdb_binsrch_info) { return NULL; } // overwrite the database-specific methods hdb_binsrch_info->base.db_type = TSK_HDB_DBTYPE_NSRL_ID; hdb_binsrch_info->base.make_index = nsrl_makeindex; hdb_binsrch_info->get_entry = nsrl_getentry; return (TSK_HDB_INFO*)hdb_binsrch_info; }
TSK_HDB_INFO *md5sum_open(FILE *hDb, const TSK_TCHAR *db_path) { TSK_HDB_BINSRCH_INFO *hdb_binsrch_info = NULL; // get the basic binary-search info struct hdb_binsrch_info = hdb_binsrch_open(hDb, db_path); if (NULL == hdb_binsrch_info) { return NULL; } // overwrite with more specific methods hdb_binsrch_info->base.db_type = TSK_HDB_DBTYPE_MD5SUM_ID; hdb_binsrch_info->get_entry = md5sum_getentry; hdb_binsrch_info->base.make_index = md5sum_makeindex; return (TSK_HDB_INFO*)hdb_binsrch_info; }