From bcb57722887794aaf3b7edb1ddd8225b486fd389 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 29 Dec 2013 12:48:06 +0000 Subject: [PATCH] HTMLv 0.99.5: Condition Script git-svn-id: svn://kolibrios.org@4417 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 67 +++++++++++++++++++++-------------- programs/cmm/TWB/acid_0.1.htm | 7 ++++ programs/cmm/browser/HTMLv.c | 25 +++++++++---- programs/cmm/liza/liza.c | 5 +++ programs/cmm/liza/parselist.c | 56 ++++++++++++++++++++++++++--- 5 files changed, 122 insertions(+), 38 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 71504f6af0..079a46c1dc 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -1,10 +1,9 @@ int downloader_id; -dword - buf, - filesize, - blink; +dword buf; +dword filesize; +dword blink; #define URL param @@ -12,9 +11,9 @@ int mouse_twb; edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; -char editURL[sizeof(URL)], - page_links[12000], - header[2048]; +char editURL[sizeof(URL)]; +char page_links[12000]; +char header[2048]; @@ -33,27 +32,28 @@ struct TWebBrowser { }; TWebBrowser WB1; -byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, - link, ignor_text, li_tab, cur_encoding, text_align; +byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, + link, ignor_text, cur_encoding, text_align; +byte condition_text_active, condition_text_val, condition_href, condition_max; enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; -dword text_colors[300], - text_color_index, - link_color, - bg_color; +dword text_colors[300]; +dword text_color_index; +dword link_color; +dword bg_color; -int stroka, - stolbec, - tab_len, - anchor_line_num; +int stroka; +int stolbec; +int tab_len; +int anchor_line_num; -char line[500], - tag[100], - tagparam[10000], - parametr[1200], - options[4096], - anchor[256]; +char line[500]; +char tag[100]; +char tagparam[10000]; +char parametr[1200]; +char options[4096]; +char anchor[256]; #include "..\TWB\history.h" #include "..\TWB\colors.h" @@ -202,7 +202,9 @@ void TWebBrowser::ParseHTML(dword bword){ if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink); b_text = i_text = u_text = s_text = blq_text = - li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //обнуляем теги + li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = + condition_text_val = condition_text_active = 0; //обнуляем теги + condition_max = 10; text_align = ALIGN_LEFT; link_color = 0x0000FF; bg_color = 0xFFFFFF; @@ -223,7 +225,8 @@ void TWebBrowser::ParseHTML(dword bword){ for ( ; buf+filesize > bword; bword++;) { bukva = ESBYTE[bword]; - if (ignor_text) && (bukva<>'<') continue; + if (ignor_text) && (bukva!='<') continue; + if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue; switch (bukva) { case 0x0a: @@ -263,8 +266,7 @@ void TWebBrowser::ParseHTML(dword bword){ bukva = ESBYTE[bword]; chrcat(#tag, bukva); } - bukva = GetUnicodeSymbol(); - if (bukva) goto DEFAULT_MARK; + if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK; break; case '<': bword++; //промотаем символ < @@ -304,6 +306,10 @@ void TWebBrowser::ParseHTML(dword bword){ strlwr(#tag); strlwr(#tagparam); + if (condition_text_active) && (condition_text_val != condition_href) + { + if (strcmp(#tag, "/condition")!=0) break; + } if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); @@ -410,6 +416,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { if (!chTag("body")) { do{ + if (!strcmp(#parametr, "condition_max=")) { condition_max = options[0]-'0'; debugi(condition_max); } if (!strcmp(#parametr, "link=")) link_color = GetColor(#options); if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options); if (!strcmp(#parametr, "bgcolor=")) @@ -544,6 +551,12 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) { TextGoDown(left1, top1, width1); return; } + if (!chTag("condition")) + { + condition_text_active = rez; + if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options); + return; + } if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки { li_text = rez; diff --git a/programs/cmm/TWB/acid_0.1.htm b/programs/cmm/TWB/acid_0.1.htm index 686c59fd67..d6924df17c 100644 --- a/programs/cmm/TWB/acid_0.1.htm +++ b/programs/cmm/TWB/acid_0.1.htm @@ -72,6 +72,13 @@ его должен проигнорировать. Еще много пробелов. А тут есть табы. Кое-какие символы: " & < > •   © ® „ “ — Їжачок іншого боку р. Євфрат з'їв ґрунт та єврейський ґербалайф. + + +

61055,  г. + Харьков, ул.  Краснознаменная, 16,  радиофизический + корпус на территории НТУ «ХПИ» +

+

