source: titan/plugins/tithek/mlehd.h @ 24234

Last change on this file since 24234 was 22199, checked in by obi, 11 years ago

[tithek] add mlehd parser

File size: 1.1 KB
Line 
1#ifndef MLEHD_H
2#define MLEHD_H
3
4char* mlehd(char* link)
5{
6        debug(99, "link %s", link);
7        char* ip = NULL, *pos = NULL, *path = NULL, *streamurl = NULL, *tmpstr = NULL, *tmppath = NULL;
8       
9        ip = string_replace("http://", "", (char*)link, 0);
10
11        if(ip != NULL)
12                pos = strchr(ip, '/');
13        if(pos != NULL)
14        {
15                pos[0] = '\0';
16                path = pos + 1;
17        }
18
19        tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0);
20        tmppath = string_resub("file: '", "'", tmpstr, 0);
21        debug(99, "tmppath: %s", tmppath);
22        free(tmpstr), tmpstr = NULL;
23
24        if(tmppath == NULL) return streamurl;
25
26        tmppath = string_replace("http://www.mle-hd.se/", "", tmppath, 1);
27        debug(99, "tmppath: %s", tmppath);     
28        tmpstr = gethttp(ip, tmppath, 80, NULL, NULL, 10000, NULL, 0);
29
30        if(tmpstr != NULL)
31        {
32                streamurl = string_resub("<location>", "</location>", tmpstr, 0);
33        }
34
35        free(tmpstr); tmpstr = NULL;
36        free(ip), ip = NULL;
37        free(tmppath), tmppath = NULL;
38
39        if(getconfigint("debuglevel", NULL) == 99)
40                writesys("/tmp/mlehd2_streamurl", streamurl, 0);
41
42// segfault munmap_chunk(): invalid pointer
43//      free(pos), pos = NULL;
44//      free(path), path = NULL;
45
46        debug(99, "streamurl: %s", streamurl); 
47        return streamurl;
48}
49
50#endif
Note: See TracBrowser for help on using the repository browser.