libyang  3.7.5
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bits.c File Reference

Built-in bits type plugin. More...

#include "plugins_types.h"
#include <ctype.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "libyang.h"
#include "compat.h"
#include "ly_common.h"
#include "plugins_internal.h"
Include dependency graph for bits.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE   /* strdup */
 
#define BITS_BITMAP_BYTE(bitmap, size, idx)   (bitmap + idx)
 Get a specific byte in a bitmap. More...
 
#define BITS_LAST_BIT_POSITION(type_bits)   (type_bits->bits[LY_ARRAY_COUNT(type_bits->bits) - 1].position)
 Get the position of the last bit. More...
 

Functions

 if (memcmp(v1->bitmap, v2->bitmap, lyplg_type_bits_bitmap_size(type_bits)))
 
 LYD_VALUE_GET (val1, v1)
 
 LYD_VALUE_GET (val2, v2)
 
LIBYANG_API_DEF size_t lyplg_type_bits_bitmap_size (const struct lysc_type_bits *type)
 Get the bitmap size of a bits value bitmap. More...
 
LIBYANG_API_DEF ly_bool lyplg_type_bits_is_bit_set (const char *bitmap, size_t size, uint32_t bit_position)
 Check whether a particular bit of a bitmap is set. More...
 
LIBYANG_API_DEF LY_ERR lyplg_type_dup_bits (const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
 Implementation of the lyplg_type_dup_clb for the built-in bits type. More...
 
LIBYANG_API_DEF void lyplg_type_free_bits (const struct ly_ctx *ctx, struct lyd_value *value)
 Implementation of the lyplg_type_free_clb for the built-in bits type. More...
 
LIBYANG_API_DEF const void * lyplg_type_print_bits (const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *UNUSED(prefix_data), ly_bool *dynamic, size_t *value_len)
 
LIBYANG_API_DEF LY_ERR lyplg_type_store_bits (const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len, uint32_t options, LY_VALUE_FORMAT format, void *UNUSED(prefix_data), uint32_t hints, const struct lysc_node *UNUSED(ctx_node), struct lyd_value *storage, struct lys_glob_unres *UNUSED(unres), struct ly_err_item **err)
 

Variables

int cmp = memcmp(v1->data, v2->data, lyplg_type_bits_bitmap_size(type_bits))
 
LIBYANG_API_DEF int
 
LIBYANG_API_DEF LY_ERR
 
return LY_SUCCESS
 
struct lyplg_type_record plugins_bits []
 Plugin information for bits type implementation. More...
 
struct lysc_type_bitstype_bits = (struct lysc_type_bits *)val1->realtype
 

Detailed Description

Built-in bits type plugin.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz Copyright (c) 2019-2021 CESNET, z.s.p.o.

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file bits.c.

Macro Definition Documentation

#define _GNU_SOURCE   /* strdup */

Definition at line 15 of file bits.c.

#define BITS_BITMAP_BYTE (   bitmap,
  size,
  idx 
)    (bitmap + idx)

Get a specific byte in a bitmap.

Definition at line 51 of file bits.c.

#define BITS_LAST_BIT_POSITION (   type_bits)    (type_bits->bits[LY_ARRAY_COUNT(type_bits->bits) - 1].position)

Get the position of the last bit.

Definition at line 43 of file bits.c.

Function Documentation

if ( memcmp(v1->bitmap, v2->bitmap, lyplg_type_bits_bitmap_size(type_bits))  )

Definition at line 379 of file bits.c.

LYD_VALUE_GET ( val1  ,
v1   
)
LYD_VALUE_GET ( val2  ,
v2   
)
LIBYANG_API_DEF const void* lyplg_type_print_bits ( const struct ly_ctx ctx,
const struct lyd_value value,
LY_VALUE_FORMAT  format,
void *  UNUSEDprefix_data,
ly_bool dynamic,
size_t *  value_len 
)

Definition at line 401 of file bits.c.

LIBYANG_API_DEF LY_ERR lyplg_type_store_bits ( const struct ly_ctx ctx,
const struct lysc_type type,
const void *  value,
size_t  value_len,
uint32_t  options,
LY_VALUE_FORMAT  format,
void *  UNUSEDprefix_data,
uint32_t  hints,
const struct lysc_node UNUSEDctx_node,
struct lyd_value storage,
struct lys_glob_unres *  UNUSEDunres,
struct ly_err_item **  err 
)

Definition at line 289 of file bits.c.

Variable Documentation

return cmp = memcmp(v1->data, v2->data, lyplg_type_bits_bitmap_size(type_bits))

Definition at line 390 of file bits.c.

LIBYANG_API_DEF int
Initial value:
{
struct lyd_value_binary *v1, *v2
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:657

Definition at line 387 of file bits.c.

LIBYANG_API_DEF LY_ERR
Initial value:
{
struct lyd_value_bits *v1, *v2
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:646

Definition at line 372 of file bits.c.

return LY_SUCCESS

Definition at line 382 of file bits.c.

struct lyplg_type_record plugins_bits[]
Initial value:
= {
{
.module = "",
.revision = NULL,
.name = LY_TYPE_BITS_STR,
.plugin.id = "libyang 2 - bits, version 1",
.plugin.store = lyplg_type_store_bits,
.plugin.validate = NULL,
.plugin.compare = lyplg_type_compare_bits,
.plugin.sort = lyplg_type_sort_bits,
.plugin.print = lyplg_type_print_bits,
.plugin.duplicate = lyplg_type_dup_bits,
.plugin.free = lyplg_type_free_bits,
.plugin.lyb_data_len = -1,
},
{0}
}
LIBYANG_API_DEF int lyplg_type_sort_bits(const struct ly_ctx *ctx, const struct lyd_value *val1, const struct lyd_value *val2)
Implementation of the lyplg_type_sort_clb for the built-in bits type.
LIBYANG_API_DECL const void * lyplg_type_print_bits(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format, void *prefix_data, ly_bool *dynamic, size_t *value_len)
Implementation of the lyplg_type_print_clb for the built-in bits type.
LIBYANG_API_DECL void lyplg_type_free_bits(const struct ly_ctx *ctx, struct lyd_value *value)
Implementation of the lyplg_type_free_clb for the built-in bits type.
Definition: bits.c:483
LIBYANG_API_DECL LY_ERR lyplg_type_compare_bits(const struct ly_ctx *ctx, const struct lyd_value *val1, const struct lyd_value *val2)
Implementation of the lyplg_type_compare_clb for the built-in bits type.
LIBYANG_API_DECL LY_ERR lyplg_type_store_bits(const struct ly_ctx *ctx, const struct lysc_type *type, const void *value, size_t value_len, uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err)
Implementation of the lyplg_type_store_clb for the built-in bits type.
LIBYANG_API_DECL LY_ERR lyplg_type_dup_bits(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
Implementation of the lyplg_type_dup_clb for the built-in bits type.
Definition: bits.c:443

Plugin information for bits type implementation.

Note that external plugins are supposed to use:

LYPLG_TYPES = {

Definition at line 504 of file bits.c.

struct lysc_type_bits * type_bits = (struct lysc_type_bits *)val1->realtype

Definition at line 374 of file bits.c.