コード例 #1
0
ファイル: test-domain-name.c プロジェクト: dsutto/DNSmezzo
int
main(int argc, char **argv)
{
    domainname      d1, d2;
    char           *data1, *data2, *data3, *data4;
    if (argc < 3) {
        printf("Usage: %s domainname domainname\n", argv[0]);
        return 1;
    }
    data1 = (char *) malloc(MAX_LENGTH);
    data2 = (char *) malloc(MAX_LENGTH);
    data3 = (char *) malloc(MAX_LENGTH);
    data4 = (char *) malloc(MAX_LENGTH);
    d1 = text_to_domain(argv[1]);
    if (!VALID(d1)) {
        printf("Invalid domain name \"%s\"\n", argv[1]);
        return 1;
    }
    d2 = text_to_domain(argv[2]);
    if (!VALID(d2)) {
        printf("Invalid domain name \"%s\"\n", argv[2]);
        return 1;
    }
    printf
        ("The canonical version of \"%s\" is \"%s\"; its TLD is \"%s\".\n\t**s registered domain is \"%s\", it has %i labels\n",
         orig_domain_name(data1, d1), domain_name(data2, d1), tld(data3, d1),
         registered_domain_name(data4, d1), (int) nlabels(d1));
    if (are_equal(d1, d2)) {
        printf("%s and %s are equivalent domain names\n", argv[1], argv[2]);
    } else {
        printf("%s and %s are NOT equivalent domain names\n", argv[1], argv[2]);
    }
    if (are_identical(d1, d2)) {
        printf("%s and %s are absolutely identical\n", argv[1], argv[2]);
    } else {
        printf("%s and %s are NOT absolutely identical\n", argv[1], argv[2]);
    }
    free(data1);
    free(data2);
    free(data3);
    free(data4);
    return 0;
}
コード例 #2
0
static struct symtab *
debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
			domain_enum domain)
{
  const struct debug_sym_fns_data *debug_data =
    objfile_data (objfile, symfile_debug_objfile_data_key);
  struct symtab *retval;

  fprintf_filtered (gdb_stdlog,
		    "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
		    debug_objfile_name (objfile), kind, name,
		    domain_name (domain));

  retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name,
						   domain);

  fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
		    retval ? debug_symtab_name (retval) : "NULL");

  return retval;
}
コード例 #3
0
void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
                                   const std::string &geom,
                                   std::string &buffer)
{
    for (const auto& place: places) {
        std::string name;
        if (place.key == "bridge" || place.key == "tunnel") {
            name = domain_name(place.key);
            if (name.empty())
                continue; // don't include unnamed bridges and tunnels
        }

        // osm_type
        buffer += osm_type;
        buffer += '\t';
        // osm_id
        buffer += (single_fmt % osm_id).str();
        // class
        escape(place.key, buffer);
        buffer += '\t';
        // type
        escape(place.value, buffer);
        buffer += '\t';
        // names
        if (!name.empty()) {
            buffer += name;
            buffer += '\t';
        } else if (!names.empty()) {
            bool first = true;
            // operator will be ignored on anything but these classes
            // (amenity for restaurant and fuel)
            bool shop = (place.key == "shop") ||
                        (place.key == "amenity") ||
                        (place.key == "tourism");
            for (const auto entry: names) {
                if (!shop && (entry->key == "operator"))
                    continue;

                if (first)
                    first = false;
                else
                    buffer += ',';

                buffer += "\"";
                escape_array_record(entry->key, buffer);
                buffer += "\"=>\"";
                escape_array_record(entry->value, buffer);
                buffer += "\"";
            }
            buffer += '\t';
        } else
            buffer += "\\N\t";
        // admin_level
        buffer += (single_fmt % admin_level).str();
        // house number
        buffer += housenumber;
        buffer += '\t';
        // street
        copy_opt_string(street, buffer);
        // addr_place
        copy_opt_string(addr_place, buffer);
        // isin
        if (!address.empty()) {
            for (const auto entry: address) {
                if (entry->key == "tiger:county") {
                    escape(std::string(entry->value, 0, entry->value.find(",")),
                           buffer);
                    buffer += " county";
                } else {
                    escape(entry->value, buffer);
                }
                buffer += ',';
            }
            buffer[buffer.length() - 1] = '\t';
        } else
            buffer += "\\N\t";
        // postcode
        copy_opt_string(postcode, buffer);
        // country code
        copy_opt_string(countrycode, buffer);
        // extra tags
        if (extratags.empty()) {
            buffer += "\\N\t";
        } else {
            bool first = true;
            for (const auto entry: extratags) {
                if (first)
                    first = false;
                else
                    buffer += ',';

                buffer += "\"";
                escape_array_record(entry->key, buffer);
                buffer += "\"=>\"";
                escape_array_record(entry->value, buffer);
                buffer += "\"";
            }
            buffer += "\t";
        }
        // geometry
        buffer += srid_str;
        buffer += geom;
        buffer += '\n';
    }
}
コード例 #4
0
ファイル: cp-namespace.c プロジェクト: eepp/binutils-gdb
struct block_symbol
cp_lookup_symbol_imports_or_template (const char *scope,
				      const char *name,
				      const struct block *block,
				      const domain_enum domain)
{
  struct symbol *function = BLOCK_FUNCTION (block);
  struct block_symbol result;

  if (symbol_lookup_debug)
    {
      fprintf_unfiltered (gdb_stdlog,
			  "cp_lookup_symbol_imports_or_template"
			  " (%s, %s, %s, %s)\n",
			  scope, name, host_address_to_string (block),
			  domain_name (domain));
    }

  if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
    {
      /* Search the function's template parameters.  */
      if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
	{
	  struct template_symbol *templ
	    = (struct template_symbol *) function;
	  struct symbol *sym = search_symbol_list (name,
						   templ->n_template_arguments,
						   templ->template_arguments);

	  if (sym != NULL)
	    {
	      if (symbol_lookup_debug)
		{
		  fprintf_unfiltered (gdb_stdlog,
				      "cp_lookup_symbol_imports_or_template"
				      " (...) = %s\n",
				      host_address_to_string (sym));
		}
	      return (struct block_symbol) {sym, block};
	    }
	}

      /* Search the template parameters of the function's defining
	 context.  */
      if (SYMBOL_NATURAL_NAME (function))
	{
	  struct type *context;
	  char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function));
	  struct cleanup *cleanups = make_cleanup (xfree, name_copy);
	  const struct language_defn *lang = language_def (language_cplus);
	  struct gdbarch *arch = symbol_arch (function);
	  const struct block *parent = BLOCK_SUPERBLOCK (block);
	  struct symbol *sym;

	  while (1)
	    {
	      unsigned int prefix_len = cp_entire_prefix_len (name_copy);

	      if (prefix_len == 0)
		context = NULL;
	      else
		{
		  name_copy[prefix_len] = '\0';
		  context = lookup_typename (lang, arch,
					     name_copy,
					     parent, 1);
		}

	      if (context == NULL)
		break;

	      sym
		= search_symbol_list (name,
				      TYPE_N_TEMPLATE_ARGUMENTS (context),
				      TYPE_TEMPLATE_ARGUMENTS (context));
	      if (sym != NULL)
		{
		  do_cleanups (cleanups);
		  if (symbol_lookup_debug)
		    {
		      fprintf_unfiltered
			(gdb_stdlog,
			 "cp_lookup_symbol_imports_or_template (...) = %s\n",
			 host_address_to_string (sym));
		    }
		  return (struct block_symbol) {sym, parent};
		}
	    }

	  do_cleanups (cleanups);
	}
    }