FreeCalypso > hg > ueda-linux
comparison pads2gpcb/decals.c @ 48:c977d637f038
pads2gpcb: decals/* writing implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 30 Jan 2016 17:31:20 +0000 |
parents | bf1be6c97c28 |
children | b3b7013d9228 |
comparison
equal
deleted
inserted
replaced
47:8fa304e2b7e1 | 48:c977d637f038 |
---|---|
253 } | 253 } |
254 return(-1); | 254 return(-1); |
255 } | 255 } |
256 | 256 |
257 static void | 257 static void |
258 write_decal_as_element() | |
259 { | |
260 char *filename, *cp, *dp; | |
261 int c; | |
262 FILE *outf; | |
263 | |
264 filename = malloc(strlen(current_decal->name) * 3 + 8); | |
265 if (!filename) { | |
266 perror("malloc for output file name"); | |
267 exit(1); | |
268 } | |
269 strcpy(filename, "decals/"); | |
270 dp = filename + 7; | |
271 for (cp = current_decal->name; *cp; ) { | |
272 c = *cp++; | |
273 if (isalnum(c) || c == '-' || c == '.') | |
274 *dp++ = c; | |
275 else { | |
276 sprintf(dp, "%%%02X", c); | |
277 dp += 3; | |
278 } | |
279 } | |
280 *dp = '\0'; | |
281 outf = fopen(filename, "w"); | |
282 if (!outf) { | |
283 perror(filename); | |
284 exit(1); | |
285 } | |
286 write_gpcb_element(outf, current_decal->body, 0, "", "", "", 0); | |
287 fclose(outf); | |
288 free(filename); | |
289 } | |
290 | |
291 static void | |
258 process_one_decal() | 292 process_one_decal() |
259 { | 293 { |
260 int num_drawing_pieces, num_padstack_defs; | 294 int num_drawing_pieces, num_padstack_defs; |
261 int num_text_items, num_attr_labels; | 295 int num_text_items, num_attr_labels; |
262 int i, valid; | 296 int i, valid; |
344 if (!current_decal->body) { | 378 if (!current_decal->body) { |
345 perror("malloc to save footprint body"); | 379 perror("malloc to save footprint body"); |
346 exit(1); | 380 exit(1); |
347 } | 381 } |
348 *current_decal->body = fpbody; | 382 *current_decal->body = fpbody; |
349 /* optional file output will go here */ | 383 if (write_decal_files) |
384 write_decal_as_element(); | |
350 } else { | 385 } else { |
351 printf("decal to gpcb fp conversion FAILED\n"); | 386 printf("decal to gpcb fp conversion FAILED\n"); |
352 free(pins_array); | 387 free(pins_array); |
353 } | 388 } |
354 } | 389 } |