Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file tree_data_helpers.c |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief Parsing and validation helper functions for data trees |
| 5 | * |
| 6 | * Copyright (c) 2015 - 2018 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 14 | |
| 15 | #include <assert.h> |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 16 | #include <stdint.h> |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 17 | #include <stdlib.h> |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 18 | #include <string.h> |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 19 | |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 20 | #include "common.h" |
| 21 | #include "context.h" |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 22 | #include "dict.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 23 | #include "hash_table.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 24 | #include "log.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 25 | #include "lyb.h" |
Radek Krejci | 7931b19 | 2020-06-25 17:05:03 +0200 | [diff] [blame] | 26 | #include "parser_data.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 27 | #include "set.h" |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 28 | #include "tree.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 29 | #include "tree_data.h" |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 30 | #include "tree_data_internal.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 31 | #include "tree_schema.h" |
| 32 | |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 33 | struct lyd_node * |
| 34 | lys_getnext_data(const struct lyd_node *last, const struct lyd_node *sibling, const struct lysc_node **slast, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 35 | const struct lysc_node *parent, const struct lysc_module *module) |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 36 | { |
| 37 | const struct lysc_node *siter = NULL; |
| 38 | struct lyd_node *match = NULL; |
| 39 | |
| 40 | assert(parent || module); |
| 41 | assert(!last || (slast && *slast)); |
| 42 | |
| 43 | if (slast) { |
| 44 | siter = *slast; |
| 45 | } |
| 46 | |
| 47 | if (last && last->next && (last->next->schema == siter)) { |
| 48 | /* return next data instance */ |
| 49 | return last->next; |
| 50 | } |
| 51 | |
| 52 | /* find next schema node data instance */ |
| 53 | while ((siter = lys_getnext(siter, parent, module, 0))) { |
| 54 | if (!lyd_find_sibling_val(sibling, siter, NULL, 0, &match)) { |
| 55 | break; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | if (slast) { |
| 60 | *slast = siter; |
| 61 | } |
| 62 | return match; |
| 63 | } |
| 64 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 65 | struct lyd_node ** |
| 66 | lyd_node_children_p(struct lyd_node *node) |
| 67 | { |
| 68 | assert(node); |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 69 | |
| 70 | if (!node->schema) { |
| 71 | return &((struct lyd_node_opaq *)node)->child; |
| 72 | } else { |
| 73 | switch (node->schema->nodetype) { |
| 74 | case LYS_CONTAINER: |
| 75 | case LYS_LIST: |
Michal Vasko | 1bf0939 | 2020-03-27 12:38:10 +0100 | [diff] [blame] | 76 | case LYS_RPC: |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 77 | case LYS_ACTION: |
| 78 | case LYS_NOTIF: |
| 79 | return &((struct lyd_node_inner *)node)->child; |
| 80 | default: |
| 81 | return NULL; |
| 82 | } |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |
Radek Krejci | dae0ee8 | 2020-05-06 16:53:24 +0200 | [diff] [blame] | 86 | API struct lyd_node * |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 87 | lyd_parent(const struct lyd_node *node) |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 88 | { |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 89 | if (!node) { |
| 90 | return NULL; |
| 91 | } |
| 92 | |
| 93 | return (struct lyd_node *)(node)->parent; |
| 94 | } |
| 95 | |
| 96 | API struct lyd_node * |
| 97 | lyd_child(const struct lyd_node *node) |
| 98 | { |
| 99 | struct lyd_node **children; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 100 | |
| 101 | if (!node) { |
| 102 | return NULL; |
| 103 | } |
| 104 | |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 105 | if (!node->schema) { |
| 106 | /* opaq node */ |
| 107 | return ((struct lyd_node_opaq *)(node))->child; |
| 108 | } |
| 109 | |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 110 | children = lyd_node_children_p((struct lyd_node *)node); |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 111 | if (children) { |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 112 | return *children; |
| 113 | } else { |
| 114 | return NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | API struct lyd_node * |
| 119 | lyd_child_no_keys(const struct lyd_node *node) |
| 120 | { |
| 121 | struct lyd_node **children; |
| 122 | |
| 123 | if (!node) { |
| 124 | return NULL; |
| 125 | } |
| 126 | |
| 127 | if (!node->schema) { |
| 128 | /* opaq node */ |
| 129 | return ((struct lyd_node_opaq *)(node))->child; |
| 130 | } |
| 131 | |
| 132 | children = lyd_node_children_p((struct lyd_node *)node); |
| 133 | if (children) { |
| 134 | struct lyd_node *child = *children; |
| 135 | while (child && child->schema && (child->schema->flags & LYS_KEY)) { |
| 136 | child = child->next; |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 137 | } |
| 138 | return child; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 139 | } else { |
| 140 | return NULL; |
| 141 | } |
| 142 | } |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 143 | |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 144 | API const struct lys_module * |
| 145 | lyd_owner_module(const struct lyd_node *node) |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 146 | { |
| 147 | const struct lysc_node *schema; |
| 148 | |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 149 | if (!node || !node->schema) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 150 | return NULL; |
| 151 | } |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 152 | |
Radek Krejci | 1e008d2 | 2020-08-17 11:37:37 +0200 | [diff] [blame] | 153 | for (schema = node->schema; schema->parent; schema = schema->parent) {} |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 154 | return schema->module; |
| 155 | } |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 156 | |
| 157 | const struct lys_module * |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 158 | lyd_mod_next_module(struct lyd_node *tree, const struct lys_module *module, const struct ly_ctx *ctx, uint32_t *i, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 159 | struct lyd_node **first) |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 160 | { |
| 161 | struct lyd_node *iter; |
| 162 | const struct lys_module *mod; |
| 163 | |
| 164 | /* get the next module */ |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 165 | if (module) { |
| 166 | if (*i) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 167 | mod = NULL; |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 168 | } else { |
| 169 | mod = module; |
| 170 | ++(*i); |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 171 | } |
| 172 | } else { |
| 173 | do { |
| 174 | mod = ly_ctx_get_module_iter(ctx, i); |
| 175 | } while (mod && !mod->implemented); |
| 176 | } |
| 177 | |
| 178 | /* find its data */ |
| 179 | *first = NULL; |
| 180 | if (mod) { |
| 181 | LY_LIST_FOR(tree, iter) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 182 | if (lyd_owner_module(iter) == mod) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 183 | *first = iter; |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | return mod; |
| 190 | } |
| 191 | |
| 192 | const struct lys_module * |
| 193 | lyd_data_next_module(struct lyd_node **next, struct lyd_node **first) |
| 194 | { |
| 195 | const struct lys_module *mod; |
| 196 | |
| 197 | if (!*next) { |
| 198 | /* all data traversed */ |
| 199 | *first = NULL; |
| 200 | return NULL; |
| 201 | } |
| 202 | |
| 203 | *first = *next; |
| 204 | |
| 205 | /* prepare next */ |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 206 | mod = lyd_owner_module(*next); |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 207 | LY_LIST_FOR(*next, *next) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 208 | if (lyd_owner_module(*next) != mod) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 209 | break; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return mod; |
| 214 | } |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 215 | |
| 216 | LY_ERR |
| 217 | lyd_parse_check_keys(struct lyd_node *node) |
| 218 | { |
| 219 | const struct lysc_node *skey = NULL; |
| 220 | const struct lyd_node *key; |
| 221 | |
| 222 | assert(node->schema->nodetype == LYS_LIST); |
| 223 | |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 224 | key = lyd_child(node); |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 225 | while ((skey = lys_getnext(skey, node->schema, NULL, 0)) && (skey->flags & LYS_KEY)) { |
| 226 | if (!key || (key->schema != skey)) { |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 227 | LOGVAL(LYD_CTX(node), LY_VLOG_LYD, node, LY_VCODE_NOKEY, skey->name); |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 228 | return LY_EVALID; |
| 229 | } |
| 230 | |
| 231 | key = key->next; |
| 232 | } |
| 233 | |
| 234 | return LY_SUCCESS; |
| 235 | } |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 236 | |
| 237 | void |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 238 | lyd_parse_set_data_flags(struct lyd_node *node, struct ly_set *when_check, struct lyd_meta **meta, uint32_t options) |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 239 | { |
| 240 | struct lyd_meta *meta2, *prev_meta = NULL; |
| 241 | |
| 242 | if (!(node->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && node->schema->when) { |
Michal Vasko | 0f3377d | 2020-11-09 20:56:11 +0100 | [diff] [blame] | 243 | if (!(options & LYD_PARSE_ONLY)) { |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 244 | /* remember we need to evaluate this node's when */ |
Radek Krejci | 3d92e44 | 2020-10-12 12:48:13 +0200 | [diff] [blame] | 245 | LY_CHECK_RET(ly_set_add(when_check, node, 1, NULL), ); |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 249 | LY_LIST_FOR(*meta, meta2) { |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 250 | if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") && |
| 251 | meta2->value.boolean) { |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 252 | /* node is default according to the metadata */ |
| 253 | node->flags |= LYD_DEFAULT; |
| 254 | |
| 255 | /* delete the metadata */ |
| 256 | if (prev_meta) { |
| 257 | prev_meta->next = meta2->next; |
| 258 | } else { |
| 259 | *meta = (*meta)->next; |
| 260 | } |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 261 | lyd_free_meta_single(meta2); |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 262 | break; |
| 263 | } |
| 264 | |
| 265 | prev_meta = meta2; |
| 266 | } |
| 267 | } |
| 268 | |
Michal Vasko | c000427 | 2020-08-06 08:32:34 +0200 | [diff] [blame] | 269 | API LY_ERR |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 270 | lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type) |
| 271 | { |
| 272 | struct lyd_node_any *t; |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 273 | |
| 274 | assert(trg->schema->nodetype & LYS_ANYDATA); |
| 275 | |
| 276 | t = (struct lyd_node_any *)trg; |
| 277 | |
| 278 | /* free trg */ |
| 279 | switch (t->value_type) { |
| 280 | case LYD_ANYDATA_DATATREE: |
| 281 | lyd_free_all(t->value.tree); |
| 282 | break; |
| 283 | case LYD_ANYDATA_STRING: |
| 284 | case LYD_ANYDATA_XML: |
| 285 | case LYD_ANYDATA_JSON: |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 286 | FREE_STRING(LYD_CTX(trg), t->value.str); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 287 | break; |
| 288 | case LYD_ANYDATA_LYB: |
| 289 | free(t->value.mem); |
| 290 | break; |
| 291 | } |
| 292 | t->value.str = NULL; |
| 293 | |
| 294 | if (!value) { |
| 295 | /* only free value in this case */ |
| 296 | return LY_SUCCESS; |
| 297 | } |
| 298 | |
| 299 | /* copy src */ |
| 300 | t->value_type = value_type; |
| 301 | switch (value_type) { |
| 302 | case LYD_ANYDATA_DATATREE: |
| 303 | if (value->tree) { |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 304 | LY_CHECK_RET(lyd_dup_siblings(value->tree, NULL, LYD_DUP_RECURSIVE, &t->value.tree)); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 305 | } |
| 306 | break; |
| 307 | case LYD_ANYDATA_STRING: |
| 308 | case LYD_ANYDATA_XML: |
| 309 | case LYD_ANYDATA_JSON: |
| 310 | if (value->str) { |
Radek Krejci | 011e4aa | 2020-09-04 15:22:31 +0200 | [diff] [blame] | 311 | LY_CHECK_RET(lydict_insert(LYD_CTX(trg), value->str, 0, &t->value.str)); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 312 | } |
| 313 | break; |
| 314 | case LYD_ANYDATA_LYB: |
| 315 | if (value->mem) { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 316 | int len = lyd_lyb_data_length(value->mem); |
Radek Krejci | 82fa8d4 | 2020-07-11 22:00:59 +0200 | [diff] [blame] | 317 | LY_CHECK_RET(len == -1, LY_EINVAL); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 318 | t->value.mem = malloc(len); |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 319 | LY_CHECK_ERR_RET(!t->value.mem, LOGMEM(LYD_CTX(trg)), LY_EMEM); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 320 | memcpy(t->value.mem, value->mem, len); |
| 321 | } |
| 322 | break; |
| 323 | } |
| 324 | |
| 325 | return LY_SUCCESS; |
| 326 | } |
| 327 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 328 | LYB_HASH |
| 329 | lyb_hash(struct lysc_node *sibling, uint8_t collision_id) |
| 330 | { |
| 331 | const struct lys_module *mod; |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 332 | uint32_t full_hash; |
| 333 | LYB_HASH hash; |
| 334 | |
| 335 | if ((collision_id < LYS_NODE_HASH_COUNT) && sibling->hash[collision_id]) { |
| 336 | return sibling->hash[collision_id]; |
| 337 | } |
| 338 | |
| 339 | mod = sibling->module; |
| 340 | |
| 341 | full_hash = dict_hash_multi(0, mod->name, strlen(mod->name)); |
| 342 | full_hash = dict_hash_multi(full_hash, sibling->name, strlen(sibling->name)); |
| 343 | if (collision_id) { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 344 | size_t ext_len; |
| 345 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 346 | if (collision_id > strlen(mod->name)) { |
| 347 | /* fine, we will not hash more bytes, just use more bits from the hash than previously */ |
| 348 | ext_len = strlen(mod->name); |
| 349 | } else { |
| 350 | /* use one more byte from the module name than before */ |
| 351 | ext_len = collision_id; |
| 352 | } |
| 353 | full_hash = dict_hash_multi(full_hash, mod->name, ext_len); |
| 354 | } |
| 355 | full_hash = dict_hash_multi(full_hash, NULL, 0); |
| 356 | |
| 357 | /* use the shortened hash */ |
| 358 | hash = full_hash & (LYB_HASH_MASK >> collision_id); |
| 359 | /* add colision identificator */ |
| 360 | hash |= LYB_HASH_COLLISION_ID >> collision_id; |
| 361 | |
| 362 | /* save this hash */ |
| 363 | if (collision_id < LYS_NODE_HASH_COUNT) { |
| 364 | sibling->hash[collision_id] = hash; |
| 365 | } |
| 366 | |
| 367 | return hash; |
| 368 | } |
| 369 | |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 370 | ly_bool |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 371 | lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models) |
| 372 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 373 | LY_ARRAY_COUNT_TYPE u; |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 374 | |
| 375 | LY_ARRAY_FOR(models, u) { |
| 376 | if (sibling->module == models[u]) { |
| 377 | return 1; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return 0; |
| 382 | } |