Subversion Repositories Kolibri OS

Rev

Rev 8565 | Rev 8785 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8565 Rev 8707
Line 1... Line 1...
1
/* Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv2 */
1
/* Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv2 */
Line -... Line 2...
-
 
2
 
2
 
3
#include 
3
#include 
4
#include 
4
#include 
5
#include 
5
#include 
-
 
6
#include 
6
#include 
7
#include 
7
#include 
8
#include 
8
#include 
9
#include 
9
#include 
10
#include 
10
#include 
Line 15... Line 15...
15
#define FALSE 0;
15
#define FALSE 0;
16
#define MAX_HASH_LEN 65 // Œ ªá¨¬ «ì­ ï ¤«¨­  áâப¨
16
#define MAX_HASH_LEN 65 // Œ ªá¨¬ «ì­ ï ¤«¨­  áâப¨
17
#define WINDOW_W 665
17
#define WINDOW_W 665
18
#define VERSION "%s - thashview 2.6.1"
18
#define VERSION "%s - thashview 2.6.1"
19
#define EDIT_TEXT_SIZE 0x10000000
19
#define EDIT_TEXT_SIZE 0x10000000
-
 
20
#define DATA(type, addr, offset) *((type*)((uint8_t*)addr+offset))
Line 20... Line 21...
20
 
21
 
Line 21... Line 22...
21
struct kolibri_system_colors sys_color_table;
22
ksys_colors_table_t sys_color_table;
22
 
23
 
23
char hash_str_md5[MAX_HASH_LEN]=   "Click the 'MD5:' button to show the md5-checksum!"; //‚뢮¤ MD5
24
char hash_str_md5[MAX_HASH_LEN]=   "Click the 'MD5:' button to show the md5-checksum!"; //‚뢮¤ MD5
24
char hash_str_sha1[MAX_HASH_LEN]=  "Click the 'SHA1:' button to show the sha1-checksum!"; //‚뢮¤ SHA1
25
char hash_str_sha1[MAX_HASH_LEN]=  "Click the 'SHA1:' button to show the sha1-checksum!"; //‚뢮¤ SHA1
Line 52... Line 53...
52
    BTN_PASTE=50       //‚áâ ¢¨âì ¢ edit_box(¯®ª  ¢ ࠧࠡ®âª¥)
53
    BTN_PASTE=50       //‚áâ ¢¨âì ¢ edit_box(¯®ª  ¢ ࠧࠡ®âª¥)
53
};
54
};
Line 54... Line 55...
54
 
55
 
55
void notify_show(char *text)
56
void notify_show(char *text)
56
{
57
{
57
   start_app("/sys/@notify", text);
58
   _ksys_exec("/sys/@notify", text);
Line 58... Line 59...
58
}
59
}
59
 
60
 
60
void* safe_malloc(size_t size) // ¥§®¯ á­ë© malloc. ®ª §ë¢ ¥â 㢥¤®¬«¥­¨¥ ®¡ ®è¨¡ª¥ ¨ § ªà뢠¥â ¯à®£à ¬¬ã ¥á«¨ ¯ ¬ïâì ­¥ ¡ë«  ¢ë¤¥«¥­ 
61
void* safe_malloc(size_t size) // ¥§®¯ á­ë© malloc. ®ª §ë¢ ¥â 㢥¤®¬«¥­¨¥ ®¡ ®è¨¡ª¥ ¨ § ªà뢠¥â ¯à®£à ¬¬ã ¥á«¨ ¯ ¬ïâì ­¥ ¡ë«  ¢ë¤¥«¥­ 
Line 158... Line 159...
158
}
159
}
Line 159... Line 160...
159
 
160
 
