[22199] | 1 | #ifndef MLEHD_H |
---|
| 2 | #define MLEHD_H |
---|
| 3 | |
---|
| 4 | char* mlehd(char* link) |
---|
| 5 | { |
---|
| 6 | debug(99, "link %s", link); |
---|
[24237] | 7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
[22199] | 8 | char* ip = NULL, *pos = NULL, *path = NULL, *streamurl = NULL, *tmpstr = NULL, *tmppath = NULL; |
---|
| 9 | |
---|
| 10 | ip = string_replace("http://", "", (char*)link, 0); |
---|
| 11 | |
---|
| 12 | if(ip != NULL) |
---|
| 13 | pos = strchr(ip, '/'); |
---|
| 14 | if(pos != NULL) |
---|
| 15 | { |
---|
| 16 | pos[0] = '\0'; |
---|
| 17 | path = pos + 1; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | tmpstr = gethttp(ip, path, 80, NULL, NULL, 10000, NULL, 0); |
---|
| 21 | tmppath = string_resub("file: '", "'", tmpstr, 0); |
---|
| 22 | debug(99, "tmppath: %s", tmppath); |
---|
| 23 | free(tmpstr), tmpstr = NULL; |
---|
| 24 | |
---|
| 25 | if(tmppath == NULL) return streamurl; |
---|
| 26 | |
---|
| 27 | tmppath = string_replace("http://www.mle-hd.se/", "", tmppath, 1); |
---|
| 28 | debug(99, "tmppath: %s", tmppath); |
---|
| 29 | tmpstr = gethttp(ip, tmppath, 80, NULL, NULL, 10000, NULL, 0); |
---|
| 30 | |
---|
| 31 | if(tmpstr != NULL) |
---|
| 32 | { |
---|
| 33 | streamurl = string_resub("<location>", "</location>", tmpstr, 0); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | free(tmpstr); tmpstr = NULL; |
---|
| 37 | free(ip), ip = NULL; |
---|
| 38 | free(tmppath), tmppath = NULL; |
---|
| 39 | |
---|
[24237] | 40 | titheklog(debuglevel, "/tmp/mlehd2_streamurl", NULL, streamurl); |
---|
[22199] | 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 |
---|