当前位置: 首页>>代码示例>>C++>>正文


C++ GetProtocol函数代码示例

本文整理汇总了C++中GetProtocol函数的典型用法代码示例。如果您正苦于以下问题:C++ GetProtocol函数的具体用法?C++ GetProtocol怎么用?C++ GetProtocol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetProtocol函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AbsPath

void AbsPath(tchar_t* Abs, int AbsLen, const tchar_t* Path, const tchar_t* Base)
{
	if (Base && GetProtocol(Base,NULL,0,NULL)!=Base && (Path[0] == '/' || Path[0] == '\\') &&
        (Path[1] != '/' && Path[1] != '\\'))
	{
		tchar_t* s;
		bool_t HasHost;

		tcscpy_s(Abs,AbsLen,Base);
		s = (tchar_t*)GetProtocol(Abs,NULL,0,&HasHost);
		if (!HasHost)
		{
			// keep "mime://" from Base
			++Path;
			*s = 0;
		}
		else
		{
			// keep "mime://host" from Base
			tchar_t *a,*b;
			a = tcschr(s,'\\');
			b = tcschr(s,'/');
			if (!a || (b && b<a))
				a=b;
			if (a)
				*a=0;
		}
	}
	else
	if (Base && GetProtocol(Path,NULL,0,NULL)==Path && Path[0] != '/' && Path[0] != '\\' &&
		!(Path[0] && Path[1]==':' && (Path[2]=='\\' || Path[2]=='\0')))
	{	
		// doesn't have mime or drive letter or pathdelimiter at the start
		const tchar_t* MimeEnd = GetProtocol(Base,NULL,0,NULL);
		tcscpy_s(Abs,AbsLen,Base);

#if defined(TARGET_WIN) || defined(TARGET_SYMBIAN)
		if (MimeEnd==Base)
			AddPathDelimiter(Abs,AbsLen);
		else
#endif
		if (MimeEnd[0])
			AddPathDelimiter(Abs,AbsLen);
	}
	else
		Abs[0] = 0;

	tcscat_s(Abs,AbsLen,Path);
    AbsPathNormalize(Abs,AbsLen);
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:50,代码来源:tools.c

示例2: GetStream

stream* GetStream(anynode *AnyNode, const tchar_t* URL, int Flags)
{
	tchar_t Protocol[MAXPROTOCOL];
	stream* Stream = NULL;
    fourcc_t FourCC;

    GetProtocol(URL,Protocol,TSIZEOF(Protocol),NULL);

    FourCC = NodeEnumClassStr(AnyNode,NULL,STREAM_CLASS,NODE_PROTOCOL,Protocol);

#if defined(CONFIG_STREAM_CACHE)
    if ((Flags & (SFLAG_NO_CACHING|SFLAG_WRONLY|SFLAG_CREATE))==0)
        Stream = (stream*)NodeCreate(AnyNode,NodeClass_Meta(NodeContext_FindClass(AnyNode,FourCC),STREAM_CACHE_CLASS,META_PARAM_CUSTOM));
#endif

    if (!Stream)
        Stream = (stream*)NodeCreate(AnyNode,FourCC);

    if (Stream && (Flags & SFLAG_NON_BLOCKING))
        Stream_Blocking(Stream,0);

    if (!Stream && !(Flags & SFLAG_SILENT))
    {
	    tcsupr(Protocol);
	    NodeReportError(AnyNode,NULL,ERR_ID,ERR_PROTO_NOT_FOUND,Protocol);
    }
#if defined(CONFIG_DEBUGCHECKS)
    if (Stream)
        tcscpy_s(Stream->URL,TSIZEOF(Stream->URL),URL);
#endif
	return Stream;
}
开发者ID:robUx4,项目名称:ResInfo,代码行数:32,代码来源:streams.c

示例3: socket_network_client

// Windows implementation of this libcutils function. This function does not make any calls to
// WSAStartup() or WSACleanup() so that must be handled by the caller.
// TODO(dpursell): share this code with adb.
static SOCKET socket_network_client(const std::string& host, int port, int type) {
    // First resolve the host and port parameters into a usable network address.
    addrinfo hints;
    memset(&hints, 0, sizeof(hints));
    hints.ai_socktype = type;
    hints.ai_protocol = GetProtocol(type);

    addrinfo* address = nullptr;
    getaddrinfo(host.c_str(), android::base::StringPrintf("%d", port).c_str(), &hints, &address);
    if (address == nullptr) {
        return INVALID_SOCKET;
    }

    // Now create and connect the socket.
    SOCKET sock = socket(address->ai_family, address->ai_socktype, address->ai_protocol);
    if (sock == INVALID_SOCKET) {
        freeaddrinfo(address);
        return INVALID_SOCKET;
    }

    if (connect(sock, address->ai_addr, address->ai_addrlen) == SOCKET_ERROR) {
        closesocket(sock);
        freeaddrinfo(address);
        return INVALID_SOCKET;
    }

    freeaddrinfo(address);
    return sock;
}
开发者ID:LedoInteractive,项目名称:platform_system_core,代码行数:32,代码来源:socket_windows.cpp

示例4: GetRightLocation

/**
 * Doku see wxFileSystemHandler
 */
wxString wxChmFSHandler::FindFirst(const wxString& spec, int flags)
{
    wxString right = GetRightLocation(spec);
    wxString left = GetLeftLocation(spec);
    wxString nativename = wxFileSystem::URLToFileName(left).GetFullPath();

    if ( GetProtocol(left) != _T("file") )
    {
        wxLogError(_("CHM handler currently supports only local files!"));
        return wxEmptyString;
    }

    m_chm = new wxChmTools(wxFileName(nativename));
    m_pattern = right.AfterLast(_T('/'));

    wxString m_found = m_chm->Find(m_pattern);

    // now fake around hhp-files which are not existing in projects...
    if (m_found.empty() &&
        m_pattern.Contains(_T(".hhp")) &&
        !m_pattern.Contains(_T(".hhp.cached")))
    {
        m_found.Printf(_T("%s#chm:%s.hhp"),
                       left.c_str(), m_pattern.BeforeLast(_T('.')).c_str());
    }

    return m_found;

}
开发者ID:gitrider,项目名称:wxsj2,代码行数:32,代码来源:chm.cpp

示例5: AbsPathNormalize

void AbsPathNormalize(tchar_t* Abs,size_t AbsLen)
{
	if (GetProtocol(Abs,NULL,0,NULL)!=Abs)
    {
        tchar_t *i;
		for (i=Abs;*i;++i)
			if (*i == '\\')
				*i = '/';
    }
    else
    {
#if defined(TARGET_WIN) || defined(TARGET_SYMBIAN)
        tchar_t *i;
		for (i=Abs;*i;++i)
			if (*i == '/')
				*i = '\\';

#if defined(TARGET_WINCE)
        if (Abs[0]!='\\')
        {
            size_t n = tcslen(Abs)+1;
            if (n>=AbsLen)
            {
                n=AbsLen-1;
                Abs[n-1]=0;
            }
            memmove(Abs+1,Abs,n*sizeof(tchar_t));
            Abs[0]='\\';
        }
#endif
#endif
    }
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:33,代码来源:tools.c

示例6: SetFileExt

bool_t SetFileExt(tchar_t* URL, size_t URLLen, const tchar_t* Ext)
{
	tchar_t *p,*q,*p2;
	bool_t HasHost;

	p = (tchar_t*) GetProtocol(URL,NULL,0,&HasHost);
	q = p;
	
	p = tcsrchr(q,'\\');
    p2 = tcsrchr(q,'/');
    if (!p || (p2 && p2>p))
		p=p2;
	if (p)
		q = p+1;
	else
	if (HasHost) // only hostname
		return 0;
	
	if (!q[0]) // no filename at all?
		return 0;

	p = tcsrchr(q,'.');
	if (p)
		*p = 0;

	tcscat_s(URL,URLLen,T("."));
	tcscat_s(URL,URLLen,Ext);
	return 1;
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:29,代码来源:tools.c

示例7: socket_inaddr_any_server

// Windows implementation of this libcutils function. This implementation creates a dual-stack
// server socket that can accept incoming IPv4 or IPv6 packets. This function does not make any
// calls to WSAStartup() or WSACleanup() so that must be handled by the caller.
// TODO(dpursell): share this code with adb.
static SOCKET socket_inaddr_any_server(int port, int type) {
    SOCKET sock = socket(AF_INET6, type, GetProtocol(type));
    if (sock == INVALID_SOCKET) {
        return INVALID_SOCKET;
    }

    // Enforce exclusive addresses (1), and enable dual-stack so both IPv4 and IPv6 work (2).
    // (1) https://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx.
    // (2) https://msdn.microsoft.com/en-us/library/windows/desktop/bb513665(v=vs.85).aspx.
    int exclusive = 1;
    DWORD v6_only = 0;
    if (setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, reinterpret_cast<const char*>(&exclusive),
                   sizeof(exclusive)) == SOCKET_ERROR ||
        setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&v6_only),
                   sizeof(v6_only)) == SOCKET_ERROR) {
        closesocket(sock);
        return INVALID_SOCKET;
    }

    // Bind the socket to our local port.
    sockaddr_in6 addr;
    memset(&addr, 0, sizeof(addr));
    addr.sin6_family = AF_INET6;
    addr.sin6_port = htons(port);
    addr.sin6_addr = in6addr_any;
    if (bind(sock, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) {
        closesocket(sock);
        return INVALID_SOCKET;
    }

    return sock;
}
开发者ID:LedoInteractive,项目名称:platform_system_core,代码行数:36,代码来源:socket_windows.cpp

示例8: GetRightLocation

wxString wxArchiveFSHandler::FindFirst(const wxString& spec, int flags)
{
    wxString right = GetRightLocation(spec);
    wxString left = GetLeftLocation(spec);
    wxString protocol = GetProtocol(spec);
    wxString key = left + wxT("#") + protocol + wxT(":");

    if (!right.empty() && right.Last() == wxT('/')) right.RemoveLast();

    if (!m_cache)
        m_cache = new wxArchiveFSCache;

    const wxArchiveClassFactory *factory;
    factory = wxArchiveClassFactory::Find(protocol);
    if (!factory)
        return wxEmptyString;

    m_Archive = m_cache->Get(key);
    if (!m_Archive)
    {
        wxFSFile *leftFile = m_fs.OpenFile(left);
        if (!leftFile)
            return wxEmptyString;
        m_Archive = m_cache->Add(key, *factory, leftFile->DetachStream());
        delete leftFile;
    }

    m_FindEntry = NULL;

    switch (flags)
    {
        case wxFILE:
            m_AllowDirs = false, m_AllowFiles = true; break;
        case wxDIR:
            m_AllowDirs = true, m_AllowFiles = false; break;
        default:
            m_AllowDirs = m_AllowFiles = true; break;
    }

    m_ZipFile = key;

    m_Pattern = right.AfterLast(wxT('/'));
    m_BaseDir = right.BeforeLast(wxT('/'));
    if (m_BaseDir.StartsWith(wxT("/")))
        m_BaseDir = m_BaseDir.Mid(1);

    if (m_Archive)
    {
        if (m_AllowDirs)
        {
            delete m_DirsFound;
            m_DirsFound = new wxArchiveFilenameHashMap();
            if (right.empty())  // allow "/" to match the archive root
                return spec;
        }
        return DoFind();
    }
    return wxEmptyString;
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:59,代码来源:fs_arc.cpp

示例9: StreamProtocolPriority

int StreamProtocolPriority(anynode *AnyNode, const tchar_t* URL)
{
	tchar_t Protocol[MAXPROTOCOL];
    GetProtocol(URL,Protocol,TSIZEOF(Protocol),NULL);
    if (tcsicmp(Protocol,T("file"))==0) // override for local files
        return PRI_MAXIMUM;
    return NodeClass_Priority(NodeContext_FindClass(AnyNode,NodeEnumClassStr(AnyNode,NULL,STREAM_CLASS,NODE_PROTOCOL,Protocol)));
}
开发者ID:robUx4,项目名称:ResInfo,代码行数:8,代码来源:streams.c

示例10: WXUNUSED

wxFSFile* wxChmFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
                                   const wxString& location)
{
    wxString right = GetRightLocation(location);
    wxString left = GetLeftLocation(location);

    wxInputStream *s;

    int index;

    if ( GetProtocol(left) != _T("file") )
    {
        wxLogError(_("CHM handler currently supports only local files!"));
        return NULL;
    }

    // Work around javascript
    wxString tmp = wxString(right);
    if ( tmp.MakeLower().Contains(_T("javascipt")) && tmp.Contains(_T("\'")) )
    {
        right = right.AfterFirst(_T('\'')).BeforeLast(_T('\''));
    }

    // now work on the right location
    if (right.Contains(_T("..")))
    {
        wxFileName abs(right);
        abs.MakeAbsolute(_T("/"));
        right = abs.GetFullPath();
    }

    // a workaround for absolute links to root
    if ( (index=right.Index(_T("//"))) != wxNOT_FOUND )
    {
        right=wxString(right.Mid(index+1));
        wxLogWarning(_("Link contained '//', converted to absolute link."));
    }

    wxFileName leftFilename = wxFileSystem::URLToFileName(left);

    // Open a stream to read the content of the chm-file
    s = new wxChmInputStream(leftFilename.GetFullPath(), right, true);

    wxString mime = GetMimeTypeFromExt(location);

    if ( s )
    {
        return new wxFSFile(s,
                            left + _T("#chm:") + right,
                            mime,
                            GetAnchor(location),
                            wxDateTime(wxFileModificationTime(left)));
    }

    delete s;
    return NULL;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:57,代码来源:chm.cpp

示例11: UpperPath

bool_t UpperPath(tchar_t* Path, tchar_t* Last, size_t LastLen)
{
	tchar_t *a,*b,*c;
	bool_t HasHost;
    tchar_t Mime[32];

	if (!*Path)
		return 0;

	RemovePathDelimiter(Path);
	c = (tchar_t*)GetProtocol(Path,Mime,TSIZEOF(Mime),&HasHost);
	
	a = tcsrchr(c,'\\');
	b = tcsrchr(c,'/');
	if (!a || (b && b>a))
		a=b;

#ifdef TARGET_PS2SDK
    if (!a && (a = tcschr(c,':'))!=NULL)
        if (a[1]==0)
            a = NULL;
#endif

	if (!a)
	{
        if (tcsicmp(Mime, T("smb")) == 0) {
            *c = 0;
            tcscpy_s(Last, LastLen, Path);
            return 1;
        }

        if (HasHost && tcsicmp(Mime, T("upnp"))!=0)
			return 0;
		a=c;
		if (!a[0]) // only mime left
			a=c=Path;
	}
	else
		++a;

	if (Last)
		tcscpy_s(Last,LastLen,a);

	if (a==c)
		*a = 0;

#ifdef TARGET_PS2SDK
    if (a>c && a[-1]==':')
        *a = 0;
#endif

	while (--a>=c && (*a=='\\' || *a=='/'))
		*a = 0;

	return 1;
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:56,代码来源:tools.c

示例12: Open

static err_t Open(urlpart* p, const tchar_t* URL, int Flags)
{
    err_t Result;
    const tchar_t *String, *Equal;
    tchar_t Value[MAXPATHFULL];
    datetime_t Date = INVALID_DATETIME_T;

    String = tcsrchr(URL,URLPART_SEP_CHAR);
    if (!String)
        return ERR_INVALID_DATA;
    
    Clear(p);
    Node_SetData((node*)p,STREAM_URL,TYPE_STRING,URL);

    Equal = GetProtocol(URL,NULL,0,NULL);
    tcsncpy_s(Value,TSIZEOF(Value),Equal,String-Equal);
    tcsreplace(Value,TSIZEOF(Value),URLPART_SEP_ESCAPE,URLPART_SEPARATOR);
    Node_SetData((node*)p,URLPART_URL,TYPE_STRING,Value);
    while (String++ && *String)
    {
        Equal = tcschr(String,T('='));
        if (Equal)
        {
            tchar_t *Sep = tcschr(Equal,T('#'));
            if (Sep)
                tcsncpy_s(Value,TSIZEOF(Value),Equal+1,Sep-Equal-1);
            else
                tcscpy_s(Value,TSIZEOF(Value),Equal+1);

            if (tcsncmp(String,T("ofs"),Equal-String)==0)
                p->Pos = StringToInt(Value,0);
            else if (tcsncmp(String,T("len"),Equal-String)==0)
                p->Length = StringToInt(Value,0);
            else if (tcsncmp(String,T("mime"),Equal-String)==0)
                Node_SetData((node*)p,URLPART_MIME,TYPE_STRING,Value);
            else if (tcsncmp(String,T("date"),Equal-String)==0)
                Date = StringToInt(Value,0);
        }
        String = tcschr(String,'#');
    }

    if (Date!=INVALID_DATETIME_T && Date != FileDateTime(Node_Context(p),Node_GetDataStr((node*)p,URLPART_URL)))
        return ERR_INVALID_DATA;

    p->Input = GetStream(p,Node_GetDataStr((node*)p,URLPART_URL),Flags);
    if (!p->Input)
        return ERR_NOT_SUPPORTED;
    Stream_Blocking(p->Input,p->Blocking);
    Result = Stream_Open(p->Input,Node_GetDataStr((node*)p,URLPART_URL),Flags);
    if (Result == ERR_NONE && p->Pos!=INVALID_FILEPOS_T) // TODO: support asynchronous stream opening
    {
        if (Stream_Seek(p->Input,p->Pos,SEEK_SET)!=p->Pos)
            return ERR_INVALID_DATA;
    }
    return Result;
}
开发者ID:ViFork,项目名称:ResInfo,代码行数:56,代码来源:urlpart.c

示例13: GetProtocol

bool wxInternetFSHandler::CanOpen(const wxString& location)
{
#if wxUSE_URL
    wxString p = GetProtocol(location);
    if ((p == wxT("http")) || (p == wxT("ftp")))
    {
        wxURL url(p + wxT(":") + StripProtocolAnchor(location));
        return (url.GetError() == wxURL_NOERR);
    }
#endif
    return false;
}
开发者ID:Ailick,项目名称:rpcs3,代码行数:12,代码来源:fs_inet.cpp

示例14: RemovePathDelimiter

void RemovePathDelimiter(tchar_t* Path)
{
    size_t n = tcslen(Path);
	const tchar_t* s = GetProtocol(Path,NULL,0,NULL);
#if defined(TARGET_WIN) || defined(TARGET_SYMBIAN)
    bool_t HasProtocol = s==Path;
	if (s[0] && n>0 && ((HasProtocol && Path[n-1] == '\\') || (!HasProtocol && Path[n-1] == '/')))
#else
	if (s[0] && n>0 && Path[n-1] == '/' && n > 1)
#endif
		Path[n-1] = 0;
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:12,代码来源:tools.c

示例15: SplitURL

void SplitURL(const tchar_t* URL, tchar_t* Protocol, int ProtocolLen, tchar_t* Host, int HostLen, int* Port, tchar_t* Path, int PathLen)
{
	bool_t HasHost;
	URL = GetProtocol(URL,Protocol,ProtocolLen,&HasHost);

    if (HasHost)
    {
	    const tchar_t* p;
	    const tchar_t* p2;

	    p = tcschr(URL,'\\');
        p2 = tcschr(URL,'/');
        if (!p || (p2 && p2>p))
		    p=p2;
        if (!p)
            p = URL+tcslen(URL);

        p2 = tcschr(URL,':'); 
	    if (p2 && p2<p)
	    {
            if (Port)
                stscanf(p2+1,T("%d"),Port);
	    }
        else
            p2 = p;

	    if (Host)
		    tcsncpy_s(Host,HostLen,URL,p2-URL);

        URL = p;
    }
    else
    {
        if (Host && HostLen>0)
            *Host = 0;
    }

    if (Path)
    {
        if (URL[0])
        {
            tchar_t* p;
            tcscpy_s(Path,PathLen,URL);
            for (p=Path;*p;++p)
                if (*p == '\\')
                    *p = '/';
        }
        else
            tcscpy_s(Path,PathLen,T("/"));
    }
}
开发者ID:CDavantzis,项目名称:foundation-source,代码行数:51,代码来源:tools.c


注:本文中的GetProtocol函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。