2 #include <minix/config.h>
6 PRIVATE
char **argv
= NULL
;
8 FORWARD
_PROTOTYPE( char *find_key
, (const char *params
, const char *key
));
10 /*===========================================================================*
12 *===========================================================================*/
13 PUBLIC
void env_setargs(arg_c
, arg_v
)
21 /*===========================================================================*
23 *===========================================================================*/
24 PUBLIC
int env_get_param(key
, value
, max_len
)
25 char *key
; /* which key to look up */
26 char *value
; /* where to store value */
27 int max_len
; /* maximum length of value */
30 static char mon_params
[128*sizeof(char *)]; /* copy parameters here */
38 for (i
= 1; i
<argc
; i
++)
40 if (strncmp(argv
[i
], key
, keylen
) != 0)
42 if (strlen(argv
[i
]) <= keylen
)
44 if (argv
[i
][keylen
] != '=')
46 key_value
= argv
[i
]+keylen
+1;
47 if (strlen(key_value
)+1 > EP_BUF_SIZE
)
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
=_taskcall(SYSTASK
, 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, make the actual copy (as far as possible). */
69 strncpy(value
, key_value
, max_len
);
71 /* See if it fits in the client's buffer. */
72 if ((strlen(key_value
)+1) > max_len
) return(E2BIG
);
77 /*==========================================================================*
79 *==========================================================================*/
80 PRIVATE
char *find_key(params
,name
)
84 register const char *namep
;
87 for (envp
= (char *) params
; *envp
!= 0;) {
88 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
90 if (*namep
== '\0' && *envp
== '=')