asn1: Add --decorate=... for internal bookkeeping
This option, `--decorate=TYPE-NAME:FIELD-TYPE:field-name[?]` allows one to add a field to any struct generated by the ASN.1 compiler for any SET or SEQUENCE type such that: - the field will be freed by the `free_TYPE_NAME()` function - the field will be copied by the `copy_TYPE_NAME()` function - the field will not be printed by the `print_TYPE_NAME()` function - the field will NOT be encoded or decoded This is useful for internal bookkeeping. The first use of this may well be for adding an optional field to `Principal` where information about name attributes will be stored, which will then allow us to have GSS name attributes for the krb5 mechanism w/o having to refactor the mechanism to use a different structure for representing `gss_name_t` mechnames than the one currently used (`Principal`; `krb5_principal` happens to be a typedef alias of `Principal *`). So w/o massive rototilling of the GSS krb5 mechanism we can have name attributes, _and_ we'll also be able to have those in the krb5 API as well w/o any massive rototilling there either.
This commit is contained in:
@@ -1355,6 +1355,8 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t
|
||||
case TSet:
|
||||
case TSequence: {
|
||||
Member *m;
|
||||
char *ft, *fn;
|
||||
int deco_opt;
|
||||
|
||||
getnewbasename(&newbasename, typedefp || level == 0, basename, name);
|
||||
|
||||
@@ -1395,6 +1397,13 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t
|
||||
fprintf(jsonfile, ",\"opentype\":");
|
||||
define_open_type(level, newbasename, name, basename, t, t);
|
||||
}
|
||||
if (decorate_type(newbasename, &ft, &fn, &deco_opt)) {
|
||||
space(level + 1);
|
||||
fprintf(headerfile, "%s %s%s;\n", ft, deco_opt ? "*" : "", fn);
|
||||
fprintf(jsonfile, ",\"decorate\":{\"type\":\"%s\",\"name\":\"%s\", \"optional\":%s}", ft, fn, deco_opt ? "true" : "false");
|
||||
free(ft);
|
||||
free(fn);
|
||||
}
|
||||
space(level);
|
||||
fprintf (headerfile, "} %s;\n", name);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user