TinyHashView 2.5:

- Added launch of OpenDialog if the program is launched without parameters.
- Macros are used for convenient work with the clipboard

git-svn-id: svn://kolibrios.org@8430 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
superturbocat2001 2020-12-16 20:10:09 +00:00
parent cd35d38ad2
commit 3b4f58dac4
3 changed files with 35 additions and 20 deletions

View File

@ -1,2 +1,2 @@
#SHS
/kolibrios/develop/tcc/tcc thashview.c -o thashview -lck -lcryptal
/kolibrios/develop/tcc/tcc thashview.c -o thashview -lck -lcryptal -ldialog

View File

@ -7,7 +7,7 @@ KPACK=kpack
SRC=thashview.c
CFLAGS=-I $(KTCC_DIR)/libc/include
LIBS = -lck -lcryptal
LIBS = -lck -lcryptal -ldialog
all:
$(KTCC) $(CFLAGS) $(SRC) $(LIBS) -o $(NAME)

View File

@ -1,5 +1,7 @@
/*€¢â®à: ‹®£ ¥¢ Œ ªá¨¬(turbocat2001) */
/* Copyright (C) 2019-2020 Logaev Maxim (turbocat2001), GPLv3 */
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <kos32sys1.h>
#include <string.h>
@ -7,14 +9,14 @@
#include <cryptal/md5.h>
#include <cryptal/sha1.h>
#include <cryptal/sha256.h>
#include <clayer/dialog.h>
#define TRUE 1;
#define FALSE 0;
#define MAX_HASH_LEN 65 // Œ ªá¨¬ «ì­ ï ¤«¨­  áâப¨
#define WINDOW_W 665
#define VERSION "%s - thashview 2.4"
#define VERSION "%s - thashview 2.5"
typedef unsigned char bool;
struct kolibri_system_colors sys_color_table;
char hex[]={"abcdefABCDEF1234567890"}; //„«ï ¯à®¢¥àª¨ ¢¢®¤¨¬ëå ᨬ¢®«®¢
@ -34,7 +36,6 @@ enum MYCOLORS //
GREY = 0x00DDD7CF
};
unsigned int str_pos=0; // <20>®§¨æ¨ï ªãàá®à  ¯à¨ ¯¥ç â¨ ¢ áâப¥ ¢¢®¤ 
int md5_flag=0, sha1_flag=0, sha256_flag=0; // ”« £¨ ¯®ª §ë¢ î騥 ¡ë«  «¨ 㦥 à ááç¨â ­  ª®â஫쭠ï á㬬  ¢ ä㭪樨 check_sum()
int edit_box_text_color=BLACK; // ˆ§­ ç «ì­ë© 梥â ⥪áâ  ¢ áâப¥ ¢¢®¤ 
@ -168,8 +169,8 @@ void sprint_hash(BYTE *hash, char* hash_str, int hash_size) //
void redraw_window() //<2F>¨á㥬 ®ª­®
{
pos_t win_pos = get_mouse_pos(0); //<2F>®«ãç ¥¬ ¯®§¨æ¨î ªãàá®à  ¬ëè¨.
sprintf(title,VERSION, filename); // “áâ ­ ¢«¨¢ ¥¬ § £®«®¢®ª ®ª­ 
pos_t win_pos = get_mouse_pos(0); // <20>®«ãç ¥¬ ª®®à¤¨­ âë ªãàá®à 
begin_draw(); //<2F> ç¨­ ¥¬ à¨á®¢ ­¨¥ ¨­â¥àä¥©á  )
sys_create_window(win_pos.x, win_pos.y, WINDOW_W, 150, title, sys_color_table.work_area, 0x14); // ‘®§¤ ñ¬ ®ª­®.
@ -213,14 +214,13 @@ void paste_to_edit_buffer() //
{
temp_buff=kol_clip_get(kol_clip_num()-1);
memset(edit_box_buff,0,MAX_HASH_LEN);
if(((int)*(temp_buff)>0) && ((int)*(temp_buff+4)==0) && ((int)*(temp_buff+8)==1))
if(DATA(int, temp_buff,0)>0 && DATA(int,temp_buff,4)==TEXT && DATA(int,temp_buff,8)==CP866)
{
strncpy(edit_box_buff,temp_buff+12, MAX_HASH_LEN-1);
str_pos=strlen(edit_box_buff);
notify_show("'Pasted from clipboard!' -I");
edit_box_text_color=BLACK;
user_free(temp_buff);
}
}
}
@ -232,8 +232,8 @@ void copy_to_clipboard(char *text) //
{
char *temp_buffer=safe_malloc(MAX_HASH_LEN+12);
memset(temp_buffer, 0, MAX_HASH_LEN);
*(temp_buffer+4)=0;
*(temp_buffer+8)=1;
DATA(char,temp_buffer,4)=TEXT;
DATA(char,temp_buffer,8)=CP866;
strncpy(temp_buffer+12, text, MAX_HASH_LEN-1);
kol_clip_set(strlen(text)+12, temp_buffer);
notify_show("'Copied to clipboard!' -I");
@ -325,15 +325,29 @@ void edit_box(oskey_t key) //
int main(int argc, char** argv)
{
// ¯®«ãç ¥¬ ¨¬ï ä ©« 
if(argc<2) // …᫨  à£ã¬¥­â®¢ ­¥â â® á®®¡é ¥¬ ®¡ í⮬
if(argc<2) // …᫨  à£ã¬¥­â®¢ ­¥â, â® § ¯ã᪠¥¬ ¤¨ «®£ ¢ë¡®à  ä ©« 
{
kolibri_dialog_init(); // ˆ­¨æ¨ «¨§ æ¨ï ¡¨¡«¨®â¥ª¨
open_dialog* dialog = kolibri_new_open_dialog(OPEN,0, 0, 420, 320);
OpenDialog_init(dialog);
OpenDialog_start(dialog);
if(dialog->status==SUCCESS) // …᫨ ä ©« ¢ë¡à ­
{
global_var_init(strlen(dialog->openfile_path));
strcpy(filename, dialog->openfile_path);
}
else // …᫨ ä ©« ­¥ ¢ë¡à ­
{
notify_show("'No file selected!' -E");
exit(0);
}
free(dialog);
}
else
{
global_var_init(strlen(argv[1]));
strcpy(filename, argv[1]);
}
if(NULL==fopen(filename,"rb")) // …᫨ ä ©«  ­¥â ¨«¨ ­¥ ®âªà뢠¥âáï
{
@ -346,11 +360,11 @@ int main(int argc, char** argv)
notify_show("'Low screen resolution! Program will not display correctrly!' -W");
}
int gui_event; // <20>¥à¥¬­ ï ¤«ï åà ­¥­¨ï ᮡëâ¨ï
int gui_event; // <20>¥à¥¬¥­­ ï ¤«ï åà ­¥­¨ï ᮡëâ¨ï
uint32_t pressed_button = 0; // Š®¤ ­ ¦ â®© ª­®¯ª¨ ¢ ®ª­¥
get_system_colors(&sys_color_table);
set_event_mask(0xC0000027); // “áâ ­ ¢«¨¢ ¥¬ ¬ áªã ᮡë⨩
set_event_mask(0xC0000027);// “áâ ­ ¢«¨¢ ¥¬ ¬ áªã ᮡë⨩
do // –¨ª« ®¡à ¡®âª¨ ᮡë⨩
{
gui_event = get_os_event(); // <20>®«ãç ¥¬ ᮡë⨥
@ -427,4 +441,5 @@ int main(int argc, char** argv)
}
}
}while(1);
exit(0);
}