Loading...
Searching...
No Matches
sysrepo-plugind Plugin API

## Macros

#define | SRP_CLEANUP_CB "sr_plugin_cleanup_cb"
| sysrepo-plugind plugin cleanup callback name that must exist in every plugin.
#define | SRP_INIT_CB "sr_plugin_init_cb"
| sysrepo-plugind plugin initialization callback name that must exist in every plugin.
#define | SRPLG_LOG_DBG(plg_name, ...)
| Log a plugin debug message with format arguments.
#define | SRPLG_LOG_ERR(plg_name, ...)
| Log a plugin error message with format arguments. Datastore and notification plugins should use srplg_log_errinfo() instead.
#define | SRPLG_LOG_INF(plg_name, ...)
| Log a plugin info message with format arguments.
#define | SRPLG_LOG_WRN(plg_name, ...)
| Log a plugin warning message with format arguments.

## Functions

void | srplg_errinfo_free (sr_error_info_t **err_info)
| Free a superfluous error info.
void int | srplg_errinfo_push_error_data (sr_error_info_t *err_info, uint32_t size, const void *data)
| Push (add) another chunk of error data for a failed plugin callback. Its meaning is specific to the error data format name (which must be set prior to calling this function) identifier and can be read from the error structure by the originator using sr_get_error_data().
void | srplg_log_errinfo (sr_error_info_t **err_info, const char *plg_name, const char *err_format_name, sr_error_t err_code, const char *format,...) _FORMAT_PRINTF(5
| Log a plugin error message and add the error into an error info structure.
typedef int(* | srp_init_cb_t) (sr_session_ctx_t *session, void **private_data)
| Sysrepo plugin initialization callback.
typedef void(* | srp_cleanup_cb_t) (sr_session_ctx_t *session, void *private_data)
| Sysrepo plugin cleanup callback.

## Detailed Description

## Macro Definition Documentation

## SRP_CLEANUP_CB

#define SRP_CLEANUP_CB "sr_plugin_cleanup_cb"

sysrepo-plugind plugin cleanup callback name that must exist in every plugin.

The callback must be of srp_cleanup_cb_t type.

Definition at line 1903 of file sysrepo.h.

## SRP_INIT_CB

#define SRP_INIT_CB "sr_plugin_init_cb"

sysrepo-plugind plugin initialization callback name that must exist in every plugin.

The callback must be of srp_init_cb_t type.

Definition at line 1896 of file sysrepo.h.

## SRPLG_LOG_DBG

#define SRPLG_LOG_DBG | ( |  | plg_name,
|  |  | ... )

Value:
srplg_log(plg_name, SR_LL_DBG, __VA_ARGS__)
srplg_log
void srplg_log(const char *plg_name, sr_log_level_t ll, const char *format,...) _FORMAT_PRINTF(3
SR_LL_DBG
@ SR_LL_DBG
Definition sysrepo_types.h:68

Log a plugin debug message with format arguments.

Parameters

  [in] | plg_name | Plugin name to print.
  [in] | ... | Format string and arguments.

Definition at line 1967 of file sysrepo.h.

## SRPLG_LOG_ERR

#define SRPLG_LOG_ERR | ( |  | plg_name,
|  |  | ... )

Value:
srplg_log(plg_name, SR_LL_ERR, __VA_ARGS__)
SR_LL_ERR
@ SR_LL_ERR
Definition sysrepo_types.h:65

Log a plugin error message with format arguments. Datastore and notification plugins should use srplg_log_errinfo() instead.

Definition at line 1943 of file sysrepo.h.

## SRPLG_LOG_INF

#define SRPLG_LOG_INF | ( |  | plg_name,
|  |  | ... )

Value:
srplg_log(plg_name, SR_LL_INF, __VA_ARGS__)
SR_LL_INF
@ SR_LL_INF
Definition sysrepo_types.h:67

Log a plugin info message with format arguments.

Parameters

  [in] | plg_name | Plugin name to print.
  [in] | ... | Format string and arguments.

Definition at line 1959 of file sysrepo.h.

## SRPLG_LOG_WRN

#define SRPLG_LOG_WRN | ( |  | plg_name,
|  |  | ... )

Value:
srplg_log(plg_name, SR_LL_WRN, __VA_ARGS__)
SR_LL_WRN
@ SR_LL_WRN
Definition sysrepo_types.h:66

Log a plugin warning message with format arguments.

Parameters

  [in] | plg_name | Plugin name to print.
  [in] | ... | Format string and arguments.

Definition at line 1951 of file sysrepo.h.

## Typedef Documentation

## srp_cleanup_cb_t

typedef void(* srp_cleanup_cb_t) (sr_session_ctx_t *session, void *private_data)

Sysrepo plugin cleanup callback.

Parameters

  [in] | session | Sysrepo session that can be used for any API calls needed for plugin cleanup (mainly for unsubscribing of subscriptions initialized in srp_init_cb_t).
  [in] | private_data | Private context as passed in srp_init_cb_t.

Definition at line 727 of file sysrepo_types.h.

## srp_init_cb_t

typedef int(* srp_init_cb_t) (sr_session_ctx_t *session, void **private_data)

Sysrepo plugin initialization callback.

Parameters

  [in] | session | Sysrepo session that can be used for any API calls needed for plugin initialization (mainly for reading of startup configuration and subscribing for notifications).
  [out] | private_data | Private context (opaque to sysrepo) that will be passed to srp_cleanup_cb_t when plugin cleanup is requested.

Returns
  Error code (SR_ERR_OK on success).

Definition at line 717 of file sysrepo_types.h.

## Function Documentation

## srplg_errinfo_free()

void srplg_errinfo_free | ( | sr_error_info_t ** | err_info | ) |

Free a superfluous error info.

Parameters

  [in,out] | err_info | Error info to free, is set to NULL.

## srplg_errinfo_push_error_data()

void int srplg_errinfo_push_error_data | ( | sr_error_info_t * | err_info,
|  | uint32_t | size,
|  | const void * | data )

Push (add) another chunk of error data for a failed plugin callback. Its meaning is specific to the error data format name (which must be set prior to calling this function) identifier and can be read from the error structure by the originator using sr_get_error_data().

Parameters

  [in] | err_info | Error info created by srplg_log_errinfo() with a specific error format name set. The last created error is being modified.
  [in] | size | Size of the error `data` chunk.
  [in] | data | Pointer to an opaque error data chunk.

Returns
  Error code (SR_ERR_OK on success).

## srplg_log_errinfo()

void srplg_log_errinfo | ( | sr_error_info_t ** | err_info,
|  | const char * | plg_name,
|  | const char * | err_format_name,
|  | sr_error_t | err_code,
|  | const char * | format,
|  |  | ... )

Log a plugin error message and add the error into an error info structure.

Parameters

  [in,out] | err_info | Empty or an exisiting error info to add to.
  [in] | plg_name | Plugin name to print.
  [in] | err_format_name | Optional arbitrary error format identifier, set its error data using srplg_errinfo_push_error_data(). More details in sr_session_set_error_format().
  [in] | err_code | Error code of the error.
  [in] | format | Error message format.
  [in] | ... | Error message format arguments.