diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2024-03-07 14:09:28 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2024-03-12 10:15:59 +0000 |
commit | 07f1f5864204dfdf455067def863fcd20c8c6a26 (patch) | |
tree | b2d3869a468de9bce1405b394b832aa711865806 /src/mm-port-serial-at.c | |
parent | 311d6f389e74899bc1790928bb44e8361e411a1b (diff) |
modem-helpers: rework AT string quote operation and add unit tests
Rework the AT string quote operation to build the output with the
GString helper, instead of manually calculating how many bytes we'll
need in the output. It just makes it clearer.
Diffstat (limited to 'src/mm-port-serial-at.c')
-rw-r--r-- | src/mm-port-serial-at.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/src/mm-port-serial-at.c b/src/mm-port-serial-at.c index a53c5745..511503a9 100644 --- a/src/mm-port-serial-at.c +++ b/src/mm-port-serial-at.c @@ -54,32 +54,6 @@ struct _MMPortSerialAtPrivate { /*****************************************************************************/ -gchar * -mm_port_serial_at_quote_string (const char *string) -{ - int len, i; - gchar *quoted, *pos; - - if (string == NULL) - len = 0; - else - len = strlen (string); - quoted = g_malloc (3 + 3 * len); /* worst case */ - - pos = quoted; - *pos++ = '"'; - for (i = 0 ; i < len; i++) { - if (string[i] < 0x20 || string[i] == '"' || string[i] == '\\') - pos += sprintf (pos, "\\%02X", string[i]); - else - *pos++ = string[i]; - } - *pos++ = '"'; - *pos++ = '\0'; - - return quoted; -} - void mm_port_serial_at_set_response_parser (MMPortSerialAt *self, MMPortSerialAtResponseParserFn fn, |