110 lines
1.8 KiB
C
110 lines
1.8 KiB
C
|
|
|||
|
#include "system/kolibri.h"
|
|||
|
#include "system/string.h"
|
|||
|
|
|||
|
#include "program_console.h"
|
|||
|
|
|||
|
char *buffer; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><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><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
char name[32]; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
int sc_init() // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
char *buf1k;
|
|||
|
unsigned PID;
|
|||
|
int result;
|
|||
|
|
|||
|
|
|||
|
buf1k = malloc(1024);
|
|||
|
if (NULL == buf1k)
|
|||
|
return -1;
|
|||
|
|
|||
|
kol_process_info(-1, buf1k); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (-1) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
PID = *(buf1k+30);
|
|||
|
free(buf1k);
|
|||
|
|
|||
|
_itoa(PID, name); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 42 -> 0042 (<28>.<2E>. <20><> 9999)
|
|||
|
strcat(name, "-SHELL");
|
|||
|
|
|||
|
*buffer = NULL;
|
|||
|
result = kol_buffer_open(name, SHM_OPEN_ALWAYS | SHM_WRITE, 1024*16, &buffer); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (16 <20><><EFBFBD>)
|
|||
|
|
|||
|
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();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|