Example #1
0
inline String argumentSignature(const ArgumentParser::Argument & _arg)
{
    String ret;

    if (_arg.argCount)
    {
        String upper = detail::stripName(_arg.identifier()).toUpper();
        ret.append(" ");
        if (_arg.argCount == '*')
        {
            ret.append("...");
        }
        else if (_arg.argCount == '+')
        {
            ret.append(AppendVariadicFlag(), upper, " ...");
        }
        else
        {
            for (Size i = 0; i < _arg.argCount; ++i)
            {
                if (i < (Size)_arg.argCount - 1)
                    ret.append(AppendVariadicFlag(), upper, " ");
                else
                    ret.append(upper);
            }
        }
    }

    return ret;
}
PassRefPtr<InspectorObject> InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo& resourceInfo)
{
    RefPtr<InspectorObject> value = InspectorObject::create();
    value->setString("name", resourceInfo.m_resource.string());
    value->setNumber("size", resourceInfo.m_size);

    String types;
    if (resourceInfo.m_isMaster)
        types.append("Master ");

    if (resourceInfo.m_isManifest)
        types.append("Manifest ");

    if (resourceInfo.m_isFallback)
        types.append("Fallback ");

    if (resourceInfo.m_isForeign)
        types.append("Foreign ");

    if (resourceInfo.m_isExplicit)
        types.append("Explicit ");

    value->setString("type", types);
    return value;
}
void UNIX_BGPEndpointStatisticsProvider::invokeMethod(
	const OperationContext& context,
	const CIMObjectPath& objectReference,
	const CIMName& methodName,
	const Array<CIMParamValue>& inParameters,
	MethodResultResponseHandler& handler)
{
	if (!objectReference.getClassName().equal("UNIX_BGPEndpointStatistics") && !objectReference.getClassName().equal("CIM_BGPEndpointStatistics")) {
		String classMessage;
		classMessage.append("UNIX_BGPEndpointStatistics Provider");
		classMessage.append (" does not support class ");
		classMessage.append (objectReference.getClassName().getString());
		throw CIMNotSupportedException(classMessage);
	}


	handler.processing();
	// Make cimom handle invokeMethod request with input parameters.
	CIMObjectPath localReference = CIMObjectPath(
		String(""),
		CIMNamespaceName("root/cimv2"),
		objectReference.getClassName(),
		objectReference.getKeyBindings());
	
	if (methodName.equal("ResetSelectedStats")) {

		if (inParameters.size() != 1)
		{
			throw new CIMOperationFailedException("Incorrect in parameters");
		}
		
		//Invoking ResetSelectedStats method.
		Uint32 invokeResetSelectedStatsReturnValue;

		Array<String> inSelectedStatistics;
		
		for(Uint32 pi = 0; pi < inParameters.size(); pi++) {
			CIMParamValue p = inParameters[pi];
			if (String::equalNoCase(p.getParameterName(), "SelectedStatistics"))
			{
				p.getValue().get(inSelectedStatistics);
			}
		}
		_p.initialize();
		_p.find(localReference.getKeyBindings());
		invokeResetSelectedStatsReturnValue = _p.invokeResetSelectedStats(

			inSelectedStatistics
		);
		_p.finalize();
		handler.deliver(invokeResetSelectedStatsReturnValue);

	}
	else {
		String message;
		message.append("UNIX_BGPEndpointStatistics");
		message.append (" does not support invokeMethod");
		throw CIMNotSupportedException(message);
	}
}
Example #4
0
    //---------------------------------
    String Utils::checkNCName ( const String &ncName )
    {
        String result;
        result.reserve ( ncName.length() );

        // check if first character is an alpha character
        char firstCharacter = ncName[0];

        if ( isAsciiAlphaChar ( firstCharacter )  )
            result.append ( 1, firstCharacter );
        else
            result.append ( 1, '_' );

        //replace all spaces and colons by underlines
        for ( size_t i = 1; i<ncName.length(); ++i )
        {
            char character = ncName[i];

            if ( isIDChar ( character ) )
                result.append ( 1, character );
            else
                result.append ( 1, '_' );
        }

        return result;
    }
