comparison pads2gpcb/parttype.c @ 79:ac13abc7dc0d

pads2gpcb -f: saving of alphapins footprints implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 01 Feb 2016 06:11:57 +0000
parents 2b71943a311b
children
comparison
equal deleted inserted replaced
78:be1fe110b6ab 79:ac13abc7dc0d
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 static void 154 static void
155 write_alpha_pins_footprint()
156 {
157 struct footprint_body *fpbody;
158 char *filename, *cp, *dp;
159 int c;
160 FILE *outf;
161
162 if (our_parttype->ndecals != 1) {
163 printf(
164 "Warning: part type with alpha pins and multiple decals: save not supported\n");
165 return;
166 }
167 fpbody = our_parttype->decals[0]->body;
168 if (!fpbody)
169 return;
170 if (our_parttype->num_alpha_pins != fpbody->npins) {
171 printf("Error: # of alpha pin names != # of actual pins\n");
172 return;
173 }
174
175 filename = malloc(strlen(our_parttype->name) * 3 + 11);
176 if (!filename) {
177 perror("malloc for output file name");
178 exit(1);
179 }
180 strcpy(filename, "alphapins/");
181 dp = filename + 10;
182 for (cp = our_parttype->name; *cp; ) {
183 c = *cp++;
184 if (isalnum(c) || c == '-' || c == '.' || c == '_')
185 *dp++ = c;
186 else {
187 sprintf(dp, "%%%02X", c);
188 dp += 3;
189 }
190 }
191 *dp = '\0';
192 outf = fopen(filename, "w");
193 if (!outf) {
194 perror(filename);
195 exit(1);
196 }
197 write_gpcb_element(outf, fpbody, our_parttype->alpha_pins,
198 "", "", "", 0);
199 fclose(outf);
200 printf("Written to %s\n", filename);
201 free(filename);
202 }
203
204 static void
155 process_one_parttype() 205 process_one_parttype()
156 { 206 {
157 int i; 207 int i;
158 208
159 process_header_line(); 209 process_header_line();
162 for (i = 0; i < nsignals; i++) 212 for (i = 0; i < nsignals; i++)
163 get_line_internal(); 213 get_line_internal();
164 if (our_parttype->num_alpha_pins) { 214 if (our_parttype->num_alpha_pins) {
165 alloc_alpha_pins_array(); 215 alloc_alpha_pins_array();
166 read_alpha_pins(); 216 read_alpha_pins();
217 if (write_footprint_files)
218 write_alpha_pins_footprint();
167 } 219 }
168 } 220 }
169 221
170 process_parttype_section() 222 process_parttype_section()
171 { 223 {