3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19 * Feedback, Bugs... info@acmesystems.it
29 #include <sys/types.h>
34 #define TMP_PLS_NAME "/var/tmp.pls"
36 char* mp3_shell_run(char *filename
, char **args
, char *buffer
, int length
){
37 int fd1
[2], fd2
[2], l
;
38 if((pipe(fd1
) !=0) || (pipe(fd2
)!=0)){
44 if ((dup2(fd1
[0], STDIN_FILENO
) == -1)
45 || (dup2(fd2
[1], STDOUT_FILENO
) == -1)){
50 execvp(filename
, args
);
51 printf("ERROR running : %s\n", filename
);
54 memset(buffer
,'\0',length
);
59 if((l
= read(fd2
[0], buffer
, length
-1)) == -1){
60 printf("read failed");
68 int mp3_pls_get_info(unsigned char *pls_url
, unsigned char *url
,
69 unsigned char *path
, unsigned int *port
){
74 for (i
= 0; i
< 5; i
++){
75 exec_args
[i
] = malloc(2048);
77 exec_args
[0][0] = '\0';
78 strcpy(exec_args
[1], "wget");
79 strcpy(exec_args
[2], pls_url
);
80 strcpy(exec_args
[3], "-O");
81 strcpy(exec_args
[4], TMP_PLS_NAME
);
83 printf("Getting pls file --> %s \n", exec_args
[2]);
84 if(mp3_shell_run("wget", &exec_args
[1],
87 stat(TMP_PLS_NAME
, &s
);
89 FILE *fp
= fopen(TMP_PLS_NAME
, "r");
91 unsigned char *data
= malloc(2048);
93 while((!*url
) && (!feof(fp
))){
94 if(fgets(data
, 2048, fp
) != NULL
){
95 if(strstr(data
, "File")){
96 unsigned char *t
= strstr(data
, "=");
99 if(mp3_stream_parse_url(t
, url
,
100 path
, port
) != MP3_OK
){
115 printf("WGET error\n");
117 for (i
= 0; i
< 5; i
++){
121 printf("Found file valid file in pls\n");
123 printf("Error whilst parsing pls\n");
This page took 0.052633 seconds and 5 git commands to generate.