1. Shell updated to 0.4.4. Author: Albom

2. @SS [ScreenSaver] now reacts to key pressing

git-svn-id: svn://kolibrios.org@1647 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Nasarus 2010-10-07 13:43:56 +00:00
parent 97f05bd867
commit 99bb0c8af2
34 changed files with 112 additions and 1512 deletions

View File

@ -1,39 +1,43 @@
/// =========================================================== /// ===========================================================
#include "kolibri.h" #include "system/boolean.h"
#include "stdlib.h" #include "system/kolibri.h"
#include "string.h" #include "system/stdlib.h"
#include "system/string.h"
#include "globals.h" #include "globals.h"
#include "prototypes.h" #include "prototypes.h"
#include "console.c" #include "system/console.c"
#include "cmd_about.c" #include "cmd/cmd_about.c"
#include "cmd_help.c" #include "cmd/cmd_help.c"
#include "cmd_ver.c" #include "cmd/cmd_ver.c"
#include "cmd_pwd.c" #include "cmd/cmd_pwd.c"
#include "cmd_ls.c" #include "cmd/cmd_ls.c"
#include "cmd_ps.c" #include "cmd/cmd_ps.c"
#include "cmd_kill.c" #include "cmd/cmd_kill.c"
#include "cmd_echo.c" #include "cmd/cmd_echo.c"
#include "cmd_date.c" #include "cmd/cmd_date.c"
#include "cmd_exit.c" #include "cmd/cmd_exit.c"
#include "cmd_cd.c" #include "cmd/cmd_cd.c"
#include "cmd_free.c" #include "cmd/cmd_free.c"
#include "cmd_reboot.c" #include "cmd/cmd_reboot.c"
#include "cmd_mkdir.c" #include "cmd/cmd_mkdir.c"
#include "cmd_rmdir.c" #include "cmd/cmd_rmdir.c"
#include "cmd_rm.c" #include "cmd/cmd_rm.c"
#include "cmd_touch.c" #include "cmd/cmd_touch.c"
#include "cmd_alias.c" #include "cmd/cmd_alias.c"
#include "cmd_more.c" #include "cmd/cmd_more.c"
#include "cmd/cmd_clear.c"
#include "cmd/cmd_ccpuid.c"
#include "cmd/cmd_sleep.c"
#include "module_command.c" #include "modules/module_command.c"
#include "module_program.c" #include "modules/module_program.c"
#include "module_script.c" #include "modules/module_script.c"
#include "module_executable.c" #include "modules/module_executable.c"
#include "module_alias.c" #include "modules/module_alias.c"
/// =========================================================== /// ===========================================================

View File

@ -1,9 +0,0 @@
void cmd_about()
{
printf("\n\rShell for KolibriOS\n\r");
printf(" version %s\n\r", SHELL_VERSION);
printf("\n\r author: Oleksandr Bogomaz aka Albom");
printf("\n\r e-mail: albom85@yandex.ru");
printf("\n\r site: http://albom06.boom.ru/\n\r\n\r");
}

View File

@ -1,17 +0,0 @@
void cmd_alias(char arg[])
{
int result;
if (NULL == arg)
{
alias_list();
return;
}
result = alias_check(arg);
if ( ( 0 != result ) && ( -1 != result ) )
alias_add(arg);
}

View File

@ -1,47 +0,0 @@
int cmd_cd(char dir[])
{
char temp[256];
unsigned result;
if (NULL == dir)
{
printf(" cd directory\n\r");
return FALSE;
}
if ( 0 == strcmp(dir, ".") )
return FALSE;
if ( ( 0 == strcmp(dir, "..") ) && ( 0 != strcmp(cur_dir, "/")) )
{
cur_dir[strlen(cur_dir)-1]='\0';
dir_truncate(cur_dir);
return FALSE;
}
if ( '/' == dir[0])
{
if ( dir_check(dir) )
{
strcpy(cur_dir, dir);
return TRUE;
}
return FALSE;
}
else
{
strcpy(temp, cur_dir);
strcat(temp, dir);
if ( dir_check(temp) )
{
strcpy(cur_dir, temp);
return TRUE;
}
return FALSE;
}
}

View File

@ -1,22 +0,0 @@
void cmd_date()
{
unsigned date;
unsigned time;
date = kol_system_date_get();
printf(" date [dd.mm.yy]: %x%x.%x%x.%x%x",
(date&0xf00000)>>20, (date&0xf0000)>>16, // day
(date&0xf000)>>12, (date&0xf00)>>8, //month
(date&0xf0)>>4, (date&0xf) ); // year
time = kol_system_time_get();
printf("\n\r time [hh:mm:ss]: %x%x:%x%x:%x%x\n\r",
(time&0xf0)>>4, (time&0xf), // hours
(time&0xf000)>>12, (time&0xf00)>>8, // minutes
(time&0xf00000)>>20, (time&0xf0000)>>16 ); // seconds
}

View File

