This source file includes following definitions.
- pmix_mca_base_parse_paramfile
- pmix_mca_base_internal_env_store
- save_value
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <src/include/pmix_config.h>
24
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "src/class/pmix_list.h"
29 #include "src/mca/mca.h"
30 #include "src/mca/base/base.h"
31 #include "src/mca/base/pmix_mca_base_vari.h"
32 #include "src/util/keyval_parse.h"
33
34 static void save_value(const char *name, const char *value);
35
36 static char * file_being_read;
37 static pmix_list_t * _param_list;
38
39 int pmix_mca_base_parse_paramfile(const char *paramfile, pmix_list_t *list)
40 {
41 file_being_read = (char*)paramfile;
42 _param_list = list;
43
44 return pmix_util_keyval_parse(paramfile, save_value);
45 }
46
47 int pmix_mca_base_internal_env_store(void)
48 {
49 return pmix_util_keyval_save_internal_envars(save_value);
50 }
51
52 static void save_value(const char *name, const char *value)
53 {
54 pmix_mca_base_var_file_value_t *fv;
55 bool found = false;
56
57
58
59
60
61 PMIX_LIST_FOREACH(fv, _param_list, pmix_mca_base_var_file_value_t) {
62 if (0 == strcmp(name, fv->mbvfv_var)) {
63 if (NULL != fv->mbvfv_value) {
64 free (fv->mbvfv_value);
65 }
66 found = true;
67 break;
68 }
69 }
70
71 if (!found) {
72
73 fv = PMIX_NEW(pmix_mca_base_var_file_value_t);
74 if (NULL == fv) {
75 return;
76 }
77
78 fv->mbvfv_var = strdup(name);
79 pmix_list_append(_param_list, &fv->super);
80 }
81
82 fv->mbvfv_value = value ? strdup(value) : NULL;
83 fv->mbvfv_file = file_being_read;
84 fv->mbvfv_lineno = pmix_util_keyval_parse_lineno;
85 }