1,8 → 1,6 |
|
#include "all.h" |
|
/// =========================================================== |
|
int dir_check(char dir[]) |
/// just checks, if dir[] is really a directory |
{ |
28,8 → 26,6 |
|
} |
|
/// =========================================================== |
|
void dir_truncate(char dir[]) |
{ |
int i; |
41,7 → 37,6 |
break; |
} |
} |
/// =========================================================== |
|
void get_file_dir_loc(char *filepath, char *dir_path) |
{ |
56,7 → 51,6 |
dir_path[pos] = '\0'; |
} |
|
/// =========================================================== |
|
int file_check(char file[]) |
{ |
79,26 → 73,14 |
return FALSE; |
} |
|
/// =========================================================== |
|
void file_not_found(char file[]) |
{ |
#if LANG_ENG |
printf (" File '%s' not found.\n\r", file); |
#elif LANG_RUS |
printf (" ©« '%s' ¥ ©¤¥.\n\r", file); |
#endif |
void file_not_found(char file[]) { |
printf (FILE_NOT_FOUND_ERROR, file); |
} |
|
/// =========================================================== |
|
int iswhite(char c) |
{ |
return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); |
} |
int iswhite(char c) {return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); } |
|
/// =========================================================== |
|
void trim(char string[]) |
{ |
int i, j; |
125,24 → 107,29 |
break; |
} |
|
/// =========================================================== |
|
void kol_main() |
// entry point |
int main(int argc, char **argv) |
{ |
int i; for (i = 1; i < argc; i++) { |
strcat(cmdline, argv[i]); |
if (i != argc - 1) { |
strcat(cmdline, " "); |
} |
} |
|
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]); |
|
strcpy(title, "SHELL "); |
strcat(title, SHELL_VERSION); |
CONSOLE_INIT(title); |
con_init_opt(-1, -1, -1, -1, title); |
|
if (sizeof (kol_struct70) != 25) |
{ |
//printf("argc = %d\ncmdline = '%s'\n", argc, cmdline); |
|
if (sizeof (kol_struct70) != 25) { |
printf("Invalid struct align kol_struct70, need to fix compile options\n\r"); |
kol_exit(); |
} |
|
|
//strcpy(cur_dir, PATH); |
//dir_truncate(cur_dir); |
getcwd(cur_dir, sizeof cur_dir); |
152,28 → 139,25 |
|
ALIASES = malloc(128*1024); |
|
if (!PARAM || PARAM[0] == 0) |
{ |
strcpy(CMD, PATH); |
if (!cmdline || cmdline[0] == 0) { |
strcpy(CMD, argv[0]); |
dir_truncate(CMD); |
strcat(CMD, ".shell"); |
if ( !file_check(CMD) ) |
strcpy(CMD, "/sys/settings/.shell"); |
} |
else |
else { |
if (cmdline[0] == '/') |
{ |
if (PARAM[0] == '/') |
{ |
strcpy(cur_dir, PARAM); |
strcpy(cur_dir, cmdline); |
*(strrchr(cur_dir, '/')+1)=0; |
} |
strcpy(CMD, PARAM); |
strcpy(CMD, cmdline); |
} |
|
command_execute(); |
|
for (;;) |
{ |
for (;;) { |
//printf("\033[32;1m"); |
printf ("# "); |
//printf("\033[0m"); |
181,8 → 165,6 |
command_execute(); |
} |
|
_exit(0); |
con_exit(0); |
kol_exit(); |
} |
|
/// =========================================================== |