示例#1
0
/** load a msg entry */
static int
load_msg(SSL* ssl, ldns_buffer* buf, struct worker* worker)
{
	struct regional* region = worker->scratchpad;
	struct query_info qinf;
	struct reply_info rep;
	char* s = (char*)ldns_buffer_begin(buf);
	unsigned int flags, qdcount, ttl, security, an, ns, ar;
	size_t i;
	int go_on = 1;

	regional_free_all(region);

	if(strncmp(s, "msg ", 4) != 0) {
		log_warn("error expected msg but got %s", s);
		return 0;
	}
	s += 4;
	s = load_qinfo(s, &qinf, buf, region);
	if(!s) {
		return 0;
	}

	/* read remainder of line */
	if(sscanf(s, " %u %u %u %u %u %u %u", &flags, &qdcount, &ttl, 
		&security, &an, &ns, &ar) != 7) {
		log_warn("error cannot parse numbers: %s", s);
		return 0;
	}
	rep.flags = (uint16_t)flags;
	rep.qdcount = (uint16_t)qdcount;
	rep.ttl = (uint32_t)ttl;
	rep.prefetch_ttl = PREFETCH_TTL_CALC(rep.ttl);
	rep.security = (enum sec_status)security;
	rep.an_numrrsets = (size_t)an;
	rep.ns_numrrsets = (size_t)ns;
	rep.ar_numrrsets = (size_t)ar;
	rep.rrset_count = (size_t)an+(size_t)ns+(size_t)ar;
	rep.rrsets = (struct ub_packed_rrset_key**)regional_alloc_zero(
		region, sizeof(struct ub_packed_rrset_key*)*rep.rrset_count);

	/* fill repinfo with references */
	for(i=0; i<rep.rrset_count; i++) {
		if(!load_ref(ssl, buf, worker, region, &rep.rrsets[i], 
			&go_on)) {
			return 0;
		}
	}

	if(!go_on) 
		return 1; /* skip this one, not all references satisfied */

	if(!dns_cache_store(&worker->env, &qinf, &rep, 0, 0, 0, NULL)) {
		log_warn("error out of memory");
		return 0;
	}
	return 1;
}
示例#2
0
int
main (int    argc,
      char **argv)
{
  CallbackData  data;

  parse_args (&data, &argc, &argv);

  load_ref (&data);
  process_coords (&data);
  cleanup_data (&data);

  return 0;
}
示例#3
0
int
main (int    argc,
      char **argv)
{
  CallbackData  data;
  GError       *error = NULL;
  int           i;

  parse_args (&data, &argc, &argv);

  load_ref (&data);
  for (i = 1; i < argc; i++)
    {
      if (data.verbose)
        g_print (">>> Loading meth file: %s\n", argv[i]);
      ref_meth_counts_add_path (data.counts,
                                data.ref,
                                argv[i],
                                &error);
      if (error)
        {
          g_printerr ("[ERROR] failed to load meth file `%s': %s\n",
                      argv[i],
                      error->message);
          exit (1);
        }
    }
  if (data.verbose)
    g_print (">>> Writing meth file: %s\n", data.output_path);
  ref_meth_counts_write (data.counts,
                         data.ref,
                         data.output_path,
                         data.print_letter,
                         data.print_all,
                         &error);
  if (error)
    {
      g_printerr ("[ERROR] failed to write meth file `%s': %s\n",
                  data.output_path,
                  error->message);
      exit (1);
    }
  cleanup_data (&data);

  return 0;
}