Example #5
0
bool CurlCacheEntry::saveResponseHeaders(const ResourceResponse& response)
{
    PlatformFileHandle headerFile = openFile(m_headerFilename, OpenForWrite);
    if (!isHandleValid(headerFile)) {
        LOG(Network, "Cache Error: Could not open %s for write\n", m_headerFilename.latin1().data());
        return false;
    }

    // Headers
    HTTPHeaderMap::const_iterator it = response.httpHeaderFields().begin();
    HTTPHeaderMap::const_iterator end = response.httpHeaderFields().end();
    while (it != end) {
        String headerField = it->key;
        headerField.append(": ");
        headerField.append(it->value);
        headerField.append("\n");
        CString headerFieldLatin1 = headerField.latin1();
        writeToFile(headerFile, headerFieldLatin1.data(), headerFieldLatin1.length());
        m_cachedResponse.setHTTPHeaderField(it->key, it->value);
        ++it;
    }

    closeFile(headerFile);
    return true;
}
Example #6
0
void
DropHelper::writeToDir(const String& destination, DragFileList& fileList, String& data)
{
    LOG((CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), destination.c_str()));

    if (!destination.empty() && !fileList.empty()) {
        std::fstream file;
        String dropTarget = destination;
#ifdef SYSAPI_WIN32
        dropTarget.append("\\");
#else
        dropTarget.append("/");
#endif
        dropTarget.append(fileList.at(0).getFilename());
        file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
        if (!file.is_open()) {
            LOG((CLOG_ERR "drop file failed: can not open %s", dropTarget.c_str()));
        }
        
        file.write(data.c_str(), data.size());
        file.close();

        LOG((CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), destination.c_str()));

        fileList.clear();
    }
    else {
        LOG((CLOG_ERR "drop file failed: drop target is empty"));
    }
}
Example #7
0
int String::nextToken(const char* szSep, String& sPart)
{
  if (empty()) { return 0; } // do nothing

  int bFound = 0;

  const char* pSep = findChar(szSep);
  if (pSep != 0) {
    sPart.append(szStr_, pSep - szStr_, 1);
    String sRemain;
    sRemain.append(pSep, nBytes_ - (pSep - szStr_));
    const char* pNext = sRemain.findNotChar(szSep);
    if (pNext == 0) {
      clear();
    } else {
      append(pNext, sRemain.bytes() - (pNext - sRemain.c_str()), 1);
    }
    bFound = 1;
  } else {
    if (nBytes_ > 0) {
      sPart = szStr_;
      clear();
      bFound = 1;
    } else {
      sPart.clear();
    }
  }

  return bFound;
}
Example #8
0
String Socket::getErrorString(){
	int code = WSAGetLastError();
	TCHAR* errString = NULL;

	int size = FormatMessage(	FORMAT_MESSAGE_ALLOCATE_BUFFER |
							FORMAT_MESSAGE_FROM_SYSTEM,
								0,
								code,
								0,
								(LPTSTR)&errString,
								0,
								0 );

	DWORD c = GetLastError();

	String s;
	TCHAR codeStr[512];
	wsprintf(codeStr, TEXT("[%d]"), code);
	s.append(codeStr);


	TCHAR b[2] = {' ', 0};

	LPTSTR p = errString ;
	while(*p){
		b[0] = (TCHAR)*p;
		s.append(b);
		p++;
	}

	LocalFree( errString );

	return s;
}
Boolean FileSystem::existsNoCase(const String& path, String& realPath)
{
#if !defined(PEGASUS_OS_VMS) && \
    !defined(PEGASUS_OS_TYPE_WINDOWS) && \
    !defined(PEGASUS_OS_DARWIN)

    // If a file exists that has the same case as the path parmater,
    // then we can bypass the expensive directory scanning below.

    if (FileSystem::exists(path))
    {
        realPath = path;
        return true;
    }

#endif

    realPath.clear();
    CString cpath = _clonePath(path);
    const char* p = cpath;

    const char* dirPath;
    const char* fileName;
    char* slash = (char *) strrchr(p, '/');

    if (slash)
    {
        *slash = '\0';
        fileName = slash + 1;
        dirPath = p;

        if (*fileName == '\0')
            return false;
    }
    else
    {
        fileName = p;
        dirPath = ".";
    }


    for (Dir dir(dirPath); dir.more(); dir.next())
    {
        if (System::strcasecmp(fileName, dir.getName()) == 0)
        {
            if (strcmp(dirPath, ".") == 0)
                realPath = dir.getName();
            else
            {
                realPath = dirPath;
                realPath.append('/');
                realPath.append(dir.getName());
            }
            return true;
        }
    }

    return false;
}
String UNIX_BIOSFeature::getName() const
{
	String s;
	s.append(getVendor());
	s.append(" ");
	s.append(getVersion());
	return s;
}
Example #11
0
String Metric::toString()
{
  String ts;

  if ( metricUnit ) ts.append( metricUnit->toString() );

  ts.append( uuidToWide(metricUUID) );

  return ts;
}
// =============================================================================
// NAME              : createInstance
// DESCRIPTION       : Create a UnixProcess instance.
// ASSUMPTIONS       : None
// PRE-CONDITIONS    :
// POST-CONDITIONS   :
// NOTES             : Currently not supported.
// PARAMETERS        :
// =============================================================================
void UNIX_PROVIDER::deleteInstance(
    const OperationContext& context,
    const CIMObjectPath& ref,
    ResponseHandler& handler)
{
    String message;
    message.append(_getClassName());
    message.append(" does not support deleteInstance");
    throw CIMNotSupportedException(message);
}
Example #13
0
String ArgumentParser::usage() const
{
    String ret = String::concat("Usage:\n./", m_applicationName, " ");
    for (auto & arg : m_args)
    {
        ret.append(
            AppendVariadicFlag(), "[", arg.identifier(), detail::argumentSignature(arg), "] ");
    }
    ret.append("\n");
    return ret;
}
Example #14
0
Vector<String> PluginDatabase::defaultPluginDirectories()
{
    Vector<String> paths;

    // Add paths specific to each platform
#if defined(XP_UNIX)
    String userPluginPath = homeDirectoryPath();
    userPluginPath.append(String("/.mozilla/plugins"));
    paths.append(userPluginPath);

    userPluginPath = homeDirectoryPath();
    userPluginPath.append(String("/.netscape/plugins"));
    paths.append(userPluginPath);

    paths.append("/usr/lib/browser/plugins");
    paths.append("/usr/local/lib/mozilla/plugins");
    paths.append("/usr/lib/firefox/plugins");
    paths.append("/usr/lib64/browser-plugins");
    paths.append("/usr/lib/browser-plugins");
    paths.append("/usr/lib/mozilla/plugins");
    paths.append("/usr/local/netscape/plugins");
    paths.append("/opt/mozilla/plugins");
    paths.append("/opt/mozilla/lib/plugins");
    paths.append("/opt/netscape/plugins");
    paths.append("/opt/netscape/communicator/plugins");
    paths.append("/usr/lib/netscape/plugins");
    paths.append("/usr/lib/netscape/plugins-libc5");
    paths.append("/usr/lib/netscape/plugins-libc6");
    paths.append("/usr/lib64/netscape/plugins");
    paths.append("/usr/lib64/mozilla/plugins");
    paths.append("/usr/lib/nsbrowser/plugins");
    paths.append("/usr/lib64/nsbrowser/plugins");

    String mozHome(getenv("MOZILLA_HOME"));
    mozHome.append("/plugins");
    paths.append(mozHome);

    Vector<String> mozPaths;
    String mozPath(getenv("MOZ_PLUGIN_PATH"));
    mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths);
    paths.appendVector(mozPaths);
