kolibri-libc:

- Removed SHELL APIs as they are not standard libc functions. 
- Will be transferred to a separate library.

git-svn-id: svn://kolibrios.org@8643 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-03-17 17:17:48 +00:00
parent 5ec58ab828
commit 075b25b5ff
14 changed files with 2 additions and 193 deletions

View File

@ -0,0 +1,2 @@
-I
source/include/

View File

@ -76,15 +76,6 @@ rename
rewind
rewinddir
seekdir
shell_printf
shell_puts
shell_putc
shell_getc
shell_gets
shell_cls
shell_exit
shell_get_pid
shell_ping
setbuf
setvbuf
sin

View File

@ -1,24 +0,0 @@
#include <shell_api.h>
#include <ksys.h>
#include <stdio.h>
int main(int argc, char**argv)
{
debug_printf("%u\n", shell_get_pid());
char string[256];
shell_cls();
shell_printf("Number of arguments %d\n",argc);
for(int i=0; i<argc; i++){
shell_printf("argv[%d]=%s\n", i, argv[i]);
}
shell_puts("This is a test console application for Shell\n\r");
shell_puts("Type a string (255 symbols max): ");
shell_gets(string);
shell_puts("You typed:\n\r");
shell_puts(string);
shell_puts("Press any key: ");
string[0] = shell_getc();
shell_puts("\n\rYou pressed: ");
shell_putc(string[0]);
shell_exit();
}

View File

@ -1,24 +0,0 @@
#include <ksys.h>
#define SHELL_OK 0
#define SHELL_EXIT 1
#define SHELL_PUTC 2
#define SHELL_PUTS 3
#define SHELL_GETC 4
#define SHELL_GETS 5
#define SHELL_CLS 6
#define SHELL_PID 7
#define SHELL_PING 8
#define SHELL_SHM_MAX 1024*16
extern char __shell_shm_name[32];
extern char *__shell_shm;
extern int __shell_is_init;
extern void __shell_init();
#define SHELL_WAIT() while (*__shell_shm) _ksys_delay(5)

View File

@ -1,8 +0,0 @@
#include "shell.h"
void shell_cls()
{
__shell_init();
*__shell_shm = SHELL_CLS;
SHELL_WAIT();
}

View File

@ -1,11 +0,0 @@
#include "shell.h"
#include "ksys.h"
void shell_exit()
{
if(__shell_is_init){
*__shell_shm = SHELL_EXIT;
SHELL_WAIT();
_ksys_shm_close(__shell_shm_name);
}
}

View File

@ -1,12 +0,0 @@
#include "shell.h"
#include <stdlib.h>
unsigned shell_get_pid()
{
unsigned pid;
__shell_init();
*__shell_shm = SHELL_PID;
SHELL_WAIT();
memcpy(&pid, __shell_shm+1, sizeof(unsigned));
return pid;
}

View File

@ -1,9 +0,0 @@
#include "shell.h"
char shell_getc()
{
__shell_init();
*__shell_shm = SHELL_GETC;
SHELL_WAIT();
return *(__shell_shm+1);
}

View File

@ -1,9 +0,0 @@
#include "shell.h"
void shell_gets(char *str)
{
__shell_init();
*__shell_shm = SHELL_GETS;
SHELL_WAIT();
strcpy(str, __shell_shm+1);
}

View File

@ -1,42 +0,0 @@
#include <ksys.h>
#include <string.h>
#include <stdlib.h>
#include "shell.h"
#include <shell_api.h>
char __shell_shm_name[32];
char*__shell_shm=NULL;
int __shell_is_init=0;
int __shell_shm_init()
{
__shell_is_init=1;
ksys_proc_table_t *proc_info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
if(proc_info == NULL){
return -1;
}
unsigned PID;
_ksys_process_info(proc_info, -1);
PID = proc_info->pid;
free(proc_info);
itoa(PID, __shell_shm_name);
strcat(__shell_shm_name, "-SHELL");
return _ksys_shm_open(__shell_shm_name, KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm);
}
void __shell_init()
{
if(!__shell_is_init){
if(__shell_shm_init()){
debug_printf("SHELL problems detected!\n");
_ksys_exit();
}
if(!shell_ping()){
debug_printf("No SHELL found!\n");
_ksys_exit();
}
}
}

View File

@ -1,14 +0,0 @@
#include "shell.h"
#include <stdlib.h>
#include <ksys.h>
int shell_ping()
{
__shell_init();
*__shell_shm = SHELL_PING;
_ksys_delay(10);
if(*__shell_shm==SHELL_OK){
return 1;
}
return 0;
}

View File

@ -1,12 +0,0 @@
#include "shell.h"
#include <stdio.h>
void shell_printf(const char *format,...)
{
va_list ap;
va_start (ap, format);
*__shell_shm=SHELL_PUTS;
vsnprintf(__shell_shm+1, SHELL_SHM_MAX, format, ap);
va_end(ap);
SHELL_WAIT();
}

View File

@ -1,9 +0,0 @@
#include "shell.h"
void shell_putc(char c)
{
__shell_init();
*__shell_shm = SHELL_PUTC;
*(__shell_shm+1) = c;
SHELL_WAIT();
}

View File

@ -1,10 +0,0 @@
#include "shell.h"
#include "string.h"
void shell_puts(const char *str)
{
__shell_init();
*__shell_shm = SHELL_PUTS;
strcpy(__shell_shm+1, str);
SHELL_WAIT();
}