@ -1,6 +0,0 @@
void cmd_echo(char text[])
{
printf("%s\n\r", text);
}

View File

@ -1,7 +0,0 @@
void cmd_exit()
{
free(ALIASES);
_exit(1);
kol_exit();
}

View File

@ -1,12 +0,0 @@
void cmd_free()
{
unsigned total, free, used;
total = kol_system_mem();
free = kol_system_memfree();
used = total - free;
printf (" total [kB / MB / %%]: %-7d / %-5d / 100\n\r free [kB / MB / %%]: %-7d / %-5d / %d\n\r used [kB / MB / %%]: %-7d / %-5d / %d\n\r",
total, total/1024, free, free/1024, (free*100)/total, used, total/1024-free/1024, 100-(free*100)/total );
}

View File

@ -1,31 +0,0 @@
int cmd_help(char cmd[])
{
int i;
char available[]={" %d commands available:\n\r"};
if (NULL == cmd)
{
printf (available, NUM_OF_CMD);
for (i = 0; i < NUM_OF_CMD; i++)
printf(" %s\n\r", HELP_COMMANDS[i]);
}
else
{
for (i=0; i<NUM_OF_CMD; i++)
if ( !strcmp(cmd, HELP_COMMANDS[i]) )
{
printf(HELP_DESC[i]);
return TRUE;
}
printf (" Command \'%s\' not found.\n\r", cmd);
printf (available, NUM_OF_CMD);
for (i = 0; i < NUM_OF_CMD; i++)
printf(" %s\n\r", HELP_COMMANDS[i]);
}
return FALSE;
}

View File

@ -1,43 +0,0 @@
int _atoi ( char *s )
{
int i, n;
n = 0;
for ( i = 0; s[i]!= '\0'; ++i)
if ((s[i]<'0') || (s[i]>'9'))
return 0;
else
n = 10 * n + s[i] - '0';
return n;
}
int cmd_kill(char process[])
{
unsigned proc;
int result;
if (NULL == process)
{
printf(" kill PID\n\r");
return FALSE;
}
else
{
proc = _atoi(process);
if ( 0 != proc )
{
result = kol_process_kill_pid(proc);
if (result < 0)
return FALSE;
else
return TRUE;
}
}
}

View File

@ -1,41 +0,0 @@
int cmd_ls(char dir[])
{
kol_struct70 k70;
unsigned *n;
unsigned num_of_file;
unsigned *t;
unsigned type_of_file;
int i;
k70.p00 = 1;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 2*1024*1024; // 2 MB
k70.p16 = malloc(2*1024*1024);
k70.p20 = 0;
k70.p21 = dir;
if ( !kol_file_70(&k70) ) // ïðîâåðÿåì ñóùåñòâîâàíèå êàòàëîãà
{
free(k70.p16);
return FALSE;
}
n = k70.p16+8;
num_of_file = *n; // ÷èñëî ôàéëîâ â êàòàëîãå
for (i = 0; i < num_of_file; i++)
{
printf (" %s", k70.p16+32+40+(264+40)*i);
t = k70.p16+32+(264+40)*i;
type_of_file = *t;
if ( (0x10 == (type_of_file&0x10)) || (8 == (type_of_file&8)) )
printf ("/");
printf ("\n\r");
}
free(k70.p16);
return TRUE;
}

View File

