- Duplicate functionality files removed;
- Refactoring of file handling functions;
- Removed broken impliments.
Gears (C + TinyGL):
- Removed because it duplicates an existing example on Fasm and uses unsupported wrappers on the KOS API.
KosJS:
- Removed. The MuJS port is too old and not used anywhere. Support is not profitable.
Backy:
- Removed useless GCC version. Support is not profitable.
DGen-SDL and SQLite3
- Fix after removing broken "dirent.h".
Fridge:
- Moving the KOS API wrapper to avoid compilation errors.
Udis86, uARM and 8086tiny:
- Fix after removing redundant "kos_LoadConsole.h".


git-svn-id: svn://kolibrios.org@9952 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat
2024-01-04 22:20:35 +00:00
parent c6d4aab9c5
commit 9562f01892
112 changed files with 344 additions and 22302 deletions

View File

@@ -1,396 +0,0 @@
/*
* Programme name: Backy
* Description: The programme for backing up a file.
*
* Backy.c
* Author: JohnXenox aka Aleksandr Igorevich.
* Port to GCC: maxcodehack
*
* Works from command line, only!
*/
#define CREATION_DATE "2020.05.27"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/kos_LoadConsole.h>
#include "Backy_lib.h"
int date = 0;
int time = 0;
char years = 0;
char months = 0;
char days = 0;
char hours = 0;
char minutes = 0;
char seconds = 0;
char *data = 0;
int length = 0;
char path_in[4096] = {0};
char path_out[4096] = {0};
char num[3] = {0};
char full_date[25] = {0};
char ext[] = ".bak";
char flag = 0;
char state;
int main(int argc, char** argv)
{
// ============================================================ //
// preprocessing arguments from the command line. ============= //
//
// 0 argument - name of the programme.
// 1 argument - path to the file with name that need to be backup.
// 2 argument - the key (-o).
// 3 argument - path to the output directory without the name of the file.
// printf("Number of args: %d\n", argc);
// printf("Argv 0: %s\n", argv[0]);
// sprintf("Argv 1: %s\n\n", argv[1]);
// ============================================================ //
// process the command line arguments. ======================== //
if (argc > 1)
{
for (int i = 1; i < argc; i++)
{
// if found the key "-o", then copy output path into the array "path_out".
if (*argv[i] == '-') // && (*(argv[i] + 1) == 'o'))
{
// printf("Key -o is found!\n");
i++;
flag = 1;
if (i <= argc)
{
// copying of a current path into the array "path_out".
strcpy(path_out, argv[i]);
// printf("Path output is copyed!\n");
i++;
break;
}
}
// if input path is found, then copy it into the array "path_in".
if (*argv[i] == '/')
{
flag = 2;
// copying of a current path into the buffer.
strcpy(path_in, argv[i]);
if (flag != 1)
{
int idx = strlen(path_in);
while (path_in[idx] != '/')
{
idx--;
}
strncpy(path_out, path_in, idx);
}
// printf("Path input is copyed!\n");
}
// if found characters.
if ( (*argv[i] > '0') && (*argv[i] < '9') || \
(*argv[i] > 'A') && (*argv[i] < 'Z') || \
(*argv[i] > 'a') && (*argv[i] < 'z') )
{
flag = 3;
strcpy(path_in, argv[0]);
// printf("Arg 0 is copyed!\n");
int idx = strlen(path_in);
while (path_in[idx] != '/')
{
path_in[idx] = 0;
idx--;
}
idx++;
strcpy(path_out, path_in);
strcpy(&path_in[idx], argv[1]);
// printf("Arg 1 is added!\n");
}
}
// if not found the flag, then copy path from "path_in" into "path_out".
if ((flag == 0) && (flag != 2) && (flag != 3))
{
// copying the input path into the output path,
strcpy(path_out, path_in);
//printf("Path input is copyed into the path output!\n");
}
}
else
{
load_console();
con_set_title("Useful info!");
#if defined (lang_en)
con_printf("\n Name: Backy");
con_printf("\n Date: %s", CREATION_DATE);
con_printf("\n Description: The programme for backing up a file.\n");
con_printf("\n Author: JohnXenox\n");
con_printf("\n Usage: backy <path1> <-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");
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");
#elif defined (lang_ru)
con_printf("\n <20><><EFBFBD>: Backy");
con_printf("\n <20><><EFBFBD><EFBFBD>: %s", CREATION_DATE);
con_printf("\n <20><><EFBFBD><EFBFBD><E1A0AD>: <20>ணࠬ<E0AEA3><E0A0AC> <20><><EFBFBD><><E1AEA7><EFBFBD><EFBFBD><EFBFBD><><EFBFBD><E0A2AD> <20><><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>.\n");
con_printf("\n <20><><EFBFBD><EFBFBD><EFBFBD>: JohnXenox\n");
con_printf("\n <20><EFBFBD><EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD>: backy <path1> <-o path2>\n");
con_printf(" path1 - <20><><EFBFBD><EFBFBD> <20><><E4A0A9>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><><E1AAAE><EFBFBD><E0AEA2><EFBFBD>.\n");
con_printf(" -o path2 - <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><E0A5AA>ਨ, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><><E1AAAE><EFBFBD><E0AEA2><EFBFBD><><EFBFBD><E0A2AD> <20><><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>.\n\n");
con_printf(" <20><EFBFBD><E0A8AC><EFBFBD>:\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);
//printf("Path_out: %s\n", path_out);
// ============================================================ //
// getting the time in BCD. =================================== //
time = getTime(); // time = 0x00SSMMHH.
hours = (char)time;
minutes = (char)(time >> 8);
seconds = (char)(time >> 16);
// ============================================================ //
// getting the date in BCD. =================================== //
date = getDate(); // date = 0x00DDMMYY.
years = (char)date;
months = (char)(date >> 8);
days = (char)(date >> 16);
// ============================================================ //
// fills the array with the date in ASCII. ==================== //
char ofs = 0;
char *dta = 0;
for (char i = 0; i < 3; i++)
{
if (i == 0)
{
dta = &years;
full_date[ofs] = '2';
ofs++;
full_date[ofs] = '0';
ofs++;
}
if (i == 1)
{
dta = &months;
}
if (i == 2)
{
dta = &days;
}
itoab(*dta, num, 16);
if (num[1] == 0)
{
full_date[ofs] = '0';
ofs++;
full_date[ofs] = num[0];
}
else
{
full_date[ofs] = num[0];
ofs++;
full_date[ofs] = num[1];
}
ofs++;
if (i != 2)
{
full_date[ofs] = '.';
ofs++;
}
}
full_date[ofs] = '_';
ofs++;
// ============================================================ //
// fills the array with the time in ASCII. ==================== //
ofs = 11;
dta = 0;
for (char i = 0; i < 3; i++)
{
if (i == 0)
dta = &hours;
if (i == 1)
dta = &minutes;
if (i == 2)
dta = &seconds;
itoab(*dta, num, 16);
if (num[1] == 0)
{
full_date[ofs] = '0';
ofs++;
full_date[ofs] = num[0];
}
else
{
full_date[ofs] = num[0];
ofs++;
full_date[ofs] = num[1];
}
ofs++;
if (i < 2)
{
full_date[ofs] = '.';
}
//else
//{
// full_date[ofs] = '_';
//}
ofs++;
}
// ============================================================ //
// adding the name of the input file to the output path. ====== //
int i = 0;
int y = 0;
// searching for a zero terminator in the input path.
while (path_in[i] != 0)
{
i++;
}
// searching for a slash in the input path.
while (path_in[i] != '/')
{
i--;
}
// searching for a zero terminator in the output path.
while (path_out[y] != 0)
{
y++;
}
// searching for a slash in the output path.
if (path_out[y - 1] == '/')
{
y--;
}
// copying the input name of the file into the output path,
strcpy(&path_out[y], &path_in[i]);
// ============================================================ //
// adding the extension and full date to the path. ============ //
i = 0;
// searching for a zero terminator in the output path.
while (path_out[i] != 0)
{
i++;
}
path_out[i] = '_';
i++;
// adding full date.
strcpy(&path_out[i], full_date);
i += strlen(full_date);
// adding the extension to a path.
strncpy(&path_out[i], ext, 4);
//printf("Path_in: %s\n", path_in);
//printf("Path_out: %s\n", path_out);
data = openFile(&length, path_in);
if(data == 0)
{
load_console();
con_set_title("Backy");
#if defined (lang_en)
con_printf("\nThe file isn't found!\n");
#elif defined (lang_ru)
con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
#endif
return 13;
}
saveFile(length, data, 0, path_out);//return checkStateOnSave(saveFile(length, data, 0, path_out));
}

View File

@@ -1,189 +0,0 @@
/*
* Backy_lib.h
* Author: JohnXenox aka Aleksandr Igorevich.
*/
#ifndef __Backy_lib_h__
#define __Backy_lib_h__
// Copied from TCC
char* strrev(char *p)
{
char *q = p, *res = p, z;
while(q && *q) ++q; /* find eos */
for(--q; p < q; ++p, --q)
{
z = *p;
*p = *q;
*q = z;
}
return res;
}
char* itoab(unsigned int n, char* s, int b)
{
char *ptr;
int lowbit;
ptr = s;
b >>= 1;
do {
lowbit = n & 1;
n = (n >> 1) & 0x7FFFFFFF;
*ptr = ((n % b) << 1) + lowbit;
if(*ptr < 10) *ptr += '0'; else *ptr += 55;
++ptr;
} while(n /= b);
*ptr = 0;
return strrev(s);
}
/*
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;
}
struct saveFileStruct
{
int p1;
int p2;
int p3;
int p4;
char* p5;
int p6;
char* p7;
};
static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path)
{
int32_t val;
struct saveFileStruct dt; // basic information structure.
dt.p1 = 2; // subfunction number.
dt.p2= 0; // reserved.
dt.p3 = 0; // reserved.
dt.p4 = nbytes; // number of bytes to write.
dt.p5 = data; // pointer to data.
dt.p6 = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
dt.p7 = path; // pointer to path.
__asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt):"memory");
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<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0A6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E4A0A9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!\n");
return 2;
case 3: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E4A0A9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!\n");
return 3;
case 5: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
return 5;
case 6: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7A8AB>!\n");
return 6;
case 7: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E0A8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
return 7;
case 8: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
return 8;
case 9: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><><E4A0A9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!\n");
return 9;
case 10: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
return 10;
case 11: con_printf("\n<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>⢠!\n");
return 11;
case 12: con_printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A8A2><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
return 12;
}
#endif
}
#endif

View File

@@ -1,25 +0,0 @@
CC = kos32-gcc
LD = kos32-ld
SDK_DIR = $(abspath ../../../../contrib/sdk)
LDFLAGS = -call_shared -nostdlib -T $(SDK_DIR)/sources/newlib/app-dynamic.lds --image-base 0
CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32
INCLUDES = -I $(SDK_DIR)/sources/newlib/libc/include
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib
ifndef LANG_
LANG_ = lang_en
endif
default: backy
backy: $(OBJECTS) Makefile
$(CC) $(CFLAGS) $(INCLUDES) -D$(LANG_) -o Backy.o Backy.c
$(LD) $(LDFLAGS) $(LIBPATH) --subsystem console -o Backy Backy.o -lgcc -lc.dll
kos32-strip -s Backy -o Backy
objcopy Backy -O binary
rm Backy.o
clean:
rm Backy

View File

@@ -1,14 +0,0 @@
if tup.getconfig("NO_GCC") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_gcc.lua")
tup.include(HELPERDIR .. "/use_newlib.lua")
if tup.getconfig("LANG") == "ru"
then CFLAGS = CFLAGS .. " -Dlang_ru"
else CFLAGS = CFLAGS .. " -Dlang_en"
end
CFLAGS = CFLAGS .. " -std=c99"
compile_gcc{"Backy.c"}
link_gcc("Backy")

View File

@@ -1,6 +0,0 @@
Port backy to gcc
Languages:
Eng:
make
Rus:
env LANG_=lang_ru make