#elif defined(XP_MACOSX)
    String userPluginPath = homeDirectoryPath();
    userPluginPath.append(String("/Library/Internet Plug-Ins"));
    paths.append(userPluginPath);
    paths.append("/Library/Internet Plug-Ins");
#elif defined(XP_WIN)
    String userPluginPath = homeDirectoryPath();
    userPluginPath.append(String("\\Application Data\\Mozilla\\plugins"));
    paths.append(userPluginPath);
#endif

    return paths;
}
Example #15
0
String StructInfo::toString() const {
    String ret = "Struct(";
    ret.append(name);
    ret.append(") {\n");
    for (const FieldInfo& info : fields) {
        ret.append(info.toString());
        ret.append("\n");
    }
    ret.append("}");
    return ret;
}
Example #16
0
bool Path::mksubdir(const String &path) const
{
    if (isDir()) {
        String combined = *this;
        if (!combined.endsWith('/'))
            combined.append('/');
        combined.append(path);
        return Path::mkdir(combined);
    }
    return false;
}
 void completeWithError(WebContentDecryptionModuleException code, unsigned long systemCode, const WebString& message) override
 {
     // Non-zero |systemCode| is appended to the |message|. If the |message|
     // is empty, we'll report "Rejected with system code (systemCode)".
     String errorString = message;
     if (systemCode != 0) {
         if (errorString.isEmpty())
             errorString.append("Rejected with system code");
         errorString.append(" (" + String::number(systemCode) + ")");
     }
     (*m_failureCallback)(WebCdmExceptionToExceptionCode(code), errorString);
 }
