Fix bags. sprintf.

Update io.h

git-svn-id: svn://kolibrios.org@5646 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-08-02 11:41:41 +00:00
parent 4ba939d3c8
commit 9326165ac8
4 changed files with 84 additions and 53 deletions

View File

@ -7,7 +7,7 @@ void main()
int id, key, i; int id, key, i;
dword file; dword file;
mem_Init(); mem_Init();
io.dir_buffer("/sys/",DIR_ONLYREAL); io.dir_buffer("",DIR_ONLYREAL);
loop() loop()
{ {
switch(WaitEvent()) switch(WaitEvent())
@ -21,8 +21,7 @@ void main()
key = GetKey(); key = GetKey();
if (key==013){ //Enter if (key==013){ //Enter
draw_window(); draw_window();
WriteText(50,90,0x80,0xFF00FF,io.dir_position(i));
if(i<io.dir.count)i++;
} }
break; break;
@ -35,8 +34,15 @@ void main()
void draw_window() void draw_window()
{ {
proc_info Form; proc_info Form;
int i;
i=0;
DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Window header"); DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Window header");
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
while(i<io.dir.count)
{
WriteText(5,i*8+3,0x80,0xFF00FF,io.dir.position(i));
i++;
}
WriteText(10,110,0x80,0,#param); WriteText(10,110,0x80,0,#param);
} }

View File

@ -51,7 +51,7 @@
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.param3 = file_count; __file_F70.param3 = file_count;
__file_F70.param4 = read_buffer; __file_F70.param4 = read_buffer;
__file_F70.name = dir_path; __file_F70.name = io.path.path(dir_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -65,7 +65,7 @@
__file_F70.param3 = 0; __file_F70.param3 = 0;
__file_F70.param4 = bdvk_struct; __file_F70.param4 = bdvk_struct;
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = file_path; __file_F70.name = io.path.path(file_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -102,7 +102,7 @@
__file_F70.param3 = 0; __file_F70.param3 = 0;
__file_F70.param4 = #io.BDVK; __file_F70.param4 = #io.BDVK;
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = file_path; __file_F70.name = io.path.path(file_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -115,7 +115,7 @@
__file_F70.param3 = __file_F70.param3 =
__file_F70.param4 = __file_F70.param4 =
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = PATH; __file_F70.name = io.path.path(PATH);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -128,7 +128,7 @@
__file_F70.param3 = read_file_size; __file_F70.param3 = read_file_size;
__file_F70.param4 = read_buffer; __file_F70.param4 = read_buffer;
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = read_file_path; __file_F70.name = io.path.path(read_file_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -141,7 +141,7 @@
__file_F70.param3 = write_file_size; __file_F70.param3 = write_file_size;
__file_F70.param4 = write_buffer; __file_F70.param4 = write_buffer;
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = write_file_path; __file_F70.name = io.path.path(write_file_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -149,9 +149,14 @@
:struct __DIR :struct __DIR
{ {
int make(dword name); int make(dword name);
dword position(dword i);
dword buffer; dword buffer;
signed count; signed count;
}; };
:dword __DIR::position(dword i)
{
return i*304+buffer+72;
}
:int __DIR::make(dword new_folder_path) :int __DIR::make(dword new_folder_path)
{ {
__file_F70.func = 9; __file_F70.func = 9;
@ -160,7 +165,7 @@
__file_F70.param3 = __file_F70.param3 =
__file_F70.param4 = __file_F70.param4 =
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.name = new_folder_path; __file_F70.name = io.path.path(new_folder_path);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -171,40 +176,28 @@
dword file(...); dword file(...);
dword path(...); dword path(...);
}; };
:char __PATH_NEW[4096]; :char __PATH_NEW[4096];
:dword __PATH::path(dword PATH) :dword __PATH::path(dword PATH)
{ {
dword _NPT; dword pos = PATH;
_NPT = #__PATH_NEW; if(DSBYTE[pos]=='/')
if(DSBYTE[PATH]=='/')
{ {
if(strcmp(PATH,"sys/",4)) pos++;
if(strcmp(PATH,"hd/",3)) if(!strncmp(pos,"sys/",4)) return PATH;
if(strcmp(PATH,"rd/",3)) if(!strncmp(pos,"hd/",3)) return PATH;
if(strcmp(PATH,"tmp/",4)) if(!strncmp(pos,"fd/",3)) return PATH;
if(strcmp(PATH,"fd/",3)) if(!strncmp(pos,"rd/",3)) return PATH;
if(strcmp(PATH,"cd/",3)) sprintf(_NPT,"/%s%s","sys",PATH); if(!strncmp(pos,"tmp/",4)) return PATH;
if(!strncmp(pos,"cd/",3)) return PATH;
if(!strncmp(pos,"bd/",3)) return PATH;
if(!strncmp(pos,"usbhd/",6)) return PATH;
sprintf(#__PATH_NEW,"/sys%s",PATH);
return #__PATH_NEW;
} }
while(DSBYTE[_NPT]) if(!strncmp(PATH,"./",2)) return PATH;
{ sprintf(#__PATH_NEW,"%s/%s",__DIR__,PATH);
if(DSBYTE[_NPT]=='.') return #__PATH_NEW;
{
if(DSBYTE[_NPT+1]=='.')
{
if(DSBYTE[_NPT+1]=='/')
{
}
}
else if(DSBYTE[_NPT+1]=='/')
{
_NPT++;
sprintf(_NPT,"/%s%s","sys",_NPT);
}
}
_NPT++;
}
return _NPT;
} }
:dword __PATH::file(dword name) :dword __PATH::file(dword name)
@ -230,7 +223,6 @@
dword get_size_dir(dword name); dword get_size_dir(dword name);
signed count(dword path); signed count(dword path);
dword dir_buffer(dword path;byte options); dword dir_buffer(dword path;byte options);
dword dir_position(dword pos);
signed int run(dword path,param); signed int run(dword path,param);
byte del(...); byte del(...);
dword read(...); dword read(...);
@ -251,10 +243,10 @@
byte size_nm[3]; byte size_nm[3];
dword bytes; dword bytes;
bytes = FILES_SIZE; bytes = FILES_SIZE;
if (bytes>=1073741824) strncpy(#size_nm, __T__GB,2); if (bytes>=1073741824) strlcpy(#size_nm, __T__GB,2);
else if (bytes>=1048576) strncpy(#size_nm, __T__MB,2); else if (bytes>=1048576) strlcpy(#size_nm, __T__MB,2);
else if (bytes>=1024) strncpy(#size_nm, __T__KB,2); else if (bytes>=1024) strlcpy(#size_nm, __T__KB,2);
else strncpy(#size_nm, __T___B,1); else strlcpy(#size_nm, __T___B,1);
while (bytes>1023) bytes/=1024; while (bytes>1023) bytes/=1024;
sprintf(#__ConvertSize_size_prefix,"%d %s",bytes,#size_nm); sprintf(#__ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
return #__ConvertSize_size_prefix; return #__ConvertSize_size_prefix;
@ -282,7 +274,7 @@
__file_F70.param4 = __file_F70.param4 =
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.param2 = rparam; __file_F70.param2 = rparam;
__file_F70.name = rpath; __file_F70.name = path.path(rpath);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40
@ -297,10 +289,7 @@
} }
return -1; return -1;
} }
:dword IO::dir_position(dword pos)
{
return pos*304+dir.buffer+72;
}
:dword IO::dir_buffer(dword PATH;byte options) :dword IO::dir_buffer(dword PATH;byte options)
{ {
count(PATH); count(PATH);

View File

@ -904,15 +904,51 @@ inline fastcall dword GetStartTime()
//WriteText(x, y, 0x80, 0x000000, #text); //WriteText(x, y, 0x80, 0x000000, #text);
} }
:void __path_name__(dword BUF,PATH)
{
dword beg = PATH;
dword pos = PATH;
dword sav = PATH;
dword i;
while(DSBYTE[pos])
{
if(DSBYTE[pos]=='/')sav = pos;
pos++;
}
i = sav-beg;
while(i)
{
DSBYTE[BUF] = DSBYTE[beg];
beg++;
BUF++;
i--;
}
/*while(DSBYTE[beg])
{
DSBYTE[BUF1] = DSBYTE[beg];
beg++;
BUF1++;
}*/
//DSBYTE[BUF1] = 0;
DSBYTE[BUF] = 0;
}
dword __generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë dword __generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
:dword program_path_length; :dword program_path_length;
char __BUF_DIR__[4096];
dword __DIR__;
//The initialization of the initial data before running //The initialization of the initial data before running
void load_init_main() void load_init_main()
{ {
SKIN.height = GetSkinHeight(); __DIR__ = #__BUF_DIR__;
__path_name__(__DIR__,I_Path);
SKIN.height = GetSkinHeight();
screen.width = GetScreenWidth(); screen.width = GetScreenWidth();
screen.height = GetScreenHeight(); screen.height = GetScreenHeight();

View File

@ -849,12 +849,12 @@ inline cdecl int sprintf(dword buf, format,...)
tmp = itoa(tmp); tmp = itoa(tmp);
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF; if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
l = strlen(tmp); l = strlen(tmp);
strncpy(buf,tmp,l); strlcpy(buf,tmp,l);
buf += l; buf += l;
break; break;
case 'a': case 'a':
case 'A': case 'A':
strncpy(buf,"0x00000000",10); strlcpy(buf,"0x00000000",10);
buf+=10; buf+=10;
l=buf; l=buf;
while(tmp) while(tmp)
@ -871,7 +871,7 @@ inline cdecl int sprintf(dword buf, format,...)
tmp = itoa(#tmp); tmp = itoa(#tmp);
if(!DSBYTE[tmp])goto END_FUNC_SPRINTF; if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
l = strlen(tmp); l = strlen(tmp);
strncpy(buf,tmp,l); strlcpy(buf,tmp,l);
buf += l; buf += l;
break; break;
case '%': case '%':