aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-09-04 14:17:39 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-09-04 14:28:00 +0200
commit334177e678cb5fdbd8ab4aa1189717791ce1260e (patch)
tree1fe349af7f9c2a934df74b8879bf30d3d31232a2 /build-aux
parentf72cbc9c5f17555374bfe3c4e421ca61f6a78f67 (diff)
qmi-codegen: allow 'max-size' in output string variables
If 'max-size' is given for an output string variable, we will read up to the specified number of bytes from the buffer. This will help us handle cases where the firmware of the device doesn't match what it sends with what it wanted to send (e.g. IMEI longer than 15 characters).
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/qmi-codegen/VariableString.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/build-aux/qmi-codegen/VariableString.py b/build-aux/qmi-codegen/VariableString.py
index c39602f..02f827b 100644
--- a/build-aux/qmi-codegen/VariableString.py
+++ b/build-aux/qmi-codegen/VariableString.py
@@ -77,12 +77,14 @@ class VariableString(Variable):
'${lp}${variable_name}[${fixed_size}] = \'\\0\';\n')
else:
translations['length_prefix'] = 'TRUE' if self.length_prefix else 'FALSE'
+ translations['max_size'] = self.max_size if self.max_size != '' else '0'
template = (
'${lp}/* Read the string variable from the buffer */\n'
'${lp}qmi_utils_read_string_from_buffer (\n'
'${lp} &${buffer_name},\n'
'${lp} &${buffer_len},\n'
'${lp} ${length_prefix},\n'
+ '${lp} ${max_size},\n'
'${lp} &(${variable_name}));\n')
f.write(string.Template(template).substitute(translations))
@@ -148,6 +150,7 @@ class VariableString(Variable):
'${lp}}\n')
else:
translations['length_prefix'] = 'TRUE' if self.length_prefix else 'FALSE'
+ translations['max_size'] = self.max_size if self.max_size != '' else '0'
template = (
'\n'
'${lp}{\n'
@@ -158,6 +161,7 @@ class VariableString(Variable):
'${lp} &${buffer_name},\n'
'${lp} &${buffer_len},\n'
'${lp} ${length_prefix},\n'
+ '${lp} ${max_size},\n'
'${lp} &tmp);\n'
'\n'
'${lp} g_string_append_printf (${printable}, "%s", tmp);\n'