void UNIX_PROVIDER::invokeMethod(
    const OperationContext& context,
    const CIMObjectPath& objectReference,
    const CIMName& methodName,
    const Array<CIMParamValue>& inParameters,
    MethodResultResponseHandler& handler)
{
    String message;
    message.append(_getClassName());
    message.append(" does not support invokeMethod");
    throw CIMNotSupportedException(message);
}
void ContentDecryptionModuleResultPromise::completeWithError(WebContentDecryptionModuleException exceptionCode, unsigned long systemCode, const WebString& errorMessage)
{
    // Non-zero |systemCode| is appended to the |errorMessage|. If the
    // |errorMessage| is empty, we'll report "Rejected with system code
    // (systemCode)".
    String errorString = errorMessage;
    if (systemCode != 0) {
        if (errorString.isEmpty())
            errorString.append("Rejected with system code");
        errorString.append(" (" + String::number(systemCode) + ")");
    }
    reject(WebCdmExceptionToExceptionCode(exceptionCode), errorString);
}
Example #20
0
// Create deformed PDB =====================================================
FileName ProgNmaAlignment::createDeformedPDB(int pyramidLevel) const {
	String program;
	String arguments;
	FileName fnRandom;
	fnRandom.initUniqueName(nameTemplate,fnOutDir);
	const char * randStr = fnRandom.c_str();

	program = "xmipp_pdb_nma_deform";
	arguments = formatString(
			"--pdb %s -o %s_deformedPDB.pdb --nma %s --deformations ",
			fnPDB.c_str(), randStr, fnModeList.c_str());
	for (size_t i = 0; i < VEC_XSIZE(trial) - 5; ++i)
		arguments += floatToString(trial(i)) + " ";
	runSystem(program, arguments, false);

	program = "xmipp_volume_from_pdb";
	arguments = formatString(
			"-i %s_deformedPDB.pdb --size %i --sampling %f -v 0", randStr,
			imgSize, sampling_rate);

	if (do_centerPDB)
		arguments.append(" --centerPDB ");

	if (useFixedGaussian) {
		arguments.append(" --intensityColumn Bfactor --fixed_Gaussian ");
		if (sigmaGaussian >= 0)
			arguments += formatString("%f",sigmaGaussian);
	}
	//else
		//arguments +=" --poor_Gaussian"; // Otherwise, a detailed conversion of the atoms takes too long in this context
		
	progVolumeFromPDB->read(arguments);
	progVolumeFromPDB->tryRun();

	if (do_FilterPDBVol) {
		program = "xmipp_transform_filter";
		arguments = formatString(
						"-i %s_deformedPDB.vol --sampling %f --fourier low_pass %f  -v 0",
						randStr, sampling_rate, cutoff_LPfilter);
		runSystem(program, arguments, false);
	}

	if (pyramidLevel != 0) {
		Image<double> I;
		FileName fnDeformed = formatString("%s_deformedPDB.vol",randStr);
		I.read(fnDeformed);
		selfPyramidReduce(BSPLINE3, I(), pyramidLevel);
		I.write(fnDeformed);
	}
	return fnRandom;
}
/*
================================================================================
NAME              : modifyInstance
DESCRIPTION       : Modify a UnixProcess instance.
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             : Currently not supported.
PARAMETERS        :
================================================================================
*/
void UNIX_PROVIDER::modifyInstance(
    const OperationContext& context,
    const CIMObjectPath& ref,
    const CIMInstance& instanceObject,
    const Boolean includeQualifiers,
    const CIMPropertyList& propertyList,
    ResponseHandler& handler)
{

    String message;
    message.append(_getClassName());
    message.append(" does not support modifyInstance");
    throw CIMNotSupportedException(message);
}
Example #22
0
static String createSearchRegexSource(const String& text)
{
    String result;
    const UChar* characters = text.characters();
    String specials(regexSpecialCharacters);

    for (unsigned i = 0; i < text.length(); i++) {
        if (specials.find(characters[i]) != notFound)
            result.append("\\");
        result.append(characters[i]);
    }

    return result;
}
Example #23
0
bool PluginDatabase::isPreferredPluginDirectory(const String& path)
{
    String preferredPath = homeDirectoryPath();

#if defined(XP_UNIX)
    preferredPath.append(String("/.mozilla/plugins"));
#elif defined(XP_MACOSX)
    preferredPath.append(String("/Library/Internet Plug-Ins"));
#elif defined(XP_WIN)
    preferredPath.append(String("\\Application Data\\Mozilla\\plugins"));
#endif

    // TODO: We should normalize the path before doing a comparison.
    return path == preferredPath;
}
Example #24
0
String IDBIndexInfo::loggingString(int indent) const
{
    String indentString;
    for (int i = 0; i < indent; ++i)
        indentString.append(" ");
    return makeString(indentString, "Index: ", m_name, " (", m_identifier, ") keyPath: ", WebCore::loggingString(m_keyPath), '\n');
}
Example #25
0
template<class String> inline
void append_string(String& dst, const String& src,
                   const typename String::size_type beg,
                   const typename String::size_type end) 
   {
     dst.append(src.begin()+beg, src.begin()+end);
   }
