void host_init_ctx(nsc_ctx_t *ctx) { ctx->dbname = NSS_DBNAM_HOSTS; ctx->db_count = 2; ctx->file_name = "/etc/inet/hosts"; hnam_db = make_cache(nsc_key_cis, NSS_DBOP_HOSTS_BYNAME, NSC_NAME_HOSTS_BYNAME, NULL, NULL, NULL, nsc_ht_default, -1); addr_db = make_cache(nsc_key_other, NSS_DBOP_HOSTS_BYADDR, NSC_NAME_HOSTS_BYADDR, hostaddr_compar, hostaddr_getlogstr, hostaddr_gethash, nsc_ht_default, -1); }
int main(int argc,char *argv[]) { parse_arg(argc,argv); Cache* C = make_cache(); caching(C,trace_file); printSummary(C->num_of_hit,C->num_of_miss,C->num_of_evict); delete_cache(C); return 0; }
void auth_init_ctx(nsc_ctx_t *ctx) { ctx->dbname = NSS_DBNAM_AUTHATTR; ctx->file_name = "/etc/security/auth_attr"; ctx->db_count = 1; nam_db = make_cache(nsc_key_ces, NSS_DBOP_AUTHATTR_BYNAME, NSC_NAME_AUTHATTR_BYNAME, NULL, NULL, NULL, nsc_ht_default, -1); }
static CACHE * load_cache(int cache_num, const char *string) { CACHE *p; if ((p = find_cache(cache_num, string)) == 0) { p = make_cache(cache_num, string); } return p; }
void passwd_init_ctx(nsc_ctx_t *ctx) { ctx->dbname = NSS_DBNAM_PASSWD; ctx->file_name = "/etc/passwd"; ctx->db_count = 2; ctx->cfg.pos_ttl = 600; nam_db = make_cache(nsc_key_ces, NSS_DBOP_PASSWD_BYNAME, NSC_NAME_PASSWD_BYNAME, NULL, NULL, NULL, nsc_ht_default, -1); uid_db = make_cache(nsc_key_other, NSS_DBOP_PASSWD_BYUID, NSC_NAME_PASSWD_BYUID, pwuid_compar, pwuid_getlogstr, pwuid_gethash, nsc_ht_default, -1); }
static krb5_error_code KRB5_CALLCONV dcc_resolve(krb5_context context, krb5_ccache *cache_out, const char *residual) { krb5_error_code ret; krb5_ccache fcc; char *primary_path = NULL, *sresidual = NULL, *dirname, *filename; *cache_out = NULL; if (*residual == ':') { /* This is a subsidiary cache within the directory. */ ret = split_path(context, residual + 1, &dirname, &filename); if (ret) return ret; ret = verify_dir(context, dirname); free(dirname); free(filename); if (ret) return ret; } else { /* This is the directory itself; resolve to the primary cache. */ ret = verify_dir(context, residual); if (ret) return ret; ret = primary_pathname(residual, &primary_path); if (ret) goto cleanup; ret = read_primary_file(context, primary_path, residual, &sresidual); if (ret == ENOENT) { /* Create an initial primary file. */ ret = write_primary_file(primary_path, "tkt"); if (ret) goto cleanup; ret = subsidiary_residual(residual, "tkt", &sresidual); if (ret) goto cleanup; } residual = sresidual; } ret = krb5_fcc_ops.resolve(context, &fcc, residual + 1); if (ret) goto cleanup; ret = make_cache(residual, fcc, cache_out); if (ret) krb5_fcc_ops.close(context, fcc); cleanup: free(primary_path); free(sresidual); return ret; }
static void load_cache(CACHE * cache, const char *string) { CACHE *p; if ((p = find_cache(cache, string)) != 0) { *cache = *p; } else { make_cache(cache, string); } }
void netmask_init_ctx(nsc_ctx_t *ctx) { ctx->dbname = NSS_DBNAM_NETMASKS; ctx->db_count = 1; ctx->file_name = "/etc/inet/netmasks"; key_db = make_cache(nsc_key_ces, NSS_DBOP_NETMASKS_BYNET, NSC_NAME_NETMASKS_BYNET, NULL, NULL, NULL, nsc_ht_default, -1); }
int main(int argc, char* argv[]) { if (argc != 5) { printf("usage: cache-sim <set bits> <associativity> <block bits> <tracefile>\n"); exit(1); } int sets = atoi(argv[1]); int lines = atoi(argv[2]); int blocks = atoi(argv[3]); char* file = argv[4]; Cache* cache = make_cache(sets, lines, blocks); CPU* cpu = make_cpu(cache, file); run_cpu(cpu); delete_cpu(cpu); delete_cache(cache); }
void CWord_correct::operator()(const std::string& search_word,std::string& search_result) { word_cache cache; std::vector<CMypair> re_vec; make_cache(cache,r_index,search_word); Json::Value correct_value; Json::FastWriter writer; if(cache.count(search_word)>0) { correct_value["type"]="输入正确"; Json::Value value; Json::Value temp; value["result"]="输入正确"; temp.append(value); correct_value["result"]=temp; } else { correct_value["type"]="输入有误,以下候选词可能是你希望输入的"; get_correct(cache,re_vec,search_word); Json::Value value; if(re_vec.size()) { std::vector<CMypair>::reverse_iterator r_iter=re_vec.rbegin(); for(r_iter;r_iter!=re_vec.rend();r_iter++) { //std::cout<<r_iter->m_str<<"->freq: "<<r_iter->m_freq<<"->m_dis: "<<r_iter->m_dis<<std::endl; Json::Value temp; temp["result"]=r_iter->m_str; value.append(temp); } correct_value["result"]=value; } else { Json::Value value; Json::Value temp; value["result"]="无此纠错结果,请输入其他查询词汇"; temp.append(value); correct_value["result"]=temp; } } search_result=writer.write(correct_value); }
void read_array (group_or_file f, std::string const & name, ArrayType & A, bool C_reorder = true) { typedef typename ArrayType::value_type V; if (!h5::exists(f, name)) TRIQS_RUNTIME_ERROR << "no such dataset : "<<name <<" in file "; try { DataSet ds = f->openDataSet( name.c_str() ); DataSpace dataspace = ds.getSpace(); static const unsigned int Rank = ArrayType::rank + (boost::is_complex<typename ArrayType::value_type>::value ? 1 : 0); int rank = dataspace.getSimpleExtentNdims(); if (rank != Rank) TRIQS_RUNTIME_ERROR << "triqs::array::h5::read. Rank mismatch : the array has rank = " <<Rank<<" while the array stored in the hdf5 file has rank = "<<rank; mini_vector<hsize_t,Rank> dims_out; //int ndims = dataspace.getSimpleExtentDims( &dims_out[0], NULL); dataspace.getSimpleExtentDims( &dims_out[0], NULL); mini_vector<size_t,ArrayType::rank > d2; for (size_t u=0; u<ArrayType::rank ; ++u) d2[u] = dims_out[u]; resize_or_check(A, d2 ); if (C_reorder) { BOOST_AUTO(C, make_cache(A, Option::C() )); ds.read( data(C.view()), data_type_mem(C.view()), data_space(C.view()) , dataspace ); } else { ds.read( data(A), data_type_mem(A), data_space(A) , dataspace ); } } TRIQS_ARRAYS_H5_CATCH_EXCEPTION; }