static bool wrap_ndr_inout_pull_test(struct torture_context *tctx, struct torture_tcase *tcase, struct torture_test *test) { bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn; const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; void *ds = talloc_zero_size(tctx, data->struct_size); struct ndr_pull *ndr; uint32_t highest_ofs; /* handle NDR_IN context */ ndr = ndr_pull_init_blob(&(data->data_context), tctx); torture_assert(tctx, ndr, "ndr init failed"); ndr->flags |= LIBNDR_FLAG_REF_ALLOC; torture_assert_ndr_success(tctx, data->pull_fn(ndr, NDR_IN, ds), "ndr pull of context failed"); if (ndr->offset > ndr->relative_highest_offset) { highest_ofs = ndr->offset; } else { highest_ofs = ndr->relative_highest_offset; } torture_assert(tctx, highest_ofs == ndr->data_size, talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs)); talloc_free(ndr); /* handle NDR_OUT */ ndr = ndr_pull_init_blob(&(data->data), tctx); torture_assert(tctx, ndr, "ndr init failed"); ndr->flags |= LIBNDR_FLAG_REF_ALLOC; torture_assert_ndr_success(tctx, data->pull_fn(ndr, NDR_OUT, ds), "ndr pull failed"); if (ndr->offset > ndr->relative_highest_offset) { highest_ofs = ndr->offset; } else { highest_ofs = ndr->relative_highest_offset; } torture_assert(tctx, highest_ofs == ndr->data_size, talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs)); talloc_free(ndr); if (check_fn) { return check_fn(tctx, ds); } else { return true; } }
gboolean has_default_route (gchar * conn_name, gboolean (*check_fn) (gchar *)) { gchar *routes = NULL, *tmp, *end; g_return_val_if_fail (conn_name != NULL, FALSE); tmp = ifnet_get_data (conn_name, "routes"); if (!tmp) return FALSE; routes = g_strdup (tmp); tmp = find_default_gateway_str (routes); if (!tmp) { goto error; } g_strstrip (tmp); if ((end = strstr (tmp, "\"")) != NULL) *end = '\0'; if (check_fn (tmp)) { g_free (routes); return TRUE; } error: g_free (routes); return FALSE; }
nt main(int argc, char *argv[]) { FILE *genome_f; int read_size=0; //the size of the reads int table_factor; //arbitrary int num_of_reads; int bf_table_size = table_factor*num_of_reads; int num_of_hash_func; BloomFilter* bf_unique; //BF for the unique tries // char* output_label=(char *)malloc(50); //label name for the output files hattrie_t* trie_unique; //hattrie that holds the unique reads hattrie_t* trie_repeat; //hattrie that holds the repetetive reads, and the one that has N inside of them. hattrie_t* trie_genome_unique; //put 'accepts' (everything that uniqe BF says yes that it's in genome) into a trie hattrie_t* trie_fp; //triw that holds false negatives set hattrie_t* trie_fn;//trie that holds false positives set // f = fopen(argv[1], "r"); trie_repeat = hattrie_create(); trie_unique = hattrie_create(); make_repeat_and_unique_tries((argv[1], "r"), trie_unique, trie_repeat); table_factor = 10; //arbitrary num_of_reads = line_number/2; bf_table_size = table_factor*num_of_reads; num_of_hash_func = (int) ceil(table_factor*0.69314); //print the keys of the uniqe and repaet tries hattrie_iteration(trie_unique, "unique", argv[3]); hattrie_iteration(trie_repeat, "repeat", argv[3]); //hashing uniqe reads trie using bloom filter bf_unique = bloom_filter_new(bf_table_size, string_hash, num_of_hash_func); hash_trie_into_bf(trie_unique, bf_unique); check_if_trie_in_bf(trie_unique, bf_unique); //create trie for all of the sliding windows in the genome reference which are in the unique reads according to the bf_unique read_size = size-2; trie_genome_unique = hattrie_create(); query_bf_with_genome(bf_unique, genome_f ,trie_genome_unique, read_size); check_if_trie_in_bf(trie_unique, bf_unique); fclose(genome_f); hattrie_iteration(trie_genome_unique, "genome_unique", argv[3]); trie_fp = hattrie_create(); trie_fn = hattrie_create(); printf("start checking for false positive \n"); check_fp(trie_unique,trie_genome_unique, trie_fp); hattrie_iteration(trie_fp, "fp_unique", argv[3]); printf("start checking for false negative \n"); check_fn(trie_unique,trie_genome_unique, trie_fn); hattrie_iteration(trie_fn, "fn_unique", argv[3]); bloom_filter_free(bf_unique); free(buffer); hattrie_free(trie_unique); hattrie_free(trie_repeat); hattrie_free(trie_genome_unique); hattrie_free(trie_fn); hattrie_free(trie_fp); return 0; }
ot_u8 vl_delete(vlBLOCK block_id, ot_u8 data_id, id_tmpl* user_id) { #if (OT_FEATURE(VLNEW) == ENABLED) vaddr header = NULL_vaddr; sub_vaddr search_fn; sub_check check_fn; /// 1. Get the header from the supplied Block ID & Data ID block_id--; switch (block_id) { case 0: check_fn = &sub_gfb_delete_check; search_fn = &sub_gfb_search; break; case 1: check_fn = &sub_isfs_delete_check; search_fn = &sub_isfs_search; break; case 2: check_fn = &sub_isf_delete_check; search_fn = &sub_isf_search; break; default: return 255; } if (check_fn(data_id) != 0) { header = search_fn(data_id); } /// 2. Bail if header is NULL if (header == NULL_vaddr) { return 0x01; } /// 3. Authenticate, when it's not a su call if (user_id != NULL) { Twobytes filemod; filemod.ushort = vworm_read(header + 4); if ( auth_check(filemod.ubyte[1], VL_ACCESS_RW, user_id) == 0 ) { return 0x04; } } sub_delete_file(header); return 0; #else return 255; //error, delete disabled #endif }
static bool wrap_ndr_pullpush_test(struct torture_context *tctx, struct torture_tcase *tcase, struct torture_test *test) { bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn; const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx); void *ds = talloc_zero_size(ndr, data->struct_size); bool ret; uint32_t highest_ofs; ndr->flags |= data->flags; ndr->flags |= LIBNDR_FLAG_REF_ALLOC; torture_assert_ndr_success(tctx, data->pull_fn(ndr, data->ndr_flags, ds), "pulling"); if (ndr->offset > ndr->relative_highest_offset) { highest_ofs = ndr->offset; } else { highest_ofs = ndr->relative_highest_offset; } torture_assert(tctx, highest_ofs == ndr->data_size, talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - highest_ofs)); if (check_fn != NULL) { ret = check_fn(tctx, ds); } else { ret = true; } if (data->push_fn != NULL) { DATA_BLOB outblob; torture_assert_ndr_success(tctx, ndr_push_struct_blob(&outblob, ndr, ds, data->push_fn), "pushing"); torture_assert_data_blob_equal(tctx, outblob, data->data, "ndr push compare"); } talloc_free(ndr); return ret; }
gboolean has_default_route (const char *conn_name, gboolean (*check_fn) (const char *)) { char *routes = NULL, *end, *tmp; gboolean success = FALSE; g_return_val_if_fail (conn_name != NULL, FALSE); routes = g_strdup (ifnet_get_data (conn_name, "routes")); if (!routes) return FALSE; tmp = find_default_gateway_str (routes); if (tmp) { g_strstrip (tmp); if ((end = strstr (tmp, "\"")) != NULL) *end = '\0'; if (check_fn (tmp)) success = TRUE; } g_free (routes); return success; }
static bool wrap_ndr_pull_test(struct torture_context *tctx, struct torture_tcase *tcase, struct torture_test *test) { bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn; const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; void *ds = talloc_zero_size(tctx, data->struct_size); struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx, lp_iconv_convenience(tctx->lp_ctx)); ndr->flags |= LIBNDR_FLAG_REF_ALLOC; torture_assert_ndr_success(tctx, data->pull_fn(ndr, data->ndr_flags, ds), "pulling"); torture_assert(tctx, ndr->offset == ndr->data_size, talloc_asprintf(tctx, "%d unread bytes", ndr->data_size - ndr->offset)); if (check_fn != NULL) return check_fn(tctx, ds); else return true; }