Obj *read_sexp(Env *env, Obj *root, char **p) { VAR(obj); VAR(head); VAR(tail); VAR(tmp); for (;;) { *obj = read_one(env, root, p); if (!*obj) error("unclosed parenthesis"); if (*obj == Dot) { if (*head == NULL) error("stray dot"); *tmp = read_one(env, root, p); (*tail)->cdr = *tmp; break; } if (*obj == Cparen) { if (*head == NULL) return Nil; break; } if (*head == NULL) { (*head) = (*tail) = make_cell(env, root, obj, &Nil); } else { *tmp = make_cell(env, root, obj, &Nil); (*tail)->cdr = *tmp; (*tail) = (*tail)->cdr; } } return *head; }
void CReg_ControlDlg::fresh_output() { reg_102=read_one(255,102); if(reg_102<0) { //MessageBox(_T("¶Áʧ°Ü£¬ÇëÖØÊÔ")); return; } reg_103=read_one(255,103); if(reg_103<0) { //MessageBox(_T("¶Áʧ°Ü£¬ÇëÖØÊÔ")); return; } for (int i=0;i<16;i++) { out_put_bit[32+i] = reg_102 &(0x0001<<i); } for (int i=0;i<16;i++) { out_put_bit[48+i] = reg_103 &(0x0001<<i); } for (int i =0;i<32;i++) { if(out_put_bit[32+i]==1) ((CButton *)GetDlgItem(2032 +32 - i))->SetCheck(1); else ((CButton *)GetDlgItem(2032 +32 - i))->SetCheck(0); } }
// Read one cv::Mat from file bool read_one(FILE * file, cv::Mat & data) { bool okay = true; int32_t rows, cols; uint32_t type; okay &= read_one(file, rows); okay &= read_one(file, cols); okay &= read_one(file, type); if (rows <= 0 || cols <= 0 || (type & ~CV_MAT_TYPE_MASK) != 0) return false; data.create(rows, cols, type); // If matrix memory is continuous, we can reshape the matrix if (data.isContinuous()) { cols = rows*cols; rows = 1; } // Currently only supports float/double matrices! if (data.depth() == CV_32F) for (int r = 0; r < rows; ++r) okay &= read_n(file, data.ptr<float>(r), cols); else if (data.depth() == CV_64F) for (int r = 0; r < rows; ++r) okay &= read_n(file, data.ptr<double>(r), cols); else return false; return okay; }
void Cconfigure::OnCbnSelchangeRangecombo() { int Item=m_controlcombo.GetCurSel(); int RegValue,Value; if (1==m_CurCol) { RegValue=read_one(g_tstat_id,200+m_CurRow); if (RegValue<0) { RegValue=0; } if (0==Item) { Value=1; } else if (1==Item) { Value=2; } else if (2==Item) { Value=4; } RegValue&=0xF0; RegValue+=Value; write_one(g_tstat_id,200+m_CurRow,RegValue); } else if (3==m_CurCol) { RegValue=read_one(g_tstat_id,200+m_CurRow); if (RegValue<0) { RegValue=0; } if (0==Item) { Value=16; } else if (1==Item) { Value=32; } RegValue&=0x0F;//留底位,去高位 RegValue+=Value;//置高位 write_one(g_tstat_id,200+m_CurRow,RegValue); } else if (4==m_CurCol) { write_one(g_tstat_id,4171+m_CurRow,Item); } OnInitDialog(); }
void CReg_ControlDlg::OnBnClickedBtnDeviceIdWrite() { // TODO: Add your control notification handler code here CString temp_id; CString temp_on_time; CString temp_cycle; int i_id; int i_time; int i_cycle; m_reg_id.GetWindowTextW(temp_id); m_reg_on_time.GetWindowTextW(temp_on_time); m_reg_cycle.GetWindowTextW(temp_cycle); i_id = _wtoi(temp_id); i_time = _wtoi(temp_on_time); i_cycle = _wtoi(temp_cycle); if(write_one(255,6,i_id)<0) { MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ")); return; } if(write_one(255,104,i_time)<0) { MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ")); return; } if(write_one(255,105,i_cycle)<0) { MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ")); return; } MessageBox(_T("дÈë³É¹¦£¡")); int id_read=0; int time_read=0; int cycle_read=0; CString temp_read_id; CString temp_read_time; CString temp_read_cycle; id_read=read_one(i_id,6,3); time_read=read_one(i_id,104,3); cycle_read=read_one(i_id,105,3); temp_read_id.Format(_T("%d"),id_read); temp_read_time.Format(_T("%d"),time_read); temp_read_cycle.Format(_T("%d"),cycle_read); GetDlgItem(IDC_STATIC_ID)->SetWindowText(temp_read_id); GetDlgItem(IDC_STATIC_TIME)->SetWindowText(temp_read_time); GetDlgItem(IDC_STATIC_CYCLE)->SetWindowText(temp_read_cycle); }
void impl::muxer::mux(volatile const bool& terminate) { atf::utils::auto_array< struct pollfd > poll_fds(new struct pollfd[m_nfds]); for (size_t i = 0; i < m_nfds; i++) { poll_fds[i].fd = m_fds[i]; poll_fds[i].events = POLLIN; } size_t nactive = m_nfds; while (nactive > 0 && !terminate) { int ret; while (!terminate && (ret = safe_poll(poll_fds.get(), 2, 250)) == 0) {} for (size_t i = 0; !terminate && i < m_nfds; i++) { if (poll_fds[i].events == 0) continue; if (poll_fds[i].revents & POLLHUP) { // Any data still available at this point will be processed by // a call to the flush method. poll_fds[i].events = 0; INV(nactive >= 1); nactive--; } else if (poll_fds[i].revents & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) { (void)read_one(i, poll_fds[i].fd, m_buffers[i], true); } } } }
void CFreeCoolDlg::OnBnClickedRadio1() { CButton* pNCRadio=((CButton*)GetDlgItem(IDC_RADIO1)); CButton* pLocalRadio=((CButton*)GetDlgItem(IDC_RADIO2)); pNCRadio->SetCheck(BST_CHECKED); pLocalRadio->SetCheck(BST_UNCHECKED); short nValue=-1; nValue =read_one(g_tstat_id,350); if(nValue<0) return; nValue=nValue|0x2; // nValue=nValue&0xFD; nValue =write_one(g_tstat_id,350,nValue); if(nValue&0x10) { //((CButton*)GetDlgItem(IDC_CHECK4))->SetCheck(BST_CHECKED); ((CButton*)GetDlgItem(IDC_STATUSSTATIC))->SetWindowText(_T("OK")); } else { //((CButton*)GetDlgItem(IDC_CHECK4))->SetCheck(BST_UNCHECKED); ((CButton*)GetDlgItem(IDC_STATUSSTATIC))->SetWindowText(_T("FAIL")); } }
static bool perform_tests(void *data) { char command[128]; int n; sol_memmap_add_map(&_memmap0); sol_memmap_add_map(&_memmap1); n = snprintf(command, sizeof(command), "truncate -s0 %s && truncate -s128 %s", _memmap0.path, _memmap0.path); ASSERT(n > 0 && (size_t)n < sizeof(command)); n = system(command); ASSERT(!n); n = snprintf(command, sizeof(command), "truncate -s0 %s && truncate -s128 %s", _memmap1.path, _memmap1.path); ASSERT(n > 0 && (size_t)n < sizeof(command)); n = system(command); ASSERT(!n); write_one(); read_one(); /* This one should happen before actually writing data */ sol_timeout_add(0, read_one_after_mainloop, NULL); /* This one should be after a main loop */ sol_timeout_add(50, write_two_timeout, NULL); /* This, much after */ sol_timeout_add(1000, read_two_after, NULL); /* Even later */ sol_timeout_add(2000, write_cancelled_timeout, NULL); return false; }
bool DataTypeClassNameParser::Parser::get_type_params(TypeParamsVec* params) { if (is_eos()) { params->clear(); return true; } if (str_[index_] != '(') { parse_error(str_, index_, "Expected '(' before type parameters"); return false; } ++index_; // Skip '(' while (skip_blank_and_comma()) { if (str_[index_] == ')') { ++index_; return true; } std::string param; if (!read_one(¶m)) { return false; } params->push_back(param); } parse_error(str_, index_, "Unexpected end of string"); return false; }
static bool read_one_after_mainloop(void *data) { read_one(); return false; }
static int lookup_wild(const char *root, struct lookup_context *ctxt) { char mkey[KEY_MAX_LEN + 1]; char mapent[MAPENT_MAX_LEN + 1]; char *mapname; FILE *f; int entry; time_t age = time(NULL); mapname = alloca(strlen(ctxt->mapname) + 6); sprintf(mapname, "file:%s", ctxt->mapname); f = fopen(ctxt->mapname, "r"); if (!f) { error(MODPREFIX "could not open map file %s", ctxt->mapname); return 0; } while(1) { entry = read_one(f, mkey, mapent); if (entry) if (strncmp(mkey, "*", 1) == 0) { fclose(f); return cache_update(root, "*", mapent, age); } if (feof(f)) break; } fclose(f); return CHE_MISSING; }
static int read_map(const char *root, time_t now, struct lookup_context *ctxt) { char key[KEY_MAX_LEN + 1]; char mapent[MAPENT_MAX_LEN + 1]; char *mapname; FILE *f; int entry; time_t age = now ? now : time(NULL); mapname = alloca(strlen(ctxt->mapname) + 6); sprintf(mapname, "file:%s", ctxt->mapname); f = fopen(ctxt->mapname, "r"); if (!f) { error(MODPREFIX "could not open map file %s", ctxt->mapname); return 0; } while(1) { entry = read_one(f, key, mapent); if (entry) cache_add(root, key, mapent, age); if (feof(f)) break; } fclose(f); /* Clean stale entries from the cache */ cache_clean(root, age); return 1; }
/* At boot, or when restarting inadyn at runtime, the memory struct holding our * current IP# is empty. We want to avoid unnecessary updates of our DDNS server * record, since we might get locked out for abuse, so we "seed" each of the DDNS * records of our struct with the cached IP# from our cache file, or from a regular * DNS query. */ int read_cache_file(ddns_t *ctx) { int i, j; /* Clear DNS cache before querying for the IP below, this to * prevent any artefacts from, e.g., nscd, which is a known * problem with DDNS clients. */ res_init(); if (!ctx) return RC_INVALID_POINTER; for (i = 0; i < ctx->info_count; i++) { ddns_info_t *info = &ctx->info[i]; int nonslookup; /* Exception for tunnelbroker.net - no name to lookup */ nonslookup = !strcmp(info->system->name, "*****@*****.**"); // XXX: TODO better plugin identifiction here for (j = 0; j < info->alias_count; j++) read_one(&info->alias[j], nonslookup); } return 0; }
BOOL ScanOnlyOneProduct() { return FALSE; int nProductID=Read_One(255,MB_Product_Model); //global scan to 255, read register 6 (model number) to see if there is any nodes on the net //TBD: add a register .h file for all modbus registeers if (nProductID<0||nProductID>254) { return FALSE; } else { int n=read_one(nProductID,188); if (n!=0||n!=1) { // return FALSE; } binary_search_result temp; if (n==1) { temp.baudrate=19200; } if (n==0) { temp.baudrate=9600; } for(int j=0;j<m_binary_search_product_background_thread.size();j++) { if(nProductID==m_binary_search_product_background_thread.at(j).id) { return TRUE;//The product has been in datebase. } } //////add to datebase ///.... temp.id=nProductID; temp.product_class_id=read_one(nProductID,7); // get_serialnumber(temp.serialnumber,temp.id ); temp.hardware_version=read_one(temp.id ,8); m_binary_search_product_background_thread.push_back(temp); if(read_one(nProductID,7)==NET_WORK_CONT_PRODUCT_MODEL)//net work controller keep_back_mac_address(nProductID); } return TRUE; }
int read_each_line (int s, char *readBuf, int *lenptr) { int rc; rc = read_one (s, readBuf, lenptr); //printf("read_each_line (rc=%d) =%s", rc, readBuf); return rc; }
void impl::muxer::flush(void) { for (size_t i = 0; i < m_nfds; i++) { while (read_one(i, m_fds[i], m_buffers[i], false) > 0) {} if (!m_buffers[i].empty()) line_callback(i, m_buffers[i]); } }
boolean ADXL345::set_bit(byte address, byte bit){ byte datum; boolean status = true; if(read_one(address, &datum)){ datum |= (1 << bit); // set bit write_one(address, datum); } else{ status = false; } return status; }
boolean ADXL345::get_range_bits(byte range_bits){ /* range: * 0 --- +- 2G * 1 --- +- 4G * 2 --- +- 8G * 3 --- +- 16G */ boolean status = read_one(ADXL345_DATA_FORMAT_ADDRESS, &range_bits); if(status){ range_bits %= 4; } return status; }
boolean ADXL345::clear_bit(byte address, byte bit){ byte datum; boolean status = true; if(read_one(address, &datum)){ datum &= ~(datum << bit); // clear bit write_one(address, datum); } else{ status = false; } return status; }
static bool write_cancelled_timeout(void *data) { write_one_cancelled(); read_one(); /* write_one_cancelled writes same values as write_one */ write_two(); /* reuse second part of test */ read_two(); sol_quit(); return false; }
//读取文件并配置程序 void read_all(char *S) { FILE *f=fopen(S,"rb"); if(f==NULL){printf("配置文件读取错误!,任意键退出");getchar();exit(-1);} struct config_s_t x; myconfig.form_n=con_form; while(1) { //读取一行 fgets(x.arr,1000,f); if(feof(f)!=0)break; //从一行提取 read_one(x.arr,x.zuo,x.you); if(strcmp(x.zuo,"")==0 || x.you[0]==0) { continue; } //printf("\n左端:--%s--\n右端:--%s--",x.zuo,x.you); //判断并配置程序 if(strcmp(x.zuo,"form")==0) { //char tmp[50]=x.you; char *tmp_c; tmp_c=strtok(x.you,","); int form_much=0; while(NULL!=tmp_c &&is_all_space(tmp_c)!=1) { sscanf(tmp_c,"%s %s %d %c",con_form[form_much].name_c,con_form[form_much].name_e,&con_form[form_much].len,&con_form[form_much].type);//myconfig.form_n[form_much].name_c,myconfig.form_n[form_much].name_e,&myconfig.form_n[form_much].len); form_much++; tmp_c=strtok(NULL,","); } myconfig.form_max=form_much; } else { if(is_all_space(x.you))x.you[0]='\0'; } if(strcmp(x.zuo,"maintitle")==0) { sscanf(x.you,"%s",myconfig.maintitle); } else if(strcmp(x.zuo,"add")==0) { sscanf(x.you,"%s",myconfig.add); } else if(strcmp(x.zuo,"delete")==0) { sscanf(x.you,"%s",myconfig.delete); } else if(strcmp(x.zuo,"print")==0)
Obj *read_one(Env *env, Obj *root, char **p) { switch (**p) { case ' ': case '\n': case '\r': case '\t': (*p)++; return read_one(env, root, p); case ')': (*p)++; return Cparen; case '.': (*p)++; return Dot; default: return read(env, root, p); } }
static gboolean exchange_packets (GstPluginLoader * l) { gint res; /* Wait for activity on our FDs */ do { do { res = gst_poll_wait (l->fdset, GST_SECOND); } while (res == -1 && (errno == EINTR || errno == EAGAIN)); if (res < 0) return FALSE; GST_LOG ("Poll res = %d. %d bytes pending for write", res, l->tx_buf_write - l->tx_buf_read); if (!l->rx_done) { if (gst_poll_fd_has_error (l->fdset, &l->fd_r) || gst_poll_fd_has_closed (l->fdset, &l->fd_r)) { GST_LOG ("read fd %d closed/errored", l->fd_r.fd); goto fail_and_cleanup; } if (gst_poll_fd_can_read (l->fdset, &l->fd_r)) { if (!read_one (l)) goto fail_and_cleanup; } } if (l->tx_buf_read < l->tx_buf_write) { if (gst_poll_fd_has_error (l->fdset, &l->fd_w) || gst_poll_fd_has_closed (l->fdset, &l->fd_r)) { GST_ERROR ("write fd %d closed/errored", l->fd_w.fd); goto fail_and_cleanup; } if (gst_poll_fd_can_write (l->fdset, &l->fd_w)) { if (!write_one (l)) goto fail_and_cleanup; } } } while (l->tx_buf_read < l->tx_buf_write); return TRUE; fail_and_cleanup: plugin_loader_cleanup_child (l); return FALSE; }
static void test_istream_unix_client(int fd) { /* 1) */ write_one(fd); read_one(fd); /* 2) */ if (fd_send(fd, send_fd, "1", 1) < 0) i_fatal("fd_send() failed: %m"); read_one(fd); /* 3) */ write_one(fd); read_one(fd); /* 4) */ if (fd_send(fd, send_fd2, "1", 1) < 0) i_fatal("fd_send() failed: %m"); read_one(fd); /* 5) */ write_one(fd); read_one(fd); /* 6) */ if (fd_send(fd, send_fd, "1", 1) < 0) i_fatal("fd_send() failed: %m"); read_one(fd); /* 7-8) */ if (fd_send(fd, send_fd, "1", 1) < 0) i_fatal("fd_send() failed: %m"); if (fd_send(fd, send_fd2, "1", 1) < 0) i_fatal("fd_send() failed: %m"); read_one(fd); /* 9-10) */ if (fd_send(fd, send_fd, "1", 1) < 0) i_fatal("fd_send() failed: %m"); if (fd_send(fd, send_fd2, "1", 1) < 0) i_fatal("fd_send() failed: %m"); read_one(fd); i_close_fd(&fd); }
void CFreeCoolDlg::OnBnClickedCheck1() { CButton* pButton=(CButton*)GetDlgItem(IDC_CHECK1); short nValue=-1; nValue =read_one(g_tstat_id,350); if(nValue<0) return; if(pButton->GetCheck()==BST_CHECKED) { nValue=nValue|0x1; } else { nValue=nValue&0xFE; } nValue =write_one(g_tstat_id,350,nValue); }
bool found_same_net_work_controller_by_mac(int id) {//because net cable no baudrate,so inspect here if(read_one(id,7)!=NET_WORK_CONT_PRODUCT_MODEL)//it is not a net work controller return false; unsigned short get_mac_address[6]={0}; Read_Multi(id,get_mac_address,100,6); for(int j=0;j<m_mac_address_list.size();j++) { if(get_mac_address[0]==m_mac_address_list.at(j).mac1 && get_mac_address[1]==m_mac_address_list.at(j).mac2 && get_mac_address[2]==m_mac_address_list.at(j).mac3 && get_mac_address[3]==m_mac_address_list.at(j).mac4 && get_mac_address[4]==m_mac_address_list.at(j).mac5 && get_mac_address[5]==m_mac_address_list.at(j).mac6) return true;//////////////////only here return true } return false; }
CString CRegisterViewerDlg::Get_ProductModel(){ CString ModelName=_T(""); if (!is_connect()) { AfxMessageBox(_T("Please Connect to your device,firstly!")); } else { m_modelno=read_one(g_tstat_id,7,20); if (m_modelno>0) { ModelName=GetProductName(m_modelno); } else { AfxMessageBox(_T("Can't read your device")); } } return ModelName; }
bool DataTypeClassNameParser::Parser::get_name_and_type_params(NameAndTypeParamsVec* params) { while (skip_blank_and_comma()) { if (str_[index_] == ')') { ++index_; return true; } std::string hex; read_next_identifier(&hex); std::string name; if (!from_hex(hex, &name)) { LOG_ERROR("Invalid hex string \"%s\" for parameter", hex.c_str()); return DataType::ConstPtr(); } skip_blank(); if (str_[index_] != ':') { parse_error(str_, index_, "Expected ':'"); return false; } ++index_; skip_blank(); std::string type; if (!read_one(&type)) { return false; } params->push_back(std::make_pair(name, type)); } parse_error(str_, index_, "Unexpected end of string"); return false; }
// Load binary IntraFace model file bool load_binary_model_file( const char * fn, int & iteration, int & points, cv::Mat & mean_shape, cv::Mat & w, double & wb, std::vector<cv::Mat> & R, std::vector<cv::Mat> & b) { FILE * file = fopen(fn, "rb"); if (!file) { fprintf(stderr, "Error opening model file \"%s\"!\n", fn); return false; } bool okay = true; uint32_t n_iter, n_points; okay &= read_one(file, n_iter); okay &= read_one(file, n_points); iteration = n_iter; points = n_points; okay &= read_one(file, mean_shape); okay &= read_one(file, w); okay &= read_one(file, wb); R.resize(n_iter); b.resize(n_iter); for (uint32_t i = 0; i < n_iter; ++i) { okay &= read_one(file, R[i]); okay &= read_one(file, b[i]); } fclose(file); if (!okay) fprintf(stderr, "Error reading model file \"%s\"! It seems to be corrupted!\n", fn); return okay; }
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size) { if (buffer[0]) return NULL; /* not the whole tree */ return read_one(&buffer, &size); }