Dynamic library: add support for input and output arguments

This commit is contained in:
Amin Ben Ramdhane 2021-04-23 10:17:58 +01:00
parent 763e267d59
commit 8c85cf9059
5 changed files with 11 additions and 5 deletions

View file

@ -370,7 +370,9 @@ The **DM_MAP_OPERATE** structure contains two arguments:
| Argument | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------- |
| `pathname` | A string of the path name operate. Example “Device.BBKSpeedTest”, “Device.WiFi.AccessPoint.*.X_IOPSYS_EU_Reset” |
| `operation` | The function which return the status of this operate. |
| `operation` | The function to be executed in the operation |
| `type` | The type of the operation. Could be **sync** or **async** |
| `args` | The input and output arguments of the operation |
For the other tables, they are defined in the same way as the Object and Parameter definition described above.

View file

@ -157,7 +157,8 @@ int load_library_dynamic_arrays(struct dmctx *ctx)
if (dynamic_operate[i].operate && dynamic_operate[i].type)
add_dynamic_operate(dynamic_operate[i].path,
dynamic_operate[i].operate,
dynamic_operate[i].type);
dynamic_operate[i].type,
dynamic_operate[i].args);
}
}

View file

@ -843,13 +843,14 @@ static int get_index_of_available_dynamic_operate(struct op_cmd *operate)
return idx;
}
int add_dynamic_operate(char *path, operation operate, char *type)
int add_dynamic_operate(char *path, operation operate, char *type, operation_args args)
{
if (dynamic_operate == NULL) {
dynamic_operate = calloc(2, sizeof(struct op_cmd));
dynamic_operate[0].name = path;
dynamic_operate[0].opt = operate;
dynamic_operate[0].type = type;
dynamic_operate[0].args = args;
} else {
int idx = get_index_of_available_dynamic_operate(dynamic_operate);
struct op_cmd *new_dynamic_operate = realloc(dynamic_operate, (idx + 2) * sizeof(struct op_cmd));
@ -861,6 +862,7 @@ int add_dynamic_operate(char *path, operation operate, char *type)
dynamic_operate[idx].name = path;
dynamic_operate[idx].opt = operate;
dynamic_operate[idx].type = type;
dynamic_operate[idx].args = args;
}
return 0;
}

View file

@ -212,10 +212,10 @@ struct op_cmd {
const char *name;
operation opt;
const char *type;
const operation_args args;
operation_args args;
};
int add_dynamic_operate(char *path, operation operate, char *type);
int add_dynamic_operate(char *path, operation operate, char *type, operation_args args);
void operate_list_cmds(struct dmctx *dmctx);
opr_ret_t operate_on_node(struct dmctx *dmctx, char *path, char *input);

View file

@ -237,6 +237,7 @@ typedef struct dm_map_operate {
char *path;
operation operate;
char *type; // sync or async
operation_args args;
} DM_MAP_OPERATE;
enum set_value_action {