SV *radio_get_status() { have_status = dp_conc_q_rstat_try_pop_all(&_dsp_chain_rstat_queue,&lrstat); float angle, angle_lpf; HV *hash; hash = newHV(); hv_stores(hash,"have_status",newSViv(have_status)); if (have_status) { ___PERL_INSERT_HASH_COPYING_lrstat angle = 30.0 * lrstat.phase_diff; angle_lpf = 30.0 * lrstat.phase_diff_lpf; angle *= 360.0; angle_lpf *= 360.0; angle += _main_radial_calibrate; angle_lpf += _main_radial_calibrate; angle = (angle < 0) ? angle + 360.0 : (angle > 360) ? angle - 360.0 : angle; angle_lpf = (angle_lpf < 0) ? angle_lpf + 360.0 : (angle_lpf > 360) ? angle_lpf - 360.0 : angle_lpf; hv_stores(hash,"angle", newSVnv(angle)); hv_stores(hash,"angle_lpf",newSVnv(angle_lpf)); char a_bit = 0; id_instr[0] = 0; while (dp_conc_q_char_try_pop(&_dsp_chain_id_text_queue, &a_bit)) { int l = strlen(id_instr); id_instr[l] = a_bit; id_instr[l+1] = 0; } hv_stores(hash,"id_instr",newSVpv(id_instr,strlen(id_instr))); id_instr[0] = 0; } return newRV_noinc((SV *)hash); }
/* Dump this index into Perl. * Used in testing only. */ SV* dump() const { HV* idx = newHV(); for (const auto& token2entries : index) { HV* entries = newHV(); for (const auto& id2tf : token2entries.second) { std::string k = std::to_string(id2tf.first); hv_store(entries, k.c_str(), k.size(), newSViv(id2tf.second), 0); } hv_store(idx, token2entries.first.c_str(), token2entries.first.size(), newRV_noinc(reinterpret_cast<SV*>(entries)), 0); } HV* len = newHV(); for (const auto& id2length : lengths) { std::string id = std::to_string(id2length.first); hv_store(len, id.c_str(), id.size(), newSVpvf("%.2f", id2length.second), 0); } HV* dump = newHV(); hv_stores(dump, "index", newRV_noinc(reinterpret_cast<SV*>(idx))); hv_stores(dump, "lengths", newRV_noinc(reinterpret_cast<SV*>(len))); return newRV_noinc(reinterpret_cast<SV*>(dump)); }
static SV* make_views_row(PLCB_t *parent, const lcb_RESPVIEWQUERY *resp) { HV *rowdata = newHV(); SV *docid = sv_from_rowdata(resp->docid, resp->ndocid); /* Key, Value, Doc ID, Geo, Doc */ hv_stores(rowdata, "key", sv_from_rowdata(resp->key, resp->nkey)); hv_stores(rowdata, "value", sv_from_rowdata(resp->value, resp->nvalue)); hv_stores(rowdata, "geometry", sv_from_rowdata(resp->geometry, resp->ngeometry)); hv_stores(rowdata, "id", docid); if (resp->docresp) { const lcb_RESPGET *docresp = resp->docresp; AV *docav = newAV(); hv_stores(rowdata, "__doc__", newRV_noinc((SV*)docav)); av_store(docav, PLCB_RETIDX_KEY, SvREFCNT_inc(docid)); plcb_doc_set_err(parent, docav, resp->rc); if (docresp->rc == LCB_SUCCESS) { SV *docval = plcb_convert_getresp(parent, docav, docresp); av_store(docav, PLCB_RETIDX_VALUE, docval); plcb_doc_set_cas(parent, docav, &docresp->cas); } } return newRV_noinc((SV *)rowdata); }
SV* polynode2perl(const ClipperLib::PolyNode& node) { HV* hv = newHV(); Slic3r::Polygon p; ClipperPath_to_Slic3rMultiPoint(node.Contour, p); if (node.IsHole()) { (void)hv_stores( hv, "hole", p.to_SV_clone_ref() ); } else { (void)hv_stores( hv, "outer", p.to_SV_clone_ref() ); } (void)hv_stores( hv, "children", polynode_children_2_perl(node) ); return (SV*)newRV_noinc((SV*)hv); }
void scan_search_entry_response(const char** src, const char* max, HV *out) { SV *dn, *key; STRLEN len; dn = newSV(0); hv_stores(out, "dn", dn); scan_string_utf8(src, max, dn); scan_sequence(src, max, &len); if (len != max - *src) croak("scan_search_entry_response: packet too short"); key = sv_newmortal(); while (*src < max) { const char *attribute_max; AV *values; scan_sequence(src, max, &len); attribute_max = *src + len; scan_string_utf8(src, max, key); values = newAV(); hv_store_ent(out, key, newRV_noinc((SV*)values), 0); scan_set(src, max, &len); if (attribute_max != *src + len) croak("bad packet"); while (*src < attribute_max) { SV *v = newSV(0); av_push(values, v); scan_string_utf8(src, attribute_max, v); } } }
SV *ast_to_sv(pTHX_ AST *ast) { SV *root = node_to_sv(aTHX_ ast->root); HV *hash = (HV*)new_Hash(); hv_stores(hash, "root", set(root)); SV *ret = set(bless(aTHX_ hash, "Compiler::Parser::AST")); return ret; }
SV *radio_get_status() { have_status = _dsp_chain_rstat_queue.try_pop_all(lrstat); HV *hash; hash = newHV(); hv_stores(hash,"have_status",newSViv(have_status)); if (have_status) { ___PERL_INSERT_HASH_COPYING_lrstat std::string a_bit = ""; while (_dsp_chain_id_text_queue.try_pop(a_bit)) { id_instr += a_bit; } hv_stores(hash,"id_instr",newSVpv(id_instr.c_str(),id_instr.size())); id_instr.clear(); } return newRV_noinc((SV *)hash); };
void scan_extended_request(const char **src, const char *max, HV *out) { U8 type; U32 tag; SV *sv = newSV(0); hv_stores(out, "oid", sv); scan_raw(src, max, &type, &tag, sv); if (type != (ASN1_CONTEXT_SPECIFIC | ASN1_PRIMITIVE) || tag != 0) croak("scan_extended_request: bad value"); if (!sv_utf8_decode(sv)) croak("scan_string_utf8: invalid UTF8 data received"); if (*src < max) { sv = newSV(0); hv_stores(out, "value", sv); scan_raw(src, max, &type, &tag, sv); if (type != (ASN1_CONTEXT_SPECIFIC | ASN1_PRIMITIVE) || tag != 1) croak("scan_extended_request: bad value"); } }
SV *radio_get_fft() { have_fft = _dsp_chain_peaks_queue.try_pop_all(pts); HV *hash; hash = newHV(); hv_stores(hash,"have_fft",newSViv(have_fft)); if (have_fft) { ___PERL_INSERT_HASH_COPYING_pts AV *av; av = newAV(); for (uint32_t i=0;i<pts.points.size();i++) { HV *h2; h2 = newHV(); hv_stores(h2,"index",newSViv(pts.points[i].bin)); hv_stores(h2,"dB",newSVnv(pts.points[i].db)); av_push(av,newRV_noinc((SV *)h2)); } hv_stores(hash,"points",newRV_noinc((SV *)av)); } return newRV_noinc((SV *)hash); };
SV *radio_get_fft() { HV *hash; uint32_t i; uint32_t sr, fr; have_fft = dp_conc_q_peaks_try_pop_all(&_dsp_chain_peaks_queue,&pts); hash = newHV(); hv_stores(hash,"have_fft",newSViv(have_fft)); if (have_fft) { ___PERL_INSERT_HASH_COPYING_pts AV *av; av = newAV(); sr = _main_sample_rate; fr = _main_freq; /* dp_radio2832_dev_cmd(radio,GT_SR,&sr); dp_radio2832_dev_cmd(radio,GT_FREQ,&fr); */ for (i=0;i<pts.actpts;i++) { HV *h2; float f; h2 = newHV(); hv_stores(h2,"index",newSViv(pts.points[i]->bin)); hv_stores(h2,"dB",newSVnv(pts.points[i]->db)); hv_stores(h2,"abs",newSVnv(pts.points[i]->abs)); f = (float)pts.points[i]->bin / (float)pts.length; f *= (float)sr; f -= 0.5 * (float)sr; f += (float)fr; hv_stores(h2,"f",newSVnv(f)); av_push(av,newRV_noinc((SV *)h2)); } hv_stores(hash,"points",newRV_noinc((SV *)av)); } return newRV_noinc((SV *)hash); }
void scan_result_response(const char** src, const char* max, HV *out) { I32 r; SV *sv; scan_enum(src, max, &r); hv_stores(out, "result", newSVsv(ldap_error2sv_noinc(r))); sv = newSV(0); hv_stores(out, "matched_dn", sv); scan_string_utf8(src, max, sv); sv = newSV(0); hv_stores(out, "message", sv); scan_string_utf8(src, max, sv); if (*src < max) { U8 type; U32 tag; STRLEN len; AV *referrals; scan_tag(src, max, &type, &tag); if (type != (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED) || tag != 3) croak("bad packed data"); scan_length(src, max, &len); if (len != max - *src) croak("scan_result_response: packet too short"); referrals = newAV(); hv_stores(out, "referrals", newRV_noinc((SV*)referrals)); while (*src < max) { SV *v = newSV(0); av_push(referrals, v); scan_string_utf8(src, max, v); } } }
static SV *new_Token(pTHX_ Token *token) { HV *hash = (HV*)new_Hash(); (void)hv_stores(hash, "stype", set(new_Int(token->stype))); (void)hv_stores(hash, "type", set(new_Int(token->info.type))); (void)hv_stores(hash, "kind", set(new_Int(token->info.kind))); (void)hv_stores(hash, "line", set(new_Int(token->finfo.start_line_num))); (void)hv_stores(hash, "has_warnings", set(new_Int(token->info.has_warnings))); (void)hv_stores(hash, "name", set(new_String(token->info.name, strlen(token->info.name)))); (void)hv_stores(hash, "data", set(new_String(token->data.c_str(), strlen(token->data.c_str())))); HV *stash = (HV *)gv_stashpv("Compiler::Lexer::Token", sizeof("Compiler::Lexer::Token") + 1); return sv_bless(new_Ref(hash), stash); }
void p5_init_callbacks( SV *(*call_p6_method)(IV, char * , I32, SV *, SV **), SV *(*call_p6_callable)(IV, SV *, SV **), void (*free_p6_object)(IV), SV *(*hash_at_key)(IV, char *), SV *(*hash_assign_key)(IV, char *, SV *) ) { perl6_callbacks *cbs = malloc(sizeof(perl6_callbacks)); cbs->call_p6_method = call_p6_method; cbs->call_p6_callable = call_p6_callable; cbs->free_p6_object = free_p6_object; cbs->hash_at_key = hash_at_key; cbs->hash_assign_key = hash_assign_key; hv_stores(PL_modglobal, "Inline::Perl5 callbacks", newSViv((IV)cbs)); }
void scan_search_reference_response(const char **src, const char *max, HV *hv) { AV *av = newAV(); hv_stores(hv, "uris", newRV_noinc((SV*)av)); scan_array_of_string_utf8(src, max, av); }
static SV *node_to_sv(pTHX_ Node *node) { SV *ret = NULL; if (!node) return ret; if (TYPE_match(node, BranchNode)) { BranchNode *branch = dynamic_cast<BranchNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, branch->tk); add_key(hash, "left", branch->left); add_key(hash, "right", branch->right); add_key(hash, "next", branch->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Branch"); } else if (TYPE_match(node, FunctionCallNode)) { FunctionCallNode *call = dynamic_cast<FunctionCallNode *>(node); Nodes *args = call->args; size_t argsize = args->size(); AV *array = new_Array(); for (size_t i = 0; i < argsize; i++) { SV *arg = node_to_sv(aTHX_ args->at(i)); if (!arg) continue; av_push(array, set(arg)); } HV *hash = (HV*)new_Hash(); add_key(hash, "next", call->next); add_token(hash, call->tk); (void)hv_stores(hash, "args", set(new_Ref(array))); ret = bless(aTHX_ hash, "Compiler::Parser::Node::FunctionCall"); } else if (TYPE_match(node, ArrayNode)) { ArrayNode *array = dynamic_cast<ArrayNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, array->tk); add_key(hash, "next", array->next); add_key(hash, "idx", array->idx); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Array"); } else if (TYPE_match(node, HashNode)) { HashNode *h = dynamic_cast<HashNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, h->tk); add_key(hash, "next", h->next); add_key(hash, "key", h->key); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Hash"); } else if (TYPE_match(node, DereferenceNode)) { DereferenceNode *dref = dynamic_cast<DereferenceNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, dref->tk); add_key(hash, "next", dref->next); add_key(hash, "expr", dref->expr); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Dereference"); } else if (TYPE_match(node, FunctionNode)) { FunctionNode *f = dynamic_cast<FunctionNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, f->tk); add_key(hash, "next", f->next); add_key(hash, "body", f->body); add_key(hash, "prototype", f->prototype); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Function"); } else if (TYPE_match(node, BlockNode)) { BlockNode *b = dynamic_cast<BlockNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, b->tk); add_key(hash, "next", b->next); add_key(hash, "body", b->body); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Block"); } else if (TYPE_match(node, ReturnNode)) { ReturnNode *r = dynamic_cast<ReturnNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, r->tk); add_key(hash, "next", r->next); add_key(hash, "body", r->body); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Return"); } else if (TYPE_match(node, SingleTermOperatorNode)) { SingleTermOperatorNode *s = dynamic_cast<SingleTermOperatorNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, s->tk); add_key(hash, "next", s->next); add_key(hash, "expr", s->expr); ret = bless(aTHX_ hash, "Compiler::Parser::Node::SingleTermOperator"); } else if (TYPE_match(node, DoubleTermOperatorNode)) { } else if (TYPE_match(node, LeafNode)) { LeafNode *leaf = dynamic_cast<LeafNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, leaf->tk); add_key(hash, "next", leaf->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Leaf"); } else if (TYPE_match(node, ListNode)) { ListNode *list = dynamic_cast<ListNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, list->tk); add_key(hash, "data", list->data); add_key(hash, "next", list->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::List"); } else if (TYPE_match(node, ArrayRefNode)) { ArrayRefNode *ref = dynamic_cast<ArrayRefNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, ref->tk); add_key(hash, "data", ref->data); add_key(hash, "next", ref->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::ArrayRef"); } else if (TYPE_match(node, HashRefNode)) { HashRefNode *ref = dynamic_cast<HashRefNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, ref->tk); add_key(hash, "data", ref->data); add_key(hash, "next", ref->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::HashRef"); } else if (TYPE_match(node, IfStmtNode)) { IfStmtNode *stmt = dynamic_cast<IfStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "expr", stmt->expr); add_key(hash, "true_stmt", stmt->true_stmt); add_key(hash, "false_stmt", stmt->false_stmt); ret = bless(aTHX_ hash, "Compiler::Parser::Node::IfStmt"); } else if (TYPE_match(node, ElseStmtNode)) { ElseStmtNode *stmt = dynamic_cast<ElseStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "stmt", stmt->stmt); ret = bless(aTHX_ hash, "Compiler::Parser::Node::ElseStmt"); } else if (TYPE_match(node, DoStmtNode)) { DoStmtNode *stmt = dynamic_cast<DoStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "stmt", stmt->stmt); ret = bless(aTHX_ hash, "Compiler::Parser::Node::DoStmt"); } else if (TYPE_match(node, ForStmtNode)) { ForStmtNode *stmt = dynamic_cast<ForStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "init", stmt->init); add_key(hash, "cond", stmt->cond); add_key(hash, "progress", stmt->progress); add_key(hash, "true_stmt", stmt->true_stmt); ret = bless(aTHX_ hash, "Compiler::Parser::Node::ForStmt"); } else if (TYPE_match(node, ForeachStmtNode)) { ForeachStmtNode *stmt = dynamic_cast<ForeachStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "itr", stmt->itr); add_key(hash, "cond", stmt->cond); add_key(hash, "true_stmt", stmt->true_stmt); ret = bless(aTHX_ hash, "Compiler::Parser::Node::ForeachStmt"); } else if (TYPE_match(node, WhileStmtNode)) { WhileStmtNode *stmt = dynamic_cast<WhileStmtNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, stmt->tk); add_key(hash, "next", stmt->next); add_key(hash, "true_stmt", stmt->true_stmt); add_key(hash, "expr", stmt->expr); ret = bless(aTHX_ hash, "Compiler::Parser::Node::WhileStmt"); } else if (TYPE_match(node, ModuleNode)) { ModuleNode *mod = dynamic_cast<ModuleNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, mod->tk); add_key(hash, "next", mod->next); add_key(hash, "args", mod->args); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Module"); } else if (TYPE_match(node, PackageNode)) { PackageNode *pkg = dynamic_cast<PackageNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, pkg->tk); add_key(hash, "next", pkg->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Package"); } else if (TYPE_match(node, RegPrefixNode)) { RegPrefixNode *reg = dynamic_cast<RegPrefixNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, reg->tk); add_key(hash, "next", reg->next); add_key(hash, "option", reg->option); add_key(hash, "expr", reg->exp); ret = bless(aTHX_ hash, "Compiler::Parser::Node::RegPrefix"); } else if (TYPE_match(node, RegReplaceNode)) { RegReplaceNode *reg = dynamic_cast<RegReplaceNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, reg->tk); add_key(hash, "next", reg->next); add_key(hash, "from", reg->from); add_key(hash, "to", reg->to); add_key(hash, "option", reg->option); ret = bless(aTHX_ hash, "Compiler::Parser::Node::RegReplace"); } else if (TYPE_match(node, RegexpNode)) { RegexpNode *reg = dynamic_cast<RegexpNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, reg->tk); add_key(hash, "next", reg->next); add_key(hash, "option", reg->option); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Regexp"); } else if (TYPE_match(node, LabelNode)) { LabelNode *label = dynamic_cast<LabelNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, label->tk); add_key(hash, "next", label->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Label"); } else if (TYPE_match(node, HandleNode)) { HandleNode *fh = dynamic_cast<HandleNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, fh->tk); add_key(hash, "expr", fh->expr); add_key(hash, "next", fh->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::Handle"); } else if (TYPE_match(node, HandleReadNode)) { HandleReadNode *fh = dynamic_cast<HandleReadNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, fh->tk); add_key(hash, "next", fh->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::HandleRead"); } else if (TYPE_match(node, ThreeTermOperatorNode)) { ThreeTermOperatorNode *term = dynamic_cast<ThreeTermOperatorNode *>(node); HV *hash = (HV*)new_Hash(); add_token(hash, term->tk); add_key(hash, "cond", term->cond); add_key(hash, "true_expr", term->true_expr); add_key(hash, "false_expr", term->false_expr); add_key(hash, "next", term->next); ret = bless(aTHX_ hash, "Compiler::Parser::Node::ThreeTermOperator"); } else { assert(0 && "node type is not found"); } return ret; }
static void append_common_pointer(pTHX_ HV *hash, Node *node) { (void)hv_stores(hash, "indent", set(new_Int(node->tk->finfo.indent))); add_key(hash, "next", node->next); add_token(hash, node->tk); }
static void xs_getaddrinfo(pTHX_ CV *cv) { dVAR; dXSARGS; SV *host; SV *service; SV *hints; char *hostname = NULL; char *servicename = NULL; STRLEN len; struct addrinfo hints_s; struct addrinfo *res; struct addrinfo *res_iter; int err; int n_res; if(items > 3) croak_xs_usage(cv, "host, service, hints"); SP -= items; if(items < 1) host = &PL_sv_undef; else host = ST(0); if(items < 2) service = &PL_sv_undef; else service = ST(1); if(items < 3) hints = NULL; else hints = ST(2); SvGETMAGIC(host); if(SvOK(host)) { hostname = SvPV_nomg(host, len); if (!len) hostname = NULL; } SvGETMAGIC(service); if(SvOK(service)) { servicename = SvPV_nomg(service, len); if (!len) servicename = NULL; } Zero(&hints_s, sizeof hints_s, char); hints_s.ai_family = PF_UNSPEC; if(hints && SvOK(hints)) { HV *hintshash; SV **valp; if(!SvROK(hints) || SvTYPE(SvRV(hints)) != SVt_PVHV) croak("hints is not a HASH reference"); hintshash = (HV*)SvRV(hints); if((valp = hv_fetch(hintshash, "flags", 5, 0)) != NULL) hints_s.ai_flags = SvIV(*valp); if((valp = hv_fetch(hintshash, "family", 6, 0)) != NULL) hints_s.ai_family = SvIV(*valp); if((valp = hv_fetch(hintshash, "socktype", 8, 0)) != NULL) hints_s.ai_socktype = SvIV(*valp); if((valp = hv_fetch(hintshash, "protocol", 8, 0)) != NULL) hints_s.ai_protocol = SvIV(*valp); } err = getaddrinfo(hostname, servicename, &hints_s, &res); XPUSHs(err_to_SV(aTHX_ err)); if(err) XSRETURN(1); n_res = 0; for(res_iter = res; res_iter; res_iter = res_iter->ai_next) { HV *res_hv = newHV(); (void)hv_stores(res_hv, "family", newSViv(res_iter->ai_family)); (void)hv_stores(res_hv, "socktype", newSViv(res_iter->ai_socktype)); (void)hv_stores(res_hv, "protocol", newSViv(res_iter->ai_protocol)); (void)hv_stores(res_hv, "addr", newSVpvn((char*)res_iter->ai_addr, res_iter->ai_addrlen)); if(res_iter->ai_canonname) (void)hv_stores(res_hv, "canonname", newSVpv(res_iter->ai_canonname, 0)); else (void)hv_stores(res_hv, "canonname", newSV(0)); XPUSHs(sv_2mortal(newRV_noinc((SV*)res_hv))); n_res++; } freeaddrinfo(res); XSRETURN(1 + n_res); }