Index: bom2.c =================================================================== --- bom2.c (revision 38016) +++ bom2.c (revision 38017) @@ -52,6 +52,7 @@ static const char *bom2_filename; +typedef pcb_subc_t bom_obj_t; #include "lib_bom.h" static const rnd_export_opt_t *bom2_get_export_options(rnd_hid_t *hid, int *n, rnd_design_t *dsg, void *appspec) @@ -84,7 +85,7 @@ if (strncmp(key, "subc.", 5) == 0) { key += 5; - if (strncmp(key, "a.", 2) == 0) return pcb_attribute_get(&ctx->subc->Attributes, key+2); + if (strncmp(key, "a.", 2) == 0) return pcb_attribute_get(&ctx->obj->Attributes, key+2); else if (strcmp(key, "name") == 0) return ctx->name; if (strcmp(key, "prefix") == 0) { static char tmp[256]; /* this is safe: caller will make a copy right after we return */ Index: lib_bom.c =================================================================== --- lib_bom.c (revision 38016) +++ lib_bom.c (revision 38017) @@ -104,7 +104,7 @@ /*** subst ***/ typedef struct bom_item_s { - pcb_subc_t *subc; /* one of the subcircuits picked randomly, for the attributes */ + bom_obj_t *obj; /* one of the objects picked randomly, for the attributes */ char *id; /* key for sorting */ gds_t refdes_list; long cnt; @@ -282,12 +282,12 @@ ctx->f = f; } -static void bom_print_add(bom_subst_ctx_t *ctx, pcb_subc_t *subc, const char *name) +static void bom_print_add(bom_subst_ctx_t *ctx, bom_obj_t *obj, const char *name) { char *id, *freeme; bom_item_t *i; - ctx->subc = subc; + ctx->obj = obj; ctx->name = (char *)name; id = freeme = render_templ(ctx, ctx->templ->sort_id); @@ -295,7 +295,7 @@ if (i == NULL) { i = malloc(sizeof(bom_item_t)); i->id = id; - i->subc = subc; + i->obj = obj; i->cnt = 1; gds_init(&i->refdes_list); @@ -319,13 +319,13 @@ long n; /* clean up and sort the array */ - ctx->subc = NULL; + ctx->obj = NULL; qsort(ctx->arr.array, ctx->arr.used, sizeof(bom_item_t *), item_cmp); /* produce the actual output from the sorted array */ for(n = 0; n < ctx->arr.used; n++) { bom_item_t *i = ctx->arr.array[n]; - ctx->subc = i->subc; + ctx->obj = i->obj; ctx->name = i->refdes_list.array; ctx->count = i->cnt; fprintf_templ(ctx->f, ctx, ctx->templ->item); Index: lib_bom.h =================================================================== --- lib_bom.h (revision 38016) +++ lib_bom.h (revision 38017) @@ -31,10 +31,15 @@ /*** subst ***/ + +/* The caller needs to typedef bom_obj_t to the app-specific object type that + is used as input for bom listings */ + + typedef struct { char utcTime[64]; char *name; - pcb_subc_t *subc; + bom_obj_t *obj; long count; gds_t tmp; const char *needs_escape; /* list of characters that need escaping */ @@ -50,6 +55,6 @@ /* Export a file; call begin, then loop over all items and call _add, then call _all and _end. */ static void bom_print_begin(bom_subst_ctx_t *ctx, FILE *f, const bom_template_t *templ); /* init ctx, print header */ -static void bom_print_add(bom_subst_ctx_t *ctx, pcb_subc_t *subc, const char *name); /* add an app_item */ +static void bom_print_add(bom_subst_ctx_t *ctx, bom_obj_t *obj, const char *name); /* add an app_item */ static void bom_print_all(bom_subst_ctx_t *ctx); /* sort and print all items */ static void bom_print_end(bom_subst_ctx_t *ctx); /* print footer and uninit ctx */