Sets *more on success: true if another altern follows */
| 214 | |
| 215 | /* Sets *more on success: true if another altern follows */ |
| 216 | static struct rune_altern *rune_altern_decode(const tal_t *ctx, |
| 217 | const char **data, size_t *len, |
| 218 | bool *more) |
| 219 | { |
| 220 | struct rune_altern *alt = tal(ctx, struct rune_altern); |
| 221 | char *value; |
| 222 | size_t strlen; |
| 223 | char c; |
| 224 | |
| 225 | /* Swallow field up to possible conditional */ |
| 226 | strlen = rune_altern_fieldname_len(*data, *len); |
| 227 | alt->fieldname = tal_strndup(alt, *data, strlen); |
| 228 | *data += strlen; |
| 229 | *len -= strlen; |
| 230 | |
| 231 | /* Grab conditional */ |
| 232 | if (!pull_char(data, len, &c) || !rune_condition_is_valid(c)) |
| 233 | return tal_free(alt); |
| 234 | |
| 235 | alt->condition = c; |
| 236 | |
| 237 | /* Assign worst case. */ |
| 238 | value = tal_arr(alt, char, *len + 1); |
| 239 | strlen = 0; |
| 240 | *more = false; |
| 241 | while (*len && pull_char(data, len, &c)) { |
| 242 | if (c == '|') { |
| 243 | *more = true; |
| 244 | break; |
| 245 | } |
| 246 | if (c == '&') |
| 247 | break; |
| 248 | |
| 249 | if (c == '\\' && !pull_char(data, len, &c)) |
| 250 | return tal_free(alt); |
| 251 | value[strlen++] = c; |
| 252 | } |
| 253 | value[strlen] = '\0'; |
| 254 | tal_resize(&value, strlen + 1); |
| 255 | alt->value = value; |
| 256 | return alt; |
| 257 | } |
| 258 | |
| 259 | static struct rune_restr *rune_restr_decode(const tal_t *ctx, |
| 260 | const char **data, size_t *len) |
no test coverage detected