Пример #1
0
static const char *
mimeTypeGuessFromFile(MIMEType *   const MIMETypeP,
                      const char * const fileName) {

    const char * retval;
    const char * ext;

    findExtension(fileName, &ext);

    retval = NULL;

    if (ext && MIMETypeP)
        retval = MIMETypeFromExt2(MIMETypeP, ext);


    if (!retval) {
        if (fileContainsText(fileName))
            retval = "text/plain";
        else
            retval = "application/octet-stream";  
    }

	if (!strcmp(retval, "text/plain"))
		retval = "text/plain; charset=utf-8";
    return retval;
}
Пример #2
0
LPTSTR
TSHPath::FindExtension(LPCTSTR pszPath)
{
  static TModuleProc1<LPTSTR,LPCTSTR>
         findExtension(GetModule(), FindExtensionStr);
  return findExtension(pszPath);
}
Пример #3
0
FileAdapter::OutputTables
FileAdapter::readFile(const std::string& fileName) {
    auto extension = findExtension(fileName);
    auto data_adapter = createAdapter(extension);
    auto& file_adapter = static_cast<FileAdapter&>(*data_adapter);
    return file_adapter.extendRead(fileName);
}
Пример #4
0
void 
FileAdapter::writeFile(const InputTables& tables, 
                       const std::string& fileName) {
    auto extension = findExtension(fileName);
    auto data_adapter = createAdapter(extension);
    auto& file_adapter = static_cast<FileAdapter&>(*data_adapter);
    file_adapter.extendWrite(tables, fileName);
}
Пример #5
0
	bool checkAvailable(const char* extension)
	{
		// Check windows extensions
		if(wglGetExtensionsStringARB == 0)
		{
			wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");

			HWND hWnd = GetActiveWindow();
			HDC hDC = GetDC(hWnd);
			wext = wglGetExtensionsStringARB(hDC);
		}

		if(findExtension(extension, (char*)glGetString(GL_EXTENSIONS)))
			return true;

		if (findExtension(extension, (char*)wext))
			return true;

		return false;
	}
Пример #6
0
bool asnCertificate::checkKeyUsage(string id) {
	asnObject * ext = findExtension(idExtKeyUsage);
	if (!ext) return false;
	asnObject decode(ext->body_start,ext->stop,0,bout);
	if (decode.tag!=SEQUENCE)
		throw asn_error("invalid ExtKeyUsage");
	for(size_t i=0; i < decode.contents.size(); i++) {
		string comp = getAlgid(decode.contents[i]);
		if (comp == id ) return true;
		}
	return false;
	}
Пример #7
0
string asnCertificate::getSubjectAltName() {
	asnObject * ext = findExtension(idSubjectAltName);
	if (!ext)
        return "";
	asnObject decode(ext->body_start,ext->stop,0,bout);
	if (decode.tag!=SEQUENCE)
		throw asn_error("invalid altName");
	std::string ret;
	for(size_t i=0; i < decode.contents.size(); i++) {
		ret.resize(ret.size()+ decode.contents[i]->size);
		copy(decode.contents[i]->body_start,decode.contents[i]->stop,
			ret.begin());
		}
	return ret;
	}
static const char *
mimeTypeFromFileName(MIMEType *   const MIMETypeP,
                     const char * const fileName) {

    const char * retval;
    const char * ext;

    assert(MIMETypeP != NULL);
    
    findExtension(fileName, &ext);

    if (ext)
        retval = MIMETypeFromExt2(MIMETypeP, ext);
    else
        retval = "application/octet-stream";

    return retval;
}
Пример #9
0
CString Utils::getFileName(const std::vector<CString>& filter, int& typeIndex, CString fileName)
{
	const int index = (typeIndex - 1) * 2 + 1;

	const CString strExtension(GetExtension(fileName));
	const int extensionIndex = findExtension(filter, strExtension);

	if (index < filter.size())
	{
		if (extensionIndex == -1)
		{
			setExtension(fileName, GetExtension(filter[index]));
		}
		else if (!IsExtension(filter[index], strExtension))
		{
			typeIndex = extensionIndex / 2 + 1;
		}
	}

	return fileName;
}
Пример #10
0
bool asnCertificate::hasExtKeyUsage() {
	return (0!=findExtension(idExtKeyUsage));
	}
