static inline isc_result_t totext_rp(ARGS_TOTEXT) { isc_region_t region; dns_name_t rmail; dns_name_t email; dns_name_t prefix; isc_boolean_t sub; REQUIRE(rdata->type == dns_rdatatype_rp); REQUIRE(rdata->length != 0); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, ®ion); dns_name_fromregion(&rmail, ®ion); isc_region_consume(®ion, rmail.length); dns_name_fromregion(&email, ®ion); isc_region_consume(®ion, email.length); sub = name_prefix(&rmail, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); RETERR(str_totext(" ", target)); sub = name_prefix(&email, tctx->origin, &prefix); return (dns_name_totext(&prefix, sub, target)); }
static inline isc_result_t totext_ch_a(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; char buf[sizeof("0177777")]; isc_uint16_t addr; REQUIRE(rdata->type == 1); REQUIRE(rdata->rdclass == dns_rdataclass_ch); /* 3 */ REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, ®ion); dns_name_fromregion(&name, ®ion); isc_region_consume(®ion, name_length(&name)); addr = uint16_fromregion(®ion); sub = name_prefix(&name, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); sprintf(buf, "%o", addr); /* note octal */ RETERR(str_totext(" ", target)); return (str_totext(buf, target)); }
static inline isc_result_t totext_lp(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; char buf[sizeof("64000")]; unsigned short num; REQUIRE(rdata->type == dns_rdatatype_lp); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, ®ion); num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); sprintf(buf, "%u", num); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, tctx->origin, &prefix); return (dns_name_totext(&prefix, sub, target)); }
static inline isc_result_t totext_naptr(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; char buf[sizeof("64000")]; unsigned short num; REQUIRE(rdata->type == dns_rdatatype_naptr); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, ®ion); /* * Order. */ num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); sprintf(buf, "%u", num); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Preference. */ num = uint16_fromregion(®ion); isc_region_consume(®ion, 2); sprintf(buf, "%u", num); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Flags. */ RETERR(txt_totext(®ion, ISC_TRUE, target)); RETERR(str_totext(" ", target)); /* * Service. */ RETERR(txt_totext(®ion, ISC_TRUE, target)); RETERR(str_totext(" ", target)); /* * Regexp. */ RETERR(txt_totext(®ion, ISC_TRUE, target)); RETERR(str_totext(" ", target)); /* * Replacement. */ dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, tctx->origin, &prefix); return (dns_name_totext(&prefix, sub, target)); }
int main(int argc, char** argv) { MeshlessDataset* meshless_datasets; int number_of_meshless_datasets; std::string file_name("../data/cartwheel.sph"); std::string name_prefix("image_"); if(argc > 1) file_name = argv[1]; if(argc > 2) name_prefix = argv[2]; load_meshless_datasets_from_file(file_name.c_str(), &meshless_datasets, &number_of_meshless_datasets); shift_meshless_datasets(meshless_datasets, number_of_meshless_datasets, -5.0f,-5.0f,-5.0f); VisConfig* vis_config = vis_config_get_default(); float* h_image = new float[vis_config->_number_of_samples.x*vis_config->_number_of_samples.y]; float* rgb_image = new float[vis_config->_number_of_samples.x*vis_config->_number_of_samples.y*3]; for(unsigned int k = 0; k != number_of_meshless_datasets; ++k) { std::string name = name_prefix; if(k < 10) name += "0"; if(k < 100) name += "0"; std::stringstream k_ss; k_ss << k; name += k_ss.str(); name += ".jpg"; std::cout << name << std::endl; MeshlessDataset meshless_dataset = meshless_datasets[k]; vis_register_meshless_dataset(vis_config, &meshless_dataset); vis_fourier_volume_rendering(&meshless_dataset, vis_config); vis_unregister_meshless_dataset(vis_config, &meshless_dataset); vis_copy_to_host(vis_config, h_image); { // compute the maximum intensity float mmax = h_image[0]; for(unsigned int i = 0; i != vis_config->_number_of_samples.x * vis_config->_number_of_samples.y; ++i) { if(h_image[i] > mmax) mmax = h_image[i]; } //normalize with respect to the maximum intensity for(unsigned int i = 0; i != vis_config->_number_of_samples.x * vis_config->_number_of_samples.y; ++i) { if(h_image[i] < 0) h_image[i] = 0; rgb_image[3*i] = rgb_image[3*i+1] = rgb_image[3*i+2] = h_image[i]/mmax; } save_rgb_float_image_to_file(name.c_str(), rgb_image, vis_config->_number_of_samples.x, vis_config->_number_of_samples.y); } } delete[] rgb_image; delete[] h_image; vis_config_destroy(vis_config); delete_meshless_datasets(meshless_datasets, number_of_meshless_datasets); return 0; }
static inline isc_result_t totext_mf(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; REQUIRE(rdata->type == dns_rdatatype_mf); REQUIRE(rdata->length != 0); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, ®ion); dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, tctx->origin, &prefix); return (dns_name_totext(&prefix, sub, target)); }
static inline isc_result_t totext_tkey(ARGS_TOTEXT) { isc_region_t sr, dr; char buf[sizeof("4294967295 ")]; unsigned long n; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; REQUIRE(rdata->type == 249); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); /* * Algorithm. */ dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_name_fromregion(&name, &sr); sub = name_prefix(&name, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); RETERR(str_totext(" ", target)); isc_region_consume(&sr, name_length(&name)); /* * Inception. */ n = uint32_fromregion(&sr); isc_region_consume(&sr, 4); sprintf(buf, "%lu ", n); RETERR(str_totext(buf, target)); /* * Expiration. */ n = uint32_fromregion(&sr); isc_region_consume(&sr, 4); sprintf(buf, "%lu ", n); RETERR(str_totext(buf, target)); /* * Mode. */ n = uint16_fromregion(&sr); isc_region_consume(&sr, 2); sprintf(buf, "%lu ", n); RETERR(str_totext(buf, target)); /* * Error. */ n = uint16_fromregion(&sr); isc_region_consume(&sr, 2); if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS) RETERR(str_totext(" ", target)); else { sprintf(buf, "%lu ", n); RETERR(str_totext(buf, target)); } /* * Key Size. */ n = uint16_fromregion(&sr); isc_region_consume(&sr, 2); sprintf(buf, "%lu", n); RETERR(str_totext(buf, target)); /* * Key Data. */ REQUIRE(n <= sr.length); dr = sr; dr.length = n; if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" (", target)); RETERR(str_totext(tctx->linebreak, target)); RETERR(isc_base64_totext(&dr, tctx->width - 2, tctx->linebreak, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" ) ", target)); else RETERR(str_totext(" ", target)); isc_region_consume(&sr, n); /* * Other Size. */ n = uint16_fromregion(&sr); isc_region_consume(&sr, 2); sprintf(buf, "%lu", n); RETERR(str_totext(buf, target)); /* * Other Data. */ REQUIRE(n <= sr.length); if (n != 0U) { dr = sr; dr.length = n; if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" (", target)); RETERR(str_totext(tctx->linebreak, target)); RETERR(isc_base64_totext(&dr, tctx->width - 2, tctx->linebreak, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" )", target)); } return (ISC_R_SUCCESS); }
static inline isc_result_t totext_sig(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("4294967295")]; dns_rdatatype_t covered; unsigned long ttl; unsigned long when; unsigned long exp; unsigned long foot; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; REQUIRE(rdata->type == dns_rdatatype_sig); REQUIRE(rdata->length != 0); dns_rdata_toregion(rdata, &sr); /* * Type covered. */ covered = uint16_fromregion(&sr); isc_region_consume(&sr, 2); /* * XXXAG We should have something like dns_rdatatype_isknown() * that does the right thing with type 0. */ if (dns_rdatatype_isknown(covered) && covered != 0) { RETERR(dns_rdatatype_totext(covered, target)); } else { sprintf(buf, "%u", covered); RETERR(str_totext(buf, target)); } RETERR(str_totext(" ", target)); /* * Algorithm. */ sprintf(buf, "%u", sr.base[0]); isc_region_consume(&sr, 1); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Labels. */ sprintf(buf, "%u", sr.base[0]); isc_region_consume(&sr, 1); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Ttl. */ ttl = uint32_fromregion(&sr); isc_region_consume(&sr, 4); sprintf(buf, "%lu", ttl); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Sig exp. */ exp = uint32_fromregion(&sr); isc_region_consume(&sr, 4); RETERR(dns_time32_totext(exp, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" (", target)); RETERR(str_totext(tctx->linebreak, target)); /* * Time signed. */ when = uint32_fromregion(&sr); isc_region_consume(&sr, 4); RETERR(dns_time32_totext(when, target)); RETERR(str_totext(" ", target)); /* * Footprint. */ foot = uint16_fromregion(&sr); isc_region_consume(&sr, 2); sprintf(buf, "%lu", foot); RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); /* * Signer. */ dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); dns_name_fromregion(&name, &sr); isc_region_consume(&sr, name_length(&name)); sub = name_prefix(&name, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); /* * Sig. */ RETERR(str_totext(tctx->linebreak, target)); if (tctx->width == 0) /* No splitting */ RETERR(isc_base64_totext(&sr, 60, "", target)); else RETERR(isc_base64_totext(&sr, tctx->width - 2, tctx->linebreak, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" )", target)); return (ISC_R_SUCCESS); }
static inline isc_result_t totext_soa(ARGS_TOTEXT) { isc_region_t dregion; dns_name_t mname; dns_name_t rname; dns_name_t prefix; isc_boolean_t sub; int i; isc_boolean_t multiline; isc_boolean_t comment; REQUIRE(rdata->type == 6); REQUIRE(rdata->length != 0); multiline = ISC_TF((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0); if (multiline) comment = ISC_TF((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0); else comment = ISC_FALSE; dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, &dregion); dns_name_fromregion(&mname, &dregion); isc_region_consume(&dregion, name_length(&mname)); dns_name_fromregion(&rname, &dregion); isc_region_consume(&dregion, name_length(&rname)); sub = name_prefix(&mname, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); RETERR(str_totext(" ", target)); sub = name_prefix(&rname, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); if (multiline) RETERR(str_totext(" (" , target)); RETERR(str_totext(tctx->linebreak, target)); for (i = 0; i < 5; i++) { unsigned long num; unsigned int len = target->used; num = uint32_fromregion(&dregion); isc_region_consume(&dregion, 4); if (i >= 1 && (tctx->flags & DNS_STYLEFLAG_TTL_UNITS) != 0) { RETERR(dns_ttl_totext(num, ISC_FALSE, target)); } else { char buf[12]; sprintf(buf, "%lu", num); RETERR(str_totext(buf, target)); } if (comment) { len = target->used - len; INSIST(len <= 10); /* "0123456789 ; " */ RETERR(str_totext(len+" ; ", target)); RETERR(str_totext(soa_fieldnames[i], target)); /* Print times in week/day/hour/minute/second form */ if (i >= 1) { RETERR(str_totext(" (", target)); RETERR(dns_ttl_totext(num, ISC_TRUE, target)); RETERR(str_totext(")", target)); } RETERR(str_totext(tctx->linebreak, target)); } else if (i < 4) { RETERR(str_totext(tctx->linebreak, target)); } } if (multiline) RETERR(str_totext(")", target)); return (ISC_R_SUCCESS); }
static inline isc_result_t totext_soa(ARGS_TOTEXT) { isc_region_t dregion; dns_name_t mname; dns_name_t rname; dns_name_t prefix; isc_boolean_t sub; int i; isc_boolean_t multiline; isc_boolean_t comment; REQUIRE(rdata->type == 6); REQUIRE(rdata->length != 0); multiline = ISC_TF((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0); comment = ISC_TF((tctx->flags & DNS_STYLEFLAG_COMMENT) != 0); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); dns_name_init(&prefix, NULL); dns_rdata_toregion(rdata, &dregion); dns_name_fromregion(&mname, &dregion); isc_region_consume(&dregion, name_length(&mname)); dns_name_fromregion(&rname, &dregion); isc_region_consume(&dregion, name_length(&rname)); sub = name_prefix(&mname, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); RETERR(str_totext(" ", target)); sub = name_prefix(&rname, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); if (multiline) RETERR(str_totext(" (" , target)); RETERR(str_totext(tctx->linebreak, target)); for (i = 0; i < 5; i++) { char buf[sizeof("2147483647")]; unsigned long num; int numlen; num = uint32_fromregion(&dregion); isc_region_consume(&dregion, 4); numlen = snprintf(buf, sizeof(buf), "%lu", num); INSIST(numlen != -1 && (size_t)numlen < sizeof(buf)); RETERR(str_totext(buf, target)); if (multiline && comment) { RETERR(str_totext(" ; " + (unsigned int)numlen, target)); RETERR(str_totext(soa_fieldnames[i], target)); /* Print times in week/day/hour/minute/second form */ if (i >= 1) { RETERR(str_totext(" (", target)); RETERR(dns_ttl_totext(num, ISC_TRUE, target)); RETERR(str_totext(")", target)); } RETERR(str_totext(tctx->linebreak, target)); } else if (i < 4) { RETERR(str_totext(tctx->linebreak, target)); } } if (multiline) RETERR(str_totext(")", target)); return (ISC_R_SUCCESS); }
static inline isc_result_t totext_ipseckey(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; dns_name_t prefix; isc_boolean_t sub; char buf[sizeof("255 ")]; unsigned short num; unsigned short gateway; REQUIRE(rdata->type == 45); REQUIRE(rdata->length >= 3); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); if (rdata->data[1] > 3U) return (ISC_R_NOTIMPLEMENTED); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext("( ", target)); /* * Precedence. */ dns_rdata_toregion(rdata, ®ion); num = uint8_fromregion(®ion); isc_region_consume(®ion, 1); sprintf(buf, "%u ", num); RETERR(str_totext(buf, target)); /* * Gateway type. */ gateway = uint8_fromregion(®ion); isc_region_consume(®ion, 1); sprintf(buf, "%u ", gateway); RETERR(str_totext(buf, target)); /* * Algorithm. */ num = uint8_fromregion(®ion); isc_region_consume(®ion, 1); sprintf(buf, "%u ", num); RETERR(str_totext(buf, target)); /* * Gateway. */ switch (gateway) { case 0: RETERR(str_totext(".", target)); break; case 1: RETERR(inet_totext(AF_INET, ®ion, target)); isc_region_consume(®ion, 4); break; case 2: RETERR(inet_totext(AF_INET6, ®ion, target)); isc_region_consume(®ion, 16); break; case 3: dns_name_fromregion(&name, ®ion); sub = name_prefix(&name, tctx->origin, &prefix); RETERR(dns_name_totext(&prefix, sub, target)); isc_region_consume(®ion, name_length(&name)); break; } /* * Key. */ if (region.length > 0U) { RETERR(str_totext(tctx->linebreak, target)); RETERR(isc_base64_totext(®ion, tctx->width - 2, tctx->linebreak, target)); } if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) RETERR(str_totext(" )", target)); return (ISC_R_SUCCESS); }