@@ -104,12 +104,25 @@ LY_ERR ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir);
104
104
/**
105
105
* @brief Clean the search path(s) from the libyang context
106
106
*
107
+ * To remove the search path by its index, use ly_ctx_unset_searchdir().
108
+ *
107
109
* @param[in] ctx Context to be modified.
108
110
* @param[in] value Searchdir to be removed, use NULL to remove them all.
109
111
* @return LY_ERR return value
110
112
*/
111
113
LY_ERR ly_ctx_unset_searchdirs (struct ly_ctx * ctx , const char * value );
112
114
115
+ /**
116
+ * @brief Remove the specific search path from the libyang context.
117
+ *
118
+ * To remove the search path by its value, use ly_ctx_unset_searchdirs().
119
+ *
120
+ * @param[in] ctx Context to be modified.
121
+ * @param[in] index Index of the searchdir to be removed.
122
+ * @return LY_ERR return value
123
+ */
124
+ LY_ERR ly_ctx_unset_searchdir (struct ly_ctx * ctx , unsigned int index );
125
+
113
126
/**
114
127
* @brief Get the NULL-terminated list of the search paths in libyang context. Do not modify the result!
115
128
*
@@ -231,6 +244,25 @@ struct lys_module *ly_ctx_get_module_latest(const struct ly_ctx *ctx, const char
231
244
*/
232
245
struct lys_module * ly_ctx_get_module_implemented (const struct ly_ctx * ctx , const char * name );
233
246
247
+ /**
248
+ * @brief Get the (only) implemented YANG module specified by its name.
249
+ *
250
+ * @param[in] ctx Context where to search.
251
+ * @param[in] name Name of the YANG module to get.
252
+ * @return The only implemented YANG module revision of the given name in the given context. NULL if there is no
253
+ * implemented module of the given name.
254
+ */
255
+ /**
256
+ * @brief Iterate over all modules in the given context.
257
+ *
258
+ * @param[in] ctx Context with the modules.
259
+ * @param[in,out] index Index of the next module to get. Value of 0 starts from the beginning.
260
+ * The value is updated with each call, so to iterate over all modules the same variable is supposed
261
+ * to be used in all calls starting with value 0.
262
+ * @return Next context module, NULL if the last was already returned.
263
+ */
264
+ const struct lys_module * ly_ctx_get_module_iter (const struct ly_ctx * ctx , unsigned int * index );
265
+
234
266
/**
235
267
* @brief Get YANG module of the given namespace and revision.
236
268
*
@@ -292,6 +324,23 @@ void ly_ctx_reset_latests(struct ly_ctx *ctx);
292
324
*/
293
325
LY_ERR ly_ctx_module_implement (struct ly_ctx * ctx , struct lys_module * mod );
294
326
327
+ /**
328
+ * @brief Try to find the model in the searchpaths of \p ctx and load it into it. If custom missing
329
+ * module callback is set, it is used instead.
330
+ *
331
+ * The context itself is searched for the requested module first. If \p revision is not specified
332
+ * (the module of the latest revision is requested) and there is implemented revision of the requested
333
+ * module in the context, this implemented revision is returned despite there might be a newer revision.
334
+ * This behavior is cause by the fact that it is not possible to have multiple implemented revisions of
335
+ * the same module in the context.
336
+ *
337
+ * @param[in] ctx Context to add to.
338
+ * @param[in] name Name of the module to load.
339
+ * @param[in] revision Optional revision date of the module. If not specified, the latest revision is loaded.
340
+ * @return Pointer to the data model structure, NULL if not found or some error occurred.
341
+ */
342
+ const struct lys_module * ly_ctx_load_module (struct ly_ctx * ctx , const char * name , const char * revision );
343
+
295
344
/**
296
345
* @brief Free all internal structures of the specified context.
297
346
*
0 commit comments