static char *get_query_first_field(MYSQL *mysql, char *query) { MYSQL_RES *result = query_result(mysql,query); char *r = NULL; if(!result) { mysqle_print(mysql, "query_result"); goto freeing; } static char buf[MAX_PROFID]; MYSQL_ROW row = mysql_fetch_row(result); if(row == NULL) { goto freeing; } snprintf(buf,MAX_PROFID,"%s",row[0]); r = &buf[0]; freeing: mysql_free_result(result); return r; }
static int send_request(struct atmarp_req *req) { struct atmarp_req reply; int s,len; s = un_attach(ATMARP_SOCKET_PATH); if (s < 0) { perror("un_attach"); exit(1); } if (write(s,req,sizeof(*req)) < 0) { perror("write"); exit(1); } len = read(s,&reply,sizeof(reply)); if (len < 0) { perror("read"); exit(1); } if (req->type == art_query) return query_result(&reply); if (len != sizeof(int)) { fprintf(stderr,"bad read: %d != %d\n",len,sizeof(int)); exit(1); } if (*(int *) &reply < 0) { fprintf(stderr,"atmarp: %s\n",strerror(-*(int *) &reply)); exit(1); } return *(int *) &reply; }
void print_answer(cmd_context& ctx) { if (m_params.get_bool(":print-answer", false)) { datalog::context& dlctx = m_dl_ctx->get_dl_context(); ast_manager& m = ctx.m(); expr_ref query_result(dlctx.get_answer_as_formula(), m); sbuffer<symbol> var_names; unsigned num_decls = 0; if (is_quantifier(m_target)) { num_decls = to_quantifier(m_target)->get_num_decls(); } ctx.display(ctx.regular_stream(), query_result, 0, num_decls, "X", var_names); ctx.regular_stream() << std::endl; } }
query_result not_query::eval(const text_query &t)const { query_result temp = t.query(query.rep()); shared_ptr<vector<string>> file = temp.get_file(); shared_ptr<set<vector<string>::size_type>> lines = make_shared<set<vector<string>::size_type>> (set<vector<string>::size_type>()); set<vector<string>::size_type>::iterator p = temp.begin(),q = temp.end(); vector<string>::size_type sz = file->size(); for(vector<string>::size_type n =0; n < sz; ++n) { if(p == q || *p != n) lines->insert(n); else if(p != q) ++p; } return query_result(query.rep(),lines,file); }
static int get_sub_bell_conf(MYSQL *sql) { MYSQL_RES *result = query_result(sql, "SELECT * FROM sub_conf"); MYSQL_ROW row = mysql_fetch_row(result); int r = 0; if(row == NULL) { r = -1; goto freeing; } sub_bell_conf.ring_before = strdup(row[0]); sub_bell_conf.ring_for = duration(row[1]); sub_bell_conf.global_enable = !! atoi(row[2]); dbg_print("Sub Bell Conf >> gap: %s dur: %ld glob: %s", sub_bell_conf.ring_before,(long)sub_bell_conf.ring_for, sub_bell_conf.global_enable?"true":"false"); freeing: mysql_free_result(result); return r; }
query_result or_query::eval(const text_query &t)const { query_result temp_l = lhs.eval(t), temp_r = rhs.eval(t); shared_ptr<set<vector<string>::size_type>> lines = make_shared<set<vector<string>::size_type>> (set<vector<string>::size_type>()); set_union(temp_l.begin(),temp_l.end(),temp_r.begin(),temp_r.end(),inserter(*lines,lines->begin())); //set<vector<string>::size_type>::iterator pl = temp_r.begin(),ql = temp_r.end(),pr = temp_r.begin(),qr = temp_r.end(); //while(pl != pr&&ql !=qr) //{ // if(*pl == *ql) // { // lines->insert(*pl); // ++pl;++ql; // } // else if(*pl < *ql) // { // lines->insert(*pl); // ++pl; // } // else // lines->insert(*ql++); //} return query_result(rep(),lines,temp_l.get_file()); }
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectuiv(GrGLuint id, GrGLenum pname, GrGLuint *params) { query_result(id, pname, params); }
static MYSQL_RES *get_rings(MYSQL *sql,char *prof) { char *q = gen_ring_query(prof); return query_result(sql,q); }
GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetQueryObjecti64v(GrGLuint id, GrGLenum pname, GrGLint64 *params) { query_result(id, pname, params); }