Skip to content

Commit

Permalink
corec: remove unused URL parsing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Jan 1, 2025
1 parent 1e65d1a commit 108ba64
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 124 deletions.
3 changes: 0 additions & 3 deletions corec/corec/helpers/file/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ FILE_DLL void RemovePathDelimiter(tchar_t* Path);
FILE_DLL void AddPathDelimiter(tchar_t* Path,size_t PathLen);
FILE_DLL const tchar_t* GetProtocol(const tchar_t* URL, tchar_t *_Protocol, int ProtoLen, bool_t* HasHost);
FILE_DLL void SplitPath(const tchar_t* Path, tchar_t* Dir, int DirLen, tchar_t* Name, int NameLen, tchar_t* Ext, int ExtLen);
FILE_DLL void SplitURL(const tchar_t* URL, tchar_t* Mime, int MimeLen, tchar_t* Host, int HostLen, int* Port, tchar_t* Path, int PathLen);
FILE_DLL bool_t SplitAddr(const tchar_t* URL, tchar_t* Peer, int PeerLen, tchar_t* Local, int LocalLen);
FILE_DLL bool_t SetFileExt(tchar_t* URL, size_t URLLen, const tchar_t* Ext);
FILE_DLL int CheckExts(const tchar_t* URL, const tchar_t* Exts);
FILE_DLL void AbsPath(tchar_t* Abs, int AbsLen, const tchar_t* Path, const tchar_t* Base);
FILE_DLL void AbsPathNormalize(tchar_t* Abs, size_t AbsLen);
Expand Down
121 changes: 0 additions & 121 deletions corec/corec/helpers/file/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,6 @@
#include "file.h"
#include <corec/str/str.h>

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;
}

void AddPathDelimiter(tchar_t* Path,size_t PathLen)
{
size_t n = tcslen(Path);
Expand Down Expand Up @@ -104,97 +74,6 @@ const tchar_t* GetProtocol(const tchar_t* URL, tchar_t* Proto, int ProtoLen, boo
return s;
}

bool_t SplitAddr(const tchar_t* URL, tchar_t* Peer, int PeerLen, tchar_t* Local, int LocalLen)
{
const tchar_t* p = NULL;
const tchar_t* p2;
const tchar_t* Addr;
bool_t HasHost;
bool_t Result = 0;

Addr = GetProtocol(URL,NULL,0,&HasHost);

if (HasHost)
{
p = tcschr(Addr,'\\');
p2 = tcschr(Addr,'/');
if (!p || (p2 && p2>p))
p=p2;
}
if (!p)
p = Addr+tcslen(Addr);

p2 = tcschr(Addr,'@');
if (!p2 || p2>p)
p2 = p;
else
Result = 1;

if (Peer)
tcsncpy_s(Peer,PeerLen,URL,p2-URL);

if (Local)
{
if (p2<p)
++p2;
tcsncpy_s(Local,LocalLen,URL,Addr-URL);
tcsncat_s(Local,LocalLen,p2,p-p2);
}
return Result;
}

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("/"));
}
}

void SplitPath(const tchar_t* URL, tchar_t* Dir, int DirLen, tchar_t* Name, int NameLen, tchar_t* Ext, int ExtLen)
{
const tchar_t *p,*p2,*p3;
Expand Down

0 comments on commit 108ba64

Please sign in to comment.