Esempio n. 1
0
static int ReadList(playlist* p,tchar_t* Path,int PathLen,tchar_t* DispName,int DispNameLen,tick_t* Length)
{
	tchar_t s[MAXLINE];

	DispName[0] = 0;
	*Length = -1;

	while (ParserLine(&p->Parser,s,MAXLINE))
	{
		if (s[0]=='#')
		{
			tcsuprto(s,':');
			if (stscanf(s,T("#EXTINF: %d ,"),Length)==1)
			{
				tchar_t* p = tcschr(s,',');
				if (p++)
				{
					while (IsSpace(*p)) ++p;
					tcscpy_s(DispName,DispNameLen,p);
				}
				if (*Length >= 0)
					*Length *= TICKSPERSEC;
			}
		}
		else
		if (s[0])
		{
			tcscpy_s(Path,PathLen,s);
			return ERR_NONE;
		}
	}

	return ERR_END_OF_FILE;
}
Esempio n. 2
0
static NOINLINE void AddField(pin* Pin,int Id,tchar_t* Value)
{
	tchar_t* p;
	if (Id == COMMENT_GENRE)
	{
		int Genre;
		p = tcschr(Value,'=');
		if (p && stscanf(p,T("=(%d)"),&Genre)==1 && Genre<GENRE_COUNT)
		{
			tchar_t* q=++p;
			while (*q && *q!=')') ++q;
			if (q[0]==')' && q[1]) // custom name
				while ((*(p++)=*(++q))!=0);
			else
			{
				AddGenre(Pin,Genre);
				return;
			}
		}
	}
	if (Id != COMMENT_COMMENT)
		for (p=Value;*p;++p)
			if (*p==10) *p=' ';
	Pin->Node->Set(Pin->Node,Pin->No,Value,(tcslen(Value)+1)*sizeof(tchar_t));
}
Esempio n. 3
0
static int ReadList(pls* p,tchar_t* Path,int PathLen,tchar_t* DispName,int DispNameLen,tick_t* Length)
{
	tchar_t s[MAXLINE];
	int No,Len;
	int Result = ERR_END_OF_FILE;

	while (Result==ERR_END_OF_FILE && ParserLine(&p->Playlist.Parser,s,MAXLINE))
	{
		tcsuprto(s,'=');
		if (stscanf(s,T("FILE%d ="),&No)==1)
		{
			if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length))
				Result = ERR_NONE;
			p->Playlist.No = No;
			tcscpy_s(p->File,TSIZEOF(p->File),tcschr(s,'=')+1);
		}
		else
		if (stscanf(s,T("TITLE%d ="),&No)==1)
		{
			if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length))
				Result = ERR_NONE;
			p->Playlist.No = No;
			tcscpy_s(p->Title,TSIZEOF(p->Title),tcschr(s,'=')+1);
		}
		else
		if (stscanf(s,T("LENGTH%d = %d"),&No,&Len)==2)
		{
			if (No != p->Playlist.No && Fill(p,Path,PathLen,DispName,DispNameLen,Length))
				Result = ERR_NONE;
			p->Playlist.No = No;
			p->Length = Len;
		}
	}

	if (Result==ERR_END_OF_FILE && Fill(p,Path,PathLen,DispName,DispNameLen,Length))
		Result = ERR_NONE;

	return Result;
}
Esempio n. 4
0
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("/"));
    }
}
Esempio n. 5
0
static void LoadTGZ(stream* p,void* Buffer)
{
	gzreader Reader;
	if (GZInit(&Reader,p))
	{
		int Size;
		tchar_t StrSize[16];
		tarhead Head;

		while (GZRead(&Reader,&Head,sizeof(Head))==sizeof(Head) && Head.size[0])
		{
			GetAsciiToken(StrSize,16,Head.size,sizeof(Head.size));
			if (stscanf(StrSize,T("%o"),&Size)!=1 || Size>MAXTEXT)
				break;
			assert(Size<MAXTEXT);
			StringAddText(Buffer,GZRead(&Reader,Buffer,Size));
			if (Size & 511)
				GZRead(&Reader,Buffer,512-(Size & 511));
		}

		GZDone(&Reader);
	}
}