@ -1,44 +0,0 @@
int cmd_mkdir(char dir[])
{
char temp[256];
kol_struct70 k70;
unsigned result;
if (NULL == dir)
{
printf(" mkdir directory\n\r");
return FALSE;
}
if ( 0 == strcmp(dir, ".") || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
{
return FALSE;
}
k70.p00 = 9;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
if ( '/' == dir[0])
k70.p21 = dir;
else
{
strcpy(temp, cur_dir);
strcat(temp, dir);
k70.p21 = temp;
}
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}

View File

@ -1,87 +0,0 @@
int cmd_more(char file[])
{
kol_struct70 k70;
kol_struct_BDVK bdvk;
unsigned result, filesize, pos, i;
char buf[81]; //áóôåð
char temp[256];
unsigned flags;
if (NULL == file)
{
printf (" less filename\n\r");
return FALSE;
}
if ( '/' == file[0])
{
strcpy(temp, file);
if ( !file_check(temp) )
{
return FALSE;
}
}
else
{
strcpy(temp, cur_dir);
strcat(temp, file);
if ( !file_check(temp) )
{
return FALSE;
}
}
k70.p00 = 5;
k70.p04 = k70.p08 = k70.p12 = 0;
k70.p16 = &bdvk;
k70.p20 = 0;
k70.p21 = temp;
result = kol_file_70(&k70); // ïîëó÷àåì èíôîðìàöèþ î ôàéëå
if ( 0 != result )
return FALSE;
filesize = bdvk.p32[0]; // ïîëó÷àåì ðàçìåð ôàéëà
buf[80]=0;
flags = con_get_flags();
for (pos=0;pos<filesize;pos+=80)
{
memset(buf, 0, 80);
k70.p00 = 0;
k70.p04 = pos;
k70.p08 = 0;
k70.p12 = 80;
k70.p16 = buf;
k70.p20 = 0;
k70.p21 = temp;
result = kol_file_70(&k70); // ÷òåíèå 80 ñèìâîëîâ
for (i=0; i<80; i++)
{
if (27 == buf[i])
con_set_flags(flags|0x100);
else con_set_flags(flags);
printf ("%c", buf[i]);
}
if ( 0 != result )
{
con_set_flags(flags);
printf ("\n\r");
return TRUE;
}
}
con_set_flags(flags);
printf ("\n\r");
return TRUE;
}

View File

@ -1,32 +0,0 @@
int cmd_ps()
{
int i, n;
char *buf1k;
unsigned PID;
unsigned *p;
short *s;
short STATE;
buf1k = malloc(1024);
if (NULL == buf1k)
return FALSE;
for (i = 1;;i++)
{
n = kol_process_info(i, buf1k);
p = buf1k+30;
PID = *p;
s = buf1k+50;
STATE = *s;
if ( 9 != STATE)
printf (" %7d %s\n\r", PID, buf1k+10);
if (i == n)
break;
}
free(buf1k);
return TRUE;
}

View File

@ -1,5 +0,0 @@
void cmd_pwd()
{
printf (" %s\n\r", cur_dir);
}

View File

@ -1,5 +0,0 @@
void cmd_reboot()
{
kol_system_end(3);
}

View File

@ -1,50 +0,0 @@
int cmd_rm(char file[])
{
kol_struct70 k70;
char temp[256];
unsigned result;
if (NULL == file)
{
printf (" rm filename\n\r");
return FALSE;
}
if ( '/' == file[0])
{
strcpy(temp, file);
if ( !file_check(temp) )
{
return FALSE;
}
}
else
{
strcpy(temp, cur_dir);
strcat(temp, file);
if ( !file_check(temp) )
{
return FALSE;
}
}
k70.p00 = 8;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = temp;
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}

View File

@ -1,46 +0,0 @@
int cmd_rmdir(char dir[])
{
char temp[256];
kol_struct70 k70;
unsigned result;
if (NULL == dir)
{
printf(" rmdir directory\n\r");
return FALSE;
}
if ( ( 0 == strcmp(dir, ".") ) || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
{
return FALSE;
}
k70.p00 = 8;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
if ( '/' == dir[0])
k70.p21 = dir;
else
{
strcpy(temp, cur_dir);
strcat(temp, dir);
k70.p21 = temp;
}
if ( !dir_check(temp) )
return FALSE;
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}

View File

@ -1,54 +0,0 @@
int cmd_touch(char file[])
{
kol_struct70 k70;
char temp[256];
unsigned result;
if (NULL == file)
{
printf(" touch filename\n\r");
return FALSE;
}
if ( ( 0 == strcmp(file, ".") ) || ( 0 == strcmp(file, "..") ) || ( 0 == strcmp(cur_dir, "/")) )
{
return FALSE;
}
if ( '/' == file[0])
{
strcpy(temp, file);
if ( !file_check(temp) )
k70.p00 = 2;
else
k70.p00 = 3;
}
else
{
strcpy(temp, cur_dir);
strcat(temp, file);
if ( !file_check(temp) )
k70.p00 = 2;
else
k70.p00 = 3;
}
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = temp;
result = kol_file_70(&k70);
if (0 == result)
return TRUE;
else
return FALSE;
}

View File

@ -1,5 +0,0 @@
void cmd_ver()
{
printf (" %s\n\r", SHELL_VERSION);
}

View File

@ -1,7 +1,9 @@
del shell.kex
del shell.o
fasm start.asm start.o fasm start.asm start.o
gcc -c shell.c gcc -c shell.c
gcc -c system/kolibri.c
gcc -c system/stdlib.c
gcc -c system/string.c
ld -nostdlib -T kolibri.ld -o shell.kex start.o kolibri.o stdlib.o string.o shell.o ld -nostdlib -T kolibri.ld -o shell.kex start.o kolibri.o stdlib.o string.o shell.o
objcopy shell.kex -O binary objcopy shell.kex -O binary
kpack shell.kex
pause pause

View File

@ -1,82 +0,0 @@
///===========================
#define CON_COLOR_BLUE 1
#define CON_COLOR_GREEN 2
#define CON_COLOR_RED 4
#define CON_COLOR_BRIGHT 8
/* öâåò ôîíà */
#define CON_BGR_BLUE 0x10
#define CON_BGR_GREEN 0x20
#define CON_BGR_RED 0x40
#define CON_BGR_BRIGHT 0x80
///===========================
void (* _stdcall con_init)(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
void (* _cdecl printf)(const char* format,...);
void (* _stdcall _exit)(char bCloseWindow);
void (* __stdcall gets)(char* str, int n);
int (* __stdcall getch)(void);
int (* __stdcall con_get_font_height)(void);
int (* __stdcall con_set_cursor_height)(int new_height);
unsigned (*__stdcall con_get_flags)(void);
unsigned (*__stdcall con_set_flags)(unsigned new_flags);
///===========================
void CONSOLE_INIT(char title[])
{
kol_struct_import *imp;
imp = kol_cofflib_load("/sys/lib/console.obj");
if (imp == NULL)
kol_exit();
con_init = ( _stdcall void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
kol_cofflib_procload (imp, "con_init");
if (con_init == NULL)
kol_exit();
printf = ( _cdecl void (*)(const char*,...))
kol_cofflib_procload (imp, "con_printf");
if (printf == NULL)
kol_exit();
_exit = ( _stdcall void (*)(char))
kol_cofflib_procload (imp, "con_exit");
if (_exit == NULL)
kol_exit();
gets = ( _stdcall void (*)(char*, int))
kol_cofflib_procload (imp, "con_gets");
if (gets == NULL)
kol_exit();
getch = ( _stdcall int (*)(void))
kol_cofflib_procload (imp, "con_getch2");
if (getch == NULL)
kol_exit();
con_get_font_height = ( _stdcall int (*)(void))
kol_cofflib_procload (imp, "con_get_font_height");
if (con_get_font_height == NULL)
kol_exit();
con_set_cursor_height = ( _stdcall int (*)(int))
kol_cofflib_procload (imp, "con_set_cursor_height");
if (con_set_cursor_height == NULL)
kol_exit();
con_get_flags = ( _stdcall unsigned (*)(void))
kol_cofflib_procload (imp, "con_get_flags");
if (con_get_flags == NULL)
kol_exit();
con_set_flags = ( _stdcall unsigned (*)(unsigned))
kol_cofflib_procload (imp, "con_set_flags");
if (con_set_flags == NULL)
kol_exit();
con_init(-1, -1, -1, -1, title);
}

View File

@ -1,8 +1,5 @@
#define FALSE 0 #define SHELL_VERSION "0.4.4"
#define TRUE 1
#define SHELL_VERSION "0.4"
extern char PATH[256]; extern char PATH[256];
extern char PARAM[256]; extern char PARAM[256];
@ -31,52 +28,70 @@ char script_sign[] = {"#SHS"};
/// =========================================================== /// ===========================================================
const NUM_OF_CMD = 19; int NUM_OF_CMD;
const char HELP_COMMANDS[][10]= /// ===========================================================
{
"about",
"alias",
"cd",
"date",
"echo",
"exit",
"free",
"help",
"kill",
"ls",
"mkdir",
"more",
"ps",
"pwd",
"reboot",
"rm",
"rmdir",
"touch",
"ver"
};
const char HELP_DESC [][70]= typedef struct
{ {
" Displays information about the program\n\r", const char* name;
" Allows the user view the current aliases\n\r", const char* help;
" Changes directories\n\r", const void* handler;
" Returns the date and time\n\r", } command_t;
" Echoes the data to the screen\n\r",
" Exits program\n\r", /// ===========================================================
" Displays total, free and used memory\n\r",
" Gives help\n\r", int cmd_about(char arg[]);
" Stops a running process\n\r", int cmd_alias(char arg[]);
" Lists the files in a directory\n\r", int cmd_ccpuid(char dir[]);
" Makes directory\n\r", int cmd_cd(char dir[]);
" Displays a data file to the screen\n\r", int cmd_clear(char arg[]);
" Lists the current processes running\n\r", int cmd_date(char arg[]);
" Displays the name of the working directory\n\r", int cmd_echo(char text[]);
" Reboots the computer\n\r", int cmd_exit(char arg[]);
" Removes files\n\r", int cmd_free(char arg[]);
" Removes directories\n\r", int cmd_help(char cmd[]);
" Creates an empty file or updates the time/date stamp on a file\n\r", int cmd_kill(char process[]);
" Displays version\n\r" int cmd_ls(char dir[]);
int cmd_mkdir(char dir[]);
int cmd_more(char file[]);
int cmd_ps(char arg[]);
int cmd_pwd(char arg[]);
int cmd_reboot(char arg[]);
int cmd_rm(char file[]);
int cmd_rmdir(char dir[]);
int cmd_touch(char file[]);
int cmd_ver(char arg[]);
int cmd_sleep(char arg[]);
/// ===========================================================
const command_t COMMANDS[]=
{
{"about", " Displays information about the program\n\r", &cmd_about},
{"alias", " Allows the user view the current aliases\n\r", &cmd_alias},
{"ccpuid"," Displays CPU information\n\r", &cmd_ccpuid},
{"cd", " Changes directories\n\r", &cmd_cd},
{"clear", " Clears the display\n\r", &cmd_clear},
{"date", " Returns the date and time\n\r", &cmd_date},
{"echo", " Echoes the data to the screen\n\r", &cmd_echo},
{"exit", " Exits program\n\r", &cmd_exit},
{"free", " Displays total, free and used memory\n\r", &cmd_free},
{"help", " Gives help\n\r", &cmd_help},
{"kill", " Stops a running process\n\r", &cmd_kill},
{"ls", " Lists the files in a directory\n\r", &cmd_ls},
{"mkdir", " Makes directory\n\r", &cmd_mkdir},
{"more", " Displays a data file to the screen\n\r", &cmd_more},
{"ps", " Lists the current processes running\n\r", &cmd_ps},
{"pwd", " Displays the name of the working directory\n\r", &cmd_pwd},
{"reboot"," Reboots the computer\n\r", &cmd_reboot},
{"rm", " Removes files\n\r", &cmd_rm},
{"rmdir", " Removes directories\n\r", &cmd_rmdir},
{"sleep", " Stops the shell for the desired period\n\r", &cmd_sleep},
{"touch", " Creates an empty file or updates the time/date stamp on a file\n\r", &cmd_touch},
{"ver", " Displays version\n\r", &cmd_ver},
}; };
/// =========================================================== /// ===========================================================

View File

@ -1,90 +0,0 @@
#define NULL ((void*)0)
typedef struct
{
unsigned p00 __attribute__((packed));
unsigned p04 __attribute__((packed));
unsigned p08 __attribute__((packed));
unsigned p12 __attribute__((packed));
unsigned p16 __attribute__((packed));
char p20 __attribute__((packed));
char *p21 __attribute__((packed));
} kol_struct70 __attribute__((packed));
typedef struct
{
unsigned p00 __attribute__((packed));
char p04 __attribute__((packed));
char p05[3] __attribute__((packed));
unsigned p08 __attribute__((packed));
unsigned p12 __attribute__((packed));
unsigned p16 __attribute__((packed));
unsigned p20 __attribute__((packed));
unsigned p24 __attribute__((packed));
unsigned p28 __attribute__((packed));
unsigned p32[2] __attribute__((packed));
unsigned p40 __attribute__((packed));
} kol_struct_BDVK __attribute__((packed));
typedef struct
{
char *name __attribute__((packed));
void *data __attribute__((packed));
} kol_struct_import __attribute__((packed));
void kol_exit();
void kol_sleep(unsigned d);
void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c);
void kol_wnd_move(unsigned x, unsigned y);
void kol_wnd_caption(char *s);
void kol_event_mask(unsigned e);
unsigned kol_event_wait();
unsigned kol_event_wait_time(unsigned time);
unsigned kol_event_check();
void kol_paint_start();
void kol_paint_end();
void kol_paint_pixel(unsigned x, unsigned y, unsigned c);
void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c);
void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c);
void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c);
void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d);
void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette);
unsigned kol_key_get();
unsigned kol_key_control();
void kol_key_lang_set(unsigned lang);
unsigned kol_key_lang_get();
void kol_key_mode_set(unsigned mode);
unsigned kol_key_mode_get();
void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c);
unsigned kol_btn_get();
void kol_btn_type(unsigned t);
unsigned kol_mouse_pos();
unsigned kol_mouse_posw();
unsigned kol_mouse_btn();
void kol_board_putc(char c);
void kol_board_puts(char *s);
void kol_board_puti(int n);
int kol_file_70(kol_struct70 *k);
kol_struct_import* kol_cofflib_load(char *name);
void* kol_cofflib_procload (kol_struct_import *imp, char *name);
unsigned kol_cofflib_procnum (kol_struct_import *imp);
void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n);
unsigned kol_system_end(unsigned param);
unsigned kol_system_cpufreq();
unsigned kol_system_mem();
unsigned kol_system_memfree();
unsigned kol_system_time_get();
unsigned kol_system_date_get();
void kol_path_file2dir(char *dir, char *fname);
void kol_path_full(char *full, char *fname);
void kol_screen_wait_rr();
void kol_screen_get_size(unsigned *w, unsigned *h);
unsigned kol_skin_height();
unsigned kol_thread_start(unsigned start, unsigned stack);
unsigned kol_time_tick();
unsigned kol_sound_speaker(char data[]);
unsigned kol_process_info(unsigned slot, char buf1k[]);
int kol_process_kill_pid(unsigned process);

