asn1: Template backend partial support for SETs
This adds enough support for SET { ... } types to the template backend to allow the X.690 sample test to be run with the template backend. Limitations: - For DER encoding, the SET { ... } members must be manually sorted by the module author. - Decoding of out-of-order encodings (BER) is not supported at this time. These shortcomings will be addressed later. Note that because we don't parse IMPORTed modules at this time, we can't sort SET { ... } members at compile time if any of them out an outer-most tag that the compiler cannot see without learning to parse IMPORTed modules.
This commit is contained in:
@@ -631,6 +631,32 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
|
||||
|
||||
break;
|
||||
}
|
||||
case TSet: {
|
||||
Member *m;
|
||||
|
||||
fprintf(get_code_file(), "/* tset: members isstruct: %d */\n", isstruct);
|
||||
|
||||
HEIM_TAILQ_FOREACH(m, t->members, members) {
|
||||
char *newbasename = NULL;
|
||||
|
||||
if (m->ellipsis)
|
||||
continue;
|
||||
|
||||
if (name) {
|
||||
if (asprintf(&newbasename, "%s_%s", basetype, name) < 0)
|
||||
errx(1, "malloc");
|
||||
} else
|
||||
newbasename = strdup(basetype);
|
||||
if (newbasename == NULL)
|
||||
errx(1, "malloc");
|
||||
|
||||
template_members(temp, newbasename, m->gen_name, m->type, m->optional, 0, isstruct, 1);
|
||||
|
||||
free(newbasename);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TSequence: {
|
||||
Member *m;
|
||||
|
||||
|
Reference in New Issue
Block a user