Subversion Repositories Kolibri OS

Rev

Rev 8629 | 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.  
  6. char __shell_shm_name[32];
  7. char*__shell_shm=NULL;
  8. int __shell_is_init=0;
  9.  
  10. int __shell_shm_init()
  11. {
  12.     __shell_is_init=1;
  13.     ksys_proc_table_t *proc_info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
  14.     if(proc_info == NULL){
  15.         return -1;
  16.     }
  17.     unsigned PID;
  18.  
  19.     _ksys_process_info(proc_info, -1);
  20.     PID = proc_info->pid;
  21.     free(proc_info);
  22.  
  23.     itoa(PID, __shell_shm_name);
  24.     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. }
  27.  
  28. int __shell_init()
  29. {
  30.     if(__shell_is_init){
  31.         return 0;
  32.     }
  33.     if(__shell_shm_init()){
  34.         debug_printf("Shell problems detected!\n");
  35.         return -1;
  36.     }
  37.     return 0;
  38. }