# HG changeset patch # User Mychaela Falconia # Date 1454175080 0 # Node ID c977d637f03890736fdff9672e5ca8358d15bbb8 # Parent 8fa304e2b7e1073169811a7793f960a00fc11369 pads2gpcb: decals/* writing implemented diff -r 8fa304e2b7e1 -r c977d637f038 pads2gpcb/decals.c --- a/pads2gpcb/decals.c Sat Jan 30 08:23:35 2016 +0000 +++ b/pads2gpcb/decals.c Sat Jan 30 17:31:20 2016 +0000 @@ -255,6 +255,40 @@ } static void +write_decal_as_element() +{ + char *filename, *cp, *dp; + int c; + FILE *outf; + + filename = malloc(strlen(current_decal->name) * 3 + 8); + if (!filename) { + perror("malloc for output file name"); + exit(1); + } + strcpy(filename, "decals/"); + dp = filename + 7; + for (cp = current_decal->name; *cp; ) { + c = *cp++; + if (isalnum(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, current_decal->body, 0, "", "", "", 0); + fclose(outf); + free(filename); +} + +static void process_one_decal() { int num_drawing_pieces, num_padstack_defs; @@ -346,7 +380,8 @@ exit(1); } *current_decal->body = fpbody; - /* optional file output will go here */ + if (write_decal_files) + write_decal_as_element(); } else { printf("decal to gpcb fp conversion FAILED\n"); free(pins_array);