diff --git a/lib/asn1/Makefile.am b/lib/asn1/Makefile.am index 5a9a4e1f8..eb0308ee1 100644 --- a/lib/asn1/Makefile.am +++ b/lib/asn1/Makefile.am @@ -25,13 +25,11 @@ endif libasn1_la_LIBADD = \ libasn1base.la \ @LIB_com_err@ \ - $(LIB_heimbase) \ $(LIBADD_roken) libasn1template_la_LIBADD = \ libasn1base.la \ @LIB_com_err@ \ - $(LIB_heimbase) \ $(LIBADD_roken) BUILT_SOURCES = \ @@ -192,12 +190,10 @@ check_timegm_LDADD = $(check_der_LDADD) check_gen_template_LDADD = \ libasn1template.la \ - $(LIB_heimbase) \ $(LIB_roken) check_gen_LDADD = \ libasn1template.la \ - $(LIB_heimbase) \ $(LIB_roken) check_ber_LDADD = $(check_gen_LDADD) diff --git a/lib/asn1/README.md b/lib/asn1/README.md index 42a6cb393..9c4e69795 100644 --- a/lib/asn1/README.md +++ b/lib/asn1/README.md @@ -1028,12 +1028,6 @@ DESCRIPTION ple, one might decorate a request type with state needed during processing of the request. - --decorate=ASN1-TYPE:heim_object_t:fname - Add to the C struct generated for the given ASN.1 SET or SEQUENCE - type named ASN1-TYPE a “hidden” field named fname of C type - ‘heim_object_t’ values of which will be copied and released with - ‘heim_retain()’ and ‘heim_release()’ respectively. - --decorate=ASN1-TYPE:void*:fname Add to the C struct generated for the given ASN.1 SET, SEQUENCE, or CHOICE type named ASN1-TYPE a “hidden” field named fname of diff --git a/lib/asn1/asn1-template.h b/lib/asn1/asn1-template.h index 7c2ace30a..07c4461e3 100644 --- a/lib/asn1/asn1-template.h +++ b/lib/asn1/asn1-template.h @@ -150,7 +150,6 @@ #define A1_FLAG_OPTIONAL (0x01000000) #define A1_FLAG_IMPLICIT (0x02000000) #define A1_FLAG_DEFAULT (0x04000000) -#define A1_FLAG_HEIM_OBJ (0x08000000) #define A1_TAG_T(CLASS,TYPE,TAG) ((A1_OP_TAG) | (((CLASS) << 22) | ((TYPE) << 21) | (TAG))) #define A1_TAG_CLASS(x) (((x) >> 22) & 0x3) diff --git a/lib/asn1/asn1_compile.1 b/lib/asn1/asn1_compile.1 index 5983b62e8..a7953df5f 100644 --- a/lib/asn1/asn1_compile.1 +++ b/lib/asn1/asn1_compile.1 @@ -258,21 +258,6 @@ used for internal bookkeeping but which do not affect interoperability because they are neither encoded nor decoded. For example, one might decorate a request type with state needed during processing of the request. -.It Fl Fl decorate=ASN1-TYPE:heim_object_t:fname -Add to the C struct generated for the given ASN.1 SET or SEQUENCE type -named -.Ar ASN1-TYPE -a -.Dq hidden -field named -.Ar fname -of C type -.Sq heim_object_t -values of which will be copied and released with -.Sq heim_retain() -and -.Sq heim_release() -respectively. .It Fl Fl decorate=ASN1-TYPE:void*:fname Add to the C struct generated for the given ASN.1 SET, SEQUENCE, or CHOICE type named diff --git a/lib/asn1/check-gen.c b/lib/asn1/check-gen.c index 29586f7dc..6b5c71c39 100644 --- a/lib/asn1/check-gen.c +++ b/lib/asn1/check-gen.c @@ -1053,7 +1053,6 @@ test_decorated(void) td.version = 3; td.version3.v = 5; td.privthing = &td; - td.privobj = heim_string_create("foo"); if ((td.version2 = malloc(sizeof(*td.version2))) == NULL) errx(1, "out of memory"); *td.version2 = 5; @@ -1097,10 +1096,6 @@ test_decorated(void) warnx("copy_TESTDecorated() did not work correctly (4)"); return 1; } - if (td_copy.privobj != td.privobj) { - warnx("copy_TESTDecorated() did not work correctly (5)"); - return 1; - } free_TESTDecorated(&td_copy); free_TESTDecorated(&td); @@ -1116,10 +1111,6 @@ test_decorated(void) warnx("free_TESTDecorated() did not work correctly (3)"); return 1; } - if (td.privobj != 0) { - warnx("free_TESTDecorated() did not work correctly (4)"); - return 1; - } return 0; } @@ -1142,7 +1133,6 @@ test_decorated_choice(void) tdc.u.version = 3; tdc.version3.v = 5; tdc.privthing = &tdc; - tdc.privobj = heim_string_create("foo"); if ((tdc.version2 = malloc(sizeof(*tdc.version2))) == NULL) errx(1, "out of memory"); *tdc.version2 = 5; @@ -1188,10 +1178,6 @@ test_decorated_choice(void) warnx("copy_TESTDecoratedChoice() did not work correctly (4)"); return 1; } - if (tdc_copy.privobj != tdc.privobj) { - warnx("copy_TESTDecoratedChoice() did not work correctly (5)"); - return 1; - } free_TESTDecoratedChoice(&tdc_copy); free_TESTDecoratedChoice(&tdc); @@ -1207,10 +1193,6 @@ test_decorated_choice(void) warnx("free_TESTDecoratedChoice() did not work correctly (3)"); return 1; } - if (tdc.privobj != 0) { - warnx("free_TESTDecoratedChoice() did not work correctly (4)"); - return 1; - } return 0; } diff --git a/lib/asn1/gen.c b/lib/asn1/gen.c index 9fadccf89..10153c603 100644 --- a/lib/asn1/gen.c +++ b/lib/asn1/gen.c @@ -1436,7 +1436,7 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t fprintf(jsonfile, "%s{" "\"type\":\"%s\",\"name\":\"%s\",\"optional\":%s," "\"external\":%s,\"pointer\":%s,\"void_star\":%s," - "\"struct_star\":%s,\"heim_object\":%s," + "\"struct_star\":%s," "\"copy_function\":\"%s\"," "\"free_function\":\"%s\",\"header_name\":%s%s%s" "}", @@ -1444,7 +1444,7 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t deco.field_type, deco.field_name, deco.opt ? "true" : "false", deco.ext ? "true" : "false", deco.ptr ? "true" : "false", deco.void_star ? "true" : "false", - deco.struct_star ? "true" : "false", deco.heim_object ? "true" : "false", + deco.struct_star ? "true" : "false", deco.copy_function_name ? deco.copy_function_name : "", deco.free_function_name ? deco.free_function_name : "", deco.header_name && deco.header_name[0] == '"' ? "" : "\"", @@ -1578,7 +1578,7 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t fprintf(jsonfile, "%s{" "\"type\":\"%s\",\"name\":\"%s\",\"optional\":%s," "\"external\":%s,\"pointer\":%s,\"void_star\":%s," - "\"struct_star\":%s,\"heim_object\":%s," + "\"struct_star\":%s," "\"copy_function\":\"%s\"," "\"free_function\":\"%s\",\"header_name\":%s%s%s" "}", @@ -1586,7 +1586,7 @@ define_type(int level, const char *name, const char *basename, Type *pt, Type *t deco.field_type, deco.field_name, deco.opt ? "true" : "false", deco.ext ? "true" : "false", deco.ptr ? "true" : "false", deco.void_star ? "true" : "false", - deco.struct_star ? "true" : "false", deco.heim_object ? "true" : "false", + deco.struct_star ? "true" : "false", deco.copy_function_name ? deco.copy_function_name : "", deco.free_function_name ? deco.free_function_name : "", deco.header_name && deco.header_name[0] == '"' ? "" : "\"", diff --git a/lib/asn1/gen_copy.c b/lib/asn1/gen_copy.c index 47cda3972..bec6f8b05 100644 --- a/lib/asn1/gen_copy.c +++ b/lib/asn1/gen_copy.c @@ -242,10 +242,7 @@ generate_type_copy (const Symbol *s) s->gen_name, s->gen_name, s->gen_name); copy_type ("from", "to", s->type, preserve); while (decorate_type(s->gen_name, &deco, &more_deco)) { - if (deco.heim_object) { - fprintf(codefile, "(to)->%s = heim_retain((from)->%s);\n", - deco.field_name, deco.field_name); - } else if (deco.ext && deco.copy_function_name == NULL) { + if (deco.ext && deco.copy_function_name == NULL) { /* Decorated with field of external type but no copy function */ if (deco.ptr) fprintf(codefile, "(to)->%s = 0;\n", deco.field_name); diff --git a/lib/asn1/gen_free.c b/lib/asn1/gen_free.c index f0d282038..0507d5421 100644 --- a/lib/asn1/gen_free.c +++ b/lib/asn1/gen_free.c @@ -190,10 +190,7 @@ generate_type_free (const Symbol *s) free_type ("data", s->type, preserve); while (decorate_type(s->gen_name, &deco, &more_deco)) { - if (deco.heim_object) { - fprintf(codefile, "heim_release((data)->%s);\n", deco.field_name); - fprintf(codefile, "(data)->%s = 0;\n", deco.field_name); - } else if (deco.ext && deco.free_function_name == NULL) { + if (deco.ext && deco.free_function_name == NULL) { /* Decorated with field of external type but no free function */ if (deco.ptr) fprintf(codefile, "(data)->%s = 0;\n", deco.field_name); diff --git a/lib/asn1/gen_locl.h b/lib/asn1/gen_locl.h index b46b9aa48..f37f14903 100644 --- a/lib/asn1/gen_locl.h +++ b/lib/asn1/gen_locl.h @@ -158,7 +158,6 @@ struct decoration { unsigned int ptr:1; /* external, pointer */ unsigned int void_star:1; /* external, void * */ unsigned int struct_star:1; /* external, struct foo * */ - unsigned int heim_object:1; /* external, heim_object_t */ }; int decorate_type(const char *, struct decoration *, ssize_t *); diff --git a/lib/asn1/gen_template.c b/lib/asn1/gen_template.c index a63de8242..883eab4b6 100644 --- a/lib/asn1/gen_template.c +++ b/lib/asn1/gen_template.c @@ -1125,10 +1125,7 @@ template_members(struct templatehead *temp, poffset2 = partial_offset(basetype, deco.field_name, 1, isstruct); - if (deco.ext && deco.heim_object) { - add_line_string(temp, "0", poffset2, - "A1_OP_TYPE_DECORATE_EXTERN |A1_FLAG_HEIM_OBJ"); - } else if (deco.ext) { + if (deco.ext) { char *ptr = NULL; /* Decorated with external C type */ @@ -1206,10 +1203,7 @@ template_members(struct templatehead *temp, poffset2 = partial_offset(basetype, deco.field_name, 1, isstruct); - if (deco.ext && deco.heim_object) { - add_line_string(temp, "0", poffset2, - "A1_OP_TYPE_DECORATE_EXTERN |A1_FLAG_HEIM_OBJ"); - } else if (deco.ext) { + if (deco.ext) { char *ptr = NULL; /* Decorated with external C type */ @@ -1411,10 +1405,7 @@ template_members(struct templatehead *temp, poffset2 = partial_offset(basetype, deco.field_name, 1, isstruct); - if (deco.ext && deco.heim_object) { - add_line_string(temp, "0", poffset2, - "A1_OP_TYPE_DECORATE_EXTERN |A1_FLAG_HEIM_OBJ"); - } else if (deco.ext) { + if (deco.ext) { char *ptr = NULL; /* Decorated with external C type */ @@ -1582,26 +1573,23 @@ generate_template(const Symbol *s) while (decorate_type(s->gen_name, &deco, &more_deco)) { if (!deco.ext) continue; - if (deco.heim_object) - fprintf(f, "#include \n"); - else if (deco.void_star && deco.header_name) + if (deco.void_star && deco.header_name) fprintf(f, "#include %s\n", deco.header_name); - if (!deco.heim_object) - fprintf(f, - "static const struct asn1_type_func asn1_extern_%s_%s = {\n" - "\t(asn1_type_encode)0,\n" - "\t(asn1_type_decode)0,\n" - "\t(asn1_type_length)0,\n" - "\t(asn1_type_copy)%s,\n" - "\t(asn1_type_release)%s,\n" - "\t(asn1_type_print)0,\n" - "\tsizeof(%s)\n" - "};\n", s->gen_name, deco.field_name, - deco.copy_function_name && deco.copy_function_name[0] ? - deco.copy_function_name : "0", - deco.free_function_name && deco.free_function_name[0] ? - deco.free_function_name : "0", - deco.void_star ? "void *" : deco.field_type); + fprintf(f, + "static const struct asn1_type_func asn1_extern_%s_%s = {\n" + "\t(asn1_type_encode)0,\n" + "\t(asn1_type_decode)0,\n" + "\t(asn1_type_length)0,\n" + "\t(asn1_type_copy)%s,\n" + "\t(asn1_type_release)%s,\n" + "\t(asn1_type_print)0,\n" + "\tsizeof(%s)\n" + "};\n", s->gen_name, deco.field_name, + deco.copy_function_name && deco.copy_function_name[0] ? + deco.copy_function_name : "0", + deco.free_function_name && deco.free_function_name[0] ? + deco.free_function_name : "0", + deco.void_star ? "void *" : deco.field_type); free(deco.field_type); } diff --git a/lib/asn1/main.c b/lib/asn1/main.c index c3ba995ad..bcfdad62e 100644 --- a/lib/asn1/main.c +++ b/lib/asn1/main.c @@ -189,7 +189,7 @@ decorate_type(const char *p, struct decoration *deco, ssize_t *more) deco->decorated = 1; deco->opt = deco->ext = deco->ptr = 0; - deco->void_star = deco->struct_star = deco->heim_object = 0; + deco->void_star = deco->struct_star = 0; deco->field_name = deco->copy_function_name = deco->free_function_name = deco->header_name = NULL; @@ -216,9 +216,6 @@ decorate_type(const char *p, struct decoration *deco, ssize_t *more) deco->ext = deco->ptr = deco->void_star = 1; deco->opt = 1; deco->header_name = NULL; - } else if (strcmp(deco->field_type, "heim_object_t") == 0) { - deco->ptr = deco->heim_object = 1; - deco->header_name = ""; } else if (strncmp(deco->field_type, "struct ", sizeof("struct ") - 1) == 0 && deco->field_type[strlen(deco->field_type) - 1] == '*') deco->ptr = deco->struct_star = 1; diff --git a/lib/asn1/template.c b/lib/asn1/template.c index c9e4e0ec8..7a19e7477 100644 --- a/lib/asn1/template.c +++ b/lib/asn1/template.c @@ -2283,10 +2283,7 @@ _asn1_free(const struct asn1_template *t, void *data) /* A1_OP_TYPE_DECORATE_EXTERN */ const struct asn1_type_func *f = t->ptr; - if (t->tt & A1_FLAG_HEIM_OBJ) { - heim_release(*(void **)el); - *(void **)el = 0; - } else if (f && f->release) + if (f && f->release) (f->release)(el); else if (f) memset(el, 0, f->size); @@ -2920,9 +2917,7 @@ _asn1_copy(const struct asn1_template *t, const void *from, void *to) const struct asn1_type_func *f = t->ptr; /* A1_OP_TYPE_DECORATE_EXTERN */ - if (t->tt & A1_FLAG_HEIM_OBJ) - *(heim_object_t *)tel = heim_retain(*(void **)fel); - else if (f && f->copy) + if (f && f->copy) ret = (f->copy)(fel, tel); else if (f) memset(tel, 0, f->size); diff --git a/lib/asn1/test.opt b/lib/asn1/test.opt index f261d4cdd..755eba01b 100644 --- a/lib/asn1/test.opt +++ b/lib/asn1/test.opt @@ -2,8 +2,6 @@ --decorate=TESTDecorated:TESTuint32:version2? --decorate=TESTDecorated:my_vers:version3:my_copy_vers:my_free_vers:"check-gen.h" --decorate=TESTDecorated:void *:privthing ---decorate=TESTDecorated:heim_object_t:privobj --decorate=TESTDecoratedChoice:TESTuint32:version2? --decorate=TESTDecoratedChoice:my_vers:version3:my_copy_vers:my_free_vers:"check-gen.h" --decorate=TESTDecoratedChoice:void *:privthing ---decorate=TESTDecoratedChoice:heim_object_t:privobj