2012-03-23 19:53:16 +01:00
|
|
|
|
|
|
|
|
|
#include "system/kolibri.h"
|
|
|
|
|
#include "system/string.h"
|
|
|
|
|
|
|
|
|
|
#include "program_console.h"
|
|
|
|
|
|
2013-02-24 11:33:37 +01:00
|
|
|
|
char *buffer; // <20>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ⮫쪮 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>⮬<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ᤥ<><E1A4A5><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쭮<EFBFBD> <20><>६<EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char name[32]; // <20><><EFBFBD> <20>㦭<EFBFBD> <20><><EFBFBD> <20><><EFBFBD> ᮧ<><E1AEA7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ⠪ <20> <20><><EFBFBD> 㤠<><E3A4A0><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>⮬<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ᤥ<><E1A4A5><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쭮<EFBFBD> <20><>६<EFBFBD><E0A5AC><EFBFBD><EFBFBD><EFBFBD>
|
2012-03-23 19:53:16 +01:00
|
|
|
|
|
2013-02-24 11:33:37 +01:00
|
|
|
|
int sc_init() // <20><><EFBFBD>樠<EFBFBD><E6A8A0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - ᮧ<><E1AEA7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-03-23 19:53:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char *buf1k;
|
|
|
|
|
unsigned PID;
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf1k = malloc(1024);
|
|
|
|
|
if (NULL == buf1k)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2013-02-24 11:33:37 +01:00
|
|
|
|
kol_process_info(-1, buf1k); // <20><><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD><EFBFBD> (-1) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䨪<EFBFBD><E4A8AA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2012-03-23 19:53:16 +01:00
|
|
|
|
PID = *(buf1k+30);
|
|
|
|
|
free(buf1k);
|
|
|
|
|
|
2013-02-24 11:33:37 +01:00
|
|
|
|
itoa(PID, name); // <20><>ନ<EFBFBD>㥬 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ப<EFBFBD>
|
2012-03-23 19:53:16 +01:00
|
|
|
|
strcat(name, "-SHELL");
|
|
|
|
|
|
|
|
|
|
*buffer = NULL;
|
2013-02-24 11:33:37 +01:00
|
|
|
|
result = kol_buffer_open(name, SHM_OPEN_ALWAYS | SHM_WRITE, 1024*16, &buffer); // ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (16 <20><><EFBFBD><EFBFBD><EFBFBD>)
|
2012-03-23 19:53:16 +01:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sc_puts(char *str)
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_PUTS;
|
|
|
|
|
strcpy(buffer+1, str);
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sc_exit()
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_EXIT;
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
kol_buffer_close(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sc_gets(char *str)
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_GETS;
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
strcpy(str, buffer+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char sc_getc()
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_GETC;
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
return *(buffer+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sc_putc(char c)
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_PUTC;
|
|
|
|
|
*(buffer+1) = c;
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sc_cls()
|
|
|
|
|
{
|
|
|
|
|
*buffer = SC_CLS;
|
|
|
|
|
while (*buffer) kol_sleep(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void kol_main()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char string[256];
|
|
|
|
|
|
|
|
|
|
sc_init();
|
|
|
|
|
|
|
|
|
|
sc_cls();
|
|
|
|
|
sc_puts("This is a test console application for Shell\n\r");
|
|
|
|
|
sc_puts("Type a string (255 symbols max): ");
|
|
|
|
|
sc_gets(string);
|
|
|
|
|
sc_puts("You typed:\n\r");
|
|
|
|
|
sc_puts(string);
|
|
|
|
|
sc_puts("Press any key: ");
|
|
|
|
|
string[0] = sc_getc();
|
|
|
|
|
sc_puts("\n\rYou pressed: ");
|
|
|
|
|
sc_putc(string[0]);
|
|
|
|
|
|
|
|
|
|
sc_exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|