Commit 85a7a3da authored by Lucas Russo's avatar Lucas Russo

hal/hal_utils/dispatch_table.*: add variable argument option

Now, an exported function can have an argument that
has a variable size, up to the maximum specified in
the function description. Particularly useful for
returning data from "read" functions
parent 7dde2561
......@@ -420,10 +420,12 @@ static halutils_err_e _disp_table_check_gen_zmq_args (const disp_op_t *disp_op,
/* We have received something and will check for (byte) size
* correctness */
if (GEN_MSG_ZMQ_ARG_SIZE(zmq_arg) != DISP_GET_ASIZE(*args_it)) {
if ((GEN_MSG_ZMQ_ARG_SIZE(zmq_arg) > DISP_GET_ASIZE(*args_it)) ||
(DISP_GET_ATYPE(*args_it) != DISP_ATYPE_VAR &&
GEN_MSG_ZMQ_ARG_SIZE(zmq_arg) != DISP_GET_ASIZE(*args_it))) {
DBE_DEBUG (DBG_HAL_UTILS | DBG_LVL_ERR,
"[halutils:disp_table] Invalid size of argument"
" received for function \"%s\"\n", disp_op->name);
"[halutils:disp_table] Invalid size of argument #%u"
" received for function \"%s\"\n", i, disp_op->name);
err = HALUTILS_ERR_INV_SIZE_ARG;
goto err_inv_size_args;
}
......
......@@ -42,7 +42,10 @@ enum _disp_at_e {
DISP_ATYPE_UINT64,
DISP_ATYPE_DOUBLE, /* float is promoted to double */
DISP_ATYPE_STRING, /* size of strings is strlen() each time */
DISP_ATYPE_STRUCT
DISP_ATYPE_STRUCT,
DISP_ATYPE_VAR /* variable argument size. Allowed to be
up to the size of the encoded argument.
Typically a structure */
};
typedef enum _disp_at_e disp_at_e;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment