diff --git a/data/Tupfile.lua b/data/Tupfile.lua index f9cf7b3048..947a5c8f23 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -27,7 +27,6 @@ img_files = { {"UNIMG", PROGS .. "/fs/unimg/unimg"}, {"VMODE", "common/vmode"}, {"3D/HOUSE.3DS", "common/3d/house.3ds"}, - {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy"}, {"DEVELOP/T_EDIT.INI", PROGS .. "/other/t_edit/t_edit.ini"}, {"File Managers/ICONS.INI", "common/File Managers/icons.ini"}, {"File Managers/KFM.INI", "common/File Managers/kfm.ini"}, @@ -74,6 +73,7 @@ img_files = { -- For russian build, add russian-only files. if build_type == "rus" then tup.append_table(img_files, { {"EXAMPLE.ASM", PROGS .. "/develop/examples/example/trunk/rus/example.asm"}, + {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy_ru"}, {"GAMES/BASEKURS.KLA", build_type .. "/games/basekurs.kla"}, {"GAMES/PADENIE", build_type .. "/games/padenie"}, {"File Managers/KFAR.INI", build_type .. "/File Managers/kfar.ini"}, @@ -84,6 +84,7 @@ if build_type == "rus" then tup.append_table(img_files, { {"SETTINGS/SYSPANEL.INI", "rus/settings/syspanel.ini"}, }) elseif build_type == "eng" then tup.append_table(img_files, { {"EXAMPLE.ASM", PROGS .. "/develop/examples/example/trunk/example.asm"}, + {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy"}, {"File Managers/KFAR.INI", "common/File Managers/kfar.ini"}, {"File Managers/KFM_KEYS.TXT", PROGS .. "/fs/kfm/trunk/docs/english/kfm_keys.txt"}, {"SETTINGS/.shell", PROGS .. "/system/shell/bin/eng/.shell"}, @@ -92,6 +93,7 @@ if build_type == "rus" then tup.append_table(img_files, { {"SETTINGS/SYSPANEL.INI", "common/settings/syspanel.ini"}, }) elseif build_type == "sp" then tup.append_table(img_files, { {"EXAMPLE.ASM", PROGS .. "/develop/examples/example/trunk/example.asm"}, + {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy"}, {"File Managers/KFAR.INI", "common/File Managers/kfar.ini"}, {"File Managers/KFM_KEYS.TXT", PROGS .. "/fs/kfm/trunk/docs/english/kfm_keys.txt"}, {"SETTINGS/.shell", PROGS .. "/system/shell/bin/eng/.shell"}, @@ -100,6 +102,7 @@ if build_type == "rus" then tup.append_table(img_files, { {"SETTINGS/SYSPANEL.INI", "common/settings/syspanel.ini"}, }) elseif build_type == "it" then tup.append_table(img_files, { {"EXAMPLE.ASM", PROGS .. "/develop/examples/example/trunk/example.asm"}, + {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy"}, {"File Managers/KFAR.INI", "common/File Managers/kfar.ini"}, {"File Managers/KFM_KEYS.TXT", PROGS .. "/fs/kfm/trunk/docs/english/kfm_keys.txt"}, {"SETTINGS/.shell", PROGS .. "/system/shell/bin/eng/.shell"}, @@ -108,6 +111,7 @@ if build_type == "rus" then tup.append_table(img_files, { {"SETTINGS/SYSPANEL.INI", "common/settings/syspanel.ini"}, }) else tup.append_table(img_files, { {"EXAMPLE.ASM", PROGS .. "/develop/examples/example/trunk/example.asm"}, + {"DEVELOP/BACKY", PROGS .. "/develop/backy/Backy"}, {"File Managers/KFM_KEYS.TXT", PROGS .. "/fs/kfm/trunk/docs/english/kfm_keys.txt"}, {"File Managers/KFAR.INI", "common/File Managers/kfar.ini"}, {"SETTINGS/.shell", PROGS .. "/system/shell/bin/eng/.shell"}, diff --git a/programs/develop/backy/Backy b/programs/develop/backy/Backy index 8df17a4185..594e073203 100644 Binary files a/programs/develop/backy/Backy and b/programs/develop/backy/Backy differ diff --git a/programs/develop/backy/Backy.c b/programs/develop/backy/Backy.c index 0a02ae5e55..a1b2f6a92b 100644 --- a/programs/develop/backy/Backy.c +++ b/programs/develop/backy/Backy.c @@ -1,21 +1,22 @@ /* - * Author: JohnXenox aka Aleksandr Igorevich. - * * Programme name: Backy * Description: The programme for backing up a file. * + * Backy.c + * Author: JohnXenox aka Aleksandr Igorevich. + * * Works from command line, only! */ -#define CREATION_DATE "2020.05.17" +#define CREATION_DATE "2020.05.27" #include -//#include #include #include -#include "Backy-lib.h" +#include "Backy_lang.h" +#include "Backy_lib.h" int date = 0; int time = 0; @@ -41,10 +42,14 @@ char ext[] = ".bak"; char flag = 0; +char state; int main(int argc, char** argv) { + if (con_init_console_dll()) return 1; // init fail. + + con_set_title("Backy"); // ============================================================ // // preprocessing arguments from the command line. ============= // @@ -60,7 +65,7 @@ int main(int argc, char** argv) // ============================================================ // -// preprocess the command line arguments. ===================== // +// process the command line arguments. ======================== // if (argc > 1) { @@ -88,7 +93,7 @@ int main(int argc, char** argv) } } - // if inut path is found, then copy it into the array "path_in". + // if input path is found, then copy it into the array "path_in". if (*argv[i] == '/') { flag = 2; @@ -146,29 +151,47 @@ int main(int argc, char** argv) } else { - //con_init_console_dll_param(-1, 23, -1, 23, "Backy"); - if (con_init_console_dll()) return 1; // init fail + con_set_title("Useful info!"); - printf("Useful info!"); + #if defined (lang_en) - printf("\n Name: Backy"); - printf("\n Date: %s", CREATION_DATE); - printf("\n Description: The programme for backing up a file.\n"); + con_printf("\n Name: Backy"); + con_printf("\n Date: %s", CREATION_DATE); + con_printf("\n Description: The programme for backing up a file.\n"); - printf("\n Author: JohnXenox\n"); + con_printf("\n Author: JohnXenox\n"); - printf("\n Usage: backy <-o path2>\n"); - printf(" path1 - path to a file to be backuped.\n"); - printf(" -o path2 - path to the output directory without the name of a file.\n\n"); + con_printf("\n Usage: backy <-o path2>\n"); + con_printf(" path1 - path to a file to be backuped.\n"); + con_printf(" -o path2 - path to the output directory without the name of a file.\n\n"); - printf(" Examples:\n"); - printf(" backy test.c\n"); - printf(" backy test.c -o /tmp0/1/\n"); - printf(" backy /hd0/1/test.c\n"); - printf(" backy /hd0/1/test.c -o /tmp0/1/\n"); + con_printf(" Examples:\n"); + con_printf(" backy test.c\n"); + con_printf(" backy test.c -o /tmp0/1/\n"); + con_printf(" backy /hd0/1/test.c\n"); + con_printf(" backy /hd0/1/test.c -o /tmp0/1/\n"); - exit(0); - return 1; + #elif defined (lang_ru) + + con_printf("\n Имя: Backy"); + con_printf("\n Дата: %s", CREATION_DATE); + con_printf("\n Описание: Программа для создания резервной копии файла.\n"); + + con_printf("\n Автор: JohnXenox\n"); + + con_printf("\n Использование: backy <-o path2>\n"); + con_printf(" path1 - путь к файлу, который надо скопировать.\n"); + con_printf(" -o path2 - путь к директории, в которую будет скопирована резервная копия файла.\n\n"); + + con_printf(" Примеры:\n"); + con_printf(" backy test.c\n"); + con_printf(" backy test.c -o /tmp0/1/\n"); + con_printf(" backy /hd0/1/test.c\n"); + con_printf(" backy /hd0/1/test.c -o /tmp0/1/\n"); + + #endif + + return 0; } //printf("Path_in: %s\n", path_in); @@ -293,29 +316,28 @@ int main(int argc, char** argv) // ============================================================ // // adding the name of the input file to the output path. ====== // - // searching the end of the path string. int i = 0; int y = 0; - // searching for zero terminator in the input path. + // searching for a zero terminator in the input path. while (path_in[i] != 0) { i++; } - // searching for slash in the input path. + // searching for a slash in the input path. while (path_in[i] != '/') { i--; } - // searching for zero terminator in the output path. + // searching for a zero terminator in the output path. while (path_out[y] != 0) { y++; } - // searching for slash in the output path. + // searching for a slash in the output path. if (path_out[y - 1] == '/') { y--; @@ -329,7 +351,7 @@ int main(int argc, char** argv) i = 0; - // searching for zero terminator in the output path. + // searching for a zero terminator in the output path. while (path_out[i] != 0) { i++; @@ -343,7 +365,7 @@ int main(int argc, char** argv) i += strlen(full_date); - // adding the extension to path. + // adding the extension to a path. strncpy(&path_out[i], ext, 4); //printf("Path_in: %s\n", path_in); @@ -351,9 +373,21 @@ int main(int argc, char** argv) data = openFile(&length, path_in); - saveFile(length, data, 0, path_out); + if(data == 0) + { + #if defined (lang_en) + con_printf("\nThe file isn't found!\n"); - return 0; + #elif defined (lang_ru) + + con_printf("\nФайл не найден!\n"); + + #endif + + return 13; + } + + return checkStateOnSave(saveFile(length, data, 0, path_out)); } diff --git a/programs/develop/backy/Backy.png b/programs/develop/backy/Backy.png index f9015d3400..08ee80988b 100644 Binary files a/programs/develop/backy/Backy.png and b/programs/develop/backy/Backy.png differ diff --git a/programs/develop/backy/Backy_lang.h b/programs/develop/backy/Backy_lang.h new file mode 100644 index 0000000000..0d7eb24ec6 --- /dev/null +++ b/programs/develop/backy/Backy_lang.h @@ -0,0 +1,3 @@ + +//#define lang_ru +#define lang_en diff --git a/programs/develop/backy/Backy_lib.h b/programs/develop/backy/Backy_lib.h new file mode 100644 index 0000000000..0e05c1e89c --- /dev/null +++ b/programs/develop/backy/Backy_lib.h @@ -0,0 +1,152 @@ + +/* + * Backy_lib.h + * Author: JohnXenox aka Aleksandr Igorevich. + */ + +#ifndef __Backy_lib_h__ +#define __Backy_lib_h__ + +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned long long uint64_t; +typedef char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long long int64_t; + +static inline uint32_t getDate(void) +{ + uint32_t date; + __asm__ __volatile__("int $0x40":"=a"(date):"a"(29)); + return date; +} + + + +static inline uint32_t getTime(void) +{ + uint32_t time; + __asm__ __volatile__("int $0x40":"=a"(time):"a"(3)); + return time; +} + + + +static inline void *openFile(uint32_t *length, const uint8_t *path) +{ + uint8_t *fd; + + __asm__ __volatile__ ("int $0x40":"=a"(fd), "=d"(*length):"a" (68), "b"(27),"c"(path)); + + return fd; +} + + + +static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path) +{ + int32_t val; + + uint8_t dt[28]; // basic information structure. + + (uint32_t) dt[0] = 2; // subfunction number. + (uint32_t) dt[4] = 0; // reserved. + (uint32_t) dt[8] = 0; // reserved. + (uint32_t) dt[12] = nbytes; // number of bytes to write. + (uint8_t *) dt[16] = data; // pointer to data. + (uint32_t) dt[20] = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8). + (uint8_t *) dt[24] = path; // pointer to path. + + __asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt)); + + return val; +} + + + + + +int checkStateOnSave(int state) +{ + #if defined (lang_en) + + switch(state) + { + case 2: con_printf("\nThe function isn't supported for the given file system!\n"); + return 2; + + case 3: con_printf("\nUnknown file system!\n"); + return 3; + + case 5: con_printf("\nFile isn't found!\n"); + return 5; + + case 6: con_printf("\nEnd of a file, EOF!\n"); + return 6; + + case 7: con_printf("\nPointer lies outside of application memory!\n"); + return 7; + + case 8: con_printf("\nDisk is full!\n"); + return 8; + + case 9: con_printf("\nFile system error!\n"); + return 9; + + case 10: con_printf("\nAccess denied!\n"); + return 10; + + case 11: con_printf("\nDevice error!\n"); + return 11; + + case 12: con_printf("\nFile system requires more memory!\n"); + return 12; + } + + #elif defined (lang_ru) + + switch(state) + { + case 2: con_printf("\nФункция не поддерживается для данной файловой системы!\n"); + return 2; + + case 3: con_printf("\nНеизвестная файловая система!\n"); + return 3; + + case 5: con_printf("\nФайл не найден!\n"); + return 5; + + case 6: con_printf("\nФайл закончился!\n"); + return 6; + + case 7: con_printf("\nУказатель вне памяти приложения!\n"); + return 7; + + case 8: con_printf("\nДиск заполнен!\n"); + return 8; + + case 9: con_printf("\nОшибка файловой системы!\n"); + return 9; + + case 10: con_printf("\nДоступ запрещён!\n"); + return 10; + + case 11: con_printf("\nОшибка устройства!\n"); + return 11; + + case 12: con_printf("\nФайловой системе недостаточно оперативной памяти!\n"); + return 12; + } + + #endif +} + + + + + + + +#endif diff --git a/programs/develop/backy/Backy_ru b/programs/develop/backy/Backy_ru new file mode 100644 index 0000000000..43395ce77c Binary files /dev/null and b/programs/develop/backy/Backy_ru differ diff --git a/programs/develop/backy/Backy_ru.png b/programs/develop/backy/Backy_ru.png new file mode 100644 index 0000000000..883bb8fd3d Binary files /dev/null and b/programs/develop/backy/Backy_ru.png differ diff --git a/programs/develop/backy/History.txt b/programs/develop/backy/History.txt index 568c3d8aa0..d566795bfc 100644 --- a/programs/develop/backy/History.txt +++ b/programs/develop/backy/History.txt @@ -1,9 +1,13 @@ History: +Backy 2020.05.27 + Added warnings about errors. + Added translation on Russian language. + Backy 2020.05.17 Code optimization. -Backy 2020.05.05 +Backy 2020.05.07 Changed an output file name. Backy 2020.04.27 diff --git a/programs/develop/backy/Readme-en.txt b/programs/develop/backy/Readme-en.txt index 00fddc5944..622a94b4c9 100644 --- a/programs/develop/backy/Readme-en.txt +++ b/programs/develop/backy/Readme-en.txt @@ -1,4 +1,4 @@ -Backy (release date 2020.05.17) +Backy (release date 2020.05.27) Backy is a programme for backing up a file. diff --git a/programs/develop/backy/Readme-ru.txt b/programs/develop/backy/Readme-ru.txt index f40ab9433c..be87a1aaa1 100644 --- a/programs/develop/backy/Readme-ru.txt +++ b/programs/develop/backy/Readme-ru.txt @@ -1,4 +1,4 @@ -Backy (╨┤╨░╤В╨░ ╨▓╤Л╨┐╤Г╤Б╨║╨░ 2020.05.17) +Backy (╨┤╨░╤В╨░ ╨▓╤Л╨┐╤Г╤Б╨║╨░ 2020.05.27) Backy - ╤Н╤В╨╛ ╨┐╤А╨╛╨│╤А╨░╨╝╨╝╨░ ╨┤╨╗╤П ╤Б╨╛╨╖╨┤╨░╨╜╨╕╤П ╤А╨╡╨╖╨╡╤А╨▓╨╜╨╛╨╣ ╨║╨╛╨┐╨╕╨╕ ╤Д╨░╨╣╨╗╨░. diff --git a/programs/system/notify3/build.bat b/programs/system/notify3/build.bat new file mode 100644 index 0000000000..8e7d66a9b6 --- /dev/null +++ b/programs/system/notify3/build.bat @@ -0,0 +1,2 @@ +@fasm notify.asm @notify +@pause \ No newline at end of file