View File

@ -1,133 +0,0 @@
/// ===========================================================
int alias_check(char alias[])
{
unsigned i;
char buf1[256];
char buf2[256];
if ( !alias_split (alias, buf1, buf2))
return FALSE;
for (i = 0; i < NUM_OF_CMD; i++)
if ( !strcmp(HELP_COMMANDS[i], buf1) )
return -1;
if (NULL == ALIASES)
ALIASES = malloc(128*1024);
if (NULL == ALIASES)
return FALSE;
if ( 0 == ALIAS_NUM )
return FALSE;
for (i = 0; i < ALIAS_NUM; i++)
{
if ( !strcmp(ALIASES+256*i, buf1) )
return TRUE;
}
return FALSE;
}
/// ===========================================================
int alias_search(char alias[])
{
unsigned i;
for (i = 0; i < ALIAS_NUM; i++)
{
if ( !strcmp(ALIASES+256*i, alias) )
return i;
}
return -1;
}
/// ===========================================================
int alias_add(char alias[])
{
char buf1[256];
char buf2[256];
if ( ALIAS_NUM > 255)
return FALSE;
if ( !alias_split (alias, buf1, buf2))
return FALSE;
strcpy (ALIASES+256*ALIAS_NUM, buf1);
strcpy (ALIASES+256*ALIAS_NUM+64*1024, buf2);
ALIAS_NUM++;
return TRUE;
}
/// ===========================================================
void alias_list()
{
unsigned i;
if ( 0 == ALIAS_NUM)
return;
for (i = 0; i < ALIAS_NUM; i++)
printf (" %s=%s\n\r",ALIASES+256*i, ALIASES+256*i+64*1024);
}
/// ===========================================================
int alias_split (char alias[], char s1[], char s2[])
{
unsigned i, j;
if (NULL == strchr(alias, '='))
return FALSE;
for (i=0, j = 0;; i++)
{
if ('=' == alias[i])
{
s1[i]='\0';
break;
}
s1[i]=alias[i];
}
j = 0;
for (;; i++, j++)
{
s2[j]=alias[i];
if ('\0' == alias[i])
break;
}
trim(s1);
for (i=0;;i++)
{
s2[i] = s2[i+1];
if ('\0' == s2[i] )
break;
}
trim(s2);
return TRUE;
}
/// ===========================================================

