# HG changeset patch # User Mychaela Falconia # Date 1454307117 0 # Node ID ac13abc7dc0d56e6d906573e83d2471f9bf4e030 # Parent be1fe110b6ab904cd40f2d7a612491005100c3b7 pads2gpcb -f: saving of alphapins footprints implemented diff -r be1fe110b6ab -r ac13abc7dc0d pads2gpcb/parttype.c --- a/pads2gpcb/parttype.c Mon Feb 01 02:22:37 2016 +0000 +++ b/pads2gpcb/parttype.c Mon Feb 01 06:11:57 2016 +0000 @@ -152,6 +152,56 @@ } static void +write_alpha_pins_footprint() +{ + struct footprint_body *fpbody; + char *filename, *cp, *dp; + int c; + FILE *outf; + + if (our_parttype->ndecals != 1) { + printf( +"Warning: part type with alpha pins and multiple decals: save not supported\n"); + return; + } + fpbody = our_parttype->decals[0]->body; + if (!fpbody) + return; + if (our_parttype->num_alpha_pins != fpbody->npins) { + printf("Error: # of alpha pin names != # of actual pins\n"); + return; + } + + filename = malloc(strlen(our_parttype->name) * 3 + 11); + if (!filename) { + perror("malloc for output file name"); + exit(1); + } + strcpy(filename, "alphapins/"); + dp = filename + 10; + for (cp = our_parttype->name; *cp; ) { + c = *cp++; + if (isalnum(c) || c == '-' || c == '.' || c == '_') + *dp++ = c; + else { + sprintf(dp, "%%%02X", c); + dp += 3; + } + } + *dp = '\0'; + outf = fopen(filename, "w"); + if (!outf) { + perror(filename); + exit(1); + } + write_gpcb_element(outf, fpbody, our_parttype->alpha_pins, + "", "", "", 0); + fclose(outf); + printf("Written to %s\n", filename); + free(filename); +} + +static void process_one_parttype() { int i; @@ -164,6 +214,8 @@ if (our_parttype->num_alpha_pins) { alloc_alpha_pins_array(); read_alpha_pins(); + if (write_footprint_files) + write_alpha_pins_footprint(); } }