Rev 9952 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9952 | Rev 9959 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | void *__idata_start; |
32 | void *__idata_start; |
33 | void *__idata_end; |
33 | void *__idata_end; |
34 | int (*main)(int argc, char **argv, char **envp); |
34 | int (*main)(int argc, char **argv, char **envp); |
35 | }; |
35 | }; |
Line -... | Line 36... | ||
- | 36 | ||
- | 37 | #define ENV_SIZE 16 |
|
- | 38 | /* TODO: Make it dynamic?* */ |
|
- | 39 | static char* __environ[ENV_SIZE] = {0}; |
|
- | 40 | char **environ = &__environ[0]; |
|
36 | 41 | ||
37 | extern void _pei386_runtime_relocator (void); |
42 | extern void _pei386_runtime_relocator (void); |
38 | extern void init_loader(void *libc_image); |
43 | extern void init_loader(void *libc_image); |
39 | extern void init_global_reent(void); |
44 | extern void init_global_reent(void); |
Line 44... | Line 49... | ||
44 | extern int link_app(void); |
49 | extern int link_app(void); |
45 | extern void* get_entry_point(void *raw); |
50 | extern void* get_entry_point(void *raw); |
Line 46... | Line 51... | ||
46 | 51 | ||
Line 47... | Line -... | ||
47 | extern void tls_init(void); |
- | |
48 | 52 | extern void tls_init(void); |
|
49 | char* __appenv; |
53 | |
- | 54 | void init_environ(void) |
|
- | 55 | { |
|
- | 56 | ksys_ufile_t envfile = _ksys_load_file("/sys/settings/system.env"); |
|
Line 50... | Line 57... | ||
50 | int __appenv_size; |
57 | if (!envfile.data || !envfile.size) |
- | 58 | return; |
|
51 | 59 | ||
52 | 60 | char *pch = strtok((char*)envfile.data, " \n\t"); |
|
- | 61 | for (size_t env_pos = 0; pch != NULL && env_pos < ENV_SIZE-1; env_pos++) |
|
- | 62 | { |
|
53 | char * __libc_getenv(const char *name) |
63 | environ[env_pos] = pch; |
Line 54... | Line 64... | ||
54 | { |
64 | pch = strtok(NULL, " \n\t"); |
55 | return NULL; |
65 | } |
56 | } |
66 | } |
Line 208... | Line 218... | ||
208 | argv = alloca((argc+1)*sizeof(char*)); |
218 | argv = alloca((argc+1)*sizeof(char*)); |
209 | argv[0] = header->path; |
219 | argv[0] = header->path; |
210 | } |
220 | } |
211 | argv[argc] = NULL; |
221 | argv[argc] = NULL; |
Line -... | Line 222... | ||
- | 222 | ||
- | 223 | init_environ(); |
|
212 | 224 | ||
213 | retval = header->main(argc, argv, NULL); |
225 | retval = header->main(argc, argv, environ); |
214 | done: |
226 | done: |
215 | if(header->__subsystem__ == 3) |
227 | if(header->__subsystem__ == 3) |
Line 216... | Line 228... | ||
216 | __fini_conio(); |
228 | __fini_conio(); |