View File

@ -1,336 +0,0 @@
/// ===========================================================
void command_clear()
{
for (;CMD_POS;CMD_POS--)
printf("%c %c", 8, 8);
CMD[0]='\0';
}
/// ===========================================================
void command_history_add(char command[])
{
if ( (0 != strcmp( CMD_HISTORY[0], CMD)) &&
(0 != strcmp( CMD_HISTORY[1], CMD)) &&
(0 != strcmp( CMD_HISTORY[2], CMD)) &&
(0 != strcmp( CMD_HISTORY[3], CMD)) &&
(0 != strcmp( CMD_HISTORY[4], CMD)) )
{
strcpy(CMD_HISTORY[4], CMD_HISTORY[3]);
strcpy(CMD_HISTORY[3], CMD_HISTORY[2]);
strcpy(CMD_HISTORY[2], CMD_HISTORY[1]);
strcpy(CMD_HISTORY[1], CMD_HISTORY[0]);
strcpy(CMD_HISTORY[0], CMD);
}
}
/// ===========================================================
void command_get()
{
unsigned key;
//unsigned pos = 0;
int hist;
CMD_POS = 0;
CMD_NUM = 0;
for (;;)
{
key = getch();
if ( 0 != (key & 0xff) )
{
key &= 0xff;
switch (key)
{
case 27: // ESC
command_clear();
break;
case 13: // ENTER
CMD[CMD_POS] = '\0';
printf("\n\r");
command_history_add(CMD);
return;
case 8: // BACKSPACE
if (CMD_POS > 0)
{
printf ("%c %c", 8, 8);
CMD_POS--;
}
break;
case 9: // TAB
break;
default:
if (CMD_POS < 255)
{
CMD[CMD_POS] = key;
CMD_POS++;
printf("%c", key);
}
break;
};
}
else // îáðàáîòêà ðàñøèðåííûõ êëàâèø
{
key = (key>>8)&0xff;
// printf ("%d\n\r", key);
switch (key)
{
case 72: // UP
for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
{
command_clear();
if (CMD_NUM < CMD_HISTORY_NUM-1)
CMD_NUM++;
else
CMD_NUM = 0;
printf( CMD_HISTORY[CMD_NUM] );
strcpy(CMD, CMD_HISTORY[CMD_NUM]);
CMD_POS = strlen(CMD);
if (0!=strlen(CMD))
break;
}
break;
case 80: // DOWN
for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
{
command_clear();
if (CMD_NUM > 0)
CMD_NUM--;
else
CMD_NUM = CMD_HISTORY_NUM-1;
printf( CMD_HISTORY[CMD_NUM] );
strcpy(CMD, CMD_HISTORY[CMD_NUM]);
CMD_POS = strlen(CMD);
if (0!=strlen(CMD))
break;
}
break;
};
}
}
}
/// ===========================================================
int command_get_cmd(char cmd[])
{
unsigned i;
for (i=0;;i++)
{
cmd[i] = CMD[i];
if (0 == cmd[i])
{
i = -2;
break;
}
if ( iswhite(cmd[i]) )
{
cmd[i] = '\0';
break;
}
}
return i+1;
}
/// ===========================================================
void command_execute()
{
char cmd[256];
char args[256];
unsigned arg;
trim(CMD);
arg = command_get_cmd(cmd);
if ( !strlen(cmd) )
return;
strcpy(args, CMD+arg);
trim(args);
if ( !strcmp(cmd, "help") )
{
if (-1 == arg)
cmd_help(NULL);
else
cmd_help(args);
return;
}
if ( !strcmp(cmd, "ver") )
{
cmd_ver();
return;
}
if ( !strcmp(cmd, "cd") )
{
if (-1 == arg)
cmd_cd(NULL);
else
cmd_cd(args);
if ( '/' != cur_dir[strlen(cur_dir)-1] )
strcat(cur_dir, "/");
return;
}
if ( !strcmp(cmd, "ls") )
{
if (-1 == arg)
cmd_ls(cur_dir);
else
cmd_ls(args);
return;
}
if ( !strcmp(cmd, "ps") )
{
cmd_ps();
return;
}
if ( !strcmp(cmd, "kill") )
{
if (-1 == arg)
cmd_kill(NULL);
else
cmd_kill(args);
return;
}
if ( !strcmp(cmd, "pwd") )
{
cmd_pwd();
return;
}
if ( !strcmp(cmd, "mkdir") )
{
if (-1 == arg)
cmd_mkdir(NULL);
else
cmd_mkdir(args);
return;
}
if ( !strcmp(cmd, "rmdir") )
{
if (-1 == arg)
cmd_rmdir(NULL);
else
cmd_rmdir(args);
return;
}
if ( !strcmp(cmd, "rm") )
{
if (-1 == arg)
cmd_rm(NULL);
else
cmd_rm(args);
return;
}
if ( !strcmp(cmd, "more") )
{
if (-1 == arg)
cmd_more(NULL);
else
cmd_more(args);
return;
}
if ( !strcmp(cmd, "echo") )
{
cmd_echo(args);
return;
}
if ( !strcmp(cmd, "exit") )
{
cmd_exit();
return;
}
if ( !strcmp(cmd, "date") )
{
cmd_date();
return;
}
if ( !strcmp(cmd, "about") )
{
cmd_about();
return;
}
if ( !strcmp(cmd, "free") )
{
cmd_free();
return;
}
if ( !strcmp(cmd, "reboot") )
{
cmd_reboot();
return;
}
if ( !strcmp(cmd, "touch") )
{
if (-1 == arg)
cmd_touch(NULL);
else
cmd_touch(args);
return;
}
if ( !strcmp(cmd, "alias") )
{
if (-1 == arg)
cmd_alias(NULL);
else
cmd_alias(args);
return;
}
if ( -1 != alias_search(CMD) )
{
strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD));
command_execute();
return;
}
executable_run(cmd, args);
}
/// ===========================================================

