From 3d4deeb59e485fc47482ef46beb63499ca71974e Mon Sep 17 00:00:00 2001 From: superturbocat2001 Date: Thu, 24 Dec 2020 22:38:37 +0000 Subject: [PATCH] - Added teatool to autobuild - Added CONFIG_NO_TCC=full to tup.config.template git-svn-id: svn://kolibrios.org@8472 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/Tupfile.lua | 1 + programs/other/TEAtool/Tupfile.lua | 10 +++ programs/other/TEAtool/teatool.c | 106 +++++++++-------------------- tup.config.template | 1 + 4 files changed, 44 insertions(+), 74 deletions(-) create mode 100644 programs/other/TEAtool/Tupfile.lua diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 604cad0884..baf5acdfaa 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -687,6 +687,7 @@ tup.append_table(extra_files, { {"kolibrios/utils/thashview", PROGS .. "/other/TinyHashView/thashview"}, {"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TinyBasic"}, {"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TBuserMan.txt"}, + {"kolibrios/utils/teatool", PROGS .. "/other/TEAtool/teatool"}, }) end -- tup.getconfig('NO_TCC') ~= 'full' diff --git a/programs/other/TEAtool/Tupfile.lua b/programs/other/TEAtool/Tupfile.lua new file mode 100644 index 0000000000..1aa1535724 --- /dev/null +++ b/programs/other/TEAtool/Tupfile.lua @@ -0,0 +1,10 @@ +if tup.getconfig("NO_TCC") ~= "" then return end + +TCC="kos32-tcc" + +CFLAGS = "-I../../develop/ktcc/trunk/libc/include" +LDFLAGS = "-nostdlib ../../develop/ktcc/trunk/bin/lib/start.o -L../../develop/ktcc/trunk/bin/lib" +LIBS = "-lck" + +COMMAND=string.format("%s %s %s %s %s ", TCC, CFLAGS, "%f -o %o", LDFLAGS, LIBS) +tup.rule("teatool.c", COMMAND .. tup.getconfig("KPACK_CMD"), "teatool") diff --git a/programs/other/TEAtool/teatool.c b/programs/other/TEAtool/teatool.c index e27382e64d..2c50170ba3 100755 --- a/programs/other/TEAtool/teatool.c +++ b/programs/other/TEAtool/teatool.c @@ -1,14 +1,14 @@ - -/* Author: turbocat2001*/ +/* Copyright (C) 2019-2020 Logaev Maxim (turbocat2001), GPLv3 */ #include -#include "tea.c" #include #include #include -#include "lang_en.c" #include +#include "lang_en.c" +#include "tea.c" + #define ENCRYPT 1 #define DECRYPT 2 @@ -28,12 +28,9 @@ long size_xcrypt_file(FILE* file) fseek(file, 0, SEEK_END); long size = ftell(file); fseek(file, 0, SEEK_SET); - if(size%8==0) - { + if(size%8==0) { return size; - } - else - { + }else{ return (size/8+1)*8; } } @@ -42,8 +39,7 @@ void xcrypt_file_speed(char *in_file, char* out_file, char arg) { FILE *input, *output; - if((input = fopen(in_file,"rb"))==NULL) - { + if((input = fopen(in_file,"rb"))==NULL){ printf(FILE_NOT_FOUND, in_file); exit(1); } @@ -55,14 +51,12 @@ void xcrypt_file_speed(char *in_file, char* out_file, char arg) size_diff=(uint8_t)(size_f-size_orig_file(input)); uint32_t *buff; buff=malloc(size_f); - if(!buff) - { + if(!buff) { puts(MEMORY_ERROR); exit(-1); } - if(arg==ENCRYPT) - { + if(arg==ENCRYPT){ printf(LOAD_IN_RAM,in_file); fread(buff, 1,size_f, input); printf(FILE_ENCRYPTION); @@ -81,8 +75,7 @@ void xcrypt_file_speed(char *in_file, char* out_file, char arg) exit(0); } - else if(arg==DECRYPT) - { + else if(arg==DECRYPT){ long size_f=size_orig_file(input); printf(LOAD_IN_RAM,in_file); fread(&size_diff,1,1,input); @@ -108,8 +101,7 @@ void xcrypt_file(char *in_file, char* out_file, char arg) uint32_t temp_block[2]; FILE *input, *output; - if((input = fopen(in_file,"rb"))==NULL) - { + if((input = fopen(in_file,"rb"))==NULL){ printf(FILE_NOT_FOUND, in_file); exit(1); } @@ -148,19 +140,15 @@ void xcrypt_file(char *in_file, char* out_file, char arg) fread(temp_block, sizeof(uint32_t), 2, input); TEA_decrypt(temp_block,key); - if(size_f>=8) - { + if(size_f>=8){ fwrite(temp_block,sizeof(uint32_t),2,output); - } - else - { + }else{ fwrite(temp_block,1,size_f,output); } - + size_f=size_f-8; - if(size_f<0) - { + if(size_f<0){ size_f=0; } } @@ -195,8 +183,7 @@ int valid_key(char *str) char hex[]={"abcdefABCDEF0123456789"}; for(int i=0; i<32; i++) { - if(strchr(hex,str[i])!=NULL) - { + if(strchr(hex,str[i])!=NULL){ count++; } } @@ -210,16 +197,11 @@ void key_con_read(char *str) char str_key[4][9]; if(valid_key(str)&&(strlen(str)==32)) { - for(int i=0; i<4; i++) - { + for(int i=0; i<4; i++){ str_to_strkey(str, str_key); key[i]=(uint32_t)strtol(str_key[i],NULL,16); } - - } - - else - { + }else{ printf(INVALID_KEY_FORMAT); exit(-1); } @@ -228,22 +210,17 @@ void key_con_read(char *str) void key_file_read(char *key_file) { FILE *keyfile; - if((keyfile = fopen(key_file,"rb"))==NULL) - { + if((keyfile = fopen(key_file,"rb"))==NULL){ printf(FILE_NOT_FOUND, key_file); exit(-1); } - if(size_orig_file(keyfile)==16) - { - fread(key,sizeof(uint32_t),4, keyfile); - } - else - { + if(size_orig_file(keyfile)==16) { + fread(key,sizeof(uint32_t),4, keyfile); + }else{ printf(INVALID_KEY_FORMAT); exit(-1); } - fclose(keyfile); } @@ -253,27 +230,23 @@ void findopt(int argc, char *argv[],char *in_file, char *out_file) char found=0; for(int j=3; j