-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplayers.c
67 lines (49 loc) · 1.08 KB
/
players.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "players.h"
ListNode *Players=NULL;
char *Player=NULL;
pid_t PlayerPid=0;
void ParsePlayer(const char *Config)
{
char *ContentType=NULL;
const char *ptr;
ptr=GetToken(Config,"\\S",&ContentType,GETTOKEN_QUOTES);
if (! Players) Players=ListCreate();
SetVar(Players,ContentType,ptr);
Destroy(ContentType);
}
char *SelectPlayer(const char *ContentType)
{
ListNode *Curr;
Curr=ListGetNext(Players);
while (Curr)
{
if (fnmatch(Curr->Tag, ContentType, 0)==0)
{
printf("PLAYER: [%s] %s\n",ContentType,Curr->Item);
Player=CopyStr(Player, (char *) Curr->Item);
return((char *) Curr->Item);
}
Curr=ListGetNext(Curr);
}
return(NULL);
}
void SetPlayer(const char *Config)
{
if (strcmp(Config, "auto")==0) Flags |= FLAG_PLAYER_AUTO;
else Player=CopyStr(Player, Config);
}
void LaunchPlayer()
{
char *Tempstr=NULL;
STREAM *S;
if (PlayerPid > 0) return;
if (! StrValid(Player)) return;
//Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
S=STREAMSpawnCommand(Player,"");
if (S)
{
AddOutputStream(Player, S);
PlayerPid=atoi(STREAMGetValue(S, "PeerPID"));
}
Destroy(Tempstr);
}