diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-01-31 10:36:50 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-01-31 15:18:35 +0100 |
commit | accd1a5841bafc81aa87db46eb35a8255ced4e22 (patch) | |
tree | 32c0ccb8d755242c4de104699813b9edf88450fe /src/mm-base-modem-at.h | |
parent | f77deb75a5d81fb1cfbfff576838900be866d016 (diff) |
base-modem: define new helper MMBaseModemAtCommandAlloc
It has the same exact format as MMBaseModemAtCommand, but its contents
are assumed heap allocated.
The only real purpose of this type is to allow defining static
constant MMBaseModemAtCommand variables without warnings when using
-Wdiscarded-qualifiers.
Diffstat (limited to 'src/mm-base-modem-at.h')
-rw-r--r-- | src/mm-base-modem-at.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mm-base-modem-at.h b/src/mm-base-modem-at.h index e155c908..d92a0610 100644 --- a/src/mm-base-modem-at.h +++ b/src/mm-base-modem-at.h @@ -51,10 +51,10 @@ typedef gboolean (* MMBaseModemAtResponseProcessor) (MMBaseModem *self, GVariant **result, GError **result_error); -/* Struct to configure AT command operations */ +/* Struct to configure AT command operations (constant) */ typedef struct { /* The AT command */ - gchar *command; + const gchar *command; /* Timeout of the command, in seconds */ guint timeout; /* Flag to allow cached replies */ @@ -164,4 +164,24 @@ const gchar *mm_base_modem_at_command_full_finish (MMBaseModem *self, GAsyncResult *res, GError **error); +/******************************************************************************/ +/* Support for MMBaseModemAtCommand with heap allocated contents */ + +/* Exactly same format as MMBaseModemAtCommand, just without + * a constant command string. */ +typedef struct { + gchar *command; + guint timeout; + gboolean allow_cached; + MMBaseModemAtResponseProcessor response_processor; +} MMBaseModemAtCommandAlloc; + +G_STATIC_ASSERT (sizeof (MMBaseModemAtCommandAlloc) == sizeof (MMBaseModemAtCommand)); +G_STATIC_ASSERT (G_STRUCT_OFFSET (MMBaseModemAtCommandAlloc, command) == G_STRUCT_OFFSET (MMBaseModemAtCommand, command)); +G_STATIC_ASSERT (G_STRUCT_OFFSET (MMBaseModemAtCommandAlloc, timeout) == G_STRUCT_OFFSET (MMBaseModemAtCommand, timeout)); +G_STATIC_ASSERT (G_STRUCT_OFFSET (MMBaseModemAtCommandAlloc, allow_cached) == G_STRUCT_OFFSET (MMBaseModemAtCommand, allow_cached)); +G_STATIC_ASSERT (G_STRUCT_OFFSET (MMBaseModemAtCommandAlloc, response_processor) == G_STRUCT_OFFSET (MMBaseModemAtCommand, response_processor)); + +void mm_base_modem_at_command_alloc_clear (MMBaseModemAtCommandAlloc *command); + #endif /* MM_BASE_MODEM_AT_H */ |