160
void redraw_window() //¨á㥬 ®ª­®
161
void redraw_window() //¨á㥬 ®ª­®
161
{
162
{
162
    sprintf(title,VERSION, filename); // “áâ ­ ¢«¨¢ ¥¬ § £®«®¢®ª ®ª­ 
163
    sprintf(title,VERSION, filename); // “áâ ­ ¢«¨¢ ¥¬ § £®«®¢®ª ®ª­ 
163
    pos_t win_pos = get_mouse_pos(0); // ®«ãç ¥¬ ª®®à¤¨­ âë ªãàá®à 
164
    ksys_pos_t win_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); // ®«ãç ¥¬ ª®®à¤¨­ âë ªãàá®à 
164
    begin_draw(); // ç¨­ ¥¬ à¨á®¢ ­¨¥ ¨­â¥àä¥©á  )
165
    _ksys_start_draw(); // ç¨­ ¥¬ à¨á®¢ ­¨¥ ¨­â¥àä¥©á  )
165
    sys_create_window(win_pos.x, win_pos.y, WINDOW_W, 150, title, sys_color_table.work_area, 0x14); // ‘®§¤ ñ¬ ®ª­®.
-
 
166
 
166
    _ksys_create_window(win_pos.x, win_pos.y, WINDOW_W, 150, title, sys_color_table.work_area, 0x14); // ‘®§¤ ñ¬ ®ª­®.
Line 167... Line 167...
167
    edit_box_draw(&hash_edit_box); // ¨á㥬 edit_box
167
    edit_box_draw(&hash_edit_box); // ¨á㥬 edit_box
168
 
168
 
169
    define_button(X_W(10,60), Y_H(30,20), BTN_MD5, GREEN); // Ž¯à¥¤¥«ï¥¬ ª­®¯ªã md5
169
    _ksys_define_button(10, 30, 60, 20, BTN_MD5, GREEN); // Ž¯à¥¤¥«ï¥¬ ª­®¯ªã md5
170
    define_button(X_W(10,60), Y_H(60,20), BTN_SHA1, GREEN);// Ž¯à¥¤¥«ï¥¬ ª­®¯ªã sha1
170
    _ksys_define_button(10, 60, 60, 20, BTN_SHA1, GREEN);// Ž¯à¥¤¥«ï¥¬ ª­®¯ªã sha1
171
    define_button(X_W(10,60), Y_H(90,20), BTN_SHA256, GREEN);// Ž¯à¥¤¥«ï¥¬ ª­®¯ªã sha256
171
    _ksys_define_button(10, 90, 60, 20, BTN_SHA256, GREEN);// Ž¯à¥¤¥«ï¥¬ ª­®¯ªã sha256
172
 
172
 
173
    draw_text_sys("MD5:", 15, 34, 0,   0x90000000 | sys_color_table.work_button_text); // ¨é¥¬ ⥪áâ ­  ª­®¯ª å
173
    _ksys_draw_text("MD5:", 15, 34, 0,   0x90000000 | sys_color_table.work_button_text); // ¨é¥¬ ⥪áâ ­  ª­®¯ª å
174
    draw_text_sys("SHA1:", 15, 64, 0,  0x90000000 | sys_color_table.work_button_text);
174
    _ksys_draw_text("SHA1:", 15, 64, 0,  0x90000000 | sys_color_table.work_button_text);
175
    draw_text_sys("SHA256:", 15,94, 0, 0x90000000 | sys_color_table.work_button_text);
175
    _ksys_draw_text("SHA256:", 15,94, 0, 0x90000000 | sys_color_table.work_button_text);
176
 
176
 
177
    draw_text_sys(hash_str_md5, 80, 34, 0, 0x90000000 | sys_color_table.work_text); // ‚뢮¤¨¬ ª®­â஫ì­ë¥ áã¬¬ë ¢ ®ª­®
177
    _ksys_draw_text(hash_str_md5, 80, 34, 0, 0x90000000 | sys_color_table.work_text); // ‚뢮¤¨¬ ª®­â஫ì­ë¥ áã¬¬ë ¢ ®ª­®
-
 
178
    _ksys_draw_text(hash_str_sha1, 80, 64, 0, 0x90000000 | sys_color_table.work_text);
178
    draw_text_sys(hash_str_sha1, 80, 64, 0, 0x90000000 | sys_color_table.work_text);
179
    _ksys_draw_text(hash_str_sha256, 80, 94, 0, 0x90000000| sys_color_table.work_text);
179
    draw_text_sys(hash_str_sha256, 80, 94, 0, 0x90000000| sys_color_table.work_text);
180
 
180
 
181
    
181
    define_button(X_W(610,42), Y_H(30, 20), BTN_COPY_MD5, sys_color_table.work_button); // Ž¯à¥¤¥«ï¥¬ ª­®¯ª¨ ¤«ï ª®¯¨à®¢ ­¨ï
182
    _ksys_define_button(610, 30, 42, 20, BTN_COPY_MD5, sys_color_table.work_button); // Ž¯à¥¤¥«ï¥¬ ª­®¯ª¨ ¤«ï ª®¯¨à®¢ ­¨ï
182
    define_button(X_W(610,42), Y_H(60, 20), BTN_COPY_SHA1, sys_color_table.work_button);
183
    _ksys_define_button(610, 60, 42, 20, BTN_COPY_MD5, sys_color_table.work_button);
183
    define_button(X_W(610,42), Y_H(90, 20), BTN_COPY_SHA256, sys_color_table.work_button);
184
    _ksys_define_button(610, 90, 42, 20, BTN_COPY_MD5, sys_color_table.work_button);
184
 
185
 
185
    draw_text_sys("Copy", 615, 34, 0,   0x90000000 | sys_color_table.work_button_text); // ¨è¥¬ copy ­  ¢á¥å ª­®¯ª å ¤«ï ª®¯¨à®¢ ­¨ï
186
    _ksys_draw_text("Copy", 615, 34, 0,   0x90000000 | sys_color_table.work_button_text); // ¨è¥¬ copy ­  ¢á¥å ª­®¯ª å ¤«ï ª®¯¨à®¢ ­¨ï
186
    draw_text_sys("Copy", 615, 64, 0,  0x90000000 | sys_color_table.work_button_text);
187
    _ksys_draw_text("Copy", 615, 64, 0,  0x90000000 | sys_color_table.work_button_text);
187
    draw_text_sys("Copy", 615, 94, 0, 0x90000000 | sys_color_table.work_button_text);
188
    _ksys_draw_text("Copy", 615, 94, 0, 0x90000000 | sys_color_table.work_button_text);
188
 
189
 
189
    define_button(X_W(592,60), Y_H(120,20), BTN_CMP, GREEN); // Ž¯à¥¤¥«ï¥¬ ª­®¯ªã ¤«ï áà ¢­¥­¨ï ª®­â®«ì­ëå á㬬
190
    _ksys_define_button(592, 120, 60, 20, BTN_CMP, GREEN); // Ž¯à¥¤¥«ï¥¬ ª­®¯ªã ¤«ï áà ¢­¥­¨ï ª®­â®«ì­ëå á㬬
190
    draw_text_sys("Compare", 595, 124 , 0,0x90000000 | sys_color_table.work_button_text); // ¨è¥¬ â¥ªá ­  ª­®¯ª¥.
191
    _ksys_draw_text("Compare", 595, 124 , 0,0x90000000 | sys_color_table.work_button_text); // ¨è¥¬ â¥ªá ­  ª­®¯ª¥.
191
    define_button(X_W(540, 45), Y_H(120,20), BTN_PASTE, sys_color_table.work_button); //Š­®¯ª  ¤«ï ¢áâ ¢ª¨ (­¥à ¡®â ¥â)
192
    _ksys_define_button(540, 120, 45, 20, BTN_PASTE, sys_color_table.work_button); //Š­®¯ª  ¤«ï ¢áâ ¢ª¨ (­¥à ¡®â ¥â)
192
    draw_text_sys("Paste", 543, 124 , 0,0x90000000 | sys_color_table.work_button_text); // ’¥ªáâ paste ­  ª­®¯ª¥
193
    _ksys_draw_text("Paste", 543, 124 , 0,0x90000000 | sys_color_table.work_button_text); // ’¥ªáâ paste ­  ª­®¯ª¥
Line 193... Line 194...
193
    end_draw();
194
    _ksys_end_draw();
194
}
195
}
195
 
