5 char **env_argv
= NULL
;
7 static const char *find_key(const char *params
, const char *key
);
9 /*===========================================================================*
11 *===========================================================================*/
12 void env_setargs(int arg_c
, char *arg_v
[])
18 /*===========================================================================*
20 *===========================================================================*/
21 int env_get_param(const char *key
, char *value
, int max_len
)
24 static char mon_params
[MULTIBOOT_PARAM_BUF_SIZE
]; /* copy parameters here */
25 const char *key_value
;
33 for (i
= 1; i
<env_argc
; i
++)
35 if (strncmp(env_argv
[i
], key
, keylen
) != 0)
37 if (strlen(env_argv
[i
]) <= keylen
)
39 if (env_argv
[i
][keylen
] != '=')
41 key_value
= env_argv
[i
]+keylen
+1;
42 if (strlen(key_value
)+1 > (size_t) max_len
)
44 strcpy(value
, key_value
);
48 /* Get copy of boot monitor parameters. */
49 m
.m_type
= SYS_GETINFO
;
50 m
.m_lsys_krn_sys_getinfo
.request
= GET_MONPARAMS
;
51 m
.m_lsys_krn_sys_getinfo
.endpt
= SELF
;
52 m
.m_lsys_krn_sys_getinfo
.val_len
= sizeof(mon_params
);
53 m
.m_lsys_krn_sys_getinfo
.val_ptr
= (vir_bytes
)mon_params
;
54 if ((s
=_kernel_call(SYS_GETINFO
, &m
)) != OK
) {
55 printf("SYS_GETINFO: %d (size %zu)\n", s
, sizeof(mon_params
));
59 /* We got a copy, now search requested key. */
60 if ((key_value
= find_key(mon_params
, key
)) == NULL
)
63 /* Value found, see if it fits in the client's buffer. Callers assume that
64 * their buffer is unchanged on error, so don't make a partial copy.
66 if ((strlen(key_value
)+1) > (size_t) max_len
) return(E2BIG
);
68 /* Make the actual copy. */
69 strcpy(value
, key_value
);
75 /*==========================================================================*
77 *==========================================================================*/
78 static const char *find_key(const char *params
, const char *name
)
80 const char *namep
, *envp
;
82 for (envp
= params
; *envp
!= 0;) {
83 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
85 if (*namep
== '\0' && *envp
== '=')