libk  Diff

Differences From Artifact [a5bf4923b7]:

To Artifact [7899b05286]:


1

2
3
4
5
6
7



























8
9
10
11
12
13
14
15
16
17
#include <k/core.h>

extern stat entry(kenv);

unsigned long long
_boot(unsigned int argc, /* argument count */
		char** argv, /* arguments */
		char** envp /* environment */ ) {



























	kenv e = { 
		/* TODO: determine terminal class and set term vs ansi correctly! */
		{ {kiostream_term, 0}, {kiostream_term, 1} }, // chan std
		{ {kiostream_closed},  {kiostream_term, 2} }, // chan err
		argc, argv, 
		null // needs parsing
	};
	return entry(e);
}
	

>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




|
<



<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

41
42
43

#include <k/core.h>
#include <k/type.h>
extern stat entry(kenv);

unsigned long long
_boot(unsigned int argc, /* argument count */
		char** argv, /* arguments */
		char** envp /* environment */ ) {

	envp ++; /* envp seems to point at a leading null;
				this is probably a sign of breakage but
				i don't know what else to do about it for
				the moment. */

	char** ep;
	/* advance ep until it points at the last element */
	for (ep = envp; *ep != 0; ++ep);

	/* allocate space for each environment variable */
	kvar variables [ep - envp];

	for (char** v = envp; *v != 0; ++v) {
		kvar* var = variables + (v - envp);
		var -> name.ptr = *v;
		char* i = *v;
		for(;*i != '=';++i);
		var -> name.size = i - *v;
		var -> val.ptr = i + 1;
		for(;*i != 0;++i);

		/* there is probably a better way to do this; my
		 * brain is too foggy to figure one out tho */
		var -> val.size = (i - *v) - var -> name.size;
	}

	kenv e = { 
		/* TODO: determine terminal class and set term vs ansi correctly! */
		{ {kiostream_term, 0}, {kiostream_term, 1} }, // chan std
		{ {kiostream_closed},  {kiostream_term, 2} }, // chan err
		argc, argv, ep - envp, variables

	};
	return entry(e);
}