- 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
This commit is contained in:
superturbocat2001 2020-12-24 22:38:37 +00:00
parent 4cc800cdfc
commit 3d4deeb59e
4 changed files with 44 additions and 74 deletions

View File

@ -687,6 +687,7 @@ tup.append_table(extra_files, {
{"kolibrios/utils/thashview", PROGS .. "/other/TinyHashView/thashview"}, {"kolibrios/utils/thashview", PROGS .. "/other/TinyHashView/thashview"},
{"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TinyBasic"}, {"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TinyBasic"},
{"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TBuserMan.txt"}, {"kolibrios/develop/TinyBasic/", PROGS .. "/develop/tinybasic/TBuserMan.txt"},
{"kolibrios/utils/teatool", PROGS .. "/other/TEAtool/teatool"},
}) })
end -- tup.getconfig('NO_TCC') ~= 'full' end -- tup.getconfig('NO_TCC') ~= 'full'

View File

@ -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")

View File

@ -1,14 +1,14 @@
/* Copyright (C) 2019-2020 Logaev Maxim (turbocat2001), GPLv3 */
/* Author: turbocat2001*/
#include <stdio.h> #include <stdio.h>
#include "tea.c"
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "lang_en.c"
#include <conio.h> #include <conio.h>
#include "lang_en.c"
#include "tea.c"
#define ENCRYPT 1 #define ENCRYPT 1
#define DECRYPT 2 #define DECRYPT 2
@ -28,12 +28,9 @@ long size_xcrypt_file(FILE* file)
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
long size = ftell(file); long size = ftell(file);
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
if(size%8==0) if(size%8==0) {
{
return size; return size;
} }else{
else
{
return (size/8+1)*8; return (size/8+1)*8;
} }
} }
@ -42,8 +39,7 @@ void xcrypt_file_speed(char *in_file, char* out_file, char arg)
{ {
FILE *input, *output; FILE *input, *output;
if((input = fopen(in_file,"rb"))==NULL) if((input = fopen(in_file,"rb"))==NULL){
{
printf(FILE_NOT_FOUND, in_file); printf(FILE_NOT_FOUND, in_file);
exit(1); 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)); size_diff=(uint8_t)(size_f-size_orig_file(input));
uint32_t *buff; uint32_t *buff;
buff=malloc(size_f); buff=malloc(size_f);
if(!buff) if(!buff) {
{
puts(MEMORY_ERROR); puts(MEMORY_ERROR);
exit(-1); exit(-1);
} }
if(arg==ENCRYPT) if(arg==ENCRYPT){
{
printf(LOAD_IN_RAM,in_file); printf(LOAD_IN_RAM,in_file);
fread(buff, 1,size_f, input); fread(buff, 1,size_f, input);
printf(FILE_ENCRYPTION); printf(FILE_ENCRYPTION);
@ -81,8 +75,7 @@ void xcrypt_file_speed(char *in_file, char* out_file, char arg)
exit(0); exit(0);
} }
else if(arg==DECRYPT) else if(arg==DECRYPT){
{
long size_f=size_orig_file(input); long size_f=size_orig_file(input);
printf(LOAD_IN_RAM,in_file); printf(LOAD_IN_RAM,in_file);
fread(&size_diff,1,1,input); 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]; uint32_t temp_block[2];
FILE *input, *output; FILE *input, *output;
if((input = fopen(in_file,"rb"))==NULL) if((input = fopen(in_file,"rb"))==NULL){
{
printf(FILE_NOT_FOUND, in_file); printf(FILE_NOT_FOUND, in_file);
exit(1); 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); fread(temp_block, sizeof(uint32_t), 2, input);
TEA_decrypt(temp_block,key); TEA_decrypt(temp_block,key);
if(size_f>=8) if(size_f>=8){
{
fwrite(temp_block,sizeof(uint32_t),2,output); fwrite(temp_block,sizeof(uint32_t),2,output);
} }else{
else
{
fwrite(temp_block,1,size_f,output); fwrite(temp_block,1,size_f,output);
} }
size_f=size_f-8; size_f=size_f-8;
if(size_f<0) if(size_f<0){
{
size_f=0; size_f=0;
} }
} }
@ -195,8 +183,7 @@ int valid_key(char *str)
char hex[]={"abcdefABCDEF0123456789"}; char hex[]={"abcdefABCDEF0123456789"};
for(int i=0; i<32; i++) for(int i=0; i<32; i++)
{ {
if(strchr(hex,str[i])!=NULL) if(strchr(hex,str[i])!=NULL){
{
count++; count++;
} }
} }
@ -210,16 +197,11 @@ void key_con_read(char *str)
char str_key[4][9]; char str_key[4][9];
if(valid_key(str)&&(strlen(str)==32)) 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); str_to_strkey(str, str_key);
key[i]=(uint32_t)strtol(str_key[i],NULL,16); key[i]=(uint32_t)strtol(str_key[i],NULL,16);
} }
}else{
}
else
{
printf(INVALID_KEY_FORMAT); printf(INVALID_KEY_FORMAT);
exit(-1); exit(-1);
} }
@ -228,22 +210,17 @@ void key_con_read(char *str)
void key_file_read(char *key_file) void key_file_read(char *key_file)
{ {
FILE *keyfile; FILE *keyfile;
if((keyfile = fopen(key_file,"rb"))==NULL) if((keyfile = fopen(key_file,"rb"))==NULL){
{
printf(FILE_NOT_FOUND, key_file); printf(FILE_NOT_FOUND, key_file);
exit(-1); exit(-1);
} }
if(size_orig_file(keyfile)==16) if(size_orig_file(keyfile)==16) {
{
fread(key,sizeof(uint32_t),4, keyfile); fread(key,sizeof(uint32_t),4, keyfile);
} }else{
else
{
printf(INVALID_KEY_FORMAT); printf(INVALID_KEY_FORMAT);
exit(-1); exit(-1);
} }
fclose(keyfile); fclose(keyfile);
} }
@ -253,27 +230,23 @@ void findopt(int argc, char *argv[],char *in_file, char *out_file)
char found=0; char found=0;
for(int j=3; j<argc; j++) for(int j=3; j<argc; j++)
{ {
if(!strcmp(argv[j],"-k")) if(!strcmp(argv[j],"-k")){
{
found=1; found=1;
key_con_read(argv[j+1]); key_con_read(argv[j+1]);
break; break;
} }
else if(!strcmp(argv[j],"-K")) else if(!strcmp(argv[j],"-K")){
{
found=1; found=1;
key_file_read(argv[j+1]); key_file_read(argv[j+1]);
break; break;
} }
} }
if(!found) if(!found){
{
printf(NO_KEY_OR_KEYFILE); printf(NO_KEY_OR_KEYFILE);
exit(-1); exit(-1);
} }
for(int i=3;i<argc; i++){ for(int i=3;i<argc; i++){
if(!strcmp(argv[i],"-e")) if(!strcmp(argv[i],"-e"))
{ {
@ -293,8 +266,7 @@ void findopt(int argc, char *argv[],char *in_file, char *out_file)
void key_write_in_file(char *keyfilename) void key_write_in_file(char *keyfilename)
{ {
FILE *keyfile; FILE *keyfile;
if((keyfile = fopen(strcat(keyfilename, ".key"), "wb"))==NULL) if((keyfile = fopen(strcat(keyfilename, ".key"), "wb"))==NULL){
{
printf(INCORRECT_FILE, keyfilename); printf(INCORRECT_FILE, keyfilename);
exit(-1); exit(-1);
} }
@ -302,44 +274,30 @@ void key_write_in_file(char *keyfilename)
printf(KEY_RECORD_IN_FILE, keyfilename); printf(KEY_RECORD_IN_FILE, keyfilename);
fclose(keyfile); fclose(keyfile);
exit(0); exit(0);
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
con_init_console_dll(); con_init_console_dll();
con_set_title("TEAtool\0"); con_set_title("TEAtool\0");
if(argc==7) if(argc==7){
{
findopt(argc,argv, argv[1],argv[2]); findopt(argc,argv, argv[1],argv[2]);
} }
else if(argc==2 && !strcmp(argv[1],"-a")) else if(argc==2 && !strcmp(argv[1],"-a")){
{
show_about(); show_about();
exit(0); exit(0);
} }
else if(argc==2 && !strcmp(argv[1],"-h")){
else if(argc==2 && !strcmp(argv[1],"-h"))
{
show_help(); show_help();
exit(0); exit(0);
} }
else if(argc==4 && !strcmp(argv[1],"-r")){
else if(argc==4 && !strcmp(argv[1],"-r"))
{
key_con_read(argv[2]); key_con_read(argv[2]);
key_write_in_file(argv[3]); key_write_in_file(argv[3]);
} }
else{
else
{
printf(INVALID_ARG); printf(INVALID_ARG);
exit(0); exit(0);
} }
return 0; return 0;
} }

View File

@ -20,6 +20,7 @@
# CONFIG_NO_GCC=full # CONFIG_NO_GCC=full
# CONFIG_NO_MSVC=full # CONFIG_NO_MSVC=full
# CONFIG_NO_CMM=full # CONFIG_NO_CMM=full
# CONFIG_NO_TCC=full
### Path to gcc toolchain library with -lgcc. ### Path to gcc toolchain library with -lgcc.
### Normally, you should not modify it, ### Normally, you should not modify it,
### since the toolchain assumes the fixed path anyway. ### since the toolchain assumes the fixed path anyway.