Zhitomyr 2008-2014
diff --git a/programs/cmm/browser/HTMLv.c b/programs/cmm/browser/HTMLv.c index b7c67888e2..6ea7a4423f 100644 --- a/programs/cmm/browser/HTMLv.c +++ b/programs/cmm/browser/HTMLv.c @@ -26,11 +26,13 @@ #include "img\URLgoto.txt"; #ifdef LANG_RUS - char version[]=" ’ҐЄбв®ўл© Ўа г§Ґа 0.99.31"; + char version[]=" ’ҐЄбв®ўл© Ўа г§Ґа 0.99.5"; ?define IMAGES_CACHE_CLEARED "Љни Є авЁ­®Є ®зЁйҐ­" + ?define T_LAST_SLIDE "ќв® Ї®б«Ґ¤­Ё© б« ©¤" #else - char version[]=" Text-based Browser 0.99.31"; + char version[]=" Text-based Browser 0.99.5"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" + ?define T_LAST_SLIDE "This slide is the last" #endif proc_info Form; @@ -338,19 +340,30 @@ void ProcessLinks(int id) { GetURLfromPageLinks(id); + //$1 - Condition Script + if (URL[0] == '$') + { + if (URL[1]=='-') && (condition_href) condition_href--; + if (URL[1]=='+') + { + if (condition_href-1) + if (strrchr(#URL, '#')!=-1) { strcpy(#anchor, #URL+strrchr(#URL, '#')); URL[strrchr(#URL, '#')-1] = 0x00; diff --git a/programs/cmm/liza/liza.c b/programs/cmm/liza/liza.c index 957f262900..f996fb8a0d 100644 --- a/programs/cmm/liza/liza.c +++ b/programs/cmm/liza/liza.c @@ -84,6 +84,11 @@ llist letter_view; #include "parselist.c" + +/* TWB integration */ +char version[]=" WebView 0.1"; +#include "../TWB/TWB.c" + void main() { mem_Init(); diff --git a/programs/cmm/liza/parselist.c b/programs/cmm/liza/parselist.c index e7be13d546..44e6bde444 100644 --- a/programs/cmm/liza/parselist.c +++ b/programs/cmm/liza/parselist.c @@ -5,8 +5,9 @@ void ParseMail() dword line_off, new_buf; char tline[256]; - if ( mailend-mailstart > 9) && (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a + if ( mailend-mailstart > 9) if (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a { + aim = STOP; mailend -= 5; DSBYTE[mailend] = '\0'; if (strstr(mailstart, "+OK")!=mailstart) @@ -16,9 +17,7 @@ void ParseMail() debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR"); return; } - aim=NULL; mailsize = mailend - mailstart; - debug("Getting QP"); if (strstri(mailstart, "quoted-printable")!=0) { @@ -33,13 +32,15 @@ void ParseMail() mailend = mailsize + mailstart; } } + debug("ProcessBase64"); + ProcessBase64(); debug("GetHeaders: From, To, Date, Subject"); GetHeader(#from, "\nFrom:"); GetHeader(#to, "\nTo:"); GetHeader(#date, "\nDate:"); GetHeader(#subj, "\nSubject:"); debug("Get mdata"); - mdata = strstr(mailstart, "\x0a\x0d") + 3; // 0x0d 0x0a, 0x0a + mdata = strstr(mailstart, "\x0a\x0d") + 3; debug("ConvertToDOS"); ConvertToDOS(mdata, mailstart); debug("FromHTMLtoTXT"); @@ -151,6 +152,7 @@ void GetHeader(dword workstr, searchstr) int q_start, b_start; strcpyb(mailstart, workstr, searchstr, "\n"); + /* debug(searchstr); debug(workstr); if (strlen(workstr)<8) return; @@ -173,4 +175,48 @@ void GetHeader(dword workstr, searchstr) strcpy(workstr, #tmpbuf); } if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';} -} \ No newline at end of file + */ +} + + + +void ProcessBase64() +{ + int b_start, b_end, b_size, b_buf; + int clean_mailstart; + + b_start = strstr(mailstart, "?B?"); + debug("b_size"); + debugi(b_start); + if (b_start) + { + b_end = strstr(b_start, "?="); + debug("b_end"); + debugi(b_end); + b_size = b_end - b_start; + debug("b_size"); + debugi(b_size); + b_buf = malloc(b_size); + strcpyb(mailstart, b_buf, "?B?", "?="); + debug("b_buf"); + debug(b_buf); + + base64_decode stdcall (b_buf, b_buf, b_size-3); + ConvertToDOS(b_buf, mailstart); + if (b_size