static struct file *mlog_vfs_create_open_new(struct mlog_ctxt *ctxt, struct mlog_logid *logid) { struct dentry *dchild = NULL; struct file *file = NULL; int ret = 0; MENTRY(); ret = mlog_vfs_create_new(ctxt, logid); if (ret) { MERROR("failed to create new log, ret = %d\n", ret); file = ERR_PTR(ret); goto out; } file = mlog_vfs_open_id(ctxt, logid); if (IS_ERR(file)) { MERROR("failed to open file, ret = %d\n", PTR_ERR(file)); goto out_put_dchild; } goto out; out_put_dchild: dput(dchild); out: MRETURN(file); }
SpeechRec::soft_func SpeechRec::Str2SoftFunc(char *str, float *a1, float *a2, float *a3) { char func[256]; *a1 = 0.0f; *a2 = 0.0f; *a3 = 0.0f; if(sscanf(str, "%255s %f %f %f", func, a1, a2, a3) != 4) { char msg[1024]; sprintf(msg, "Invalid softening function format '%s'. The format should be function identificator and three floating point arguments.\n", str); MERROR(msg); return &SoftLog; } soft_func pfunc = 0; if(strcmp(func, "none") == 0) pfunc = &SpeechRec::SoftNone; else if(strcmp(func, "log") == 0) pfunc = &SpeechRec::SoftLog; else if(strcmp(func, "igor") == 0) pfunc = &SpeechRec::SoftIgor; else if(strcmp(func, "gmm_bypass") == 0) pfunc = &SpeechRec::SoftGMMBypass; else { char msg[1024]; sprintf(msg, "Unknow softening function '%s'. Supported softening functions are 'none', 'log', 'igor'.\n", str); MERROR(msg); return &SoftLog; } return pfunc; }
bool ssl_options_t::has_fingerprint(boost::asio::ssl::verify_context &ctx) const { // can we check the certificate against a list of fingerprints? if (!fingerprints_.empty()) { X509_STORE_CTX *sctx = ctx.native_handle(); if (!sctx) { MERROR("Error getting verify_context handle"); return false; } X509* cert = nullptr; const STACK_OF(X509)* chain = X509_STORE_CTX_get_chain(sctx); if (!chain || sk_X509_num(chain) < 1 || !(cert = sk_X509_value(chain, 0))) { MERROR("No certificate found in verify_context"); return false; } // buffer for the certificate digest and the size of the result std::vector<uint8_t> digest(EVP_MAX_MD_SIZE); unsigned int size{ 0 }; // create the digest from the certificate if (!X509_digest(cert, EVP_sha256(), digest.data(), &size)) { MERROR("Failed to create certificate fingerprint"); return false; } // strip unnecessary bytes from the digest digest.resize(size); return std::binary_search(fingerprints_.begin(), fingerprints_.end(), digest); }
bool Simple_Shader::crearFS(std::string codigo) { _fsID = glCreateShader(GL_FRAGMENT_SHADER); const char* cod =codigo.c_str(); glShaderSource(_fsID,1,&cod,NULL); glCompileShader(_fsID); GLint exito; GLchar log[512]; glGetShaderiv(_fsID,GL_COMPILE_STATUS,&exito); if(!exito) { MERROR("ERROR COMPILANDO FRAGMENT SHADER"); MERROR("No se pudo compilar:"); MERROR(cod); MERROR("\nError:"); MERROR(log); return false; } else { MLOG("Fragment shader cargado correctamente"); return true; } }
static int ext_support_init(void) { int ret = 0; MDEBUG("registering mtfs async juntion for ext2\n"); ret = junction_register(&mtfs_ext2_junction); if (ret) { MERROR("failed to register junction for ext2, ret = %d\n", ret); goto out; } ret = junction_register(&mtfs_ext3_junction); if (ret) { MERROR("failed to register junction for ext3, ret = %d\n", ret); goto out_unregister_ext2; } ret = junction_register(&mtfs_ext4_junction); if (ret) { MERROR("failed to register junction for ext4, ret = %d\n", ret); goto out_unregister_ext3; } goto out; out_unregister_ext3: junction_unregister(&mtfs_ext3_junction); out_unregister_ext2: junction_unregister(&mtfs_ext2_junction); out: return ret; }
static int masync_replica_ext_init(void) { int ret = 0; MDEBUG("registering async_replica junction for ext2/ext3/ext4\n"); ret = junction_register(&mtfs_ext2_junction); if (ret) { MERROR("failed to register async_replica junction for ext2: error %d\n", ret); goto out; } ret = junction_register(&mtfs_ext3_junction); if (ret) { MERROR("failed to register async_replica junction for ext3: error %d\n", ret); goto out_unregister_ext2; } goto out; out_unregister_ext2: junction_unregister(&mtfs_ext2_junction); out: return ret; }
std::vector<std::string> parse_dns_public(const char *s) { unsigned ip0, ip1, ip2, ip3; char c; std::vector<std::string> dns_public_addr; if (!strcmp(s, "tcp")) { for (size_t i = 0; i < sizeof(DEFAULT_DNS_PUBLIC_ADDR) / sizeof(DEFAULT_DNS_PUBLIC_ADDR[0]); ++i) dns_public_addr.push_back(DEFAULT_DNS_PUBLIC_ADDR[i]); LOG_PRINT_L0("Using default public DNS server(s): " << boost::join(dns_public_addr, ", ") << " (TCP)"); } else if (sscanf(s, "tcp://%u.%u.%u.%u%c", &ip0, &ip1, &ip2, &ip3, &c) == 4) { if (ip0 > 255 || ip1 > 255 || ip2 > 255 || ip3 > 255) { MERROR("Invalid IP: " << s << ", using default"); } else { dns_public_addr.push_back(std::string(s + strlen("tcp://"))); } } else { MERROR("Invalid DNS_PUBLIC contents, ignored"); } return dns_public_addr; }
static struct file *mlog_vfs_create_open_name(struct mlog_ctxt *ctxt, const char *name) { struct dentry *dchild = NULL; struct file *file = NULL; MENTRY(); dchild = mtfs_dchild_create(ctxt->moc_dlog, name, strlen(name), S_IFREG | S_IRWXU, 0, NULL, 0); if (IS_ERR(dchild)) { MERROR("failed to create [%.*s/%s], ret = %d\n", ctxt->moc_dlog->d_name.len, ctxt->moc_dlog->d_name.name, name, PTR_ERR(dchild)); file = (struct file *)dchild; goto out; } file = mtfs_dentry_open(dchild, mntget(ctxt->moc_mnt), O_RDWR | O_CREAT | O_LARGEFILE, current_cred()); if (IS_ERR(file)) { MERROR("failed to open file\n"); goto out_put_dchild; } goto out_free_name; out_put_dchild: dput(dchild); out_free_name: out: MRETURN(file); }
int mlog_process(struct mlog_handle *loghandle, mlog_cb_t cb, void *data, void *catdata) { struct mlog_process_info *mpi; int ret; MENTRY(); MTFS_ALLOC_PTR(mpi); if (mpi == NULL) { MERROR("cannot alloc pointer\n"); ret = -ENOMEM; goto out; } mpi->mpi_loghandle = loghandle; mpi->mpi_cb = cb; mpi->mpi_cbdata = data; mpi->mpi_catdata = catdata; #ifdef __KERNEL__ init_completion(&mpi->mpi_completion); ret = mtfs_create_thread(mlog_process_thread, mpi, CLONE_VM | CLONE_FILES); if (ret < 0) { MERROR("cannot start thread: %d\n", ret); MTFS_FREE_PTR(mpi); goto out; } wait_for_completion(&mpi->mpi_completion); #else mlog_process_thread(mpi); #endif ret = mpi->mpi_ret; MTFS_FREE_PTR(mpi); out: MRETURN(ret); }
static int mlog_vfs_pad(struct mtfs_lowerfs *lowerfs, struct file *file, int len, int index) { struct mlog_rec_hdr rec = { 0 }; struct mlog_rec_tail tail; int ret = 0; MENTRY(); MASSERT(len >= MLOG_MIN_REC_SIZE && (len & 0x7) == 0); tail.mrt_len = rec.mrh_len = len; tail.mrt_index = rec.mrh_index = index; rec.mrh_type = MLOG_PAD_MAGIC; ret = mlowerfs_write_record(lowerfs, file, &rec, sizeof(rec), &file->f_pos, 0); if (ret) { MERROR("error writing padding record, ret = %d\n", ret); goto out; } file->f_pos += len - sizeof(rec) - sizeof(tail); ret = mlowerfs_write_record(lowerfs, file, &tail, sizeof(tail),&file->f_pos, 0); if (ret) { MERROR("error writing padding record, ret = %d\n", ret); goto out; } out: MRETURN(ret); }
static int mlog_vfs_write_blob(struct mtfs_lowerfs *lowerfs, struct file *file, struct mlog_rec_hdr *rec, void *buf, loff_t off) { int ret = 0; struct mlog_rec_tail end; loff_t saved_off = file->f_pos; int buflen = rec->mrh_len; MENTRY(); file->f_pos = off; if (buflen == 0) { MWARN("0-length record\n"); } if (!buf) { ret = mlowerfs_write_record(lowerfs, file, rec, buflen,&file->f_pos,0); if (ret) { MERROR("error writing log record, ret = %d\n", ret); goto out; } goto out; } /* the buf case */ rec->mrh_len = sizeof(*rec) + buflen + sizeof(end); ret = mlowerfs_write_record(lowerfs, file, rec, sizeof(*rec), &file->f_pos, 0); if (ret) { MERROR("error writing log hdr, ret = %d\n", ret); goto out; } ret = mlowerfs_write_record(lowerfs, file, buf, buflen, &file->f_pos, 0); if (ret) { MERROR("error writing log buffer, ret = %d\n", ret); goto out; } end.mrt_len = rec->mrh_len; end.mrt_index = rec->mrh_index; ret = mlowerfs_write_record(lowerfs, file, &end, sizeof(end), &file->f_pos, 0); if (ret) { MERROR("error writing log tail, ret = %d\n", ret); goto out; } out: if (saved_off > file->f_pos) file->f_pos = saved_off; MASSERT(ret <= 0); MRETURN(ret); }
bool SpeechRec::RunLive() { terminated = false; // allocate buffer char *formatStr = C.GetString("source", "format"); wave_format iwformat = Str2WaveFormat(formatStr); if(iwformat == wfUnknown) return false; int NBytesPerSample = WaveFormat2NBytesPerSample(iwformat); assert(NBytesPerSample != 0); int len = C.GetInt("source", "sample_freq") / 8 * NBytesPerSample; char *buff = new char [len]; if(!buff) { MERROR("Insufficient memory\n"); return false; } // open waveform source try { WFS.setFormat(C.GetInt("source", "sample_freq"), 1, 8 * NBytesPerSample); WFS.open(); } catch(wf_error &er) { delete [] buff; MERROR("Can not open waveform input device"); return false; } // prepare classes actualParams->Reset(); TR.Reset(); DE->Init(); ResetBunchBuff(); // read data and process it while(!terminated) { WFS.read(buff, len); if(!ProcessOnline(buff, len, false)) break; } DE->Done(); // free buffer delete [] buff; return true; }
static int mlog_vfs_read_header(struct mlog_handle *handle) { struct mtfs_lowerfs *lowerfs = NULL; int ret = 0; MENTRY(); MASSERT(sizeof(*handle->mgh_hdr) == MLOG_CHUNK_SIZE); lowerfs = handle->mgh_ctxt->moc_lowerfs; if (i_size_read(handle->mgh_file->f_dentry->d_inode) == 0) { MDEBUG("not reading header from 0-byte log\n"); ret = MLOG_EEMPTY; goto out; } ret = mlog_vfs_read_blob(lowerfs, handle->mgh_file, handle->mgh_hdr, MLOG_CHUNK_SIZE, 0); if (ret) { MERROR("error reading log header from %.*s\n", handle->mgh_file->f_dentry->d_name.len, handle->mgh_file->f_dentry->d_name.name); } else { struct mlog_rec_hdr *mlh_hdr = &handle->mgh_hdr->mlh_hdr; if (MLOG_REC_HDR_NEEDS_SWABBING(mlh_hdr)) { mlog_swab_hdr(handle->mgh_hdr); } if (mlh_hdr->mrh_type != MLOG_HDR_MAGIC) { MERROR("bad log %.*s header magic: %#x (expected %#x)\n", handle->mgh_file->f_dentry->d_name.len, handle->mgh_file->f_dentry->d_name.name, mlh_hdr->mrh_type, MLOG_HDR_MAGIC); ret = -EIO; } else if (mlh_hdr->mrh_len != MLOG_CHUNK_SIZE) { MERROR("incorrectly sized log %.*s header: %#x " "(expected %#x)\n", handle->mgh_file->f_dentry->d_name.len, handle->mgh_file->f_dentry->d_name.name, mlh_hdr->mrh_len, MLOG_CHUNK_SIZE); ret = -EIO; } } handle->mgh_last_idx = handle->mgh_hdr->mlh_tail.mrt_index; handle->mgh_file->f_pos = i_size_read(handle->mgh_file->f_dentry->d_inode); out: MRETURN(ret); }
int mtrace_super_init(struct super_block *sb) { int ret = 0; struct mrecord_handle *handle = NULL; struct msubject_trace_info *info = NULL; struct mrecord_file_info *mrh_file = NULL; mtfs_bindex_t bindex = mtfs_s2bnum(sb) - 1; MENTRY(); MTFS_ALLOC_PTR(info); if (info == NULL) { ret = -ENOMEM; MERROR("not enough memory\n"); goto out; } handle = &info->msti_handle; handle->mrh_ops = &mrecord_file_ops; mrh_file = &handle->u.mrh_file; mrh_file->mrfi_mnt = mtfs_s2mntbranch(sb, bindex); mrh_file->mrfi_dparent = mtfs_s2bdreserve(sb, bindex); mrh_file->mrfi_fname = MTFS_RESERVE_RECORD; ret = mrecord_init(handle); if (ret) { MERROR("failed to init handle, ret = %d\n", ret); goto out_free_handle; } ret = mrecord_cleanup(handle); if (ret) { MERROR("failed to cleanup handle, ret = %d\n", ret); goto out_fini_handle; } #ifdef CONFIG_SYSCTL #ifdef HAVE_REGISTER_SYSCTL_2ARGS info->msti_ctl_table = register_sysctl_table(mtrace_top_table, 0); #else /* !HAVE_REGISTER_SYSCTL_2ARGS */ info->msti_ctl_table = register_sysctl_table(mtrace_top_table); #endif /* !HAVE_REGISTER_SYSCTL_2ARGS */ #endif /* CONFIG_SYSCTL */ mtfs_s2subinfo(sb) = (void *)info; goto out; out_fini_handle: mrecord_fini(handle); out_free_handle: MTFS_FREE_PTR(handle); out: MRETURN(ret); }
/* This is a callback from the mlog_* functions. * Assumes caller has already pushed us into the kernel context. */ int mlog_vfs_create(struct mlog_ctxt *ctxt, struct mlog_handle **res, struct mlog_logid *logid, const char *name) { struct mlog_handle *handle = NULL; int ret = 0; MENTRY(); handle = mlog_alloc_handle(); if (handle == NULL) { ret = -ENOMEM; goto out; } *res = handle; MASSERT(ctxt); if (logid != NULL) { handle->mgh_file = mlog_vfs_open_id(ctxt, logid); if (IS_ERR(handle->mgh_file)) { ret = PTR_ERR(handle->mgh_file); MERROR("failed to open by logid, ret = %d\n", ret); goto out_free_handle; } /* assign the value of mgh_id for handle directly */ handle->mgh_id = *logid; } else if (name) { handle->mgh_file = mlog_vfs_create_open_name(ctxt, name); if (IS_ERR(handle->mgh_file)) { ret = PTR_ERR(handle->mgh_file); MERROR("failed to open by name, ret = %d\n", ret); goto out_free_handle; } handle->mgh_id.mgl_ogr = 1; handle->mgh_id.mgl_oid = handle->mgh_file->f_dentry->d_inode->i_ino; handle->mgh_id.mgl_ogen = handle->mgh_file->f_dentry->d_inode->i_generation; } else { handle->mgh_file = mlog_vfs_create_open_new(ctxt, &handle->mgh_id); if (IS_ERR(handle->mgh_file)) { ret = PTR_ERR(handle->mgh_file); MERROR("failed to open new, ret = %d\n", ret); goto out_free_handle; } } handle->mgh_ctxt = ctxt; goto out; out_free_handle: mlog_free_handle(handle); out: MRETURN(ret); }
static int ext_support_init(void) { int ret = 0; unsigned long address = 0; MDEBUG("registering mtfs lowerfs for ext\n"); ret = mtfs_symbol_get("ext3", "ext3_bread", &address, &_mlowerfs_ext3_bread_owner); if (ret) { MERROR("failed to get address of symbple ext3_bread, ret = %d\n", ret); goto out; } MASSERT(_mlowerfs_ext3_bread_owner != NULL); _mlowerfs_ext3_bread_pointer = (_mlowerfs_ext3_bread_t)address; ret = mtfs_symbol_get("ext3", "ext3_iget", &address, &_mlowerfs_ext3_iget_owner); if (ret) { MERROR("failed to get address of symbple ext3_bread, ret = %d\n", ret); goto out_ext3_bread_put; } MASSERT(_mlowerfs_ext3_iget_owner != NULL); _mlowerfs_ext3_iget_pointer = (_mlowerfs_ext3_iget_t)address; ret = mlowerfs_register(&lowerfs_ext2); if (ret) { MERROR("failed to register lowerfs for ext2, ret = %d\n", ret); goto out_ext3_iget_put; } ret = mlowerfs_register(&lowerfs_ext3); if (ret) { MERROR("failed to register lowerfs for ext3, ret = %d\n", ret); goto out_unregister_ext2; } ret = mlowerfs_register(&lowerfs_ext4); if (ret) { MERROR("failed to register lowerfs for ext4, ret = %d\n", ret); goto out_unregister_ext3; } goto out; out_unregister_ext3: mlowerfs_unregister(&lowerfs_ext3); out_unregister_ext2: mlowerfs_unregister(&lowerfs_ext2); out_ext3_iget_put: mtfs_symbol_put(_mlowerfs_ext3_iget_owner); out_ext3_bread_put: mtfs_symbol_put(_mlowerfs_ext3_bread_owner); out: return ret; }
// this obviously will need to change, but is here to reflect the above // stop-gap measure and to make the tests pass at least... boost::optional<std::string> ipv6_to_string(const char* src, size_t len) { if (len < 8) { MERROR("Invalid IPv4 address: " << std::string(src, len)); return boost::none; } std::stringstream ss; unsigned int bytes[8]; for (int i = 0; i < 8; i++) { unsigned char a = src[i]; bytes[i] = a; } ss << bytes[0] << ":" << bytes[1] << ":" << bytes[2] << ":" << bytes[3] << ":" << bytes[4] << ":" << bytes[5] << ":" << bytes[6] << ":" << bytes[7]; return ss.str(); }
bool Simple_Shader::cargar(const char* archivo,int tiposhader) { std::ifstream shader; shader.open(archivo,std::ios::in); if(shader.is_open()) { std::string linea; std::string contenido; while(!shader.eof()) { getline(shader,linea); contenido=contenido+"\n"+linea; } if(tiposhader==GL_VERTEX_SHADER) crearVS(contenido); if(tiposhader==GL_FRAGMENT_SHADER) crearFS(contenido); } else { MERROR("ERROR: No se pudo abrir el archivo "<< archivo); return false; } return true; }
int main() { int ret = 0; struct mlowerfs_bucket *bucket = NULL; int i = 0; int operation_num = 0; struct mtfs_interval_node_extent extent; MTFS_ALLOC(bucket, sizeof(*bucket)); if (bucket == NULL) { MERROR("not enough memory\n"); ret = -ENOMEM; goto out; } fscanf(stdin, "%d", &operation_num); for (i = 0; i < operation_num; i ++) { fscanf(stdin, "%llu%llu", &extent.start, &extent.end); _mlowerfs_bucket_add(bucket, &extent); } _mlowerfs_bucket_dump(bucket); out_free_bucket: MTFS_FREE(bucket, sizeof(*bucket)); out: return ret; }
boost::optional<std::string> NodeRPCProxy::get_fee_quantization_mask(uint64_t &fee_quantization_mask) const { uint64_t height; boost::optional<std::string> result = get_height(height); if (result) return result; if (m_offline) return boost::optional<std::string>("offline"); if (m_dynamic_base_fee_estimate_cached_height != height) { cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req_t = AUTO_VAL_INIT(req_t); cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response resp_t = AUTO_VAL_INIT(resp_t); m_daemon_rpc_mutex.lock(); req_t.grace_blocks = m_dynamic_base_fee_estimate_grace_blocks; bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_fee_estimate", req_t, resp_t, m_http_client, rpc_timeout); m_daemon_rpc_mutex.unlock(); CHECK_AND_ASSERT_MES(r, std::string("Failed to connect to daemon"), "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(resp_t.status != CORE_RPC_STATUS_BUSY, resp_t.status, "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(resp_t.status == CORE_RPC_STATUS_OK, resp_t.status, "Failed to get fee estimate"); m_dynamic_base_fee_estimate = resp_t.fee; m_dynamic_base_fee_estimate_cached_height = height; m_fee_quantization_mask = resp_t.quantization_mask; } fee_quantization_mask = m_fee_quantization_mask; if (fee_quantization_mask == 0) { MERROR("Fee quantization mask is 0, forcing to 1"); fee_quantization_mask = 1; } return boost::optional<std::string>(); }
static void *mlowerfs_ext3_start(struct inode *inode, int op) { int nblocks = EXT3_SINGLEDATA_TRANS_BLOCKS; //journal_t *journal = NULL; void *handle = NULL; MENTRY(); if (current->journal_info) { goto journal_start; } /* Increase block number according to operation type */ journal_start: MASSERT(nblocks > 0); handle = _mlowerfs_ext3_journal_start(inode, nblocks); if (!IS_ERR(handle)) { MASSERT(current->journal_info == handle); } else { MERROR("error starting handle for op %u (%u credits): rc %ld\n", op, nblocks, PTR_ERR(handle)); } MRETURN(handle); }
int mtfs_branch_valid_flag(struct inode *inode, mtfs_bindex_t bindex, __u32 valid_flags) { int is_valid = 1; __u32 mtfs_flag = 0; int ret = 0; MENTRY(); if (mtfs_i2branch(inode, bindex) == NULL) { is_valid = 0; MDEBUG("branch[%d] is null, return invalid\n", bindex); goto out; } if (valid_flags == MTFS_BRANCH_VALID) { is_valid = 1; MDEBUG("branch[%d] is not null, return valid\n", bindex); goto out; } ret = mtfs_branch_getflag(inode, bindex, &mtfs_flag); if (ret) { MERROR("failed to get branch flag, ret = %d\n", ret); is_valid = 0; goto out; } if ((valid_flags & MTFS_DATA_VALID) != 0 && (mtfs_flag & MTFS_FLAG_DATABAD) != 0) { MDEBUG("data of branch[%d] is not valid\n", bindex); is_valid = 0; } out: MRETURN(is_valid); }
static int mlowerfs_ext3_commit_async(struct inode *inode, void *h, void **wait_handle) { unsigned long tid = 0; transaction_t *transaction = NULL; handle_t *handle = h; journal_t *journal = NULL; int ret = 0; MENTRY(); MASSERT(current->journal_info == handle); transaction = handle->h_transaction; journal = transaction->t_journal; tid = transaction->t_tid; /* we don't want to be blocked */ handle->h_sync = 0; ret = _mlowerfs_ext3_journal_stop(handle); if (ret) { MERROR("error while stopping transaction: %d\n", ret); goto out; } log_start_commit(journal, tid); *wait_handle = (void *) tid; out: MRETURN(ret); }
static int __mtrace_proc_dobitmasks(void *data, int write, loff_t pos, void *buffer, int nob) { const int tmpstrlen = 512; char *tmpstr; int ret; unsigned int *mask = data; int is_ops = (mask == &mtrace_operations) ? 1 : 0; int is_unit = (mask == &mtrace_units) ? 1 : 0; const char *(*mask2str)(int bit) = NULL; MENTRY(); MTFS_ALLOC(tmpstr, tmpstrlen); if (tmpstr == NULL) { MERROR("not enough memory\n"); ret = -ENOMEM; goto out; } MASSERT(is_ops || is_unit); if (is_ops) { mask2str = mtrace_ops2str; } else { mask2str = mtrace_unit2str; } ret = mtfs_common_proc_dobitmasks(data, write, pos, buffer, nob, 0, tmpstr, tmpstrlen, mask2str); MTFS_FREE(tmpstr, tmpstrlen); out: MRETURN(ret); }
/* returns negative on error; 0 if success; 1 if success & log destroyed */ int mlog_cancel_rec(struct mlog_handle *loghandle, int index) { struct mlog_log_hdr *mlh = loghandle->mgh_hdr; int ret = 0; MENTRY(); MDEBUG("Canceling %d in log %llx\n", index, loghandle->mgh_id.mgl_oid); if (index == 0) { MERROR("Can't cancel index 0 which is header\n"); ret = -EINVAL; goto out; } if (!ext2_clear_bit(index, mlh->mlh_bitmap)) { MDEBUG("Catalog index %u already clear?\n", index); ret = -ENOENT; goto out; } mlh->mlh_count--; if ((mlh->mlh_flags & MLOG_F_ZAP_WHEN_EMPTY) && (mlh->mlh_count == 1) && (loghandle->mgh_last_idx == (MLOG_BITMAP_BYTES * 8) - 1)) { ret = mlog_destroy(loghandle); if (ret) { MERROR("Failure destroying log after last cancel: %d\n", ret); ext2_set_bit(index, mlh->mlh_bitmap); mlh->mlh_count++; } else { ret = 1; } goto out; } ret = mlog_write_rec(loghandle, &mlh->mlh_hdr, NULL, 0, NULL, 0); if (ret) { MERROR("Failure re-writing header %d\n", ret); ext2_set_bit(index, mlh->mlh_bitmap); mlh->mlh_count++; } out: MRETURN(ret); }
bool SpeechRec::ProcessFileList(data_format inpf, data_format outpf, char *list, char *outMLFFile) { assert((int)outpf > (int)inpf); // open file list FILE *fp_list = fopen(list, "r"); if(!fp_list) { char msg[1024]; sprintf(msg, "Can not open the file list: %s\n", list); MERROR(msg); return false; } // open MLF FILE *fp_mlf = 0; if(outMLFFile) { fp_mlf = fopen(outMLFFile, "w"); if(!fp_mlf) { fclose(fp_list); char msg[1024]; sprintf(msg, "Can not create the MLF: %s\n", outMLFFile); MERROR(msg); return false; } fprintf(fp_mlf, "#!MLF!#\n"); } char line[1024]; // process the list while(fgets(line, 1023, fp_list)) { if(!ProcessFileListLine(inpf, outpf, line, fp_mlf)) break; } // close files if(fp_mlf) fclose(fp_mlf); fclose(fp_list); return true; }
bool GL_Contexto::iniciar() { glfwInit(); #if 0 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); glfwWindowHint(GLFW_REFRESH_RATE,GLFW_DONT_CARE); #endif _ventana = glfwCreateWindow(_ancho, _alto,_titulo.c_str() , NULL, NULL); if (_ventana == NULL) { MERROR("No se pudo crear la ventana GLFW"); glfwTerminate(); return false; } glfwMakeContextCurrent(_ventana); glewExperimental=GL_TRUE; if (glewInit() != GLEW_OK) { MERROR("No se pudo iniciar GLEW"); glfwTerminate(); return false; } /*glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK);*/ MLOG(glGetString(GL_VENDOR)); MLOG(glGetString(GL_VERSION)); GLint numext; glGetIntegerv(GL_NUM_EXTENSIONS,&numext); #if LOG_EXT for(int i=0;i<numext;i++) MLOG(glGetStringi(GL_EXTENSIONS,i)); #endif return true;; }
bool Simple_Shader::cargar(const char* VS,const char* FS) { std::string linea; std::string contenido; std::ifstream shader; shader.open(VS,std::ios::in); if(shader.is_open()) { while(!shader.eof()) { getline(shader,linea); contenido=contenido+"\n"+linea; } crearVS(contenido); shader.close(); } else { MERROR("ERROR: No se pudo abrir el archivo "<< VS); return false; } shader.open(FS,std::ios::in); if(shader.is_open()) { contenido=""; while(!shader.eof()) { getline(shader,linea); contenido=contenido+"\n"+linea; } crearFS(contenido); shader.close(); } else { MERROR("ERROR: No se pudo abrir el archivo "<<FS); return false; } link(); return true; }
static int mlog_vfs_close(struct mlog_handle *handle) { int ret = 0; MENTRY(); ret = filp_close(handle->mgh_file, 0); if (ret) { MERROR("error closing log, ret = %d\n", ret); } MRETURN(ret); }
static ssize_t mtrace_file_rw(int is_write, struct file *file, const struct iovec *iov, unsigned long nr_segs, loff_t *ppos) { ssize_t size = 0; int ret = 0; struct mtfs_io *io = NULL; size_t rw_size = 0; MENTRY(); rw_size = get_iov_count(iov, &nr_segs); if (rw_size <= 0) { ret = rw_size; goto out; } MTFS_SLAB_ALLOC_PTR(io, mtfs_io_cache); if (io == NULL) { MERROR("not enough memory\n"); size = -ENOMEM; goto out; } ret = mtrace_io_init_rw(io, is_write, file, iov, nr_segs, ppos, rw_size); if (ret) { size = ret; goto out_free_io; } ret = mtfs_io_loop(io); if (ret) { MERROR("failed to loop on io\n"); size = ret; } else { size = io->mi_result.ssize; } out_free_io: MTFS_SLAB_FREE_PTR(io, mtfs_io_cache); out: MRETURN(size); }