196
 
196
void paste_to_edit_buffer()    // ‚áâ ¢¨âì ¨§ ¡ãää¥à  ®¡¬¥­ 
197
void paste_to_edit_buffer()    // ‚áâ ¢¨âì ¨§ ¡ãää¥à  ®¡¬¥­ 
197
{
198
{
198
    char *temp_buff=NULL;
199
    char *temp_buff=NULL;
199
    if(kol_clip_num()>0){
200
    if(_ksys_clip_num()>0){
200
        temp_buff=kol_clip_get(kol_clip_num()-1);
201
        temp_buff=_ksys_clip_get(_ksys_clip_num()-1);
201
        memset(edit_box_buff,0,MAX_HASH_LEN);
202
        memset(edit_box_buff,0,MAX_HASH_LEN);
202
        if(DATA(int, temp_buff,0)>0 && DATA(int,temp_buff,4)==CLIP_TEXT && DATA(int,temp_buff,8)==CLIP_CP866){
203
        if(DATA(int, temp_buff,0)>0 && DATA(int,temp_buff,4)==KSYS_CLIP_TEXT && DATA(int,temp_buff,8)==KSYS_CLIP_CP866){
203
            strncpy(edit_box_buff,temp_buff+12, MAX_HASH_LEN-1);
204
            strncpy(edit_box_buff,temp_buff+12, MAX_HASH_LEN-1);
204
            edit_box_set_text(&hash_edit_box,edit_box_buff);
205
            edit_box_set_text(&hash_edit_box,edit_box_buff);
205
            notify_show("'Pasted from clipboard!' -I");
206
            notify_show("'Pasted from clipboard!' -I");
206
            hash_edit_box.text_color = BLACK;
207
            hash_edit_box.text_color = BLACK;
207
            user_free(temp_buff);
208
            free(temp_buff);
Line 208... Line 209...
208
        }
209
        }
Line 216... Line 217...
216
       text_hash_len==SHA1_BLOCK_SIZE || 
217
       text_hash_len==SHA1_BLOCK_SIZE || 
217
       text_hash_len==SHA256_BLOCK_SIZE) // …᫨ ⥪áâ ï¥âáï åíè-áâப®©
218
       text_hash_len==SHA256_BLOCK_SIZE) // …᫨ ⥪áâ ï¥âáï åíè-áâப®©
218
    {
219
    {
219
        char *temp_buffer=safe_malloc(MAX_HASH_LEN+12); // ‚뤥«ï¥¬ ¯ ¬ïâì ¤«ï ¢à¥¬­­®£® ¡ãä¥à 
220
        char *temp_buffer=safe_malloc(MAX_HASH_LEN+12); // ‚뤥«ï¥¬ ¯ ¬ïâì ¤«ï ¢à¥¬­­®£® ¡ãä¥à 
220
        memset(temp_buffer, 0, MAX_HASH_LEN);   // ‡ ­ã«ï¥¬ ¡ãä¥à
221
        memset(temp_buffer, 0, MAX_HASH_LEN);   // ‡ ­ã«ï¥¬ ¡ãä¥à
221
        DATA(char,temp_buffer,4)=CLIP_TEXT;     // “áâ ­ ¢«¨¢ ¥¬ TEXT ¤«ï ¡ãä¥à (‘¬¥é¥­¨¥ 4 ¡ ©â )
222
        DATA(char,temp_buffer,4)=KSYS_CLIP_TEXT;     // “áâ ­ ¢«¨¢ ¥¬ TEXT ¤«ï ¡ãä¥à (‘¬¥é¥­¨¥ 4 ¡ ©â )
222
        DATA(char,temp_buffer,8)=CLIP_CP866;    // “áâ ­ ¢«¨¢ ¥¬ ª®¤¨à®¢ªã CP866(‘¬¥é¥­¨¥ 8 ¡ ©â)
223
        DATA(char,temp_buffer,8)=KSYS_CLIP_CP866;    // “áâ ­ ¢«¨¢ ¥¬ ª®¤¨à®¢ªã CP866(‘¬¥é¥­¨¥ 8 ¡ ©â)
223
        strncpy(temp_buffer+12, text, MAX_HASH_LEN-1); // Š®¯¨à㥬 ¤ ­­ë¥ ¨§ text ¢® ¢à¥¬¥­­ë© ¡ãä¥à(‘¬¥é¥­¨¥ 12 ¡ ©â)
224
        strncpy(temp_buffer+12, text, MAX_HASH_LEN-1); // Š®¯¨à㥬 ¤ ­­ë¥ ¨§ text ¢® ¢à¥¬¥­­ë© ¡ãä¥à(‘¬¥é¥­¨¥ 12 ¡ ©â)
224
        kol_clip_set(strlen(text)+12, temp_buffer); // ‚믮«­ï¥¬ á¨á⥬­ë© ¢ë§®¢ ¨ ¯¥à¥¬¥é ¥¬ ¤ ­­ë¥ ¨§ ¢à¥¬¥­­®£® ¡ãä¥à  ¢ ¡ãä¥à ®¡¬¥­ 
225
        _ksys_clip_set(strlen(text)+12, temp_buffer); // ‚믮«­ï¥¬ á¨á⥬­ë© ¢ë§®¢ ¨ ¯¥à¥¬¥é ¥¬ ¤ ­­ë¥ ¨§ ¢à¥¬¥­­®£® ¡ãä¥à  ¢ ¡ãä¥à ®¡¬¥­ 
225
        notify_show("'Copied to clipboard!' -I");   
226
        notify_show("'Copied to clipboard!' -I");   
226
        free(temp_buffer); // Žá¢®¡®¦ ¥¬ ¢à¥¬¥­­ë© ¡ãä¥à.
227
        free(temp_buffer); // Žá¢®¡®¦ ¥¬ ¢à¥¬¥­­ë© ¡ãä¥à.
227
    }
228
    }
228
}
229
}
Line 294... Line 295...
294
 
