libk  Diff

Differences From Artifact [a5bf4923b7]:

To Artifact [7899b05286]:


     1      1   #include <k/core.h>
            2  +#include <k/type.h>
     2      3   extern stat entry(kenv);
     3      4   
     4      5   unsigned long long
     5      6   _boot(unsigned int argc, /* argument count */
     6      7   		char** argv, /* arguments */
     7      8   		char** envp /* environment */ ) {
            9  +
           10  +	envp ++; /* envp seems to point at a leading null;
           11  +				this is probably a sign of breakage but
           12  +				i don't know what else to do about it for
           13  +				the moment. */
           14  +
           15  +	char** ep;
           16  +	/* advance ep until it points at the last element */
           17  +	for (ep = envp; *ep != 0; ++ep);
           18  +
           19  +	/* allocate space for each environment variable */
           20  +	kvar variables [ep - envp];
           21  +
           22  +	for (char** v = envp; *v != 0; ++v) {
           23  +		kvar* var = variables + (v - envp);
           24  +		var -> name.ptr = *v;
           25  +		char* i = *v;
           26  +		for(;*i != '=';++i);
           27  +		var -> name.size = i - *v;
           28  +		var -> val.ptr = i + 1;
           29  +		for(;*i != 0;++i);
           30  +
           31  +		/* there is probably a better way to do this; my
           32  +		 * brain is too foggy to figure one out tho */
           33  +		var -> val.size = (i - *v) - var -> name.size;
           34  +	}
           35  +
     8     36   	kenv e = { 
     9     37   		/* TODO: determine terminal class and set term vs ansi correctly! */
    10     38   		{ {kiostream_term, 0}, {kiostream_term, 1} }, // chan std
    11     39   		{ {kiostream_closed},  {kiostream_term, 2} }, // chan err
    12         -		argc, argv, 
    13         -		null // needs parsing
           40  +		argc, argv, ep - envp, variables
    14     41   	};
    15     42   	return entry(e);
    16     43   }
    17         -