5 char **env_argv
= NULL
;
7 static char *find_key(const char *params
, const char *key
);
9 /*===========================================================================*
11 *===========================================================================*/
12 void env_setargs(arg_c
, arg_v
)
20 /*===========================================================================*
22 *===========================================================================*/
23 int env_get_param(key
, value
, max_len
)
24 char *key
; /* which key to look up */
25 char *value
; /* where to store value */
26 int max_len
; /* maximum length of value */
29 static char mon_params
[MULTIBOOT_PARAM_BUF_SIZE
]; /* copy parameters here */
38 for (i
= 1; i
<env_argc
; i
++)
40 if (strncmp(env_argv
[i
], key
, keylen
) != 0)
42 if (strlen(env_argv
[i
]) <= keylen
)
44 if (env_argv
[i
][keylen
] != '=')
46 key_value
= env_argv
[i
]+keylen
+1;
47 if (strlen(key_value
)+1 > (size_t) max_len
)
49 strcpy(value
, key_value
);
53 /* Get copy of boot monitor parameters. */
54 m
.m_type
= SYS_GETINFO
;
55 m
.I_REQUEST
= GET_MONPARAMS
;
57 m
.I_VAL_LEN
= sizeof(mon_params
);
58 m
.I_VAL_PTR
= mon_params
;
59 if ((s
=_kernel_call(SYS_GETINFO
, &m
)) != OK
) {
60 printf("SYS_GETINFO: %d (size %u)\n", s
, sizeof(mon_params
));
64 /* We got a copy, now search requested key. */
65 if ((key_value
= find_key(mon_params
, key
)) == NULL
)
68 /* Value found, see if it fits in the client's buffer. Callers assume that
69 * their buffer is unchanged on error, so don't make a partial copy.
71 if ((strlen(key_value
)+1) > (size_t) max_len
) return(E2BIG
);
73 /* Make the actual copy. */
74 strcpy(value
, key_value
);
80 /*==========================================================================*
82 *==========================================================================*/
83 static char *find_key(params
,name
)
87 register const char *namep
;
90 for (envp
= (char *) params
; *envp
!= 0;) {
91 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
93 if (*namep
== '\0' && *envp
== '=')