295
 
295
    if(NULL==fopen(filename,"rb")){ // …᫨ ä ©«  ­¥â ¨«¨ ­¥ ®âªà뢠¥âáï
296
    if(NULL==fopen(filename,"rb")){ // …᫨ ä ©«  ­¥â ¨«¨ ­¥ ®âªà뢠¥âáï
296
        notify_show("'File not found!' -E");
297
        notify_show("'File not found!' -E");
297
        exit(0);
298
        exit(0);
298
    }
-
 
299
 
299
    }
300
    if(GetScreenSize()/65536
300
    if(_ksys_screen_size().x
301
        notify_show("'Low screen resolution! Program will not display correctrly!' -W");
301
        notify_show("'Low screen resolution! Program will not display correctrly!' -W");
Line 302... Line 302...
302
    }
302
    }
303
 
303
 
Line 304... Line 304...
304
    int gui_event; // ¥à¥¬¥­­ ï ¤«ï åà ­¥­¨ï ᮡëâ¨ï
304
    int gui_event; // ¥à¥¬¥­­ ï ¤«ï åà ­¥­¨ï ᮡëâ¨ï
305
    uint32_t pressed_button = 0; // Š®¤ ­ ¦ â®© ª­®¯ª¨ ¢ ®ª­¥
305
    uint32_t pressed_button = 0; // Š®¤ ­ ¦ â®© ª­®¯ª¨ ¢ ®ª­¥
