source: titan/plugins/tithek/tithek.h @ 15299

Last change on this file since 15299 was 15299, checked in by nit, 12 years ago

[titan] fix segfault and memleak in tithek

File size: 18.2 KB
Line 
1#ifndef TITHEK_H
2#define TITHEK_H
3
4#define TITHEKPATH "/tmp/tithek"
5
6//flag 0: not used
7//flag 1: not used
8//flag 2: streamlink allgemein
9//flag 4: streamlink youtube
10//flag 1000: menu with pin
11struct tithek
12{
13        char* title;
14        char* link;
15        char* pic;
16        char* localname;
17        char* menutitle;       
18        int flag;
19        struct tithek* prev;
20        struct tithek* next;
21};
22struct tithek *tithek = NULL;
23
24struct tithek* addtithek(char *line, int count, struct tithek* last)
25{
26        //debug(1000, "in");
27        struct tithek *newnode = NULL, *prev = NULL, *node = tithek;
28        char *link = NULL, *pic = NULL, *title = NULL, *localname = NULL, *menutitle = NULL;
29        int ret = 0;
30
31        if(line == NULL) return NULL;
32
33        newnode = (struct tithek*)malloc(sizeof(struct tithek));       
34        if(newnode == NULL)
35        {
36                err("no memory");
37                return NULL;
38        }
39
40        link = malloc(MINMALLOC);
41        if(link == NULL)
42        {
43                err("no memory");
44                free(newnode);
45                return NULL;
46        }
47
48        pic = malloc(MINMALLOC);
49        if(pic == NULL)
50        {
51                err("no memory");
52                free(newnode);
53                free(link);
54                return NULL;
55        }
56
57        title = malloc(MINMALLOC);
58        if(title == NULL)
59        {
60                err("no memory");
61                free(newnode);
62                free(link);
63                free(pic);
64                return NULL;
65        }
66
67        localname = malloc(MINMALLOC);
68        if(localname == NULL)
69        {
70                err("no memory");
71                free(newnode);
72                free(link);
73                free(pic);
74                free(title);
75                return NULL;
76        }
77
78        menutitle = malloc(MINMALLOC);
79        if(menutitle == NULL)
80        {
81                err("no memory");
82                free(newnode);
83                free(link);
84                free(pic);
85                free(title);
86                free(localname);               
87                return NULL;
88        }
89
90        memset(newnode, 0, sizeof(struct tithek));
91
92        ret = sscanf(line, "%[^#]#%[^#]#%[^#]#%[^#]#%[^#]#%d", title, link, pic, localname, menutitle, &newnode->flag);
93        if(ret != 6)
94        {
95                if(count > 0)
96                {
97                        err("tithek line %d not ok or double", count);
98                }
99                else
100                {
101                        err("add tithek");
102                }
103                free(link);
104                free(pic);
105                free(title);
106                free(localname);
107                free(menutitle);
108                free(newnode);
109                return NULL;
110        }
111
112        newnode->link = ostrcat(link, "", 1, 0);
113        newnode->pic = ostrcat(pic, "", 1, 0);
114        newnode->title = ostrcat(title, "", 1, 0);
115        newnode->localname = ostrcat(localname, "", 1, 0);
116        newnode->menutitle = ostrcat(menutitle, "", 1, 0);
117
118        if(last == NULL)
119        {
120                while(node != NULL)
121                {
122                        prev = node;
123                        node = node->next;
124                }
125        }
126        else
127        {
128                prev = last;
129                node = last->next;
130        }
131
132        if(prev == NULL)
133                tithek = newnode;
134        else
135        {
136                prev->next = newnode;
137                newnode->prev = prev;
138        }
139        newnode->next = node;
140        if(node != NULL) node->prev = newnode;
141       
142        //debug(1000, "out");
143        return newnode;
144}
145
146int readtithek(const char* filename)
147{
148        debug(1000, "in");
149        FILE *fd = NULL;
150        char *fileline = NULL;
151        int linecount = 0;
152        struct tithek* last = NULL, *tmplast = NULL;
153
154        fileline = malloc(MINMALLOC);
155        if(fileline == NULL)
156        {
157                err("no memory");
158                return 1;
159        }
160
161        fd = fopen(filename, "r");
162        if(fd == NULL)
163        {
164                perr("can't open %s", filename);
165                free(fileline);
166                return 1;
167        }
168
169        while(fgets(fileline, MINMALLOC, fd) != NULL)
170        {
171                if(fileline[0] == '#' || fileline[0] == '\n')
172                        continue;
173                if(fileline[strlen(fileline) - 1] == '\n')
174                        fileline[strlen(fileline) - 1] = '\0';
175                if(fileline[strlen(fileline) - 1] == '\r')
176                        fileline[strlen(fileline) - 1] = '\0';
177
178                linecount++;
179
180                if(last == NULL) last = tmplast;
181                last = addtithek(fileline, linecount, last);
182                if(last != NULL) tmplast = last;
183        }
184
185        free(fileline);
186        fclose(fd);
187        return 0;
188}
189
190int deltithek(char* link)
191{
192        debug(1000, "in");
193        int ret = 1;
194        struct tithek *node = tithek, *prev = tithek;
195
196        while(node != NULL)
197        {
198                if(ostrcmp(link, node->link) == 0)
199                {
200                        ret = 0;
201                        if(node == tithek)
202                        {
203                                tithek = node->next;
204                                if(tithek != NULL)
205                                        tithek->prev = NULL;
206                        }
207                        else
208                        {
209                                prev->next = node->next;
210                                if(node->next != NULL)
211                                        node->next->prev = prev;
212                        }
213
214                        free(node->link);
215                        node->link = NULL;
216
217                        free(node->pic);
218                        node->pic = NULL;
219
220                        free(node->title);
221                        node->title = NULL;
222
223                        free(node->localname);
224                        node->localname = NULL;
225
226                        free(node->menutitle);
227                        node->menutitle = NULL;
228
229                        free(node);
230                        node = NULL;
231
232                        break;
233                }
234
235                prev = node;
236                node = node->next;
237        }
238
239        debug(1000, "out");
240        return ret;
241}
242
243void freetithek()
244{
245        debug(1000, "in");
246        struct tithek *node = tithek, *prev = tithek;
247
248        while(node != NULL)
249        {
250                prev = node;
251                node = node->next;
252                if(prev != NULL)
253                        deltithek(prev->link);
254        }
255        debug(1000, "out");
256}
257
258char* tithekdownload(char* link, char* localname, char* pw, int flag)
259{
260        int ret = 1;
261        char* ip = NULL, *pos = NULL, *path = NULL;
262        char* tmpstr = NULL, *localfile = NULL;
263
264        if(link == NULL) return NULL;
265
266        ip = string_replace("http://", "", (char*)link, 0);
267
268        if(ip != NULL)
269                pos = strchr(ip, '/');
270        if(pos != NULL)
271        {
272                pos[0] = '\0';
273                path = pos + 1;
274        }
275
276        tmpstr = ostrcat(path, NULL, 0, 0);
277
278        if(flag == 0)
279        {
280                localfile = ostrcat(TITHEKPATH, "/", 0, 0);
281                if(localname == NULL)
282                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
283                else
284                        localfile = ostrcat(localfile, localname, 1, 0);
285        }
286        else
287        {
288                localfile = ostrcat(getconfig("rec_path", NULL), "/", 0, 0);
289                if(localname == NULL)
290                        localfile = ostrcat(localfile, basename(tmpstr), 1, 0);
291                else
292                        localfile = ostrcat(localfile, localname, 1, 0);
293        }
294
295        if(flag == 0)
296        {
297                if(!file_exist(localfile))
298                        gethttp(ip, path, 80, localfile, pw, NULL, 0);
299        }
300        else
301        {
302                if(file_exist(localfile))
303                        ret = textbox(_("Message"), _("File exist, overwrite?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
304
305                if(ret == 1)
306                        screendownload("Download", ip, path, 80, localfile, pw, 0);
307        }
308
309        free(ip); ip = NULL;
310        free(tmpstr); tmpstr = NULL;
311
312        return localfile;
313}
314
315int createtithekplay(char* titheklink, struct skin* grid, struct skin* listbox, struct skin* countlabel)
316{
317        int gridbr = 0, posx = 0, count = 0, sumcount = 0;
318        struct skin* tmp = NULL;
319        char* tithekfile = NULL;
320        char* tmpstr = NULL;
321
322        tithekfile = tithekdownload(titheklink, NULL, HTTPAUTH, 0);
323
324        delmarkedscreennodes(grid, 1);
325        freetithek();
326        if(readtithek(tithekfile) != 0) return 1;
327
328        struct tithek* titheknode = tithek;
329
330        while(titheknode != NULL)
331        {
332                tmp = addlistbox(grid, listbox, tmp, 1);
333                if(tmp != NULL)
334                {
335                        sumcount++;
336                        count++;
337                        if(gridbr == 0)
338                                tmp->type = GRIDBR;
339                        gridbr = 1;
340                        tmp->wrap = YES;
341
342                        tmp->picheight = 230;
343                        tmp->picwidth = 370;
344
345                        tmp->height = 280;
346                        tmp->width = 390;
347                        tmp->prozwidth = 0;
348                        //tmp->bgcol = 0xffffff;
349                        tmp->bgspace = 1;
350                        tmp->vspace = 10;
351                        tmp->hspace = 10;
352                        tmp->posx = posx;
353                        //tmp->fontcol = 0x0000ff;
354                        tmp->halign = CENTER;
355                        tmp->valign = TEXTBOTTOM;
356                        changetext(tmp, titheknode->title);
357                        tmp->handle = (char*)titheknode;
358                        posx += tmp->width;
359                        if(count >= 3)
360                        {
361                                count = 0;
362                                posx = 0;
363                                gridbr = 0;
364                        }
365                }
366                titheknode = titheknode->next;
367        }
368
369        tmpstr = oitoa(sumcount);
370        changetext(countlabel, tmpstr);
371        free(tmpstr); tmpstr = NULL;
372
373        free(tithekfile); tithekfile = NULL;
374        return 0;
375}
376
377void screentithekplay(char* titheklink, char* title, int first)
378{
379        int rcret = -1, oaktline = 1, oaktpage = -1, ogridcol = 0;
380       
381        if(first == 1)
382        {
383                rcret = servicestop(status.aktservice, 1, 1);
384                if(rcret == 1) return;
385        }
386
387        struct skin* grid = getscreen("titheklist");
388        struct skin* listbox = getscreennode(grid, "listbox");
389        struct skin* countlabel = getscreennode(grid, "countlabel");
390        struct skin* tmp = NULL;
391        char* tithekpic = NULL;
392       
393        if(titheklink == NULL) return;
394       
395        listbox->aktpage = -1;
396        listbox->aktline = 1;
397        listbox->gridcol = 0;
398        listbox->select = NULL;
399
400        if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) return;
401                               
402        drawscreen(grid, 0);
403        addscreenrc(grid, listbox);
404                               
405        while(1)
406        {
407                changetitle(grid, _(title));
408                if(listbox->select != NULL && listbox->select->handle != NULL)
409                {
410                        tmp = listbox->select;
411                        while(tmp != NULL)
412                        {
413                                if(tmp->pagecount != listbox->aktpage) break;
414                                if(tmp->handle != NULL)
415                                {
416                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 0);
417                                        changepic(tmp, tithekpic);
418                                        free(tithekpic); tithekpic = NULL;
419                                }
420                                tmp = tmp->prev;
421                        }
422                        tmp = listbox->select;
423                        while(tmp != NULL)
424                        {
425                                if(tmp->pagecount != listbox->aktpage) break;
426                                if(tmp->handle != NULL)
427                                {
428                                        tithekpic = tithekdownload(((struct tithek*)tmp->handle)->pic, ((struct tithek*)tmp->handle)->localname, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 0);
429                                        changepic(tmp, tithekpic);
430                                        free(tithekpic); tithekpic = NULL;
431                                }
432                                tmp = tmp->next;
433                        }
434
435                        drawscreen(grid, 0);
436                }
437               
438                int count = getfilecount(TITHEKPATH);
439                if(count > 500)
440                        delallfiles(TITHEKPATH, ".jpg");
441               
442                rcret = waitrc(grid, 0, 0);
443
444                if(rcret == getrcconfigint("rcexit", NULL)) break;
445
446                if(rcret == getrcconfigint("rcred", NULL))
447                {
448                        if(listbox->select != NULL && listbox->select->handle != NULL)
449                        {
450                                if(((struct tithek*)listbox->select->handle)->flag == 2)
451                                {
452                                        if(status.security == 1)
453                                        {
454                                                char* tmpstr = tithekdownload((((struct tithek*)listbox->select->handle)->link), NULL, NULL, 1);
455                                                free(tmpstr); tmpstr = NULL;
456                                                drawscreen(grid, 0);
457                                        }
458                                        else
459                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
460                                }
461                                else if(((struct tithek*)listbox->select->handle)->flag == 4)
462                                {
463                                        if(status.security == 1)
464                                        {
465                                                char* tmpstr = NULL, *tmpstr1 = NULL, *tmpstr2 = NULL;
466                                                tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
467                                                if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, NULL, NULL, 1);
468                                                tmpstr2 = changefilenameext(((struct tithek*)tmp->handle)->localname, ".mp4");
469                                                free(tmpstr); tmpstr = NULL;
470                                                       
471                                                if(tmpstr1 != NULL)
472                                                {
473                                                        char* tmpstr = tithekdownload(tmpstr1, tmpstr2, NULL, 1);
474                                                        free(tmpstr); tmpstr = NULL;
475                                                        drawscreen(grid, 0);
476                                                }
477                                                else
478                                                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
479                                                free(tmpstr1); tmpstr1 = NULL;
480                                                free(tmpstr2); tmpstr2 = NULL;
481                                        }
482                                        else
483                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
484                                }
485                        }
486                }
487
488                if(rcret == getrcconfigint("rcok", NULL))
489                {
490                        if(listbox->select != NULL && listbox->select->handle != NULL)
491                        {
492                                clearscreen(grid);
493                                if(((struct tithek*)listbox->select->handle)->flag == 2)
494                                {
495                                        if(status.security == 1)
496                                        {
497                                                if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
498                                                        screenplay((((struct tithek*)listbox->select->handle)->link), 2, 0);                           
499                                        }
500                                        else
501                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
502                                }
503                                else if(((struct tithek*)listbox->select->handle)->flag == 4)
504                                {
505                                        if(status.security == 1)
506                                        {
507                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
508                                                char* tmpstr1 = NULL;
509                                                if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, NULL, NULL, 1);
510                                                free(tmpstr); tmpstr = NULL;
511                                                       
512                                                if(tmpstr1 != NULL)
513                                                {
514                                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
515                                                                screenplay(tmpstr1, 2, 0);                             
516                                                }
517                                                else
518                                                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
519                                                free(tmpstr1); tmpstr1 = NULL;
520                                        }
521                                        else
522                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);                 
523                                }
524                                else if((((struct tithek*)listbox->select->handle)->flag == 5) || (((struct tithek*)listbox->select->handle)->flag == 6) || (((struct tithek*)listbox->select->handle)->flag == 7) || (((struct tithek*)listbox->select->handle)->flag == 8))
525                                {
526                                        if(status.security == 1)
527                                        {
528                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
529                                                char* tmpstr1 = NULL;
530                                               
531                                                if(((struct tithek*)listbox->select->handle)->flag == 5)
532                                                {
533                                                        if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://rtl2now.rtl2.de", "rtl2now", 2);
534                                                }
535                                                else if(((struct tithek*)listbox->select->handle)->flag == 6)
536                                                {
537                                                        if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://www.superrtlnow.de", "superrtlnow", 2);
538                                                }
539                                                else if(((struct tithek*)listbox->select->handle)->flag == 7)
540                                                {
541                                                        if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://rtl-now.rtl.de", "rtlnow", 2);
542                                                }
543                                                else if(((struct tithek*)listbox->select->handle)->flag == 8)
544                                                {
545                                                        if(tmpstr != NULL) tmpstr1 = getstreamurl(tmpstr, "http://www.voxnow.de", "voxnow", 2);
546                                                }
547       
548                                                free(tmpstr); tmpstr = NULL;
549                                                       
550                                                if(tmpstr1 != NULL)
551                                                {
552                                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
553                                                                screenplay(tmpstr1, 2, 0);                             
554                                                }
555                                                else
556                                                        textbox(_("Message"), _("Can't get Streamurl !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
557                                                free(tmpstr1); tmpstr1 = NULL;
558                                        }
559                                        else
560                                                textbox(_("Message"), _("Registration needed, please contact Atemio !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);                 
561                                }
562                                else
563                                {
564                                        int pincheck = 0;
565                                        if(((struct tithek*)listbox->select->handle)->flag == 1000)
566                                                pincheck = screenpincheck(0, NULL);
567                                        if(pincheck == 0)
568                                        {
569                                                oaktpage = listbox->aktpage;
570                                                oaktline = listbox->aktline;
571                                                ogridcol = listbox->gridcol;
572                                                char* tmpstr = ostrcat(((struct tithek*)listbox->select->handle)->link, NULL, 0, 0);
573                                                char* tmpstr1 = ostrcat(((struct tithek*)listbox->select->handle)->menutitle, " - ", 0, 0);                                     
574                                                char* tmpstr2 = ostrcat(tmpstr1, ((struct tithek*)listbox->select->handle)->title, 1, 0);
575                                                screentithekplay(tmpstr, tmpstr2, 0);
576                                                free(tmpstr); tmpstr = NULL;
577                                                free(tmpstr2); tmpstr2 = NULL;                                 
578                                                if(createtithekplay(titheklink, grid, listbox, countlabel) != 0) break;
579                                                listbox->aktpage = oaktpage;
580                                                listbox->aktline = oaktline;
581                                                listbox->gridcol = ogridcol;
582                                                addscreenrc(grid, listbox);
583                                        }
584                                }
585                                drawscreen(grid, 0);                   
586                        }                       
587                }
588        }
589
590        freetithek();
591        delmarkedscreennodes(grid, 1);
592        delownerrc(grid);
593        clearscreen(grid);
594
595        if(first == 1)
596        {
597                delallfiles("/tmp/tithek", ".list");
598                servicecheckret(servicestart(status.lastservice->channel, NULL, NULL, 0), 0);
599        }
600}
601
602// flag 1 = youtube streamlink
603// flag 2 = rtlnow streamlinksrc
604// flag 3 = rtlnow streamlink
605char* getstreamurl(char* link, char* url, char* name, int flag)
606{
607        debug(99, "link(%d): %s", flag, link);
608        char* ip = NULL, *pos = NULL, *path = NULL;
609       
610        ip = string_replace("http://", "", (char*)link, 0);
611
612        if(ip != NULL)
613                pos = strchr(ip, '/');
614        if(pos != NULL)
615        {
616                pos[0] = '\0';
617                path = pos + 1;
618        }
619
620        char* tmpstr = NULL;
621        tmpstr = gethttp(ip, path, 80, NULL, NULL, NULL, 0);
622        char* streamurl = NULL;
623               
624        if(flag == 1)
625        {
626                string_resub("\": \"url=", "\", \"", tmpstr);
627       
628                while(string_find(",url=", tmpstr))
629                        tmpstr = string_replace(",url=", "\nurl=", tmpstr, 1);
630       
631                tmpstr = string_decode(tmpstr, 0);
632       
633                int count = 0;
634                int i = 0;
635                struct splitstr* ret1 = NULL;
636                ret1 = strsplit(tmpstr, "\n", &count);
637                if(ret1 != NULL)
638                {
639                        int max = count;
640                        for(i = 0; i < max; i++)
641                        {
642                                if(string_find("type=video/mp4",(&ret1[i])->part))
643                                {
644                                        streamurl = ostrcat(streamurl, (&ret1[i])->part, 1, 0);
645                                        int count2 = 0;
646                                        struct splitstr* ret2 = NULL;
647                                        ret2 = strsplit((&ret1[i])->part, "+", &count2);
648                                        if(ret2 != NULL)
649                                        {
650                                                free(streamurl);
651                                                streamurl = ostrcat("", (&ret2[0])->part, 0, 0);
652                                                free(ret2); ret2 = NULL;
653                                        }
654                                }
655                        }
656                        free(ret1); ret1 = NULL;
657                       
658                        streamurl = string_replace("url=", "", streamurl, 1);
659                }
660                free(tmpstr); tmpstr = NULL;
661        }
662        else if(flag == 2)
663        {
664                string_resub("data:'", "',", tmpstr);
665                debug(99, "tmpstr: %s", tmpstr);
666
667                htmldecode(tmpstr, tmpstr);
668                tmpstr = ostrcat(url, tmpstr, 0, 1);
669                debug(99, "streamurl: %s", tmpstr);
670                streamurl = getstreamurl(tmpstr, url, name, 3);
671                free(tmpstr); tmpstr = NULL;
672        }
673        else if(flag == 3)
674        {
675                string_resub("<filename><![CDATA[", "]]></filename>", tmpstr);
676                debug(99, "tmpstr: %s", tmpstr);
677
678                int count = 0;
679                int i = 0;
680                struct splitstr* ret1 = NULL;
681                ret1 = strsplit(tmpstr, "/", &count);
682                if(ret1 != NULL)
683                {
684                        int max = count;
685                        char* link = NULL;
686                        char* path = NULL;
687                        for(i = 0; i < max; i++)
688                        {
689                                if(i < 3)
690                                {
691                                        if(count > i)
692                                                link = ostrcat(link, (&ret1[i])->part, 1, 0);
693
694                                        if(i == 0)
695                                                link = ostrcat(link, "//", 1, 0);
696                                        else
697                                                link = ostrcat(link, "/", 1, 0);
698                                }
699                                else
700                                {
701                                        if(count > i)
702                                                path = ostrcat(path, (&ret1[i])->part, 1, 0);
703                                        if(i != max - 1)
704                                                path = ostrcat(path, "/", 1, 0);
705                                }
706                        }
707                        free(ret1), ret1 = NULL;
708
709                        debug(99, "link: %s", link);
710                        debug(99, "path: %s", path);
711       
712                        streamurl = ostrcat(link, " swfVfy=1 playpath=mp4:", 0, 0);
713                        streamurl = ostrcat(streamurl, path, 1, 0);
714                        streamurl = ostrcat(streamurl, " app=", 1, 0);
715                        streamurl = ostrcat(streamurl, name, 1, 0);
716                        streamurl = ostrcat(streamurl, "/_definst_ pageUrl=", 1, 0);
717                        streamurl = ostrcat(streamurl, url, 1, 0);
718                        streamurl = ostrcat(streamurl, "/p/ tcUrl=", 1, 0);
719                        streamurl = ostrcat(streamurl, link, 1, 0);
720                        streamurl = ostrcat(streamurl, " swfUrl=", 1, 0);
721                        streamurl = ostrcat(streamurl, url, 1, 0);
722                        streamurl = ostrcat(streamurl, "/includes/vodplayer.swf", 1, 0);               
723       
724                        if(link != NULL)
725                                free(link), link = NULL;
726       
727                        if(path != NULL)
728                                free(path), path = NULL;
729                }
730                free(tmpstr); tmpstr = NULL;
731                debug(99, "streamurl: %s", streamurl);
732        }
733        return streamurl;
734}
735
736#endif
Note: See TracBrowser for help on using the repository browser.