Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77be090c57 | ||
|
|
bb85667b09 | ||
|
|
4588b2a7ac | ||
|
|
3e90a90b94 |
No files matched your search
+4
-2
@@ -89,7 +89,7 @@ checkbox tbMenuButton = { MENU_BUTTON };
|
||||
checkbox dkFsize = { FSIZE };
|
||||
checkbox dkAshow = { ASHOW };
|
||||
|
||||
int dkLocation;
|
||||
int dkLocation=0;
|
||||
checkbox tbRunApplButton;
|
||||
checkbox tbClnDeskButton;
|
||||
|
||||
@@ -174,6 +174,7 @@ void DrawWindowContent()
|
||||
dword frame_y;
|
||||
word win_center_x = Form.cwidth / 2 + 20;
|
||||
incn y;
|
||||
int i;
|
||||
|
||||
SetDisabledMode();
|
||||
|
||||
@@ -198,7 +199,8 @@ void DrawWindowContent()
|
||||
//DOCKY
|
||||
frame_y = calc(y.inc(20));
|
||||
DefineButton(22, y.inc(18), PIMG_W-1, PIMG_H-1, 200 + BT_HIDE, 0);
|
||||
DrawPanelsImage(y.n, dkLocation+1);
|
||||
if (!dkLocation) i=2; else i=dkLocation;
|
||||
DrawPanelsImage(y.n, i+1);
|
||||
WriteTextWithBg(68, y.inc(7), 0xD0, sc.work_text, CHANGE_POS, sc.work);
|
||||
dkFsize.draw(22, y.inc(35));
|
||||
dkAshow.draw(win_center_x, y.n);
|
||||
|
||||
@@ -160,11 +160,8 @@ bool TWebBrowser::RenderImage(dword cur_img)
|
||||
|
||||
if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
|
||||
|
||||
if (secondrun)
|
||||
if (secondrun)
|
||||
{
|
||||
if (bg_colors.get_last() - bg_colors.get(0)) {
|
||||
canvas.DrawBar(draw_x, draw_y, img_w, list.item_h, bg_colors.get_last());
|
||||
}
|
||||
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
|
||||
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
|
||||
$push eax
|
||||
|
||||
+5
-16
@@ -304,9 +304,6 @@ void TWebBrowser::tag_img()
|
||||
{
|
||||
char img_path[4096]=0;
|
||||
dword base64img;
|
||||
dword img_data=0, img_size=0;
|
||||
|
||||
if (!secondrun) return;
|
||||
|
||||
if (!tag.get_value_of("data-large-image"))
|
||||
if (!tag.get_value_of("data-src"))
|
||||
@@ -337,22 +334,16 @@ void TWebBrowser::tag_img()
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
}
|
||||
|
||||
if (cache2.is_contain(#img_path))
|
||||
{
|
||||
read_file(cache2.path.get(cache2.cur), #img_data, #img_size);
|
||||
if (img_size) {
|
||||
img_decode stdcall (img_data, img_size, 0);
|
||||
if (EAX) goto IMGOK;
|
||||
} else {
|
||||
//cache2.url.set_null(cache2.cur);
|
||||
}
|
||||
if (cache.has(#img_path)) {
|
||||
img_decode stdcall (cache.current_buf, cache.current_size, 0);
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
} else {
|
||||
if (img_url.get_pos_by_name(#img_path)==-1) img_url.add(#img_path);
|
||||
goto NOIMG;
|
||||
}
|
||||
goto NOIMG;
|
||||
|
||||
IMGOK:
|
||||
if (RenderImage(EAX)) goto IMG_END;
|
||||
if (RenderImage(EAX)) return;
|
||||
|
||||
NOIMG:
|
||||
if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
|
||||
@@ -370,8 +361,6 @@ NOIMG:
|
||||
RenderTextbuf();
|
||||
style.image = false;
|
||||
text_colors.pop();
|
||||
IMG_END:
|
||||
free(img_data);
|
||||
}
|
||||
|
||||
struct TABLE {
|
||||
|
||||
+55
-79
@@ -78,6 +78,7 @@ char search_engine[256];
|
||||
#include "settings.h"
|
||||
#include "tabs.h"
|
||||
|
||||
dword cur_img_url;
|
||||
dword shared_url;
|
||||
dword http_get_type=PAGE;
|
||||
dword render_start_time;
|
||||
@@ -90,10 +91,6 @@ char editURL[URL_SIZE+1];
|
||||
edit_box omnibox_edit = {250, 0, 0, 0xffffff,
|
||||
0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
|
||||
|
||||
int img_downloaders[256];
|
||||
int img_downloaders_count = 0;
|
||||
bool img_loading = false;
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// CODE //
|
||||
@@ -143,9 +140,8 @@ void main()
|
||||
LoadLibraries();
|
||||
LoadIniConfig();
|
||||
HandleParam();
|
||||
cache2.load();
|
||||
|
||||
omnibox_edit.left = PADDING+TSZE*3+PADDING+8;
|
||||
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
|
||||
omnibox_edit.top = PADDING+3;
|
||||
|
||||
WB1.list.SetFont(8, 14, 10011000b);
|
||||
@@ -206,8 +202,9 @@ void main()
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2-random(80),
|
||||
skin_h-WIN_H/2-random(80),WIN_W,WIN_H,0x73,0,0,0);
|
||||
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2-random(80),GetScreenHeight()-WIN_H/2-random(80),
|
||||
//DefineAndDrawWindow(0,0,
|
||||
WIN_W,WIN_H,0x73,0,0,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
ProcessMenuClick();
|
||||
sc.get();
|
||||
@@ -220,13 +217,12 @@ void main()
|
||||
case evNetwork:
|
||||
if (http.transfer <= 0) break;
|
||||
http.receive();
|
||||
if (http.receive_result != 0) break;
|
||||
|
||||
if (http.receive_result != 0) break;
|
||||
if (debug_mode) {
|
||||
EAX = http.transfer;
|
||||
debugln(#EAX.http_msg.http_header);
|
||||
}
|
||||
|
||||
if (http.status_code >= 300) && (http.status_code < 400)
|
||||
{
|
||||
// Handle redirects
|
||||
@@ -236,6 +232,7 @@ void main()
|
||||
} else {
|
||||
StopLoading();
|
||||
redirect_count = 0;
|
||||
if (http_get_type==IMG) goto _IMG_RES;
|
||||
notify("'Too many redirects.' -E");
|
||||
}
|
||||
} else {
|
||||
@@ -259,6 +256,18 @@ void main()
|
||||
free(http.content_pointer);
|
||||
DrawOmnibox();
|
||||
}
|
||||
else if (http_get_type==IMG) {
|
||||
_IMG_RES:
|
||||
if (http.status_code >= 200) && (http.status_code < 300) {
|
||||
cache.add(cur_img_url, http.content_pointer, http.content_received, IMG, NULL);
|
||||
} else {
|
||||
cache.add(cur_img_url, 0, 0, IMG, NULL);
|
||||
}
|
||||
http.hfree();
|
||||
free(http.content_pointer);
|
||||
GetImg(false);
|
||||
}
|
||||
debugln("end evNetwork");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -267,7 +276,6 @@ void main()
|
||||
ESDWORD[shared_url] = '\0';
|
||||
ActivateWindow(GetProcessSlot(Form.ID));
|
||||
}
|
||||
if (img_loading) CheckImgDownloads();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +290,7 @@ void ProcessButtonClick(dword id__)
|
||||
{
|
||||
switch (id__)
|
||||
{
|
||||
case 1: cache2.save(); ExitProcess();
|
||||
case 1: ExitProcess();
|
||||
case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return;
|
||||
case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return;
|
||||
case ENCODINGS...ENCODINGS+6: EventManuallyChangeEncoding(id__-ENCODINGS); return;
|
||||
@@ -355,7 +363,7 @@ void ProcessKeyEvent()
|
||||
|
||||
void SetElementSizes()
|
||||
{
|
||||
omnibox_edit.width = Form.cwidth - omnibox_edit.left - 51;
|
||||
omnibox_edit.width = Form.cwidth - BUTTON_W - SEARCH_GO_GAP - BUTTON_W - omnibox_edit.left - 52 - 23;
|
||||
if (Form.cwidth - scroll_wv.size_x != WB1.list.w) {
|
||||
//temporary fix for crash
|
||||
//related to 'cur_img_url' var read
|
||||
@@ -383,15 +391,14 @@ void draw_window()
|
||||
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.dark, sc.work, 180));
|
||||
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.line);
|
||||
DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work);
|
||||
DrawBar(omnibox_edit.left+omnibox_edit.width+2, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-2, TSZE+1, sc.work);
|
||||
DrawBar(omnibox_edit.left+omnibox_edit.width+24, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-24, TSZE+1, sc.work);
|
||||
|
||||
DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
|
||||
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
|
||||
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE + 2 , PADDING, -1, burger_active); //burger menu
|
||||
|
||||
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-4, PADDING, -1, burger_active); //burger menu
|
||||
|
||||
//DrawTopPanelButton(SEARCH_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W, PADDING, 49, false); // Search web button
|
||||
//DrawTopPanelButton(GO_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W - SEARCH_GO_GAP - BUTTON_W, PADDING, 12, false); // go to address button
|
||||
DrawTopPanelButton(SEARCH_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W, PADDING, 49, false); // Search web button
|
||||
DrawTopPanelButton(GO_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W - SEARCH_GO_GAP - BUTTON_W, PADDING, 12, false); // go to address button
|
||||
|
||||
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.line);
|
||||
|
||||
@@ -485,10 +492,8 @@ void EventCopyLinkToClipboard()
|
||||
|
||||
void StopLoading()
|
||||
{
|
||||
http.stop();
|
||||
//if (http.stop()) pause(10);
|
||||
if (http.stop()) pause(10);
|
||||
prbar.value = 0;
|
||||
img_loading = false;
|
||||
}
|
||||
|
||||
//rewrite into
|
||||
@@ -568,8 +573,6 @@ void OpenPage(dword _open_URL)
|
||||
anchors.take_anchor_from(#new_url);
|
||||
}
|
||||
|
||||
debug("\nWebView GET => "); debugln(#new_url);
|
||||
|
||||
/*
|
||||
There could be several possible types of addresses:
|
||||
- cached page (only http/https)
|
||||
@@ -770,9 +773,9 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
|
||||
WB1.DrawPage();
|
||||
}
|
||||
http.hfree();
|
||||
if (WB1.img_url.count) {
|
||||
GetImg();
|
||||
DrawOmnibox();
|
||||
if (WB1.img_url.count) {
|
||||
GetImg(true);
|
||||
DrawOmnibox();
|
||||
} else {
|
||||
PageLoaded();
|
||||
}
|
||||
@@ -922,18 +925,18 @@ void DrawStatusBar(dword _msg)
|
||||
void DrawOmnibox()
|
||||
{
|
||||
int imgxoff;
|
||||
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+2, 24, sc.line,
|
||||
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+24, 24, sc.line,
|
||||
sc.line, sc.line, sc.dark);
|
||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+2, 1, 0xD8DCD8);
|
||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+2, 1, omnibox_edit.bg_color);
|
||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+24, 1, 0xD8DCD8);
|
||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+24, 1, omnibox_edit.bg_color);
|
||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.bg_color);
|
||||
|
||||
if (http.transfer) || (img_loading) { imgxoff = 67; } else imgxoff = 66;
|
||||
DrawTopPanelButton(REFRESH_BUTTON, PADDING+TSZE*2+PADDING+2, PADDING, imgxoff, false);
|
||||
|
||||
if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
|
||||
EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);
|
||||
edit_box_draw stdcall(#omnibox_edit);
|
||||
if (http.transfer) imgxoff = 23*23*3; else imgxoff = 0;
|
||||
PutImage(omnibox_edit.left+omnibox_edit.width, omnibox_edit.top-1, 23, 23, imgxoff + #editbox_icons);
|
||||
DefineHiddenButton(omnibox_edit.left+omnibox_edit.width, omnibox_edit.top-2, 22, 23, REFRESH_BUTTON);
|
||||
|
||||
DrawProgress();
|
||||
}
|
||||
@@ -998,64 +1001,37 @@ void HandleRedirect()
|
||||
free(redirect_url);
|
||||
}
|
||||
|
||||
void GetImg()
|
||||
dword GetImg(bool _new)
|
||||
{
|
||||
int i;
|
||||
char cur_downloader_path[4096];
|
||||
char local_path[64];
|
||||
dword cur_img_url;
|
||||
if (!show_images) return;
|
||||
http_get_type = IMG;
|
||||
|
||||
if (!show_images) || (!WB1.img_url.count) return;
|
||||
|
||||
img_downloaders_count = math.min(WB1.img_url.count, 256);
|
||||
CreateDir("/tmp0/1/Cache");
|
||||
|
||||
for (i = 0; i < img_downloaders_count; i++) {
|
||||
for (i = 0; i < WB1.img_url.count; i++)
|
||||
{
|
||||
cur_img_url = WB1.img_url.get(i);
|
||||
if (cache2.is_contain(cur_img_url)) continue;
|
||||
sprintf(#local_path, "/tmp0/1/Cache/wv_%i_%i.png", Form.ID, cache2.url.count + 1);
|
||||
sprintf(#cur_downloader_path, "-i %s|%s", cur_img_url, #local_path);
|
||||
cache2.add(cur_img_url, #local_path);
|
||||
img_downloaders[i] = RunProgram("/sys/network/dl", #cur_downloader_path);
|
||||
}
|
||||
|
||||
img_loading = true;
|
||||
prbar.max = img_downloaders_count;
|
||||
prbar.value = 0;
|
||||
}
|
||||
|
||||
void CheckImgDownloads()
|
||||
{
|
||||
int i;
|
||||
int done_count = 0;
|
||||
|
||||
for (i = 0; i < img_downloaders_count; i++) {
|
||||
if (!img_downloaders[i]) || (!GetProcessSlot(img_downloaders[i])) {
|
||||
img_downloaders[i] = 0;
|
||||
done_count++;
|
||||
if (cache.has(cur_img_url)==false) {
|
||||
prbar.max = WB1.img_url.count;
|
||||
prbar.value = i;
|
||||
if (GetUrl(cur_img_url)) {
|
||||
DrawStatusBar(cur_img_url);
|
||||
DrawProgress();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (done_count < img_downloaders_count) {
|
||||
prbar.max = img_downloaders_count;
|
||||
prbar.value = done_count;
|
||||
DrawProgress();
|
||||
sprintf(#param, "Downloading images: %i/%i...", prbar.value, prbar.max);
|
||||
DrawStatusBar(#param);
|
||||
} else {
|
||||
DrawStatusBar(T_RENDERING);
|
||||
WB1.Reparse();
|
||||
WB1.DrawPage();
|
||||
PageLoaded();
|
||||
img_loading = false;
|
||||
DrawOmnibox();
|
||||
}
|
||||
if (_new) return;
|
||||
DrawOmnibox();
|
||||
DrawStatusBar(T_RENDERING);
|
||||
WB1.Reparse();
|
||||
WB1.DrawPage();
|
||||
PageLoaded();
|
||||
}
|
||||
|
||||
void PageLoaded()
|
||||
{
|
||||
DrawStatusBar(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100,
|
||||
GetStartTime()-render_start_time*10));
|
||||
GetStartTime()-render_start_time*10));
|
||||
}
|
||||
|
||||
stop:
|
||||
@@ -61,68 +61,4 @@ void _cache::clear()
|
||||
current_size = NULL;
|
||||
current_type = NULL;
|
||||
current_charset = NULL;
|
||||
}
|
||||
|
||||
|
||||
struct _cache2
|
||||
{
|
||||
collection url;
|
||||
collection path;
|
||||
dword cur;
|
||||
|
||||
void add();
|
||||
bool is_contain();
|
||||
void clear();
|
||||
|
||||
void save();
|
||||
void load();
|
||||
} cache2;
|
||||
|
||||
void _cache2::add(dword _url, _path)
|
||||
{
|
||||
if (!is_contain(_url)) {
|
||||
url.add(_url);
|
||||
path.add(_path);
|
||||
}
|
||||
}
|
||||
|
||||
bool _cache2::is_contain(dword _url)
|
||||
{
|
||||
cur = url.get_pos_by_name(_url);
|
||||
if (cur == -1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void _cache2::clear()
|
||||
{
|
||||
url.drop();
|
||||
path.drop();
|
||||
}
|
||||
|
||||
void _cache2::save()
|
||||
{
|
||||
dword buf, buf_size, i;
|
||||
buf_size = url.data_size + path.data_size + url.count + url.count + 7;
|
||||
buf = malloc(buf_size);
|
||||
strcpy(buf, "[img]\n");
|
||||
for ( i = 0 ; i < path.count ; i++ ) {
|
||||
if (!url.get(i)) continue;
|
||||
strcat(buf, url.get(i));
|
||||
strcat(buf, "=");
|
||||
strcat(buf, path.get(i));
|
||||
strcat(buf, "\n");
|
||||
}
|
||||
strcat(buf, "\0");
|
||||
CreateFile(math.min(buf_size, strlen(buf)), buf, "/tmp0/1/Cache/_list_db.ini");
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void _cache2::load()
|
||||
{
|
||||
ini_enum_keys stdcall ("/tmp0/1/Cache/_list_db.ini", "img", #_cache2_load_sections);
|
||||
}
|
||||
|
||||
byte _cache2_load_sections(dword key_value, key_name, sec_name, f_name)
|
||||
{
|
||||
cache2.add(key_name, key_value);
|
||||
}
|
||||
+3
-1
@@ -108,9 +108,11 @@ enum {
|
||||
TAB_CLOSE_ID = 900
|
||||
};
|
||||
|
||||
char editbox_icons[] = FROM "res/editbox_icons.raw";
|
||||
|
||||
#define WIN_W 850
|
||||
#define WIN_H 920
|
||||
|
||||
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
||||
|
||||
char version[]="WebView 4";
|
||||
char version[]="WebView 3.98";
|
||||
@@ -26,7 +26,6 @@
|
||||
<a href=//menuetos.net>menuetos.net</a>
|
||||
<a href=//osnews.com>osnews.com</a>
|
||||
|
||||
<kosicon n=6><a href=https://cobradile.neocities.org>145 images</a>
|
||||
|
||||
<h3><kosicon n=54>Cyrillic only</h3>
|
||||
<a href=//dgmag.in>dgmag.in</a> <a href=//old-dos.ru>old-dos.ru</a> <a href=//lionovsky.us>lionovsky.us</a> <a href=//mirrors.pdp-11.ru>mirrors.pdp-11.ru</a>
|
||||
|
||||
+7
-34
@@ -13,7 +13,6 @@
|
||||
#include "const.h"
|
||||
|
||||
bool open_file = false;
|
||||
bool invisible = false;
|
||||
|
||||
dword speed;
|
||||
|
||||
@@ -59,7 +58,7 @@ void main()
|
||||
sc.get();
|
||||
InitDownload();
|
||||
|
||||
if (param[0]) {
|
||||
if (param) {
|
||||
path_pointer = #param;
|
||||
//save path specified? Example: https://example.com/file|/sys/media/ac97snd
|
||||
if (save_path_separator_pos = strchr(#param, '|')) {
|
||||
@@ -67,19 +66,11 @@ void main()
|
||||
strcpy(#filepath, save_path_separator_pos+1);
|
||||
ESBYTE[save_path_separator_pos] = '\0';
|
||||
}
|
||||
// invisible window
|
||||
if (!strncmp(#param, "-i ", 3)) {
|
||||
autoclose.checked = true;
|
||||
invisible = true;
|
||||
path_pointer += 3;
|
||||
}
|
||||
// autoclose
|
||||
if (!strncmp(#param, "-e ", 3)) {
|
||||
if (streqrp(#param, "-e ")) {
|
||||
autoclose.checked = true;
|
||||
path_pointer += 3;
|
||||
}
|
||||
// autoclose and open file
|
||||
if (!strncmp(#param, "-eo ", 4)) {
|
||||
if (streqrp(#param, "-eo ")) {
|
||||
autoclose.checked = true;
|
||||
open_file = true;
|
||||
path_pointer += 4;
|
||||
@@ -160,8 +151,6 @@ void DrawDlButton(int x, id, t)
|
||||
|
||||
void DefineWindow()
|
||||
{
|
||||
if (invisible) return;
|
||||
|
||||
sc.get();
|
||||
pb.frame_color = ed.border_color = ed.focus_border_color = sc.line;
|
||||
DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9,
|
||||
@@ -172,9 +161,6 @@ void DefineWindow()
|
||||
void DrawWindow()
|
||||
{
|
||||
#define BUT_Y 58;
|
||||
|
||||
if (invisible) return;
|
||||
|
||||
if (!http.transfer) && (!filepath) {
|
||||
DrawBar(GAPX, 102, WIN_W - GAPX - GAPX+1, 24+1, sc.work);
|
||||
DeleteButton(BTN_DIR);
|
||||
@@ -234,7 +220,6 @@ void StartDownloading()
|
||||
DrawWindow();
|
||||
} else {
|
||||
pb.progress_color = PB_COL_ERROR;
|
||||
if (invisible) ExitProcess();
|
||||
notify(T_ERROR_STARTING_DOWNLOAD);
|
||||
StopDownloading();
|
||||
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
|
||||
@@ -320,9 +305,7 @@ void MonitorProgress()
|
||||
void CompleteDownload()
|
||||
{
|
||||
SaveFile(0);
|
||||
if (autoclose.checked) {
|
||||
ExitProcess();
|
||||
}
|
||||
if (autoclose.checked) ExitProcess();
|
||||
pb.value = pb.max;
|
||||
pb.progress_color = PB_COL_COMPLETE;
|
||||
StopDownloading();
|
||||
@@ -335,8 +318,6 @@ void SaveFile(int attempt)
|
||||
int i;
|
||||
char notify_message[4296];
|
||||
char file_name[URL_SIZE+96];
|
||||
bool quote = false;
|
||||
dword filename_pos;
|
||||
|
||||
//if save_path is not set then we have to combine it
|
||||
if (!save_path_set) {
|
||||
@@ -355,19 +336,11 @@ void SaveFile(int attempt)
|
||||
|
||||
//Content-Disposition: attachment; filename="RealFootball_2018_Nokia_5800_EN_IGP_EU_TS_101.zip"
|
||||
if (http.header_field("content-disposition", #file_name, sizeof(file_name))) {
|
||||
filename_pos = strstr(#file_name,"filename=");
|
||||
if (filename_pos) {
|
||||
if (ESBYTE[filename_pos] == '\"') {
|
||||
quote = true;
|
||||
filename_pos++;
|
||||
}
|
||||
strcat(#filepath, filename_pos+9);
|
||||
if (EDX = strstr(#file_name,"filename=\"")) {
|
||||
strcat(#filepath, EDX+10);
|
||||
ESBYTE[strchr(#filepath,'\"')] = '\0';
|
||||
ESBYTE[strchr(#filepath,' ')] = '\0';
|
||||
ESBYTE[strchr(#filepath,';')] = '\0';
|
||||
}
|
||||
}
|
||||
if (!filename_pos) {
|
||||
} else {
|
||||
// Clean all slashes at the end
|
||||
strcpy(#file_name, #uEdit);
|
||||
while (file_name[strlen(#file_name)-1] == '/') {
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2025
|
||||
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2026
|
||||
//GNU GPL license.
|
||||
|
||||
/*
|
||||
@@ -10,9 +10,9 @@ TODO:
|
||||
http://board.kolibrios.org/viewtopic.php?f=23&t=4521&p=77334#p77334
|
||||
*/
|
||||
|
||||
#define ABOUT_TITLE "Eolite 5.33"
|
||||
#define TITLE_EOLITE "Eolite File Manager 5.33"
|
||||
#define TITLE_KFM "Kolibri File Manager 2.33";
|
||||
#define ABOUT_TITLE "Eolite 5.34"
|
||||
#define TITLE_EOLITE "Eolite File Manager 5.34"
|
||||
#define TITLE_KFM "Kolibri File Manager 2.34";
|
||||
|
||||
#define MEMSIZE 1024 * 250
|
||||
#include "../lib/clipboard.h"
|
||||
@@ -112,7 +112,7 @@ edit_box popin_text = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x1000000
|
||||
|
||||
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
|
||||
|
||||
_ini icons_ini = { "/sys/File managers/icons.ini", NULL };
|
||||
_ini icons_ini = { "/sys/File managers/icon2ext.ini", NULL };
|
||||
|
||||
#include "include\settings.h"
|
||||
#include "include\gui.h"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1012 B After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.5 KiB |
+10
-7
@@ -51,9 +51,9 @@ char *kfm_func = {
|
||||
#define T_DEVICES "Устройства"
|
||||
#define T_ACTIONS "Действия"
|
||||
char *actions[] = {
|
||||
59, "Новый файл", "F9",
|
||||
57, "Новая папка", "F7",
|
||||
60, "Настройки", "F10",
|
||||
59, "Новый файл", " F9",
|
||||
57, "Новая папка", " F7",
|
||||
60, "Настройки", "F10",
|
||||
0,0,0
|
||||
};
|
||||
#define T_SYS "Система "
|
||||
@@ -65,6 +65,7 @@ char *actions[] = {
|
||||
#define T_NVME "NVMe disk "
|
||||
#define T_USB "USB диск "
|
||||
#define T_RAM "RAM диск "
|
||||
#define T_VD "Виртуальный "
|
||||
#define T_UNC "Неизвестно "
|
||||
|
||||
#define WINDOW_TITLE_PROPERTIES "Свойства"
|
||||
@@ -150,9 +151,9 @@ char *kfm_func = {
|
||||
#define T_DEVICES "Devices"
|
||||
#define T_ACTIONS "Actions"
|
||||
char *actions[] = {
|
||||
59, "New file", "F9",
|
||||
57, "New folder", "F7",
|
||||
60, "Settings", "F10",
|
||||
59, "New file", " F9",
|
||||
57, "New folder", " F7",
|
||||
60, "Settings", "F10",
|
||||
0,0,0
|
||||
};
|
||||
#define T_SYS "System "
|
||||
@@ -164,6 +165,7 @@ char *actions[] = {
|
||||
#define T_NVME "NVMe disk "
|
||||
#define T_USB "USB disk "
|
||||
#define T_RAM "RAM disk "
|
||||
#define T_VD "Virtual "
|
||||
#define T_UNC "Unknown "
|
||||
|
||||
#define WINDOW_TITLE_PROPERTIES "Properties"
|
||||
@@ -257,10 +259,11 @@ char *devinfo = {
|
||||
"nv", 4, T_NVME,
|
||||
"tm", 5, T_RAM,
|
||||
"us", 6, T_USB,
|
||||
"vd", 7, T_VD,
|
||||
0
|
||||
};
|
||||
|
||||
#define DEV_H 17
|
||||
#define DEV_H 18
|
||||
#define DDW 110
|
||||
#define KFM2_DEVH 20
|
||||
#define SELECTY 10
|
||||
|
||||
+14
-12
@@ -127,25 +127,27 @@ void Tip(int y, dword caption, id, arrow)
|
||||
void ActionsDraw(int actions_y)
|
||||
{
|
||||
int i;
|
||||
Tip(actions_y-18, T_ACTIONS, 77, "");
|
||||
Tip(actions_y, T_ACTIONS, 77, "");
|
||||
actions_y += 18;
|
||||
for (i=0; actions[i*3]!=0; i++, actions_y+=DEV_H)
|
||||
{
|
||||
DrawBar(SB_BLOCKX,actions_y,SB_BLOCKW,DEV_H,0xFFFFFF); //схыюх
|
||||
DefineButton(SB_BLOCKX,actions_y,SB_BLOCKW-1,DEV_H,actions[i*3]+BT_HIDE,0xE4DFE1);
|
||||
WriteText(45,actions_y+4,0x80,0,actions[i*3+1]);
|
||||
WriteText(-strlen(actions[i*3+2])*6+SIDEBAR_W-SBPAD-7,actions_y+4,0x80,0x999999,actions[i*3+2]);
|
||||
DrawBar(SB_BLOCKX,actions_y,SB_BLOCKW,DEV_H,0xFFFFFF);
|
||||
DefineButton(SB_BLOCKX,actions_y,SB_BLOCKW-1,DEV_H,actions[i*3]+BT_HIDE,NULL);
|
||||
WriteText(45,actions_y+5,0x80,0,actions[i*3+1]);
|
||||
WriteText(SIDEBAR_W-SBPAD-7-18,actions_y+5,0x80,0x999999,actions[i*3+2]);
|
||||
PutImage(23,actions_y+2, 14,13, i*14*13*3+#factions);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLeftPanelBg(int actions_y)
|
||||
void DrawLeftPanelBg(int devices_h)
|
||||
{
|
||||
int start_y = actions_y+159;
|
||||
#define ACTIONS_H DEV_H*3 + 18
|
||||
int start_y = ACTIONS_H + devices_h + 90;
|
||||
int area_h;
|
||||
DrawBar(2,41,SIDEBAR_W-2,SBPAD,waves_pal[0]); //above devices block
|
||||
DrawBar(SB_BLOCKX,actions_y+75,SB_BLOCKW,SBPAD,EDX); //below devices block
|
||||
DrawBar(2,56,SBPAD,actions_y+103,EDX); //on the left
|
||||
DrawBar(SIDEBAR_W-SBPAD,56,SBPAD,actions_y+103,EDX); //on the right
|
||||
DrawBar(SB_BLOCKX,devices_h+75,SB_BLOCKW,SBPAD,EDX); //below devices block
|
||||
DrawBar(2,56,SBPAD,devices_h+ACTIONS_H+34,EDX); //on the left
|
||||
DrawBar(SIDEBAR_W-SBPAD,56,SBPAD,devices_h+ACTIONS_H+34,EDX); //on the right
|
||||
area_h = Form.cheight-start_y-2 - status_bar_h;
|
||||
if (area_h < 268){
|
||||
PutPaletteImage(#blue_hl, 190, area_h, 2, start_y, 8, #waves_pal);
|
||||
@@ -153,8 +155,8 @@ void DrawLeftPanelBg(int actions_y)
|
||||
DrawBar(2,start_y,SIDEBAR_W-2, area_h-268, waves_pal[0]);
|
||||
PutPaletteImage(#blue_hl, 190, 268, 2, Form.cheight-270-status_bar_h, 8, #waves_pal);
|
||||
}
|
||||
PutShadow(SB_BLOCKX,actions_y+75,SB_BLOCKW,1,1,3);
|
||||
PutShadow(SB_BLOCKX+1,actions_y+75+1,SB_BLOCKW-2,1,1,1);
|
||||
PutShadow(SB_BLOCKX,devices_h+75,SB_BLOCKW,1,1,3);
|
||||
PutShadow(SB_BLOCKX+1,devices_h+75+1,SB_BLOCKW-2,1,1,1);
|
||||
PutShadow(SB_BLOCKX,start_y,SB_BLOCKW,1,1,3);
|
||||
PutShadow(SB_BLOCKX+1,start_y+1,SB_BLOCKW-2,1,1,1);
|
||||
}
|
||||
|
||||
+62
-10
@@ -3,13 +3,71 @@ struct ICONS_INI {
|
||||
collection exts;
|
||||
collection_int i18;
|
||||
collection_int i32;
|
||||
byte loaded;
|
||||
int get();
|
||||
void load();
|
||||
void put();
|
||||
} ini_icons;
|
||||
|
||||
// Stores the icon number for a single extension, keeping the exts/i18/i32
|
||||
// collections aligned by position regardless of the order keys are read in.
|
||||
void ICONS_INI::put(dword _ext, int size, icon_n)
|
||||
{
|
||||
int ext_pos = exts.get_pos_by_name(_ext);
|
||||
if (ext_pos == -1) {
|
||||
exts.add(_ext);
|
||||
ext_pos = exts.count - 1;
|
||||
}
|
||||
if (size == 18) i18.set(ext_pos, icon_n);
|
||||
else i32.set(ext_pos, icon_n);
|
||||
}
|
||||
|
||||
// Callback for ini_enum_keys: key_name is the icon number, key_value is a
|
||||
// comma-separated list of extensions sharing that icon, e.g.
|
||||
// 3=doc,docx,exc,inf,log,ob07,odt,rtf,txt,wtx
|
||||
byte icons_ini_enum_key(dword key_value, key_name, sec_name, f_name)
|
||||
{
|
||||
char ext[7];
|
||||
int icon_n, size, i;
|
||||
dword src;
|
||||
|
||||
icon_n = atoi(key_name);
|
||||
if (streq(sec_name, "icons18")) size = 18; else size = 32;
|
||||
|
||||
src = key_value;
|
||||
while (ESBYTE[src]) {
|
||||
i = 0;
|
||||
while (ESBYTE[src]) && (ESBYTE[src] != ',') {
|
||||
if (ESBYTE[src] != ' ') && (i < 6) {
|
||||
ext[i] = ESBYTE[src];
|
||||
i++;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
ext[i] = '\0';
|
||||
if (i) {
|
||||
strlwr(#ext);
|
||||
ini_icons.put(#ext, size, icon_n);
|
||||
}
|
||||
if (ESBYTE[src] == ',') src++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reads the whole icon map once into the collections.
|
||||
void ICONS_INI::load()
|
||||
{
|
||||
if (loaded) return;
|
||||
loaded = true;
|
||||
ini_enum_keys stdcall (icons_ini.path, "icons18", #icons_ini_enum_key);
|
||||
ini_enum_keys stdcall (icons_ini.path, "icons32", #icons_ini_enum_key);
|
||||
}
|
||||
|
||||
int ICONS_INI::get(dword _file_path, _ext, int size)
|
||||
{
|
||||
char file_4bytes[4], ext[7];
|
||||
int ext_pos;
|
||||
load();
|
||||
if (!_ext) {
|
||||
ReadFile(0,4,#file_4bytes,_file_path);
|
||||
IF(DSDWORD[#file_4bytes]=='KCPK')
|
||||
@@ -22,16 +80,10 @@ int ICONS_INI::get(dword _file_path, _ext, int size)
|
||||
ext_pos = exts.get_pos_by_name(#ext);
|
||||
if (ext_pos != -1) {
|
||||
if (size == 18) return i18.get(ext_pos);
|
||||
else if (size == 32) return i32.get(ext_pos);
|
||||
} else {
|
||||
exts.add(#ext);
|
||||
icons_ini.section = "icons18";
|
||||
i18.set(exts.count-1, icons_ini.GetInt(#ext, 2));
|
||||
|
||||
icons_ini.section = "icons32";
|
||||
i32.set(exts.count-1, icons_ini.GetInt(#ext, 95));
|
||||
return get(#ext, size);
|
||||
if (size == 32) return i32.get(ext_pos);
|
||||
}
|
||||
if (size == 18) return 2;
|
||||
return 95;
|
||||
}
|
||||
|
||||
void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
|
||||
@@ -49,7 +101,7 @@ void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
|
||||
icons_ini.section = "drives32";
|
||||
icon_n = icons_ini.GetInt(#ext, 50);
|
||||
} else {
|
||||
icons_ini.section = "drives16";
|
||||
icons_ini.section = "drives18";
|
||||
icon_n = icons_ini.GetInt(#ext, 50);
|
||||
}
|
||||
} else {
|
||||
|
||||
+19
-15
@@ -81,11 +81,15 @@ void GetDiskIconAndName(dword dev_name, icon, disc_name)
|
||||
strcpy(disc_name, T_UNC);
|
||||
}
|
||||
|
||||
#define DISK_COUNT 8
|
||||
void _SystemDiscs::Draw()
|
||||
{
|
||||
char dev_name[15], disc_name[100], i, dev_icon;
|
||||
bool is_active=0;
|
||||
int draw_y, draw_x;
|
||||
#define DRAW_Y 74
|
||||
#define DRAW_X 17
|
||||
#define DRAW_PAD 2
|
||||
int draw_y = DRAW_Y+DRAW_PAD;
|
||||
|
||||
if (efm) {
|
||||
DrawSelect(2, KFM_DEV_DROPDOWN_1, location[0]);
|
||||
@@ -93,36 +97,36 @@ void _SystemDiscs::Draw()
|
||||
files.y = 40 + 17;
|
||||
} else {
|
||||
Tip(56, T_DEVICES, 55, "=");
|
||||
DrawBar(DRAW_X,DRAW_Y,SB_BLOCKW,DRAW_PAD,0xFFFFFF);
|
||||
for (i=0; i<30; i++) DeleteButton(100+i);
|
||||
|
||||
draw_y = 74;
|
||||
draw_x = 17;
|
||||
for (i=0;i<list.count;i++) {
|
||||
strcpy(#dev_name, list.get(i));
|
||||
GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
|
||||
if (strstr(path, #dev_name)==path) is_active=true; else is_active=false;
|
||||
|
||||
DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
|
||||
DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
|
||||
DefineHiddenButton(draw_x,draw_y,159,16,100+i);
|
||||
DrawBar(DRAW_X,draw_y,6,DEV_H+1,0xFFFFFF);
|
||||
DrawBar(DRAW_X+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
|
||||
DefineHiddenButton(DRAW_X,draw_y,159,17,100+i);
|
||||
if (show_dev_name.checked)
|
||||
{
|
||||
strcat(#disc_name, #dev_name);
|
||||
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
|
||||
WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
|
||||
if (is_active) WriteText(DRAW_X+30,draw_y+5,0x80,0x555555,#disc_name);
|
||||
WriteText(DRAW_X+29,draw_y+5,0x80,0,#disc_name);
|
||||
//if (is_active) kfont.bold = true;
|
||||
//kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
|
||||
//kfont.WriteIntoWindow(DRAW_X + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
|
||||
//kfont.bold = false;
|
||||
} else {
|
||||
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
|
||||
WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
|
||||
if (is_active) WriteText(DRAW_X+30,draw_y+5,0x80,0x555555,#dev_name);
|
||||
WriteText(DRAW_X+29,draw_y+5,0x80,0,#dev_name);
|
||||
}
|
||||
PutImage(draw_x+6,draw_y, 18,17, is_active*7+dev_icon*17*18*3+#devices);
|
||||
PutImage(DRAW_X+6,draw_y, 18,17, is_active*DISK_COUNT+dev_icon*17*18*3+#devices);
|
||||
DrawBar(DRAW_X+6, draw_y+DEV_H-1, 18, 1, 0xFFffFF);
|
||||
draw_y += DEV_H;
|
||||
}
|
||||
DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
|
||||
ActionsDraw(list.count*DEV_H+108);
|
||||
DrawLeftPanelBg(list.count*DEV_H);
|
||||
DrawBar(DRAW_X, draw_y, SB_BLOCKW, DRAW_PAD, 0xFFFFFF);
|
||||
ActionsDraw(draw_y+17);
|
||||
DrawLeftPanelBg(draw_y - DRAW_Y + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -89,7 +89,7 @@ void RESULTS::drop()
|
||||
|
||||
void SearchThread()
|
||||
{
|
||||
int prev_first, prev_cur_y, clicked_item;
|
||||
int prev_first, prev_cur_y, clicked_item;
|
||||
|
||||
load_dll(Proc_lib, #OpenDialog_init,0);
|
||||
OpenDialog_init stdcall (#open_folder_dialog);
|
||||
@@ -112,17 +112,17 @@ void SearchThread()
|
||||
SelectList_Draw();
|
||||
} else {
|
||||
SelectList_DrawLine(select_list.cur_y);
|
||||
|
||||
clicked_item = mouse.y - select_list.y / select_list.item_h + select_list.first;
|
||||
|
||||
clicked_item = mouse.y - select_list.y / select_list.item_h + select_list.first;
|
||||
|
||||
if (select_list.MouseOver(mouse.x, mouse.y))
|
||||
{
|
||||
if (mouse.key&MOUSE_LEFT) && (mouse.up) {
|
||||
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventRunFile();
|
||||
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventRunFile();
|
||||
}
|
||||
|
||||
if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
|
||||
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventShowFileInFolder();
|
||||
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventShowFileInFolder();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,8 +222,7 @@ void SelectList_DrawLine(dword i)
|
||||
} else {
|
||||
strcpy(#tname, results.name.get(select_list.first + i));
|
||||
strlwr(#tname);
|
||||
icons_ini.section = "icons18";
|
||||
icon = icons_ini.GetInt(#tname + strrchr(#tname, '.'), 2);
|
||||
icon = ini_icons.get(0, #tname + strrchr(#tname, '.'), 18);
|
||||
}
|
||||
|
||||
#define ICONX 7
|
||||
|
||||
+6
-5
@@ -223,13 +223,14 @@ void _http::receive()
|
||||
|
||||
switch(ESBYTE[new_URL]) {
|
||||
case '.':
|
||||
if (ESBYTE[new_URL+1] == '/') {
|
||||
new_URL+=2;
|
||||
new_URL++;
|
||||
if (ESBYTE[new_URL] == '/') {
|
||||
new_URL++;
|
||||
}
|
||||
else if (ESBYTE[new_URL+1] == '.') && (ESBYTE[new_URL+2] == '/') {
|
||||
else if (ESBYTE[new_URL] == '.') && (ESBYTE[new_URL+1] == '/') {
|
||||
_GO_UP:
|
||||
new_URL+=3;
|
||||
newurl[strrchr(#newurl, '/')-1] = '\0';
|
||||
new_URL+=2;
|
||||
newurl[strrchr(#newurl, '/')-1] = '\0';
|
||||
}
|
||||
goto _DEFAULT;
|
||||
case '?':
|
||||
|
||||
+115
-19
@@ -94,6 +94,9 @@ int fat_off;
|
||||
int root_off;
|
||||
int data_off;
|
||||
|
||||
int lfn_nonascii;
|
||||
int lfn_checksum;
|
||||
|
||||
char cur_path[4096];
|
||||
int cur_path_len;
|
||||
|
||||
@@ -150,7 +153,6 @@ void extract_file(dword buf, int size, int cluster)
|
||||
while (cluster >= 2) && (cluster < 0xFF7) {
|
||||
src = cluster_to_offset(cluster);
|
||||
n = bpc;
|
||||
// clamp to remaining size
|
||||
if (written + n > size) n = size - written;
|
||||
if (n <= 0) break;
|
||||
// Stop on a corrupt FAT chain pointing outside the image
|
||||
@@ -166,7 +168,6 @@ void make_parent_dirs(dword initial_dir)
|
||||
char path[4096];
|
||||
int i;
|
||||
strncpy(#path, initial_dir, strlen(initial_dir) + 1);
|
||||
//debugln(#path);
|
||||
for (i = 1; path[i]; i++) {
|
||||
if (path[i] == '/') {
|
||||
path[i] = '\0';
|
||||
@@ -183,7 +184,6 @@ int entry_short_name(int off, dword out)
|
||||
if (!b) return -1;
|
||||
if (b == 0xE5) return 0;
|
||||
attr = fat_u8(off + 11);
|
||||
if (attr & 0x0F == 0x0F) return 0;
|
||||
if (attr & 0x08) return 0;
|
||||
|
||||
n = 0;
|
||||
@@ -208,23 +208,110 @@ int entry_short_name(int off, dword out)
|
||||
return n;
|
||||
}
|
||||
|
||||
int handle_entry(int off)
|
||||
// Extracts characters from an LFN record.
|
||||
// Zeroes the buffer when the end of line (0x0000 or 0xFFFF) is encountered.
|
||||
int get_lfn_chars(int off, dword out)
|
||||
{
|
||||
char name[13];
|
||||
int nlen, attr, cluster, size, saved_len;
|
||||
int i, c, pos;
|
||||
// LFN stores 13 UCS-2 chars at non-contiguous offsets 1..10, 14..25, 28..31
|
||||
// (gaps: 11..13 attr/type/checksum, 26..27 cluster).
|
||||
i = 1;
|
||||
for (pos = 0; pos < 13; pos++) {
|
||||
c = fat_u16(off + i);
|
||||
if (c == 0x0000) || (c == 0xFFFF) { ESBYTE[out+pos] = 0; return pos; }
|
||||
if (c > 0x7F) lfn_nonascii = 1;
|
||||
ESBYTE[out + pos] = c & 0xFF;
|
||||
i += 2;
|
||||
if (i == 11) i = 14;
|
||||
if (i == 26) i = 28;
|
||||
}
|
||||
ESBYTE[out + pos] = 0;
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Returns -1 to stop iteration, 0 to continue.
|
||||
int process_one_entry(int entry_off, dword lfn_buf, dword p_seq)
|
||||
{
|
||||
char chunk[15];
|
||||
int b, attr, seq, chunk_len, dest_offset;
|
||||
|
||||
b = fat_u8(entry_off);
|
||||
if (!b) return -1;
|
||||
if (b == 0xE5) { ESDWORD[p_seq] = -1; return 0; }
|
||||
|
||||
attr = fat_u8(entry_off + 11);
|
||||
if (attr == 0x0F) {
|
||||
seq = b;
|
||||
if (seq & 0x40) {
|
||||
seq &= 0x3F;
|
||||
if (seq < 1) || (seq > 20) { ESDWORD[p_seq] = -1; return 0; }
|
||||
ESDWORD[p_seq] = seq;
|
||||
lfn_nonascii = 0;
|
||||
lfn_checksum = fat_u8(entry_off + 13);
|
||||
EDI = lfn_buf; ECX = 65; EAX = 0; MEMSETD(EDI, ECX, EAX);
|
||||
}
|
||||
if (seq == ESDWORD[p_seq]) {
|
||||
chunk_len = get_lfn_chars(entry_off, #chunk);
|
||||
dest_offset = seq - 1;
|
||||
dest_offset *= 13;
|
||||
memmov(lfn_buf + dest_offset, #chunk, chunk_len);
|
||||
ESDWORD[p_seq] = ESDWORD[p_seq] - 1;
|
||||
} else {
|
||||
ESDWORD[p_seq] = -1;
|
||||
}
|
||||
} else {
|
||||
if (ESDWORD[p_seq] == 0) {
|
||||
if (handle_entry(entry_off, lfn_buf) < 0) return -1;
|
||||
} else {
|
||||
if (handle_entry(entry_off, NULL) < 0) return -1;
|
||||
}
|
||||
ESDWORD[p_seq] = -1;
|
||||
ESBYTE[lfn_buf] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_entry(int off, dword lfn_name)
|
||||
{
|
||||
char name[256];
|
||||
int nlen, attr, cluster, size, saved_len, use_lfn, sum, hi, i;
|
||||
dword buf;
|
||||
|
||||
if (off < 0) || (off + 32 > img_sz) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
nlen = entry_short_name(off, #name);
|
||||
attr = fat_u8(off + 11);
|
||||
if (attr == 0x0F) return 0;
|
||||
|
||||
if (nlen < 0) return -1;
|
||||
if (nlen == 0) return 0;
|
||||
if (name[0] == '.') return 0;
|
||||
// Verify LFN checksum against the short-name field (off..off+10).
|
||||
use_lfn = 0;
|
||||
if (lfn_name) && (ESBYTE[lfn_name]) && (!lfn_nonascii) {
|
||||
sum = 0;
|
||||
for (i = 0; i < 11; i++) {
|
||||
hi = sum & 1;
|
||||
hi = hi << 7;
|
||||
sum = sum >> 1;
|
||||
sum = sum + hi;
|
||||
sum = sum + fat_u8(off + i);
|
||||
sum = sum & 0xFF;
|
||||
}
|
||||
if (sum == lfn_checksum) use_lfn = 1;
|
||||
}
|
||||
|
||||
if (use_lfn) {
|
||||
strncpy(#name, lfn_name, 255);
|
||||
nlen = strlen(#name);
|
||||
} else {
|
||||
nlen = entry_short_name(off, #name);
|
||||
if (nlen < 0) return -1;
|
||||
if (nlen == 0) return 0;
|
||||
}
|
||||
|
||||
// Skip only the "." and ".." directory entries (a real LFN name may start with '.').
|
||||
if (name[0] == '.') && (name[1] == '\0') return 0;
|
||||
if (name[0] == '.') && (name[1] == '.') && (name[2] == '\0') return 0;
|
||||
|
||||
attr = fat_u8(off + 11);
|
||||
cluster = fat_u16(off + 26);
|
||||
|
||||
saved_len = cur_path_len;
|
||||
@@ -258,12 +345,16 @@ int handle_entry(int off)
|
||||
|
||||
void handle_folder(int cluster)
|
||||
{
|
||||
int off, entries, i;
|
||||
int off, entries, i, entry_off;
|
||||
int lfn_expected_seq;
|
||||
char lfn_buf[260];
|
||||
|
||||
lfn_buf[0] = 0;
|
||||
lfn_expected_seq = -1;
|
||||
|
||||
while (cluster >= 2) && (cluster < 0xFF7) {
|
||||
off = cluster_to_offset(cluster);
|
||||
|
||||
// Check that offset don't go negative
|
||||
// and we don't read over img size (img_sz)
|
||||
if (off < 0) || (off + bpc > img_sz) {
|
||||
notify(MSG_OOB);
|
||||
return;
|
||||
@@ -271,7 +362,8 @@ void handle_folder(int cluster)
|
||||
|
||||
entries = bpc / 32;
|
||||
for (i = 0; i < entries; i++) {
|
||||
if (handle_entry(i * 32 + off) < 0) return;
|
||||
entry_off = i * 32 + off;
|
||||
if (process_one_entry(entry_off, #lfn_buf, #lfn_expected_seq) < 0) return;
|
||||
}
|
||||
cluster = next_cluster(cluster);
|
||||
}
|
||||
@@ -288,7 +380,8 @@ void main()
|
||||
{
|
||||
char img_file[4096];
|
||||
char img_info[512];
|
||||
int i;
|
||||
char root_lfn[260];
|
||||
int i, entry_off, lfn_expected_seq;
|
||||
|
||||
mem_init();
|
||||
|
||||
@@ -312,8 +405,8 @@ void main()
|
||||
cur_path_len = strlen(#cur_path);
|
||||
|
||||
read_file(#img_file, #img_ptr, #img_sz);
|
||||
if (!img_ptr) || (!img_sz) {
|
||||
NotifyAndExit(MSG_READ, #img_file);
|
||||
if (!img_ptr) || (!img_sz) {
|
||||
NotifyAndExit(MSG_READ, #img_file);
|
||||
}
|
||||
|
||||
fat12__open();
|
||||
@@ -327,8 +420,11 @@ void main()
|
||||
NotifyAndExit(MSG_MKDIR, #cur_path);
|
||||
}
|
||||
|
||||
root_lfn[0] = 0;
|
||||
lfn_expected_seq = -1;
|
||||
for (i = 0; i < mre; i++) {
|
||||
if (handle_entry(i * 32 + root_off) < 0) break;
|
||||
entry_off = i * 32 + root_off;
|
||||
if (process_one_entry(entry_off, #root_lfn, #lfn_expected_seq) < 0) break;
|
||||
}
|
||||
|
||||
NotifyAndExit(MSG_DONE, #cur_path);
|
||||
|
||||
Reference in new issue
Block a user