Subversion Repositories Kolibri OS

Rev

Rev 8632 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8632 Rev 8635
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include "shell.h"
4
#include "shell.h"
-
 
5
#include 
5
 
6
 
6
char __shell_shm_name[32]; 
7
char __shell_shm_name[32]; 
7
char*__shell_shm=NULL;
8
char*__shell_shm=NULL;
8
int __shell_is_init=0;
9
int __shell_is_init=0;
9
 
10
 
10
int __shell_shm_init()
11
int __shell_shm_init()
11
{
12
{
12
    __shell_is_init=1;
13
    __shell_is_init=1;
13
    ksys_proc_table_t *proc_info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
14
    ksys_proc_table_t *proc_info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
14
    if(proc_info == NULL){
15
    if(proc_info == NULL){
15
        return -1;
16
        return -1;
16
    }
17
    }
17
    unsigned PID;
18
    unsigned PID;
18
 
19
 
19
    _ksys_process_info(proc_info, -1); 
20
    _ksys_process_info(proc_info, -1); 
20
    PID = proc_info->pid;
21
    PID = proc_info->pid;
21
    free(proc_info);
22
    free(proc_info);
22
 
23
 
23
    itoa(PID, __shell_shm_name);
24
    itoa(PID, __shell_shm_name);
24
    strcat(__shell_shm_name, "-SHELL");
25
    strcat(__shell_shm_name, "-SHELL");
25
    return _ksys_shm_open(__shell_shm_name,  KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm);
26
    return _ksys_shm_open(__shell_shm_name,  KSYS_SHM_OPEN_ALWAYS | KSYS_SHM_WRITE, SHELL_SHM_MAX, &__shell_shm);
26
}
27
}
27
 
28
 
28
int __shell_init()
29
void __shell_init()
29
{
30
{
30
    if(__shell_is_init){
-
 
31
        return 0;
-
 
32
    }
31
    if(!__shell_is_init){
33
    if(__shell_shm_init()){
32
        if(__shell_shm_init()){
-
 
33
        debug_printf("SHELL problems detected!\n");
-
 
34
        _ksys_exit();
-
 
35
        }
-
 
36
 
-
 
37
        if(!shell_ping()){
34
        debug_printf("Shell problems detected!\n");
38
        debug_printf("No SHELL found!\n");
-
 
39
        _ksys_exit();
35
        return -1;
40
        }
36
    }
-
 
37
    return 0;
41
    }
38
}
42
}