ContentData* RenderStyle::prepareToSetContent(StringImpl* string, bool add)
{
    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
    ContentData* lastContent = content.get();
    while (lastContent && lastContent->next())
        lastContent = lastContent->next();

    if (string && add && lastContent && lastContent->isText()) {
        // Augment the existing string and share the existing ContentData node.
        String newText = lastContent->text();
        newText.append(string);
        lastContent->setText(newText.impl());
        return 0;
    }

    bool reuseContent = !add;
    OwnPtr<ContentData> newContentData;
    if (reuseContent && content) {
        content->clear();
        newContentData = content.release();
    } else
        newContentData = adoptPtr(new ContentData);

    ContentData* result = newContentData.get();

    if (lastContent && !reuseContent)
        lastContent->setNext(newContentData.release());
    else
        content = newContentData.release();

    return result;
}
static String trimInputSample(const char* p, size_t len)
{
    String s = String(p, std::min<size_t>(len, maxInputSampleSize));
    if (len > maxInputSampleSize)
        s.append(horizontalEllipsis);
    return s;
}
void Document::loadFileToString( const String& file_name_, String &buffer_ )
{
	FRL_EXCEPT_GUARD();
	if( ! fs::exists( file_name_ ) )
		FRL_THROW_S_CLASS( Document::FileNotFound );
	size_t length = static_cast< size_t >( fs::file_size( file_name_ ) );
	if( length == 0 )
		FRL_THROW_S_CLASS( Document::EmptyFile );
	if( ! buffer_.empty() )
		buffer_.clear();

	static const size_t buffer_size = 4096;
	stream_std::InFile in( file_name_.c_str(), std::ios::binary );
	if( ! in.is_open() )
		FRL_THROW_S_CLASS( Document::UnknownError );
	std::vector< Char > buf( buffer_size );

	buffer_.reserve( length );
	while( in )
	{
		in.read( &buf[ 0 ], buffer_size );
		buffer_.append( &buf[ 0 ], in.gcount() );
	}
	in.close();
}
void RequestTest::onBodyFrag( const char *data, size_t size )
{
  _body.append( String( data, size ) );

  if ( _body.size() >= _size )
    AppLoop::exit(0);
}
Example #30
0
	void buildOutput()
	{
		// sort replacements in order of occurrence
		std::sort(replacements.begin(), replacements.end());
		String::size_type cur = start;
		for (vector<ReplacementMark>::type::iterator it = replacements.begin(); it != replacements.end(); ++it)
		{
			ReplacementMark& mark = *it;
			if (mark.pos > cur)
				output.append(source, cur, mark.pos-cur);
			output.append(mark.replaceWith);
			cur = mark.pos+mark.len;
		}
		if (cur < source.size())
			output.append(source, cur, String::npos);
	}