Line 306... Line 306...
306
 
306
 
307
    get_system_colors(&sys_color_table);
307
    _ksys_get_system_colors(&sys_color_table);
308
    hash_edit_box.shift_color=sys_color_table.work_button;
308
    hash_edit_box.shift_color=sys_color_table.work_button;
309
 
309
 
310
    set_event_mask(0xC0000027);// “áâ ­ ¢«¨¢ ¥¬ ¬ áªã ᮡë⨩
310
    _ksys_set_event_mask(0xC0000027);// “áâ ­ ¢«¨¢ ¥¬ ¬ áªã ᮡë⨩
311
    do // –¨ª« ®¡à ¡®âª¨ ᮡë⨩
311
    do // –¨ª« ®¡à ¡®âª¨ ᮡë⨩
312
    {
312
    {
313
        gui_event = get_os_event(); // ®«ãç ¥¬ ᮡë⨥
313
        gui_event = _ksys_get_event(); // ®«ãç ¥¬ ᮡë⨥
314
        switch(gui_event){ // Ž¡à ¡ â뢠¥¬ ᮡëâ¨ï
314
        switch(gui_event){ // Ž¡à ¡ â뢠¥¬ ᮡëâ¨ï
315
            case KOLIBRI_EVENT_NONE:
315
            case KSYS_EVENT_NONE:
316
                break;
316
                break;
317
            case KOLIBRI_EVENT_REDRAW:
317
            case KSYS_EVENT_REDRAW:
318
                redraw_window();
318
                redraw_window();
319
                break;
319
                break;
320
            case KOLIBRI_EVENT_MOUSE:
320
            case KSYS_EVENT_MOUSE:
321
                edit_box_mouse(&hash_edit_box);
321
                edit_box_mouse(&hash_edit_box);
322
                break;        
322
                break;        
323
            case KOLIBRI_EVENT_KEY:
323
            case KSYS_EVENT_KEY:
324
                hash_edit_box.text_color = BLACK;
324
                hash_edit_box.text_color = BLACK;
325
                edit_box_key(&hash_edit_box,get_key().val);
325
                edit_box_key(&hash_edit_box, _ksys_get_key().val);
326
                break;
326
                break;
327
            case KOLIBRI_EVENT_BUTTON: // ‘®¡ë⨥ ®¡à ¡®âª¨ ª­®¯®ª
327
            case KSYS_EVENT_BUTTON: // ‘®¡ë⨥ ®¡à ¡®âª¨ ª­®¯®ª
328
                pressed_button = get_os_button(); // ®«ã祭¨¥ ª®¤  ­ ¦ â®© ª­®¯ª¨.
328
                pressed_button = _ksys_get_button(); // ®«ã祭¨¥ ª®¤  ­ ¦ â®© ª­®¯ª¨.
329
                switch (pressed_button){ // à®¢¥àª  ª ª ï ª­®¯ª  ¡ë«  ­ ¦ â 
329
                switch (pressed_button){ // à®¢¥àª  ª ª ï ª­®¯ª  ¡ë«  ­ ¦ â