void bip_parallel_init(int flags) { if (flags & INIT_SHARED) { #ifdef NEW_ORACLE (void) exported_built_in(in_dict("get_oracle", 3), p_get_oracle3, B_UNSAFE); (void) exported_built_in(in_dict("install_oracle", 1), p_install_oracle, B_SAFE); (void) exported_built_in(in_dict("install_pending_oracle", 0), p_install_pending_oracle, B_SAFE); (void) built_in(in_dict("recomputing", 0), p_recomputing, B_SAFE); (void) exported_built_in(in_dict("oracle_check", 1), p_oracle_check, B_UNSAFE); (void) local_built_in(in_dict("set_par_goal", 1), p_set_par_goal, B_UNSAFE); (void) local_built_in(in_dict("get_par_goal", 1), p_get_par_goal, B_UNSAFE|U_UNIFY); #endif (void) local_built_in(in_dict("dbag_create", 1), p_dbag_create, B_SAFE|U_GROUND); (void) local_built_in(in_dict("dbag_enter", 2), p_dbag_enter, B_SAFE|U_NONE); (void) local_built_in(in_dict("dbag_dissolve", 2), p_dbag_dissolve, B_UNSAFE|U_UNIFY); } }
int main(int argc, char **argv) { if (argc < 2) { std::cout << "Useage: 11.33 <dict filename> [<input filename>] " "[<output filename>]" << std::endl; return -1; } std::ifstream in_dict(argv[1]); if (!in_dict.is_open()) { std::cerr << "Cannot open file: " << argv[1] << std::endl; return -2; } std::ifstream in_text; if (argc >= 3) { in_text.open(argv[2]); if (!in_text.is_open()) { std::cerr << "Cannot open file: " << argv[2] << std::endl; return -2; } } std::istream &in = (argc >= 3 ? in_text : std::cin); std::ofstream out_text; if (argc >= 4) { out_text.open(argv[3]); if (!out_text.is_open()) { std::cerr << "Cannot open file: " << argv[3] << std::endl; return -2; } } std::ostream &out = (argc >= 4 ? out_text : std::cout); word_transform(in_dict, in, out); return 0; }
ContainerId ddfs_index_search(Fingerprint *finger) { ContainerId resultId = TMP_CONTAINER_ID; /* search in cache */ Container *container = container_cache_lookup(fingers_cache, finger); if (container != 0) { return container->id; } /* search in bloom filter */ if (!in_dict(filter, (char*) finger, sizeof(Fingerprint))) { return TMP_CONTAINER_ID; } /* search in database */ resultId = db_lookup_fingerprint(finger); if (resultId != TMP_CONTAINER_ID) { index_read_times++; Container* container = container_cache_insert_container(fingers_cache, resultId); if (container) { //index_read_times++; index_read_entry_counter += container_get_chunk_num(container); } } return resultId; }
void module_init(int flags) { if (flags & INIT_SHARED) { value v1; v1.did = d_.kernel_sepia; (void) p_create_module(v1,tdict); v1.did = d_.default_module; /* needed while -b option is in C */ (void) p_create_module(v1,tdict); #ifdef DFID v1.did = in_dict("dfid", 0); /* to initialize global vars */ (void) p_create_module(v1,tdict); #endif AbolishedProcedures = 0; AbolishedDynProcedures = 0; CompiledStructures = 0; AbolishedProcedures = 0; } }
void bip_shelf_init(int flags) { if (flags & INIT_SHARED) { (void) built_in(in_dict("shelf_create", 3), p_shelf_create3, B_SAFE|U_SIMPLE); (void) built_in(in_dict("shelf_create", 2), p_shelf_create2, B_SAFE|U_SIMPLE); (void) built_in(in_dict("shelf_get_",4), p_shelf_get, B_UNSAFE|U_FRESH); (void) built_in(in_dict("shelf_set_",4), p_shelf_set, B_SAFE); (void) built_in(in_dict("shelf_inc_",3), p_shelf_inc, B_SAFE); (void) built_in(in_dict("shelf_dec_",3), p_shelf_dec, B_SAFE); (void) built_in(in_dict("shelf_abolish", 1), p_handle_free, B_SAFE|U_NONE); (void) local_built_in(in_dict("shelf_name",3), p_shelf_name, B_SAFE); } }
void testing_words(unsigned char filter[], char *file_in, char *file_res) { FILE *fi = fopen(file_in, "r"); FILE *fr = fopen(file_res, "w"); char word[WORD_BUF_SIZE + 1]; if (!fi) { err("[e] %s: can't open file \"%s\"\n", __FUNCTION__, file_in); } if (!fr) { err("[e] %s: can't open file \"%s\"\n", __FUNCTION__, file_res); } while (fgets(word, WORD_BUF_SIZE, (FILE *) fi)) { int len = strlen(word); if (len == WORD_BUF_SIZE - 1) { err("[e] WORD_BUF_SIZE is small\n"); } word[strcspn(word, "\n")] = 0; len--; int result = 0; if (is_corrcet_len(len) && is_correct_quote(word)) { if (len == 1) result = 1; else { IF_CNT { result = in_dict(filter, word); } ELSE_CNT } } if (result) { fprintf(fr, "\"%s\": \"true\"\n", word); } else { fprintf(fr, "\"%s\": \"false\"\n", word); } } fclose(fi); fclose(fr); }
void bip_op_init(int flags) { if (!(flags & INIT_SHARED)) return; (void) local_built_in(in_dict("op_", 5), p_op_, B_SAFE); (void) local_built_in(in_dict("is_prefix_op", 5), p_is_prefix_op, B_SAFE); (void) local_built_in(in_dict("is_postfix_op", 5), p_is_postfix_op, B_SAFE); (void) local_built_in(in_dict("is_infix_op", 5), p_is_infix_op, B_SAFE); (void) local_built_in(in_dict("abolish_op_", 3),p_abolish_op_, B_SAFE); (void) local_built_in(in_dict("legal_current_op", 4), p_legal_current_op, B_SAFE); }
int satisfies(char key[4]) { struct dec dec; char * tok; int i; dec_init(&dec, cipher, cipher_length, key, 3); while (NULL != (tok = dec_token(&dec))) { i=0; while (tok[i] != (char)0) { tok[i] = lowercase(tok[i]); ++i; } if (!in_dict(tok)) { return 0; } } return 1; }
void compiler_init(int flags) { if (flags & INIT_SHARED) { CompileId = 0; } d_call_susp_ = in_dict("call_suspension", 1); d_module2 = in_dict("module", 2); d_module3 = in_dict("module", 3); d_module_interface = in_dict("module_interface", 1); d_begin_module = in_dict("begin_module", 1); d_erase_module_ = in_dict("erase_module", 1); d_create_module3_ = in_dict("create_module", 3); d_eclipse_language_ = in_dict("eclipse_language", 0); /* * A suspension which is marked as dead. Any suspension that occurs * in a compiled clause is compiled into a TSUSP pointer to this one. */ Init_Susp_Dead(&woken_susp_); }
double score(char key[4]) { struct dec dec; char * tok; int i; size_t k, n; k = 0; n = 0; dec_init(&dec, cipher, cipher_length, key, 3); while (NULL != (tok = dec_token(&dec))) { i=0; while (tok[i] != (char)0) { tok[i] = lowercase(tok[i]); ++i; } if (in_dict(tok)) { k += 1; } n += 1; } return (double)k / (double)n; }
void error_init(int flags) { if (flags & INIT_SHARED) { int i; /* * Due to the user entries, part of the message array is * mutable and must be in shared memory. */ ErrorMessage = (char **) hg_alloc_size(sizeof(char *) * MAX_ERRORS); for(i=0; i<MAX_ERRORS; i++) { ErrorMessage[i] = ec_error_message[i]; } (void) built_in(in_dict("error_id", 2), p_error_id, B_UNSAFE|U_SIMPLE); (void) local_built_in(in_dict("max_error", 1), p_max_error, B_UNSAFE|U_SIMPLE); (void) local_built_in(in_dict("set_last_errno", 1), p_set_last_errno, B_SAFE); (void) local_built_in(in_dict("get_last_errno", 1), p_get_last_errno, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("errno_id", 1), p_errno_id1, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("errno_id", 2), p_errno_id, B_UNSAFE|U_SIMPLE); } }
/* * FUNCTION NAME: bip_strings_init() * * PARAMETERS: NONE. * * DESCRIPTION: links the 'C' functions in this file with SEPIA * built-in predicates. */ void bip_strings_init(int flags) { if (flags & INIT_PRIVATE) { empty_string = enter_string_n("", 0, DICT_PERMANENT); d_sha_ = in_dict("sha", 0); } if (flags & INIT_SHARED) { built_in(in_dict("string_list", 2), p_string_list, B_UNSAFE|U_GROUND|PROC_DEMON) -> mode = BoundArg(1, NONVAR) | BoundArg(2, NONVAR); built_in(in_dict("utf8_list", 2), p_utf8_list, B_UNSAFE|U_GROUND|PROC_DEMON) -> mode = BoundArg(1, NONVAR) | BoundArg(2, NONVAR); (void) built_in(in_dict("hash_secure", 3), p_hash_secure, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("string_length", 2), p_string_length,B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("get_string_code", 3), p_get_string_code, B_UNSAFE|U_SIMPLE); (void) b_built_in(in_dict("string_code", 4), p_string_code, d_.kernel_sepia); (void) built_in(in_dict("substring", 3), p_substring, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("atom_length", 2), p_atom_length, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("string_upper", 2), p_string_upper, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("string_lower", 2), p_string_lower, B_UNSAFE|U_SIMPLE); (void) built_in(in_dict("concat_atoms", 3), p_concat_atoms, B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("concat_atom", 2), p_concat_atom, B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("concat_strings", 3), p_concat_strings,B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("concat_string", 2), p_concat_string,B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("atomics_to_string", 2),p_concat_string,B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("join_string", 3), p_join_string, B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("atomics_to_string", 3),p_join_string, B_UNSAFE|U_SIMPLE|PROC_DEMON); (void) built_in(in_dict("text_to_string", 2), p_text_to_string, B_UNSAFE|U_SIMPLE|PROC_DEMON); built_in(in_dict("split_string", 4), p_split_string, B_UNSAFE|U_GROUND) -> mode = BoundArg(4, GROUND); built_in(in_dict("char_int", 2), p_char_int, B_UNSAFE|U_SIMPLE) -> mode = BoundArg(1, NONVAR) | BoundArg(2, NONVAR); (void) exported_built_in(in_dict("first_substring", 4), p_first_substring, B_UNSAFE|U_SIMPLE); exported_built_in(in_dict("string_print_length", 4), p_string_print_length, B_UNSAFE|U_SIMPLE) -> mode = BoundArg(3, CONSTANT); } }
/*ARGSUSED*/ void op_init(int flags) { if (!(flags & INIT_PRIVATE)) return; /* initialize the associativity table */ didassoc[FX] = in_dict("fx", 0); didassoc[FY] = in_dict("fy", 0); didassoc[XF] = in_dict("xf", 0); didassoc[YF] = in_dict("yf", 0); didassoc[XFX] = in_dict("xfx", 0); didassoc[XFY] = in_dict("xfy", 0); didassoc[YFX] = in_dict("yfx", 0); didassoc[FXX] = in_dict("fxx", 0); didassoc[FXY] = in_dict("fxy", 0); d_comma0_ = in_dict(",", 0); d_bar0_ = in_dict("|", 0); }
void bip_module_init(int flags) { if (!(flags & INIT_SHARED)) return; (void) local_built_in(in_dict("erase_module_", 2), p_erase_module, B_SAFE); (void) local_built_in(in_dict("is_a_module", 1), p_is_module, B_SAFE); (void) local_built_in(in_dict("authorized_module", 1), p_authorized_module, B_SAFE); (void) built_in(in_dict("is_locked", 1), p_is_locked, B_SAFE); (void) built_in(in_dict("begin_module", 1), p_begin_module, B_SAFE); (void) local_built_in(in_dict("begin_module", 2), p_begin_module, B_SAFE); (void) local_built_in(in_dict("create_module_", 1), p_create_module, B_SAFE); (void) built_in(d_.lock, p_lock1, B_SAFE); (void) built_in(in_dict("lock", 2), p_lock2, B_SAFE); (void) built_in(in_dict("lock_pass_", 2), p_lock_pass_, B_SAFE); (void) built_in(in_dict("unlock", 2), p_unlock2, B_SAFE); (void) exported_built_in(in_dict("tool_", 2), p_tool1, B_UNSAFE); (void) exported_built_in(in_dict("tool_", 3), p_tool2, B_UNSAFE); exported_built_in(in_dict("tool_body_", 4), p_tool_body, B_UNSAFE|U_GROUND) -> mode = BoundArg(2, GROUND) | BoundArg(3, CONSTANT); (void) local_built_in(d_.localb, p_local, B_UNSAFE); (void) exported_built_in(in_dict("implicit_local",2), p_implicit_local, B_UNSAFE); (void) local_built_in(d_.exportb, p_export, B_UNSAFE); (void) local_built_in(in_dict("reexport_from_",3), p_reexport_from, B_UNSAFE); (void) local_built_in(d_.import_fromb, p_import_from, B_UNSAFE); (void) local_built_in(in_dict("import_", 2), p_import, B_UNSAFE); (void) local_built_in(in_dict("module_tag", 2), p_module_tag, B_UNSAFE); (void) exported_built_in(in_dict("default_module", 1), p_default_module, B_UNSAFE|U_SIMPLE); (void) exported_built_in(in_dict("pr", 1), p_pr, B_SAFE); }