Added shared struct to allow the same option names for different functions
[project/uqmi.git] / commands.h
1 #ifndef __UQMI_COMMANDS_H
2 #define __UQMI_COMMANDS_H
3
4 #include <stdbool.h>
5 #include "commands-wds.h"
6 #include "commands-dms.h"
7 #include "commands-nas.h"
8 #include "commands-wms.h"
9 #include "commands-wda.h"
10
11 enum qmi_cmd_result {
12         QMI_CMD_DONE,
13         QMI_CMD_REQUEST,
14         QMI_CMD_EXIT,
15 };
16
17 enum {
18         CMD_TYPE_OPTION = -1,
19 };
20
21 struct uqmi_cmd_handler {
22         const char *name;
23         int type;
24
25         enum qmi_cmd_result (*prepare)(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg);
26         void (*cb)(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg);
27 };
28
29 struct uqmi_cmd {
30         const struct uqmi_cmd_handler *handler;
31         char *arg;
32 };
33
34 #define __uqmi_commands \
35         __uqmi_command(version, get-versions, no, QMI_SERVICE_CTL), \
36         __uqmi_command(set_client_id, set-client-id, required, CMD_TYPE_OPTION), \
37         __uqmi_command(get_client_id, get-client-id, required, QMI_SERVICE_CTL), \
38         __uqmi_command(ctl_set_data_format, set-data-format, required, QMI_SERVICE_CTL), \
39         __uqmi_wds_commands, \
40         __uqmi_dms_commands, \
41         __uqmi_nas_commands, \
42         __uqmi_wms_commands, \
43         __uqmi_wda_commands
44
45 #define __uqmi_command(_name, _optname, _arg, _option) __UQMI_COMMAND_##_name
46 enum uqmi_command {
47         __uqmi_commands,
48         __UQMI_COMMAND_LAST
49 };
50 #undef __uqmi_command
51
52 extern bool single_line;
53 extern const struct uqmi_cmd_handler uqmi_cmd_handler[];
54 void uqmi_add_command(char *arg, int longidx);
55 bool uqmi_run_commands(struct qmi_dev *qmi);
56 int uqmi_add_error(const char *msg);
57
58 #endif