Subversion Repositories Kolibri OS

Rev

Rev 7802 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7802 Rev 8827
Line 1... Line 1...
1
#include "all.h"
1
#include "all.h"
Line 2... Line -...
2
 
-
 
3
/// ===========================================================
-
 
4
 
2
 
5
int dir_check(char dir[])
3
int dir_check(char dir[])
6
/// just checks, if dir[] is really a directory
4
/// just checks, if dir[] is really a directory
7
{
5
{
8
kol_struct70	k70;
6
    kol_struct70	k70;
Line 26... Line 24...
26
	return FALSE;
24
        return FALSE;
27
 
25
 
Line 28... Line 26...
28
}
26
}
Line 29... Line -...
29
 
-
 
30
/// ===========================================================
-
 
31
 
27
 
32
void dir_truncate(char dir[])
28
void dir_truncate(char dir[])
33
{
29
{
34
int i;
30
    int i;
35
i = strlen(dir)-1;
31
    i = strlen(dir)-1;
Line 39... Line 35...
39
		dir[i+1] = 0;
35
            dir[i+1] = 0;
40
		break;
36
            break;
41
		}
37
            }
42
}
38
}
43
/// ===========================================================
39
 
44
 
-
 
Line 45... Line 40...
45
void get_file_dir_loc(char *filepath, char *dir_path)
40
void get_file_dir_loc(char *filepath, char *dir_path)
46
{
41
{
47
	char *res = strrchr(filepath, '/');
42
    char *res = strrchr(filepath, '/');
48
	if (res == 0)
43
    if (res == 0)
Line 54... Line 49...
54
	strncpy(dir_path, filepath, pos);
49
    strncpy(dir_path, filepath, pos);
55
	dir_path[pos] = '\0';
50
    dir_path[pos] = '\0';
56
}
51
}
57
 
52
 
Line 58... Line -...
58
/// ===========================================================
-
 
Line 59... Line 53...
59
 
53
 
60
int file_check(char file[])
54
int file_check(char file[])
61
{
55
{
62
kol_struct70	k70;
56
    kol_struct70	k70;
Line 77... Line 71...
77
else 
71
    else 
78
	return FALSE;
72
        return FALSE;
79
}
73
}
80
 
74
 
Line 81... Line -...
81
/// ===========================================================
-
 
Line 82... Line 75...
82
 
75
 
83
void file_not_found(char file[])
-
 
84
{
-
 
85
#if LANG_ENG
76
void file_not_found(char file[]) {
86
	printf ("  File '%s' not found.\n\r", file);
-
 
87
#elif LANG_RUS
-
 
88
	printf ("  ” ©« '%s' ­¥ ­ ©¤¥­.\n\r", file);
-
 
89
#endif
77
    printf (FILE_NOT_FOUND_ERROR, file);
Line 90... Line -...
90
}
-
 
Line 91... Line -...
91
 
-
 
92
/// ===========================================================
-
 
93
 
78
}
94
int iswhite(char c)
-
 
95
{
-
 
96
return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c));
-
 
Line 97... Line 79...
97
}
79
 
98
 
80
 
99
/// ===========================================================
81
int iswhite(char c) {return ((' ' == c) || ('\t' == c) || (13 == c) || (10 == c)); }
Line 123... Line 105...
123
	else
105
        else
124
		break;
106
            break;
125
}
107
}
126
 
108
 
Line 127... Line -...
127
/// ===========================================================
-
 
Line 128... Line 109...
128
 
109
 
-
 
110
// entry point
129
void kol_main()
111
int main(int argc, char **argv)
-
 
112
{
-
 
113
    int i; for (i = 1; i < argc; i++) {
-
 
114
        strcat(cmdline, argv[i]);
-
 
115
        if (i != argc - 1) {
-
 
116
            strcat(cmdline, " ");
-
 
117
        }
Line 130... Line 118...
130
{
118
    }
131
 
-
 
132
NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
119
 
133
 
120
    NUM_OF_CMD = sizeof(COMMANDS)/sizeof(COMMANDS[0]);
134
strcpy(title, "SHELL ");
121
    strcpy(title, "SHELL ");
Line 135... Line 122...
135
strcat(title, SHELL_VERSION);
122
    strcat(title, SHELL_VERSION);
136
CONSOLE_INIT(title);
123
    con_init_opt(-1, -1, -1, -1, title);
-
 
124
 
137
 
125
    //printf("argc = %d\ncmdline = '%s'\n", argc, cmdline);
138
if (sizeof (kol_struct70) != 25)
126
 
139
{
127
    if (sizeof (kol_struct70) != 25) {
Line 140... Line -...
140
	printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
-
 
141
	kol_exit();
128
        printf("Invalid struct align kol_struct70, need to fix compile options\n\r");
142
}
129
        kol_exit();
143
 
130
    }
144
 
131
 
Line 145... Line 132...
145
//strcpy(cur_dir, PATH);
132
    //strcpy(cur_dir, PATH);
Line 146... Line 133...
146
//dir_truncate(cur_dir);
133
    //dir_truncate(cur_dir);
Line 147... Line 134...
147
getcwd(cur_dir, sizeof cur_dir);
134
    getcwd(cur_dir, sizeof cur_dir);
148
//printf("curdir %s\n", cur_dir);
-
 
149
 
135
    //printf("curdir %s\n", cur_dir);
150
con_set_cursor_height(con_get_font_height()-1);
136
 
151
 
137
    con_set_cursor_height(con_get_font_height()-1);
152
ALIASES = malloc(128*1024);
138
 
153
 
139
    ALIASES = malloc(128*1024);
154
if (!PARAM || PARAM[0] == 0)
140
 
155
{
141
    if (!cmdline || cmdline[0] == 0) {
156
   strcpy(CMD, PATH);
-
 
157
   dir_truncate(CMD);
142
        strcpy(CMD, argv[0]);
158
   strcat(CMD, ".shell");
143
        dir_truncate(CMD);
159
   if ( !file_check(CMD) )
144
        strcat(CMD, ".shell");
160
       strcpy(CMD, "/sys/settings/.shell");
145
        if ( !file_check(CMD) )
161
}
146
            strcpy(CMD, "/sys/settings/.shell");
162
else
147
    }
163
{
148
    else {
Line 164... Line 149...
164
	if (PARAM[0] == '/')
149
        if (cmdline[0] == '/')
Line 165... Line 150...
165
	{
150
        {
166
		strcpy(cur_dir, PARAM);
-
 
167
		*(strrchr(cur_dir, '/')+1)=0;
151
            strcpy(cur_dir, cmdline);
168
	}
152
            *(strrchr(cur_dir, '/')+1)=0;
169
	strcpy(CMD, PARAM);
153
        }
170
}
154
        strcpy(CMD, cmdline);
171
 
155
    }
172
command_execute();
156
 
Line 173... Line 157...
173
 
157
    command_execute();
174
for (;;)
158
 
175
	{
159
    for (;;) {
176
	//printf("\033[32;1m"); 
-
 
177
	printf ("# ");
-