Index: altium/pcbdoc_bin.c =================================================================== --- altium/pcbdoc_bin.c (revision 35481) +++ altium/pcbdoc_bin.c (revision 35482) @@ -356,3 +356,81 @@ return 0; } +/* parse the fields of a pad (the 120 long block of pads6) */ +static int pcbdoc_bin_parse_pads6_fields(rnd_hidlib_t *hidlib, altium_tree_t *tree, altium_buf_t *tmp, const char *name) +{ + unsigned char *d = tmp->data; + + /* if layer[0] is 74 (multilayer), use all shapes, else use only top on the specified layer */ + + printf("pad: layer=%d..%d net=%ld (comp=%ld) '%s'\n", d[0], d[1], load_int(d+3, 2), load_int(d+7, 2), name); + printf(" x=%.2f y=%.2f hole=%.2f plated=%d mode=%d rot=%.3f\n", bmil(d+13), bmil(d+17), bmil(d+45), d[60], d[62], load_dbl(d+52)); + printf(" top: %d sx=%.2f sy=%.2f; mid: %d sx=%.2f sy=%.2f; bot: %d sx=%.2f mid-sy=%.2f\n", d[49], bmil(d+21), bmil(d+25), d[50], bmil(d+29), bmil(d+33), d[51], bmil(d+37), bmil(d+41)); + return 0; +} + +int pcbdoc_bin_parse_pads6(rnd_hidlib_t *hidlib, altium_tree_t *tree, ucdf_file_t *fp, altium_buf_t *tmp) +{ + for(;;) { + char rtype; + long res, slen; + + if ((res = ucdf_fread(fp, (void *)&rtype, 1)) != 1) + return res; + + if (rtype == 2) { + long len, name_len; + char name[260]; + int n; + + len = read_rec_l4b(fp, tmp); + if (len <= 0) + return len; + + /* 0: tmp is name */ + if (len >= 256) { + rnd_message(RND_MSG_ERROR, "pads6 name too long: %ld (truncating)\n", len); + len = 256; + } + tmp->data[len] = '\0'; + strcpy(name, tmp->data+1); + + for(n = 0; ; n++) { + len = read_rec_l4b(fp, tmp); +/* printf("len[%d]=%ld\n", n, len);*/ + if (len == 0) + break; + if (len < 0) + return len; +/* if ((n == 0)||(n == 2)) { printf("#%d: %d (len=%ld)\n", n, tmp->data[0], len); }*/ +/* if (n == 1) { printf("#%d: %d %d %d %d %d\n", n, tmp->data[0], tmp->data[1], tmp->data[2], tmp->data[3], tmp->data[4]); }*/ + if (n == 3) { + if (len < 120) + rnd_message(RND_MSG_ERROR, "pads6 record block3 with wrong lengt; expected 120, got %ld\n", len); + else if (pcbdoc_bin_parse_pads6_fields(hidlib, tree, tmp, name) != 0) + return -1; + } + } +/* printf("tell=%ld %x\n", ftell(fp), ftell(fp));*/ + } + else { /* not a pad */ + long len; + + fprintf(stderr, "non-pad object in padstack!\n"); + len = read_rec_l4b(fp, tmp); + if (len <= 0) + return len; + + TODO("read and handle snippet of slen in tmp"); + switch(rtype) { + case 1: /* arc */ + case 4: /* track */ + case 6: /* fill */ + break; + } + } + + } + return 0; +} + Index: altium/test.c =================================================================== --- altium/test.c (revision 35481) +++ altium/test.c (revision 35482) @@ -3,7 +3,7 @@ #include "pcbdoc_ascii.h" #include "pcbdoc_bin.h" -int pcbdoc_bin_parse_components6(rnd_hidlib_t *hidlib, altium_tree_t *tree, ucdf_file_t *fp, altium_buf_t *tmp); +int pcbdoc_bin_parse_pads6(rnd_hidlib_t *hidlib, altium_tree_t *tree, ucdf_file_t *fp, altium_buf_t *tmp); int main(int argc, char *argv[]) { @@ -20,7 +20,7 @@ exit(1); } - res = pcbdoc_bin_parse_components6(&hidlib, &tree, f, &tmp); + res = pcbdoc_bin_parse_pads6(&hidlib, &tree, f, &tmp); printf("res=%d @ %ld\n", res, ftell(f));