/usr/include/yuma/ncx/yang.h is in libyuma-dev 2.9-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 | /*
* Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _H_yang
#define _H_yang
/* FILE: yang.h
*********************************************************************
* *
* P U R P O S E *
* *
*********************************************************************
YANG Module parser utilities
*********************************************************************
* *
* C H A N G E H I S T O R Y *
* *
*********************************************************************
date init comment
----------------------------------------------------------------------
15-nov-07 abb Begun; start from yang_parse.c
*/
#include <xmlstring.h>
#ifndef _H_dlq
#include "dlq.h"
#endif
#ifndef _H_ext
#include "ext.h"
#endif
#ifndef _H_grp
#include "grp.h"
#endif
#ifndef _H_ncxtypes
#include "ncxtypes.h"
#endif
#ifndef _H_obj
#include "obj.h"
#endif
#ifndef _H_status
#include "status.h"
#endif
#ifndef _H_tk
#include "tk.h"
#endif
#ifndef _H_typ
#include "typ.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************
* *
* T Y P E S *
* *
*********************************************************************/
/* YANG parser mode entry types */
typedef enum yang_parsetype_t_ {
YANG_PT_NONE,
YANG_PT_TOP, /* called from top level [sub]module */
YANG_PT_INCLUDE, /* called from module include-stmt */
YANG_PT_IMPORT /* called from module import-stmt */
} yang_parsetype_t;
/* YANG statement types for yang_stmt_t order struct */
typedef enum yang_stmttype_t_ {
YANG_ST_NONE,
YANG_ST_TYPEDEF, /* node is typ_template_t */
YANG_ST_GROUPING, /* node is grp_template_t */
YANG_ST_EXTENSION, /* node is ext_template_t */
YANG_ST_OBJECT, /* node is obj_template_t */
YANG_ST_IDENTITY, /* node is ncx_identity_t */
YANG_ST_FEATURE, /* node is ncx_feature_t */
YANG_ST_DEVIATION /* node is ncx_deviation_t */
} yang_stmttype_t;
/* YANG statement node to track top-level statement order for doc output */
typedef struct yang_stmt_t_ {
dlq_hdr_t qhdr;
yang_stmttype_t stmttype;
/* these node pointers are back-pointers and not malloced here */
union s_ {
typ_template_t *typ;
grp_template_t *grp;
ext_template_t *ext;
obj_template_t *obj;
ncx_identity_t *identity;
ncx_feature_t *feature;
obj_deviation_t *deviation;
} s;
} yang_stmt_t;
/* YANG node entry to track if a module has been used already */
typedef struct yang_node_t_ {
dlq_hdr_t qhdr;
const xmlChar *name; /* module name in imp/inc/failed */
const xmlChar *revision; /* revision date in imp/inc/failed */
ncx_module_t *mod; /* back-ptr to module w/ imp/inc */
ncx_module_t *submod; /* submod for allincQ */
xmlChar *failed; /* saved name for failed entries */
xmlChar *failedrev; /* saved revision for failed entries */
status_t res; /* saved result for 'failed' */
ncx_error_t tkerr;
} yang_node_t;
/* YANG import pointer node to track all imports used */
typedef struct yang_import_ptr_t_ {
dlq_hdr_t qhdr;
xmlChar *modname;
xmlChar *modprefix;
xmlChar *revision;
} yang_import_ptr_t;
/* YANG parser control block
*
* top level parse can be for a module or a submodule
*
* The allimpQ is a cache of pointers to all the imports that
* have been processed. This is used by yangdump for
* document processing and error detection.
*
* The impchainQ is really a stack of imports that
* are being processed, used for import loop detection
*
* The allincQ is a cache of all the includes that have been
* processed. Includes can be nested, and are only parsed once,
*
* The incchainQ is really a stack of includes that
* are being processed, used for include loop detection
*
* The failedQ is a list of all the modules that had fatal
* errors, and have already been processed. This is used
* to prevent error messages from imports to be printed more
* than once, and speeds up validation processing
*/
typedef struct yang_pcb_t_ {
struct ncx_module_t_ *top; /* top-level file */
struct ncx_module_t_ *retmod; /* nested [sub]mod being returned */
struct ncx_module_t_ *parentparm; /* parent passed for submodule */
const xmlChar *revision; /* back-ptr to rev to match */
boolean with_submods;
boolean stmtmode; /* save top-level stmt order */
boolean diffmode; /* TRUE = yangdiff old ver */
boolean deviationmode; /* TRUE if keeping deviations only */
boolean searchmode; /* TRUE if just getting ns & version */
boolean parsemode; /* TRUE if full parse but no reg-load */
boolean keepmode; /* TRUE to keep new mod even if loaded */
boolean topfound; /* TRUE if top found, not added */
boolean topadded; /* TRUE if top in registry; F: need free */
boolean savetkc; /* TRUE if tkc should be kept in tkc */
boolean docmode; /* TRUE if saving strings in origtkQ */
dlq_hdr_t allimpQ; /* Q of yang_import_ptr_t */
dlq_hdr_t *savedevQ; /* ptr to Q of ncx_save_deviations_t */
tk_chain_t *tkc; /* live or NULL parse chain */
/* 2 Qs of yang_node_t */
dlq_hdr_t impchainQ; /* cur chain of import used */
dlq_hdr_t failedQ; /* load mod or submod failed */
} yang_pcb_t;
/********************************************************************
* *
* F U N C T I O N S *
* *
*********************************************************************/
/********************************************************************
* FUNCTION yang_consume_semiapp
*
* consume a stmtsep clause
* Consume a semi-colon to end a simple clause, or
* consume a vendor extension
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* appinfoQ == queue to receive any vendor extension found
*
* OUTPUTS:
* *appinfoQ has the extesnion added if any
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_semiapp (tk_chain_t *tkc,
ncx_module_t *mod,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_string
*
* consume 1 string token
* Consume a YANG string token in any of the 3 forms
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* field == address of field to get the string (may be NULL)
*
* OUTPUTS:
* if field not NULL,
* *field is set with a malloced string in NO_ERR
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_string (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **field);
/********************************************************************
* FUNCTION yang_consume_keyword
*
* consume 1 YANG keyword or vendor extension keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* prefix == address of field to get the prefix string (may be NULL)
* field == address of field to get the name string (may be NULL)
*
* OUTPUTS:
* if prefix not NULL,
* *prefix is set with a malloced string in NO_ERR
* if field not NULL,
* *field is set with a malloced string in NO_ERR
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_keyword (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **prefix,
xmlChar **field);
/********************************************************************
* FUNCTION yang_consume_nowsp_string
*
* consume 1 string without any whitespace
* Consume a YANG string token in any of the 3 forms
* Check No whitespace allowed!
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* field == address of field to get the string (may be NULL)
*
* OUTPUTS:
* if field not NULL,
* *field is set with a malloced string in NO_ERR
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_nowsp_string (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **field);
/********************************************************************
* FUNCTION yang_consume_id_string
*
* consume an identifier-str token
* Consume a YANG string token in any of the 3 forms
* Check that it is a valid YANG identifier string
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* field == address of field to get the string (may be NULL)
*
* OUTPUTS:
* if field not NULL:
* *field is set with a malloced string in NO_ERR
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_id_string (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **field);
/********************************************************************
* FUNCTION yang_consume_pid_string
*
* consume an identifier-ref-str token
* Consume a YANG string token in any of the 3 forms
* Check that it is a valid identifier-ref-string
* Get the prefix if any is set
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* prefix == address of prefix string if any is used (may be NULL)
* field == address of field to get the string (may be NULL)
*
* OUTPUTS:
* if field not NULL:
* *field is set with a malloced string in NO_ERR
* current token is advanced
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_pid_string (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **prefix,
xmlChar **field);
/********************************************************************
* FUNCTION yang_consume_error_stmts
*
* consume the range. length. pattern. must error info extensions
* Parse the sub-section as a sub-section for error-app-tag
* and error-message clauses
*
* Current token is the starting left brace for the sub-section
* that is extending a range, length, pattern, or must statement
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* errinfo == pointer to valid ncx_errinfo_t struct
* The struct will be filled in by this fn
* appinfoQ == Q to hold any extensions found
*
* OUTPUTS:
* *errinfo filled in with any clauses found
* *appinfoQ filled in with any extensions found
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_error_stmts (tk_chain_t *tkc,
ncx_module_t *mod,
ncx_errinfo_t *errinfo,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_descr
*
* consume one descriptive string clause
* Parse the description or reference statement
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* str == string to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found
*
* OUTPUTS:
* *str set to the value if str not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_descr (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **str,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_pid
*
* consume one [prefix:]name clause
* Parse the rest of the statement (2 forms):
*
* keyword [prefix:]name;
*
* keyword [prefix:]name { appinfo }
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* prefixstr == prefix string to set (may be NULL)
* str == string to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found
*
* OUTPUTS:
* *str set to the value if str not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_pid (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **prefixstr,
xmlChar **str,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_strclause
*
* consume one normative string clause
* Parse the string-parameter-based statement
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* str == string to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *str set to the value if str not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_strclause (tk_chain_t *tkc,
ncx_module_t *mod,
xmlChar **str,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_status
*
* consume one status clause
* Parse the status statement
*
* Current token is the 'status' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* stat == status object to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *stat set to the value if stat not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_status (tk_chain_t *tkc,
ncx_module_t *mod,
ncx_status_t *status,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_ordered_by
*
* consume one ordered-by clause
* Parse the ordered-by statement
*
* Current token is the 'ordered-by' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* ordsys == ordered-by object to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *ordsys set to the value if not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_ordered_by (tk_chain_t *tkc,
ncx_module_t *mod,
boolean *ordsys,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_max_elements
*
* consume one max-elements clause
* Parse the max-elements statement
*
* Current token is the 'max-elements' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* maxelems == max-elements object to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *maxelems set to the value if not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_max_elements (tk_chain_t *tkc,
ncx_module_t *mod,
uint32 *maxelems,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_must
*
* consume one must-stmt into mustQ
* Parse the must statement
*
* Current token is the 'must' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* mustQ == address of Q of xpath_pcb_t structs to store
* a new malloced xpath_pcb_t
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* must entry malloced and added to mustQ (if NO_ERR)
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_must (tk_chain_t *tkc,
ncx_module_t *mod,
dlq_hdr_t *mustQ,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_when
*
* consume one when-stmt into obj->when
* Parse the when statement
*
* Current token is the 'when' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* obj == obj_template_t of the parent object of this 'when'
* whenflag == address of boolean set-once flag for the when-stmt
* an error will be generated if the value passed
* in is TRUE. Set the initial value to FALSE
* before first call, and do not change it after that
* OUTPUTS:
* obj->when malloced and dilled in
* *whenflag set if not set already
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_when (tk_chain_t *tkc,
ncx_module_t *mod,
obj_template_t *obj,
boolean *whenflag);
/********************************************************************
* FUNCTION yang_consume_iffeature
*
* consume one if-feature-stmt into iffeatureQ
* Parse the if-feature statement
*
* Current token is the 'if-feature' keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* iffeatureQ == Q of ncx_iffeature_t to hold the new if-feature
* appinfoQ == queue to store appinfo (extension usage)
*
* OUTPUTS:
* ncx_iffeature_t malloced and added to iffeatureQ
* maybe ncx_appinfo_t structs added to appinfoQ
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_iffeature (tk_chain_t *tkc,
ncx_module_t *mod,
dlq_hdr_t *iffeatureQ,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_boolean
*
* consume one boolean clause
* Parse the boolean parameter based statement
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* boolval == boolean value to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *str set to the value if str not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_boolean (tk_chain_t *tkc,
ncx_module_t *mod,
boolean *boolval,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_int32
*
* consume one int32 clause
* Parse the int32 based parameter statement
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* num == int32 value to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *num set to the value if num not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_int32 (tk_chain_t *tkc,
ncx_module_t *mod,
int32 *num,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_consume_uint32
*
* consume one uint32 clause
* Parse the uint32 based parameter statement
*
* Current token is the starting keyword
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain
* mod == module in progress
* num == uint32 value to set (may be NULL)
* dupflag == flag to check if entry already found (may be NULL)
* appinfoQ == Q to hold any extensions found (may be NULL)
*
* OUTPUTS:
* *num set to the value if num not NULL
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_consume_uint32 (tk_chain_t *tkc,
ncx_module_t *mod,
uint32 *num,
boolean *dupflag,
dlq_hdr_t *appinfoQ);
/********************************************************************
* FUNCTION yang_find_imp_typedef
*
* Find the specified imported typedef
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* pcb == parser control block to use
* tkc == token chain
* mod == module in progress
* prefix == prefix value to use
* name == type name to use
* tkerr == error record to use in error messages (may be NULL)
* typ == address of return typ_template_t pointer
*
* OUTPUTS:
* *typ set to the found typ_template_t, if NO_ERR
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_find_imp_typedef (yang_pcb_t *pcb,
tk_chain_t *tkc,
ncx_module_t *mod,
const xmlChar *prefix,
const xmlChar *name,
ncx_error_t *tkerr,
typ_template_t **typ);
/********************************************************************
* FUNCTION yang_find_imp_grouping
*
* Find the specified imported grouping
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* pcb == parser control block to use
* tkc == token chain
* mod == module in progress
* prefix == prefix value to use
* name == grouping name to use
* tkerr == error record to use in error messages (may be NULL)
* grp == address of return grp_template_t pointer
*
* OUTPUTS:
* *grp set to the found grp_template_t, if NO_ERR
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_find_imp_grouping (yang_pcb_t *pcb,
tk_chain_t *tkc,
ncx_module_t *mod,
const xmlChar *prefix,
const xmlChar *name,
ncx_error_t *tkerr,
grp_template_t **grp);
/********************************************************************
* FUNCTION yang_find_imp_extension
*
* Find the specified imported extension
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* pcb == parser control block to use
* tkc == token chain
* mod == module in progress
* prefix == prefix value to use
* name == extension name to use
* tkerr == error struct to use in error messages (may be NULL)
* ext == address of return ext_template_t pointer
*
* OUTPUTS:
* *ext set to the found ext_template_t, if NO_ERR
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_find_imp_extension (yang_pcb_t *pcb,
tk_chain_t *tkc,
ncx_module_t *mod,
const xmlChar *prefix,
const xmlChar *name,
ncx_error_t *tkerr,
ext_template_t **ext);
/********************************************************************
* FUNCTION yang_find_imp_feature
*
* Find the specified imported feature
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* pcb == parser control block to use
* tkc == token chain
* mod == module in progress
* prefix == prefix value to use
* name == feature name to use
* tkerr == error struct to use in error messages (may be NULL)
* feature == address of return ncx_feature_t pointer
*
* OUTPUTS:
* *feature set to the found ncx_feature_t, if NO_ERR
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_find_imp_feature (yang_pcb_t *pcb,
tk_chain_t *tkc,
ncx_module_t *mod,
const xmlChar *prefix,
const xmlChar *name,
ncx_error_t *tkerr,
ncx_feature_t **feature);
/********************************************************************
* FUNCTION yang_find_imp_identity
*
* Find the specified imported identity
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* pcb == parser control block to use
* tkc == token chain
* mod == module in progress
* prefix == prefix value to use
* name == feature name to use
* tkerr == error struct to use in error messages (may be NULL)
* identity == address of return ncx_identity_t pointer
*
* OUTPUTS:
* *identity set to the found ncx_identity_t, if NO_ERR
*
* RETURNS:
* status of the operation
*********************************************************************/
extern status_t
yang_find_imp_identity (yang_pcb_t *pcb,
tk_chain_t *tkc,
ncx_module_t *mod,
const xmlChar *prefix,
const xmlChar *name,
ncx_error_t *tkerr,
ncx_identity_t **identity);
/********************************************************************
* FUNCTION yang_check_obj_used
*
* generate warnings if local typedefs/groupings not used
* Check if the local typedefs and groupings are actually used
* Generate warnings if not used
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain in progress
* mod == module in progress
* typeQ == typedef Q to check
* grpQ == pgrouping Q to check
*
*********************************************************************/
extern void
yang_check_obj_used (tk_chain_t *tkc,
ncx_module_t *mod,
dlq_hdr_t *typeQ,
dlq_hdr_t *grpQ);
/********************************************************************
* FUNCTION yang_check_imports_used
*
* generate warnings if imports not used
* Check if the imports statements are actually used
* Check if the import is newer than the importing module
* Generate warnings if so
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* INPUTS:
* tkc == token chain in progress
* mod == module in progress
*
*********************************************************************/
extern void
yang_check_imports_used (tk_chain_t *tkc,
ncx_module_t *mod);
/********************************************************************
* FUNCTION yang_new_node
*
* Create a new YANG parser node
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_node_t *
yang_new_node (void);
/********************************************************************
* FUNCTION yang_free_node
*
* Delete a YANG parser node
*
* INPUTS:
* node == parser node to delete
*
*********************************************************************/
extern void
yang_free_node (yang_node_t *node);
/********************************************************************
* FUNCTION yang_clean_nodeQ
*
* Delete all the node entries in a YANG parser node Q
*
* INPUTS:
* que == Q of yang_node_t to clean
*
*********************************************************************/
extern void
yang_clean_nodeQ (dlq_hdr_t *que);
/********************************************************************
* FUNCTION yang_find_node
*
* Find a YANG parser node in the specified Q
*
* INPUTS:
* que == Q of yang_node_t to check
* name == module name to find
* revision == module revision date (may be NULL)
*
* RETURNS:
* pointer to found node, NULL if not found
*********************************************************************/
extern yang_node_t *
yang_find_node (const dlq_hdr_t *que,
const xmlChar *name,
const xmlChar *revision);
/********************************************************************
* FUNCTION yang_dump_nodeQ
*
* log_debug output for contents of the specified nodeQ
*
* INPUTS:
* que == Q of yang_node_t to check
* name == Q name (may be NULL)
*
* RETURNS:
* pointer to found node, NULL if not found
*********************************************************************/
extern void
yang_dump_nodeQ (dlq_hdr_t *que,
const char *name);
/********************************************************************
* FUNCTION yang_new_pcb
*
* Create a new YANG parser control block
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_pcb_t *
yang_new_pcb (void);
/********************************************************************
* FUNCTION yang_free_pcb
*
* Delete a YANG parser control block
*
* INPUTS:
* pcb == parser control block to delete
*
*********************************************************************/
extern void
yang_free_pcb (yang_pcb_t *pcb);
/********************************************************************
* FUNCTION yang_new_typ_stmt
*
* Create a new YANG stmt node for a typedef
*
* INPUTS:
* typ == type template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_typ_stmt (typ_template_t *typ);
/********************************************************************
* FUNCTION yang_new_grp_stmt
*
* Create a new YANG stmt node for a grouping
*
* INPUTS:
* grp == grouping template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_grp_stmt (grp_template_t *grp);
/********************************************************************
* FUNCTION yang_new_ext_stmt
*
* Create a new YANG stmt node for an extension
*
* INPUTS:
* ext == extension template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_ext_stmt (ext_template_t *ext);
/********************************************************************
* FUNCTION yang_new_obj_stmt
*
* Create a new YANG stmt node for an object
*
* INPUTS:
* obj == object template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_obj_stmt (obj_template_t *obj);
/********************************************************************
* FUNCTION yang_new_id_stmt
*
* Create a new YANG stmt node for an identity
*
* INPUTS:
* identity == identity template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_id_stmt (ncx_identity_t *identity);
/********************************************************************
* FUNCTION yang_new_feature_stmt
*
* Create a new YANG stmt node for a feature definition
*
* INPUTS:
* feature == feature template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_feature_stmt (ncx_feature_t *feature);
/********************************************************************
* FUNCTION yang_new_deviation_stmt
*
* Create a new YANG stmt node for a deviation definition
*
* INPUTS:
* deviation == deviation template to use for new statement struct
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_stmt_t *
yang_new_deviation_stmt (obj_deviation_t *deviation);
/********************************************************************
* FUNCTION yang_free_stmt
*
* Delete a YANG statement node
*
* INPUTS:
* stmt == yang_stmt_t node to delete
*
*********************************************************************/
extern void
yang_free_stmt (yang_stmt_t *stmt);
/********************************************************************
* FUNCTION yang_clean_stmtQ
*
* Delete a Q of YANG statement node
*
* INPUTS:
* que == Q of yang_stmt_t node to delete
*
*********************************************************************/
extern void
yang_clean_stmtQ (dlq_hdr_t *que);
/********************************************************************
* FUNCTION yang_validate_date_string
*
* Validate a YANG date string for a revision entry
*
* Expected format is:
*
* YYYY-MM-DD
*
* Error messages are printed by this function
*
* INPUTS:
* tkc == token chain in progress
* mod == module in progress
* tkerr == error struct to use (may be NULL to use tkc->cur)
* datestr == string to validate
*
* RETURNS:
* status
*********************************************************************/
extern status_t
yang_validate_date_string (tk_chain_t *tkc,
ncx_module_t *mod,
ncx_error_t *tkerr,
const xmlChar *datestr);
/********************************************************************
* FUNCTION yang_skip_statement
*
* Skip past the current invalid statement, starting at
* an invalid keyword
*
* INPUTS:
* tkc == token chain in progress
* mod == module in progress
*********************************************************************/
extern void
yang_skip_statement (tk_chain_t *tkc,
ncx_module_t *mod);
/********************************************************************
* FUNCTION yang_top_keyword
*
* Check if the string is a top-level YANG keyword
*
* INPUTS:
* keyword == string to check
*
* RETURNS:
* TRUE if a top-level YANG keyword, FALSE otherwise
*********************************************************************/
extern boolean
yang_top_keyword (const xmlChar *keyword);
/********************************************************************
* FUNCTION yang_new_import_ptr
*
* Create a new YANG import pointer node
*
* INPUTS:
* modname = module name to set
* modprefix = module prefix to set
* revision = revision date to set
*
* RETURNS:
* pointer to new and initialized struct, NULL if memory error
*********************************************************************/
extern yang_import_ptr_t *
yang_new_import_ptr (const xmlChar *modname,
const xmlChar *modprefix,
const xmlChar *revision);
/********************************************************************
* FUNCTION yang_free_impptr_ptr
*
* Delete a YANG import pointer node
*
* INPUTS:
* impptr == import pointer node to delete
*
*********************************************************************/
extern void
yang_free_import_ptr (yang_import_ptr_t *impptr);
/********************************************************************
* FUNCTION yang_clean_import_ptrQ
*
* Delete all the node entries in a YANG import pointer node Q
*
* INPUTS:
* que == Q of yang_import_ptr_t to clean
*
*********************************************************************/
extern void
yang_clean_import_ptrQ (dlq_hdr_t *que);
/********************************************************************
* FUNCTION yang_find_import_ptr
*
* Find a YANG import pointer node in the specified Q
*
* INPUTS:
* que == Q of yang_import_ptr_t to check
* name == module name to find
*
* RETURNS:
* pointer to found node, NULL if not found
*********************************************************************/
extern yang_import_ptr_t *
yang_find_import_ptr (dlq_hdr_t *que,
const xmlChar *name);
/********************************************************************
* FUNCTION yang_compare_revision_dates
*
* Compare 2 revision strings, which either may be NULL
*
* INPUTS:
* revstring1 == revision string 1 (may be NULL)
* revstring2 == revision string 2 (may be NULL)
*
* RETURNS:
* -1 if revision 1 < revision 2
* 0 of they are the same
* +1 if revision1 > revision 2
*********************************************************************/
extern int32
yang_compare_revision_dates (const xmlChar *revstring1,
const xmlChar *revstring2);
/********************************************************************
* FUNCTION yang_make_filename
*
* Malloc and construct a YANG filename
*
* INPUTS:
* modname == [sub]module name
* revision == [sub]module revision date (may be NULL)
* isyang == TRUE for YANG extension
* FALSE for YIN extension
*
* RETURNS:
* malloced and filled in string buffer with filename
* NULL if any error
*********************************************************************/
extern xmlChar *
yang_make_filename (const xmlChar *modname,
const xmlChar *revision,
boolean isyang);
/********************************************************************
* FUNCTION yang_copy_filename
*
* Construct a YANG filename into a provided buffer
*
* INPUTS:
* modname == [sub]module name
* revision == [sub]module revision date (may be NULL)
* buffer == buffer to copy filename into
* bufflen == number of bytes available in buffer
* isyang == TRUE for YANG extension
* FALSE for YIN extension
*
* RETURNS:
* malloced and filled in string buffer with filename
* NULL if any error
*********************************************************************/
extern status_t
yang_copy_filename (const xmlChar *modname,
const xmlChar *revision,
xmlChar *buffer,
uint32 bufflen,
boolean isyang);
/********************************************************************
* FUNCTION yang_split_filename
*
* Split a module parameter into its filename components
*
* INPUTS:
* filename == filename string
* modnamelen == address of return modname length
*
* OUTPUTS:
* *modnamelen == module name length
*
* RETURNS:
* TRUE if module@revision form was found
* FALSE if not, and ignore the output because a
* different form of the module parameter was used
*********************************************************************/
extern boolean
yang_split_filename (const xmlChar *filename,
uint32 *modnamelen);
/********************************************************************
* FUNCTION yang_fileext_is_yang
*
* Check if the filespec ends with the .yang extension
*
* INPUTS:
* filename == filename string
*
* RETURNS:
* TRUE if .yang file extension found
* FALSE if not
*********************************************************************/
extern boolean
yang_fileext_is_yang (const xmlChar *filename);
/********************************************************************
* FUNCTION yang_fileext_is_yin
*
* Check if the filespec ends with the .yin extension
*
* INPUTS:
* filename == filename string
*
* RETURNS:
* TRUE if .yin file extension found
* FALSE if not
*********************************************************************/
extern boolean
yang_fileext_is_yin (const xmlChar *filename);
/********************************************************************
* FUNCTION yang_fileext_is_xml
*
* Check if the filespec ends with the .xml extension
*
* INPUTS:
* filename == filename string
*
* RETURNS:
* TRUE if .xml file extension found
* FALSE if not
*********************************************************************/
extern boolean
yang_fileext_is_xml (const xmlChar *filename);
/********************************************************************
* FUNCTION yang_final_memcheck
*
* Check the node malloc and free counts
*********************************************************************/
extern void
yang_final_memcheck (void);
#ifdef __cplusplus
} /* end extern 'C' */
#endif
#endif /* _H_yang */
|