blob: f992a788631a1a66ff5d73eeeeb3dab9ce621ada [file] [log] [blame]
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001/**
2 * @file libyang.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskob4750962022-10-06 15:33:35 +02004 * @author Michal Vasko <mvasko@cesnet.cz>
Radek Krejci5aeea3a2018-09-05 13:29:36 +02005 * @brief The main libyang public header.
6 *
Michal Vaskob4750962022-10-06 15:33:35 +02007 * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
Radek Krejci5aeea3a2018-09-05 13:29:36 +02008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef LY_LIBYANG_H_
17#define LY_LIBYANG_H_
18
Radek Krejci0af5f5d2018-09-07 15:00:30 +020019#include <stdint.h>
20
Radek Krejci5aeea3a2018-09-05 13:29:36 +020021#ifdef __cplusplus
22extern "C" {
23#endif
24
Radek Krejcica376bd2020-06-11 16:04:06 +020025#include "context.h"
26#include "dict.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020027#include "in.h"
Radek Krejci47fab892020-11-05 17:02:41 +010028#include "log.h"
Michal Vasko5c00c072022-11-08 12:22:19 +010029#include "metadata.h"
Radek Krejci47fab892020-11-05 17:02:41 +010030#include "out.h"
Radek Krejci7931b192020-06-25 17:05:03 +020031#include "parser_data.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020032#include "parser_schema.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020033#include "printer_data.h"
34#include "printer_schema.h"
Radek Krejci6caa6ab2018-10-24 10:04:48 +020035#include "set.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020036#include "tree.h"
37#include "tree_data.h"
Radek Krejci6caa6ab2018-10-24 10:04:48 +020038#include "tree_schema.h"
39
Radek Krejci47fab892020-11-05 17:02:41 +010040/*
41 * The following headers are supposed to be included explicitly:
Michal Vaskoae130f52023-04-20 14:25:16 +020042 * - hash_table.h
Michal Vaskob4750962022-10-06 15:33:35 +020043 * - metadata.h
Radek Krejci47fab892020-11-05 17:02:41 +010044 * - plugins_types.h
45 * - plugins_exts.h
46 */
47
Radek Krejci5aeea3a2018-09-05 13:29:36 +020048/**
Radek Krejcie53a8dc2018-10-17 12:52:40 +020049 * @mainpage About
50 *
51 * libyang is a library implementing processing of the YANG schemas and data modeled by the YANG language. The
52 * library is implemented in C for GNU/Linux and provides C API.
53 *
54 * @section about-features Main Features
55 *
Radek Krejci8678fa42020-08-18 16:07:28 +020056 * - [Parsing (and validating) schemas](@ref howtoSchema) in YANG format.
57 * - [Parsing (and validating) schemas](@ref howtoSchema) in YIN format.
58 * - [Parsing, validating and printing instance data](@ref howtoData) in XML format.
59 * - [Parsing, validating and printing instance data](@ref howtoData) in JSON format
Radek Krejcie53a8dc2018-10-17 12:52:40 +020060 * ([RFC 7951](https://tools.ietf.org/html/rfc7951)).
Radek Krejci8678fa42020-08-18 16:07:28 +020061 * - [Manipulation with the instance data](@ref howtoDataManipulation).
62 * - Support for [default values in the instance data](@ref howtoDataWD) ([RFC 6243](https://tools.ietf.org/html/rfc6243)).
63 * - Support for [YANG extensions and user types](@ref howtoPlugins).
Radek Krejci75104122021-04-01 15:37:45 +020064 * - Support for [YANG Metadata](@ref howtoDataMetadata) ([RFC 7952](https://tools.ietf.org/html/rfc6243)).
Michal Vasko1fd27412022-02-11 10:04:50 +010065 * - Support for [YANG Schema Mount](@ref howtoDataMountpoint) ([RFC 8528](https://tools.ietf.org/html/rfc8528)).
Radek Krejcie53a8dc2018-10-17 12:52:40 +020066 *
67 * The current implementation covers YANG 1.0 ([RFC 6020](https://tools.ietf.org/html/rfc6020)) as well as
68 * YANG 1.1 ([RFC 7950](https://tools.ietf.org/html/rfc7950)).
69 *
70 * @section about-license License
71 *
Michal Vasko1fd27412022-02-11 10:04:50 +010072 * Copyright (c) 2015-2022 CESNET, z.s.p.o.
Radek Krejcie53a8dc2018-10-17 12:52:40 +020073 *
74 * (The BSD 3-Clause License)
75 *
76 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
78 * are met:
79 * 1. Redistributions of source code must retain the above copyright
80 * notice, this list of conditions and the following disclaimer.
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in
83 * the documentation and/or other materials provided with the
84 * distribution.
85 * 3. Neither the name of the Company nor the names of its contributors
86 * may be used to endorse or promote products derived from this
87 * software without specific prior written permission.
88 */
89
90/**
Radek Krejci52785a22019-09-11 12:57:26 +020091 * @page howto libyang API Overview
Radek Krejcie53a8dc2018-10-17 12:52:40 +020092 *
Radek Krejci8678fa42020-08-18 16:07:28 +020093 * @section howtoGeneral General notes
94 *
95 * libyang is primarily intended for handling data modeled by YANG modeling language, so the library is supposed to be optimized
96 * for this purpose. However, as a side effect, the library has to be able precisely process YANG modules. Thus, it is usable by
97 * YANG module authors to validate their modules and schemas in the development process.
98 *
99 * - @subpage howtoStructures
100 * - @subpage howtoErrors
101 * - @subpage howtoLogger
102 * - @subpage howtoThreads
103 * - @subpage howtoContext
Michal Vaskoafac7822020-10-20 14:22:26 +0200104 * - @subpage howtoInput
105 * - @subpage howtoOutput
Radek Krejci8678fa42020-08-18 16:07:28 +0200106 * - @subpage howtoSchema
107 * - @subpage howtoData
108 * - @subpage howtoXPath
109 * - @subpage howtoPlugins
110 */
111
112/**
113 * @page howtoStructures Data Structures
114 *
115 * @section sizedarrays Sized Arrays
116 *
117 * The structure starts with 32bit number storing size of the array - the number of the items inside. The size is part of the
118 * array to have it allocated together with the array itself only when it is needed. However, the pointers to the array always
119 * points after the 32b number, so items can be accessed directly as for standard C arrays. Because of a known size (available
120 * via ::LY_ARRAY_COUNT macro), it is not terminated by any special byte (sequence), so there is also no limitation for specific
121 * content of the stored records (e.g. that first byte must not be NULL).
122 *
123 * The sized arrays must be carefully freed (which should be done anyway only internally), since pointers to the sized arrays used
124 * in libyang structures, does not point to the beginning of the allocated space.
125 *
126 * - ::LY_ARRAY_COUNT
127 * - ::LY_ARRAY_FOR
128 *
129 * @section struct_lists Lists
130 *
131 * The lists are structures connected via a `next` and `prev` pointers. Iterating over the siblings can be simply done by
132 * ::LY_LIST_FOR macro. Examples of such structures are ::lyd_node or ::lysc_node.
133 *
134 * The `prev` pointer is always filled. In case there is just a single item in the list, the `prev` pointer points to the
135 * item itself. Otherwise, the `prev` pointer of the first item points to the last item of the list. In contrast, the
136 * `next` pointer of the last item in the list is always NULL.
137 */
138
139/**
Michal Vasko5a5e7f82021-04-15 11:11:03 +0200140 * @page howtoThreads Threading Limitations
141 *
142 * @section context Context
143 *
144 * It is safe to read from ::ly_ctx structure concurrently and use its dictionary, which is protected by a lock.
145 * Thread-safe functions include any ones working with data trees (only context dictionary is accessed) and all
146 * the `ly_ctx_get_*()` functions. Generally, they are the functions with `const` context parameter.
147 *
148 * @section data Data Trees
149 *
150 * Data trees are not internally synchronized so the general safe practice of a single writer **or** several concurrent
151 * readers should be followed. Specifically, only the functions with non-const ::lyd_node parameters modify the node(s)
152 * and no concurrent execution of such functions should be allowed on a single data tree or subtrees of one.
153 */
154
155/**
Radek Krejci290a6a52019-09-12 17:13:17 +0200156 * @internal
157 * @page internals Developers' Notes
158 * @tableofcontents
159 *
160 * Following texts describes various internal subsystems and mechanism in libyang which are hidden from external users, but important
161 * for libyang developers. The texts should explain various decisions made and internal processes utilized in libyang.
162 */
163
Radek Krejci0af5f5d2018-09-07 15:00:30 +0200164#ifdef __cplusplus
165}
166#endif
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200167
168#endif /* LY_LIBYANG_H_ */