Subversion Repositories Kolibri OS

Rev

Rev 8632 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

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