From 815dd495eb087b3b3ea02a8ed43716efac43db1c Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Fri, 29 Jun 2018 14:12:50 -0700 Subject: [PATCH] kernel: Support having strings in structs Add handling for strings in structs in the kernel-style code generator. Signed-off-by: Bjorn Andersson --- kernel.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel.c b/kernel.c index b6127bd..24e0d05 100644 --- a/kernel.c +++ b/kernel.c @@ -32,6 +32,10 @@ static void emit_struct_definition(FILE *fp, const char *package, case TYPE_U64: fprintf(fp, "\t%s %s;\n", sz_native_types[qsm->type], qsm->name); break; + case TYPE_STRING: + fprintf(fp, "\tuint32_t %s_len;\n", qsm->name); + fprintf(fp, "\tchar %s[256];\n", qsm->name); + break; } } @@ -67,6 +71,15 @@ static void emit_struct_ei(FILE *fp, const char *package, struct qmi_struct *qs) case TYPE_U64: emit_struct_native_ei(fp, package, qs, qsm); break; + case TYPE_STRING: + fprintf(fp, "\t{\n" + "\t\t.data_type = QMI_STRING,\n" + "\t\t.elem_len = 256,\n" + "\t\t.elem_size = sizeof(char),\n" + "\t\t.offset = offsetof(struct %1$s_%2$s, %3$s)\n" + "\t},\n", + package, qs->name, qsm->name); + break; } }