/ include / lsplugin / param.h
param.h
 1  /*
 2   * SPDX-FileCopyrightText: 2023-2024 Le'Sec Plugin collective
 3   *
 4   * SPDX-License-Identifier: LGPL-3.0-or-later
 5   */
 6  
 7  #ifndef LSPLUGIN_PARAM_H
 8  # define LSPLUGIN_PARAM_H
 9  
10  # include <stddef.h>
11  # include <stdbool.h>
12  # include <leutils/status.h>
13  # include <lscore/param.h>
14  
15  /*
16   * Common function sets for handling parameters
17   */
18  typedef struct LSplugin_param_functions_st LSplugin_param_functions_t;
19  struct LSplugin_param_functions_st {
20    size_t lsp_data_offset, lsp_datalen_offset;
21    size_t lsp_data_set_offset;   // This field MUST be _Bool
22    _Bool lsp_set_data_set;
23    LE_STATUS (*lsp_set)(void *o, LSC_param_t *data, size_t index,
24                         size_t data_offset, size_t datalen_offset);
25    LE_STATUS (*lsp_get)(void *o, LSC_param_t *data, size_t index,
26                         size_t data_offset, size_t datalen_offset);
27  };
28  
29  /* input is supposed to be |int *input| */
30  LE_STATUS LSplugin_set_int_param(void *o, LSC_param_t *data, size_t index,
31                                   size_t input_offset,
32                                   /* ignored */ size_t inputlen_offset);
33  /* input is supposed to be |int *output| */
34  LE_STATUS LSplugin_get_int_param(void *o, LSC_param_t *data, size_t index,
35                                   size_t output_offset,
36                                   /* ignored */ size_t outputlen_offset);
37  
38  /* input is supposed to be |size_t *input| */
39  LE_STATUS LSplugin_set_size_t_param(void *o, LSC_param_t *data, size_t index,
40                                      size_t input_offset,
41                                      /* ignored */ size_t inputlen_offset);
42  /* input is supposed to be |size_t *output| */
43  LE_STATUS LSplugin_get_size_t_param(void *o, LSC_param_t *data, size_t index,
44                                      size_t output_offset,
45                                      /* ignored */ size_t outputlen_offset);
46  
47  /* input is supposed to be |unsigned char *input| */
48  LE_STATUS LSplugin_set_bitstring_param(void *o, LSC_param_t *data, size_t index,
49                                         size_t input_offset, size_t inputlen_offset);
50  /* output is supposed to be |unsigned char *output| */
51  LE_STATUS LSplugin_get_bitstring_param(void *o, LSC_param_t *data, size_t index,
52                                         size_t output_offset, size_t outputlen_offset);
53  
54  /* input is supposed to be |unsigned char *input| */
55  LE_STATUS LSplugin_set_octetstring_param(void *o, LSC_param_t *data, size_t index,
56                                           size_t input_offset, size_t inputlen_offset);
57  /* output is supposed to be |unsigned char *output| */
58  LE_STATUS LSplugin_get_octetstring_param(void *o, LSC_param_t *data, size_t index,
59                                           size_t output_offset, size_t outputlen_offset);
60  
61  /* Helper function to set or get params */
62  LE_STATUS LSplugin_do_param(void *o, _Bool set, LSC_param_t *data,
63                              const LSC_param_desc_t *pd);
64  
65  #endif