blob: 6cc4a15d1446abc251e31d790d7b778f6cabef7d [file] [log] [blame]
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001/**
2 * @file libyang.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief The main libyang public header.
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 */
14
15#ifndef LY_LIBYANG_H_
16#define LY_LIBYANG_H_
17
Radek Krejci0af5f5d2018-09-07 15:00:30 +020018#include <stdint.h>
19
Radek Krejci5aeea3a2018-09-05 13:29:36 +020020#ifdef __cplusplus
21extern "C" {
22#endif
23
Radek Krejcica376bd2020-06-11 16:04:06 +020024#include "context.h"
25#include "dict.h"
Radek Krejci6caa6ab2018-10-24 10:04:48 +020026#include "log.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020027#include "in.h"
Radek Krejci7931b192020-06-25 17:05:03 +020028#include "parser_data.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020029#include "parser_schema.h"
30#include "plugins_types.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020031#include "out.h"
Radek Krejcif0e1ba52020-05-22 15:14:35 +020032#include "printer_data.h"
33#include "printer_schema.h"
Radek Krejci6caa6ab2018-10-24 10:04:48 +020034#include "set.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020035#include "tree.h"
36#include "tree_data.h"
Radek Krejci6caa6ab2018-10-24 10:04:48 +020037#include "tree_schema.h"
38
Radek Krejci5aeea3a2018-09-05 13:29:36 +020039/**
Radek Krejcie53a8dc2018-10-17 12:52:40 +020040 * @mainpage About
41 *
42 * libyang is a library implementing processing of the YANG schemas and data modeled by the YANG language. The
43 * library is implemented in C for GNU/Linux and provides C API.
44 *
45 * @section about-features Main Features
46 *
Radek Krejci8678fa42020-08-18 16:07:28 +020047 * - [Parsing (and validating) schemas](@ref howtoSchema) in YANG format.
48 * - [Parsing (and validating) schemas](@ref howtoSchema) in YIN format.
49 * - [Parsing, validating and printing instance data](@ref howtoData) in XML format.
50 * - [Parsing, validating and printing instance data](@ref howtoData) in JSON format
Radek Krejcie53a8dc2018-10-17 12:52:40 +020051 * ([RFC 7951](https://tools.ietf.org/html/rfc7951)).
Radek Krejci8678fa42020-08-18 16:07:28 +020052 * - [Manipulation with the instance data](@ref howtoDataManipulation).
53 * - Support for [default values in the instance data](@ref howtoDataWD) ([RFC 6243](https://tools.ietf.org/html/rfc6243)).
54 * - Support for [YANG extensions and user types](@ref howtoPlugins).
55 * - Support for [YANG Metadata](@ref howtoPluginsExtensionsMetadata) ([RFC 7952](https://tools.ietf.org/html/rfc6243)).
Radek Krejcie53a8dc2018-10-17 12:52:40 +020056 *
57 * The current implementation covers YANG 1.0 ([RFC 6020](https://tools.ietf.org/html/rfc6020)) as well as
58 * YANG 1.1 ([RFC 7950](https://tools.ietf.org/html/rfc7950)).
59 *
60 * @section about-license License
61 *
Radek Krejci8678fa42020-08-18 16:07:28 +020062 * Copyright (c) 2015-2020 CESNET, z.s.p.o.
Radek Krejcie53a8dc2018-10-17 12:52:40 +020063 *
64 * (The BSD 3-Clause License)
65 *
66 * Redistribution and use in source and binary forms, with or without
67 * modification, are permitted provided that the following conditions
68 * are met:
69 * 1. Redistributions of source code must retain the above copyright
70 * notice, this list of conditions and the following disclaimer.
71 * 2. Redistributions in binary form must reproduce the above copyright
72 * notice, this list of conditions and the following disclaimer in
73 * the documentation and/or other materials provided with the
74 * distribution.
75 * 3. Neither the name of the Company nor the names of its contributors
76 * may be used to endorse or promote products derived from this
77 * software without specific prior written permission.
78 */
79
80/**
Radek Krejci52785a22019-09-11 12:57:26 +020081 * @page howto libyang API Overview
Radek Krejcie53a8dc2018-10-17 12:52:40 +020082 *
Radek Krejci8678fa42020-08-18 16:07:28 +020083 * @section howtoGeneral General notes
84 *
85 * libyang is primarily intended for handling data modeled by YANG modeling language, so the library is supposed to be optimized
86 * for this purpose. However, as a side effect, the library has to be able precisely process YANG modules. Thus, it is usable by
87 * YANG module authors to validate their modules and schemas in the development process.
88 *
89 * - @subpage howtoStructures
90 * - @subpage howtoErrors
91 * - @subpage howtoLogger
92 * - @subpage howtoThreads
93 * - @subpage howtoContext
Michal Vaskoafac7822020-10-20 14:22:26 +020094 * - @subpage howtoInput
95 * - @subpage howtoOutput
Radek Krejci8678fa42020-08-18 16:07:28 +020096 * - @subpage howtoSchema
97 * - @subpage howtoData
98 * - @subpage howtoXPath
99 * - @subpage howtoPlugins
100 */
101
102/**
103 * @page howtoStructures Data Structures
104 *
105 * @section sizedarrays Sized Arrays
106 *
107 * The structure starts with 32bit number storing size of the array - the number of the items inside. The size is part of the
108 * array to have it allocated together with the array itself only when it is needed. However, the pointers to the array always
109 * points after the 32b number, so items can be accessed directly as for standard C arrays. Because of a known size (available
110 * via ::LY_ARRAY_COUNT macro), it is not terminated by any special byte (sequence), so there is also no limitation for specific
111 * content of the stored records (e.g. that first byte must not be NULL).
112 *
113 * The sized arrays must be carefully freed (which should be done anyway only internally), since pointers to the sized arrays used
114 * in libyang structures, does not point to the beginning of the allocated space.
115 *
116 * - ::LY_ARRAY_COUNT
117 * - ::LY_ARRAY_FOR
118 *
119 * @section struct_lists Lists
120 *
121 * The lists are structures connected via a `next` and `prev` pointers. Iterating over the siblings can be simply done by
122 * ::LY_LIST_FOR macro. Examples of such structures are ::lyd_node or ::lysc_node.
123 *
124 * The `prev` pointer is always filled. In case there is just a single item in the list, the `prev` pointer points to the
125 * item itself. Otherwise, the `prev` pointer of the first item points to the last item of the list. In contrast, the
126 * `next` pointer of the last item in the list is always NULL.
127 */
128
129/**
130 * @page howtoPlugins Plugins
131 *
132 * libyang supports several types of plugins to better support generic features of YANG that need some specific code for
133 * their specific instances in YANG schemas. This is the case of YANG types, which are derived from YANG built-in types
134 * (which are implemented by libyang), but the description of the derived type can specify some additional requirements or
135 * restriction that cannot be implemented generically and some special code is needed. The second case for libyang plugins
136 * are YANG extensions. For YANG extensions, most of the specification stays in their description (e.g. allowed substatements
137 * or place of the extension instanciation) and libyang is not able to process such a text in a generic way. In both cases,
138 * libyang provides API to provide functionality implementing the specifics of each type or extension.
139 *
140 * - @subpage howtoPluginsTypes
141 * - @subpage howtoPluginsExtensions
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200142 */
143
144/**
Radek Krejci290a6a52019-09-12 17:13:17 +0200145 * @internal
146 * @page internals Developers' Notes
147 * @tableofcontents
148 *
149 * Following texts describes various internal subsystems and mechanism in libyang which are hidden from external users, but important
150 * for libyang developers. The texts should explain various decisions made and internal processes utilized in libyang.
151 */
152
Radek Krejci0af5f5d2018-09-07 15:00:30 +0200153#ifdef __cplusplus
154}
155#endif
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200156
157#endif /* LY_LIBYANG_H_ */