View File

@ -1,60 +0,0 @@
/// ===========================================================
int executable_run(char cmd[], char args[])
{
char exec[256];
char error_starting[]={" No such command '%s'.\n\r"};
int result;
if ( '/' == cmd[0]) // åñëè ïóòü àáñîëáòíûé
{
strcpy(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
printf(error_starting, cmd);
return FALSE;
}
}
else
{
strcpy(exec, cur_dir); // ïðîâåðÿåì ôàéë â òåêóùåì êàòàëîãå
strcat(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
strcpy(exec, "/rd/1/"); // ïðîâåðÿåì ôàéë íà âèðòóàëüíîì äèñêå
strcat(exec, cmd);
if ( !file_check(exec) ) // ïðîâåðÿåì ñóùåñòâîâàíèå ôàéëà
{
printf(error_starting, cmd);
return FALSE;
}
}
}
if ( script_check(exec) )
{
return script_run(exec, args);
}
/* çàïóñê ïðîãðàììû */
result = program_run(exec, args);
if (result > 0)
{
printf (" '%s' started. PID = %d\n\r", cmd, result);
return TRUE;
}
else
{
printf(error_starting, cmd);
return FALSE;
}
}
/// ===========================================================

View File

@ -1,16 +0,0 @@
int program_run(char cmd[], char param[])
{
kol_struct70 k70;
k70.p00 = 7;
k70.p04 = 0;
k70.p08 = param;
k70.p12 = 0;
k70.p16 = 0;
k70.p20 = 0;
k70.p21 = cmd;
return kol_file_70(&k70);
}

