Rev 7802 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
959 | leency | 1 | |
2 | |||
3 | |||
4 | /// just checks, if dir[] is really a directory |
||
6857 | siemargl | 5 | { |
959 | leency | 6 | kol_struct70 k70; |
8827 | rgimad | 7 | int result; |
8 | |||
959 | leency | 9 | |
8827 | rgimad | 10 | k70.p04 = 0; |
11 | //k70.p08 = 0; |
||
12 | k70.p12 = 2; // enough to read . & .. |
||
13 | k70.p16 = (unsigned)malloc(32+k70.p12*560); |
||
14 | k70.p20 = 0; |
||
15 | k70.p21 = dir; |
||
16 | |||
959 | leency | 17 | |
8827 | rgimad | 18 | |
959 | leency | 19 | |
8827 | rgimad | 20 | |
959 | leency | 21 | |
8827 | rgimad | 22 | return TRUE; |
23 | else |
||
24 | return FALSE; |
||
25 | |||
959 | leency | 26 | |
27 | |||
28 | |||
29 | { |
||
30 | int i; |
||
8827 | rgimad | 31 | i = strlen(dir)-1; |
32 | for (;;i--) |
||
33 | if ('/' == dir[i]) |
||
34 | { |
||
35 | dir[i+1] = 0; |
||
36 | break; |
||
37 | } |
||
38 | } |
||
959 | leency | 39 | |
40 | |||
7802 | rgimad | 41 | { |
42 | char *res = strrchr(filepath, '/'); |
||
8827 | rgimad | 43 | if (res == 0) |
44 | { |
||
45 | dir_path = '\0'; |
||
46 | return; |
||
47 | } |
||
48 | size_t pos = res - filepath; |
||
49 | strncpy(dir_path, filepath, pos); |
||
50 | dir_path[pos] = '\0'; |
||
51 | } |
||
7802 | rgimad | 52 | |
53 | |||
959 | leency | 54 | |
55 | { |
||
56 | kol_struct70 k70; |
||
8827 | rgimad | 57 | int result; |
58 | |||
959 | leency | 59 | |
8827 | rgimad | 60 | k70.p04 = 0; |
61 | //k70.p08 = 0; |
||
62 | k70.p12 = 0; |
||
63 | k70.p16 = 0; |
||
64 | k70.p20 = 0; |
||
65 | k70.p21 = file; |
||
66 | |||
959 | leency | 67 | |
8827 | rgimad | 68 | |
959 | leency | 69 | |
8827 | rgimad | 70 | return TRUE; |
71 | else |
||
72 | return FALSE; |
||
73 | } |
||
959 | leency | 74 | |
75 | |||
76 | |||
8827 | rgimad | 77 | printf (FILE_NOT_FOUND_ERROR, file); |
78 | } |
||
2617 | Albom | 79 | |
80 | |||
81 | |||
8827 | rgimad | 82 | |
959 | leency | 83 | |
84 | { |
||
85 | int i, j; |
||
8827 | rgimad | 86 | |
959 | leency | 87 | |
8827 | rgimad | 88 | if ( !iswhite(string[i]) ) |
89 | break; |
||
90 | j = 0; |
||
91 | for (;;i++, j++) |
||
92 | { |
||
93 | string[j] = string[i]; |
||
94 | if ('\0' == string[i] ) |
||
95 | break; |
||
96 | } |
||
97 | |||
959 | leency | 98 | |
8827 | rgimad | 99 | if ('\0' == string[i]) |
100 | break; |
||
101 | i--; |
||
102 | for (;i>0;--i) |
||
103 | if ( iswhite(string[i]) ) |
||
104 | string[i] = '\0'; |
||
105 | else |
||
106 | break; |
||
107 | } |
||
959 | leency | 108 | |
109 | |||
110 | |||
8827 | rgimad | 111 | int main(int argc, char **argv) |
112 | { |
||
959 | leency | 113 | int i; for (i = 1; i < argc; i++) { |
8827 | rgimad | 114 | strcat(cmdline, argv[i]); |
115 | if (i != argc - 1) { |
||
116 | strcat(cmdline, " "); |
||
117 | } |
||
118 | } |
||
119 | |||
959 | leency | 120 | |
8827 | rgimad | 121 | strcpy(title, "SHELL "); |
122 | strcat(title, SHELL_VERSION); |
||
123 | con_init_opt(-1, -1, -1, -1, title); |
||
124 | |||
1647 | Nasarus | 125 | |
8827 | rgimad | 126 | |
959 | leency | 127 | |
8827 | rgimad | 128 | printf("Invalid struct align kol_struct70, need to fix compile options\n\r"); |
129 | kol_exit(); |
||
130 | } |
||
131 | |||
6826 | siemargl | 132 | |
8827 | rgimad | 133 | //dir_truncate(cur_dir); |
134 | getcwd(cur_dir, sizeof cur_dir); |
||
135 | //printf("curdir %s\n", cur_dir); |
||
136 | |||
6826 | siemargl | 137 | |
8827 | rgimad | 138 | |
959 | leency | 139 | |
8827 | rgimad | 140 | |
959 | leency | 141 | |
8827 | rgimad | 142 | strcpy(CMD, argv[0]); |
143 | dir_truncate(CMD); |
||
144 | strcat(CMD, ".shell"); |
||
145 | if ( !file_check(CMD) ) |
||
146 | strcpy(CMD, "/sys/settings/.shell"); |
||
147 | } |
||
148 | else { |
||
149 | if (cmdline[0] == '/') |
||
150 | { |
||
151 | strcpy(cur_dir, cmdline); |
||
152 | *(strrchr(cur_dir, '/')+1)=0; |
||
153 | } |
||
154 | strcpy(CMD, cmdline); |
||
155 | } |
||
156 | |||
1647 | Nasarus | 157 | |
8827 | rgimad | 158 | |
959 | leency | 159 | |
8827 | rgimad | 160 | //printf("\033[32;1m"); |
161 | printf ("# "); |
||
162 | //printf("\033[0m"); |
||
163 | command_get(); |
||
164 | command_execute(); |
||
165 | } |
||
166 | |||
959 | leency | 167 | |
8827 | rgimad | 168 | kol_exit(); |
169 | }> |
||
959 | leency | 170 |