Example #1
0
string f$dirname (const string &name) {
  string name_copy (name.c_str(), name.size());
  dl::enter_critical_section();//OK
  const char *result_c_str = dirname (name_copy.buffer());
  dl::leave_critical_section();
  return string (result_c_str, (dl::size_type)strlen (result_c_str));;
}
Example #2
0
string f$basename (const string &name, const string &suffix) {
  string name_copy (name.c_str(), name.size());
  dl::enter_critical_section();//OK
  const char *result_c_str = __xpg_basename (name_copy.buffer());
  dl::leave_critical_section();
  int l = (int)strlen (result_c_str);
  if ((int)suffix.size() <= l && !strcmp (result_c_str + l - suffix.size(), suffix.c_str())) {
    l -= suffix.size();
  }
  return string (result_c_str, (dl::size_type)l);
}
Example #3
0
asset* new_asset(asset_file_builder* afb, u32 code, const char* name) {
	asset_bank* b = get_bank(afb, code);
	asset* a = b->assets.push_back(new asset);

	if (!a)
		panic("new_asset: out of memory");

	name_copy(a->name, name);

	return a;
}
Example #4
0
mapnik::keys get_key(std::string const& name)
{
    std::string name_copy(name);
    boost::algorithm::replace_all(name_copy,"_","-");
    for (unsigned i=0; i< const_max_key ; ++i)
    {
        property_meta_type const& item = key_meta[i];
        if (name_copy == std::get<0>(item))
        {
            return static_cast<mapnik::keys>(i);
        }
    }
    throw std::runtime_error("no key found for '" + name + "'");
    return static_cast<mapnik::keys>(0);
}
Example #5
0
static void
parse_query(DNS_query *query, DNS_rr *rr)
{
	long offset;
	unsigned char *ptr;

	ptr = query->packet.data;

	rr->name_length = name_copy(&query->packet, ptr, &ptr, rr->name, sizeof (rr->name));

	rr->type = networkGetShort(ptr);
	ptr += NET_SHORT_SIZE;

	rr->data_length = 0;

	if (0 < debug)
		syslog(LOG_DEBUG, "query %d %lu:%s", rr->type, (unsigned long) rr->name_length, rr->name);

	if (0 <= (offset = TextInsensitiveEndsWith((char *) rr->name, domain_suffix))) {
		rr->name_length = offset;
		rr->name[offset] = '\0';
	}
}
OP_STATUS
OpScopeCookieManager::DoRemoveCookie(const RemoveCookieArg &in)
{
	OpString in_domain;
	RETURN_IF_ERROR(in_domain.Set(in.GetDomain()));
	RETURN_IF_ERROR(Cookie_Manager::CheckLocalNetworkAndAppendDomain(in_domain));

	// we need non-const strings for the URL API
	uni_char *domain = NULL;
	OpAutoArray<uni_char> domain_copy( OP_NEWA(uni_char, in_domain.Length() + 1) );
	{
		RETURN_OOM_IF_NULL(domain_copy.get());
		uni_strcpy(domain_copy.get(), in_domain.CStr());
		domain = domain_copy.get();
	}
	uni_char *path = NULL;
	OpAutoArray<uni_char> path_copy( in.HasPath() ? OP_NEWA(uni_char, in.GetPath().Length() + 1) : NULL );
	if (in.HasPath())
	{
		RETURN_OOM_IF_NULL(path_copy.get());
		uni_strcpy(path_copy.get(), in.GetPath().CStr());
		path = path_copy.get();
	}
	uni_char *name = NULL;
	OpAutoArray<uni_char> name_copy( in.HasName() ? OP_NEWA(uni_char, in.GetName().Length() + 1) : NULL );
	if (in.HasName())
	{
		RETURN_OOM_IF_NULL(name_copy.get());
		uni_strcpy(name_copy.get(), in.GetName().CStr());
		name = name_copy.get();
	}

	OP_STATUS status = g_url_api->RemoveCookieList(domain, path, name);
	if (OpStatus::IsError(status))
		return SetCommandError(OpScopeTPHeader::BadRequest, UNI_L("Failure while removing cookies for specified domain, path and name"));
	return OpStatus::OK;
}