Пример #11
0
bool egl_display_t::haveExtension(const char* name, size_t nameLen) const {
    if (!nameLen) {
        nameLen = strlen(name);
    }
    return findExtension(mExtensionString.string(), name, nameLen);
}
Пример #12
0
EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {

    Mutex::Autolock _l(lock);

    if (refs > 0) {
        if (major != NULL)
            *major = VERSION_MAJOR;
        if (minor != NULL)
            *minor = VERSION_MINOR;
        refs++;
        return EGL_TRUE;
    }

#if EGL_TRACE

    // Called both at early_init time and at this time. (Early_init is pre-zygote, so
    // the information from that call may be stale.)
    initEglTraceLevel();
    initEglDebugLevel();

#endif

    setGLHooksThreadSpecific(&gHooksNoContext);

    // initialize each EGL and
    // build our own extension string first, based on the extension we know
    // and the extension supported by our client implementation

    egl_connection_t* const cnx = &gEGLImpl;
    cnx->major = -1;
    cnx->minor = -1;
    if (cnx->dso) {
        EGLDisplay idpy = disp.dpy;
        if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
            //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
            //        idpy, cnx->major, cnx->minor, cnx);

            // display is now initialized
            disp.state = egl_display_t::INITIALIZED;

            // get the query-strings for this display for each implementation
            disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
                    EGL_VENDOR);
            disp.queryString.version = cnx->egl.eglQueryString(idpy,
                    EGL_VERSION);
            disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
                    EGL_EXTENSIONS);
            disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
                    EGL_CLIENT_APIS);

        } else {
            ALOGW("eglInitialize(%p) failed (%s)", idpy,
                    egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
        }
    }

    // the query strings are per-display
    mVendorString.setTo(sVendorString);
    mVersionString.setTo(sVersionString);
    mClientApiString.setTo(sClientApiString);

    mExtensionString.setTo(gBuiltinExtensionString);
    char const* start = gExtensionString;
    char const* end;
    do {
        // find the space separating this extension for the next one
        end = strchr(start, ' ');
        if (end) {
            // length of the extension string
            const size_t len = end - start;
            if (len) {
                // NOTE: we could avoid the copy if we had strnstr.
                const String8 ext(start, len);
                if (findExtension(disp.queryString.extensions, ext.string(),
                        len)) {
                    mExtensionString.append(start, len+1);
                }
            }
            // process the next extension string, and skip the space.
            start = end + 1;
        }
    } while (end);

    egl_cache_t::get()->initialize(this);

    char value[PROPERTY_VALUE_MAX];
    property_get("debug.egl.finish", value, "0");
    if (atoi(value)) {
        finishOnSwap = true;
    }

    property_get("debug.egl.traceGpuCompletion", value, "0");
    if (atoi(value)) {
        traceGpuCompletion = true;
    }

    refs++;
    if (major != NULL)
        *major = VERSION_MAJOR;
    if (minor != NULL)
        *minor = VERSION_MINOR;

    mHibernation.setDisplayValid(true);

    return EGL_TRUE;
}
EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {

    {
        Mutex::Autolock _rf(refLock);

        refs++;
        if (refs > 1) {
            if (major != NULL)
                *major = VERSION_MAJOR;
            if (minor != NULL)
                *minor = VERSION_MINOR;
            while(!eglIsInitialized) refCond.wait(refLock);
            return EGL_TRUE;
        }

        while(eglIsInitialized) refCond.wait(refLock);
    }

    {
        Mutex::Autolock _l(lock);

        setGLHooksThreadSpecific(&gHooksNoContext);

        // initialize each EGL and
        // build our own extension string first, based on the extension we know
        // and the extension supported by our client implementation

        egl_connection_t* const cnx = &gEGLImpl;
        cnx->major = -1;
        cnx->minor = -1;
        if (cnx->dso) {
            EGLDisplay idpy = disp.dpy;
            if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
                //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p",
                //        idpy, cnx->major, cnx->minor, cnx);

                // display is now initialized
                disp.state = egl_display_t::INITIALIZED;

                // get the query-strings for this display for each implementation
                disp.queryString.vendor = cnx->egl.eglQueryString(idpy,
                        EGL_VENDOR);
                disp.queryString.version = cnx->egl.eglQueryString(idpy,
                        EGL_VERSION);
                disp.queryString.extensions = cnx->egl.eglQueryString(idpy,
                        EGL_EXTENSIONS);
                disp.queryString.clientApi = cnx->egl.eglQueryString(idpy,
                        EGL_CLIENT_APIS);

            } else {
                ALOGW("eglInitialize(%p) failed (%s)", idpy,
                        egl_tls_t::egl_strerror(cnx->egl.eglGetError()));
            }
        }

        // the query strings are per-display
        mVendorString.setTo(sVendorString);
        mVersionString.setTo(sVersionString);
        mClientApiString.setTo(sClientApiString);

        mExtensionString.setTo(gBuiltinExtensionString);
        char const* start = gExtensionString;
        do {
            // length of the extension name
            size_t len = strcspn(start, " ");
            if (len) {
                // NOTE: we could avoid the copy if we had strnstr.
                const String8 ext(start, len);
                if (findExtension(disp.queryString.extensions, ext.string(),
                        len)) {
                    mExtensionString.append(ext + " ");
                }
                // advance to the next extension name, skipping the space.
                start += len;
                start += (*start == ' ') ? 1 : 0;
            }
        } while (*start != '\0');

        egl_cache_t::get()->initialize(this);

        char value[PROPERTY_VALUE_MAX];
        property_get("debug.egl.finish", value, "0");
        if (atoi(value)) {
            finishOnSwap = true;
        }

        property_get("debug.egl.traceGpuCompletion", value, "0");
        if (atoi(value)) {
            traceGpuCompletion = true;
        }

        if (major != NULL)
            *major = VERSION_MAJOR;
        if (minor != NULL)
            *minor = VERSION_MINOR;
    }

    {
        Mutex::Autolock _rf(refLock);
        eglIsInitialized = true;
        refCond.broadcast();
    }

    return EGL_TRUE;
}