View File

@ -1,102 +0,0 @@
/// ===========================================================
int script_check(char file[])
{
kol_struct70 k70;
char buf[4];
k70.p00 = 0;
k70.p04 = 0;
k70.p08 = 0;
k70.p12 = 4; // ÷èòàòü 4 áàéòà
k70.p16 = buf;
k70.p20 = 0;
k70.p21 = file;
kol_file_70(&k70);
if ( !strcmp(buf, script_sign) )
return TRUE;
else
return FALSE;
}
/// ===========================================================
int script_run(char exec[], char args[])
{
kol_struct70 k70;
kol_struct_BDVK bdvk;
unsigned result, filesize, pos, i;
char *buf; //áóôåð, êóäà êîïèðóåòñÿ ñêðèïò
k70.p00 = 5;
k70.p04 = k70.p08 = k70.p12 = 0;
k70.p16 = &bdvk;
k70.p20 = 0;
k70.p21 = exec;
result = kol_file_70(&k70); // ïîëó÷àåì èíôîðìàöèþ î ôàéëå
if ( 0 != result )
return FALSE;
filesize = bdvk.p32[0]; // ïîëó÷àåì ðàçìåð ôàéëà
buf = malloc(filesize+256);
if (NULL == buf)
return FALSE;
buf[filesize]=0;
k70.p00 = 0;
k70.p04 = k70.p08 = 0;
k70.p12 = filesize;
k70.p16 = buf;
k70.p20 = 0;
k70.p21 = exec;
result = kol_file_70(&k70); // ñ÷èòûâàåì ôàéë â áóôåð
if ( 0 != result )
{
free(buf);
return FALSE;
}
pos = 0;
for (;;) // îáðàáîòêà ñêðèïòà
{
if (pos > filesize)
break;
for (i=0;;i++) // ñ÷èòûâàíèå ñòðîêè
{
if ((0x0A == buf[pos])||(0x0D == buf[pos])||(0 == buf[pos]))
{
pos++;
CMD[i] = '\0';
break;
}
CMD[i] = buf[pos];
pos++;
}
if ( 0 == strlen(CMD) ) // ïóñòàÿ ñòðîêà
continue;
if ('#' == CMD[0]) // êîììåíòàðèé
continue;
command_execute();
}
free(buf);
return TRUE;
}
/// ===========================================================

