23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_OTHER 37 case YAML_MEMORY_ERROR:
38 fprintf(stderr,
"Memory error: Not enough memory for parsing\n");
40 case YAML_READER_ERROR:
41 if (
parser->problem_value != -1)
42 fprintf(stderr,
"Reader error: %s: #%X at %lu\n",
46 fprintf(stderr,
"Reader error: %s at %lu\n",
49 case YAML_SCANNER_ERROR:
51 fprintf(stderr,
"Scanner error: %s at line %lu, column %lu" 52 " %s at line %lu, column %lu\n",
55 parser->problem_mark.line+1,
56 parser->problem_mark.column+1);
58 fprintf(stderr,
"Scanner error: %s at line %lu, column %lu\n",
60 parser->problem_mark.column+1);
62 case YAML_PARSER_ERROR:
64 fprintf(stderr,
"Parser error: %s at line %lu, column %lu" 65 " %s at line %lu, column %lu\n",
68 parser->problem_mark.line+1,
69 parser->problem_mark.column+1);
71 fprintf(stderr,
"Parser error: %s at line %lu, column %lu\n",
73 parser->problem_mark.column+1);
75 case YAML_COMPOSER_ERROR:
76 case YAML_WRITER_ERROR:
77 case YAML_EMITTER_ERROR:
97 yaml_node_t *root_node;
99 M0_ENTRY(
"file_path=`%s'", file_path);
105 perror(
"Failed to open file ");
106 printf(
"%s, errno = %d\n", file_path, errno);
112 fprintf(stderr,
"Failed to initialize parser!\n");
125 fprintf(stderr,
"yaml parser load failed!!\n");
130 if (root_node ==
NULL) {
134 fprintf(stderr,
"document get root node failed\n");
144 return M0_RC(-EINVAL);
159 unsigned char *data_value;
162 for ( ;
node < doc->nodes.top;
node++) {
163 if (
node->type == YAML_SCALAR_NODE) {
164 data_value =
node->data.scalar.value;
189 #undef M0_TRACE_SUBSYSTEM
yaml_document_t cyi_document
static struct net_test_cmd_node * node
M0_INTERNAL int m0_cons_yaml_init(const char *file_path)
Inititalizes parser by opening given file. and also checks for error by getting root node...
static yaml_node_t * search_node(const char *name)
static struct m0_cons_yaml_info yaml_info
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_cons_yaml_fini(void)
Deletes the parser and closes the YAML file.
yaml_node_t * cyi_current
M0_INTERNAL int m0_cons_yaml_set_value(const char *name, void *data)
Search for specified string and get the respctive value form YAML file. (like "name : console") ...
Keeps info for YAML parser.
M0_INTERNAL void * m0_cons_yaml_get_value(const char *name)
Search for specified string and set the respctive value form YAML file. (like "name : console") ...
M0_INTERNAL bool yaml_support
static void yaml_parser_error_detect(const yaml_parser_t *parser)
#define M0_IMPOSSIBLE(fmt,...)