kolibrios/programs/develop/backy/gcc_version/Backy_lib.h

162 lines
3.9 KiB
C
Raw Normal View History

/*
* 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;
}
// FILE SAVING NOT WORKING
/*
struct saveFile__
{
int num;
int res_;
int res;
int nbyte;
char* data_;
int enc_;
char* path_;
};
*/
static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path)
{
int32_t val;
/*
struct saveFile__ dt;
//uint8_t dt[28]; // basic information structure.
dt.num = 2; // subfunction number.
dt.res_= 0; // reserved.
dt.res = 0; // reserved.
dt.nbyte = nbytes; // number of bytes to write.
dt.data_ = data; // pointer to data.
dt.enc_ = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
dt.path_ = 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<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