yaml_parser_t *parser;
void *buffer;
const char *errmsg;
+ int error;
struct nl_sock *nl;
bool complete;
bool async;
if (keys[i].lkp_data_type != NLA_NUL_STRING &&
keys[i].lkp_data_type != NLA_NESTED) {
- if (!attr)
+ if (!attr && keys[i].lkp_data_type != NLA_FLAG)
continue;
if (!(mapping & LNKF_FLOW)) {
nla_get_string(attr));
break;
+ case NLA_FLAG:
+ len = snprintf(data->buffer, *size, "%s",
+ attr ? "true" : "false");
+ break;
+
case NLA_U16:
len = snprintf(data->buffer, *size, "%hu",
nla_get_u16(attr));
}
#endif /* HAVE_USRSPC_NLMSGERR */
data->errmsg = errstr;
+ data->error = errmsg->error;
data->parser->error = YAML_READER_ERROR;
data->complete = true;
}
if (!buf)
return NULL;
+ errno = buf->error;
return buf->errmsg;
}
enum lnet_nl_key_format fmt,
char *line)
{
- char *sep = strchr(line, ':');
+ char *sep = strstr(line, ": "); /* handle mappings */
int rc = 0;
long num;
+ if (!sep) {
+ char *tmp = strchr(line, ':');
+
+ if (tmp && strlen(tmp) == 1) /* handle simple scalar */
+ sep = tmp;
+ }
if (sep)
*sep++ = '\0';
}
if (fmt & LNKF_FLOW) {
- char *tmp = strchr(*hdr, '{');
+ char *tmp = strchr(*hdr, '{'), *split = NULL;
bool format = false;
if (!tmp) {
/* Flow can be splt across lines by libyaml library. */
if (strchr(line, ',')) {
+ split = line;
*hdr = line;
continue;
}
/* Move to next YAML line */
if (format) {
- strsep(entry, "\n");
+ if (!split)
+ line = *entry;
+ else
+ *entry = NULL;
break;
}
}
goto nla_put_failure;
}
+ if (line && line[0] == '-')
+ *indent = 0;
+
nla_nest_end(msg, list);
} else {
do {
}
} while (strcmp(*entry, ""));
- if (line && line[0] == '-' && !*indent) {
- line[0] = ' ';
- *indent = 2;
+ if (line && line[*indent] == '-') {
+ line[*indent] = ' ';
+ *indent += 2;
goto have_next_line;
}
if (*entry && !strlen(*entry))