View File

@ -1,27 +0,0 @@
Shell for KolibriOS
version 0.4
author: Oleksandr Bogomaz aka Albom
e-mail: albom85@yandex.ru
site: http://albom06.boom.ru/
Available commands:
about Displays information about the program
alias Allows the user view the current aliases
cd Changes directories
date Returns the date and time
echo Echoes the data to the screen
exit Exits program
free Displays total, free and used memory
help Gives help
kill Stops a running process
ls Lists the files in a directory
mkdir Makes directory
more Displays a data file to the screen
ps Lists the current processes running
pwd Displays the name of the working directory
reboot Reboots the computer
rm Removes files
rmdir Removes directories
touch Creates an empty file or updates the time/date stamp on a file
ver Displays version

View File

@ -104,6 +104,8 @@ for (;i>0;--i)
void kol_main() void kol_main()
{ {
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
strcpy(title, "SHELL "); strcpy(title, "SHELL ");
strcat(title, SHELL_VERSION); strcat(title, SHELL_VERSION);
CONSOLE_INIT(title); CONSOLE_INIT(title);
@ -113,6 +115,8 @@ dir_truncate(cur_dir);
con_set_cursor_height(con_get_font_height()-1); con_set_cursor_height(con_get_font_height()-1);
ALIASES = malloc(128*1024);
if (strlen(PARAM) > 0) if (strlen(PARAM) > 0)
strcpy(CMD, PARAM); strcpy(CMD, PARAM);
else else

View File

@ -1,14 +0,0 @@
#define RAND_MAX 0x7FFFU
#define isspace(c) ((c)==' ')
#define abs(i) (((i)<0)?(-(i)):(i))
#define random(num) ((rand()*(num))/((RAND_MAX+1)))
void* malloc(unsigned size);
void free(void *pointer);
void* realloc(void* pointer, unsigned size);
void srand (unsigned seed);
int rand (void);

View File

@ -1,12 +0,0 @@
#define NULL ((void*)0)
void* memset(void *mem, int c, unsigned size);
void* memcpy(void *dst, const void *src, unsigned size);
void strcat(char strDest[], char strSource[]);
int strcmp(const char* string1, const char* string2);
void strcpy(char strDest[], const char strSource[]);
char* strncpy(char *strDest, const char *strSource, unsigned n);
int strlen(const char* string);
char *strchr(const char* string, int c);

View File

@ -36,6 +36,8 @@ bgr_changed:
shl eax, 16 shl eax, 16
mov [top_right_corner], eax mov [top_right_corner], eax
mcall 66, 4, 57, 0 ; hot key for {Space}
mcall 66, 4, 28, 0 ; hot key for {Enter}
still: still:
movzx ebx, [time] movzx ebx, [time]
imul ebx, 60*100 imul ebx, 60*100
@ -62,6 +64,14 @@ create_setup:
jmp still jmp still
key: key:
mcall ; eax = 2 mcall ; eax = 2
cmp al, 2 ; hot key?
jne still ; no hotkey, evenets handling go on
xor edx, edx
mov dl, ah
mov eax, 72
mov ebx, 1
mov ecx, 2
mcall ; transfer key code to active window after interception
jmp still jmp still
create_ss_thread: create_ss_thread: