/* --------------------------------------------------------------------------- * writes data header * the name of the PCB, cursor location, zoom and grid * layergroups and some flags */ static void WritePCBDataHeader (FILE * FP) { Cardinal group; /* * ************************** README ******************* * ************************** README ******************* * * If the file format is modified in any way, update * PCB_FILE_VERSION in file.h * * ************************** README ******************* * ************************** README ******************* */ fprintf (FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); fprintf (FP, "FileVersion[%i]\n", PCB_FILE_VERSION); fputs ("\nPCB[", FP); PrintQuotedString (FP, (char *)EMPTY (PCB->Name)); fprintf (FP, " %i %i]\n\n", (int) PCB->MaxWidth, (int) PCB->MaxHeight); fprintf (FP, "Grid[%s %i %i %i]\n", c_dtostr (PCB->Grid), (int) PCB->GridOffsetX, (int) PCB->GridOffsetY, (int) Settings.DrawGrid); fprintf (FP, "Cursor[%i %i %s]\n", (int) TO_PCB_X (Output.Width / 2), (int) TO_PCB_Y (Output.Height / 2), c_dtostr (PCB->Zoom)); fprintf (FP, "PolyArea[%s]\n", c_dtostr (PCB->IsleArea)); fprintf (FP, "Thermal[%s]\n", c_dtostr (PCB->ThermScale)); fprintf (FP, "DRC[%i %i %i %i %i %i]\n", PCB->Bloat, PCB->Shrink, PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); fprintf (FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); fprintf (FP, "Groups(\"%s\")\n", LayerGroupsToString (&PCB->LayerGroups)); fputs ("Styles[\"", FP); for (group = 0; group < NUM_STYLES - 1; group++) fprintf (FP, "%s,%i,%i,%i,%i:", PCB->RouteStyle[group].Name, PCB->RouteStyle[group].Thick, PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); fprintf (FP, "%s,%i,%i,%i,%i\"]\n\n", PCB->RouteStyle[group].Name, PCB->RouteStyle[group].Thick, PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); }
/* --------------------------------------------------------------------------- * writes data header * the name of the PCB, cursor location, zoom and grid * layergroups and some flags */ static void WritePCBDataHeader (FILE * FP) { Cardinal group; /* * ************************** README ******************* * ************************** README ******************* * * If the file format is modified in any way, update * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded() * at the top of this file. * * ************************** README ******************* * ************************** README ******************* */ fprintf (FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); fprintf (FP, "FileVersion[%i]\n", PCBFileVersionNeeded ()); fputs ("\nPCB[", FP); PrintQuotedString (FP, (char *)EMPTY (PCB->Name)); pcb_fprintf (FP, " %mr %mr]\n\n", PCB->MaxWidth, PCB->MaxHeight); pcb_fprintf (FP, "Grid[%.1mr %mr %mr %d]\n", PCB->Grid, PCB->GridOffsetX, PCB->GridOffsetY, Settings.DrawGrid); pcb_fprintf (FP, "Cursor[%mr %mr %s]\n", Crosshair.X, Crosshair.Y, c_dtostr (PCB->Zoom)); /* PolyArea should be output in square cmils, no suffix */ fprintf (FP, "PolyArea[%s]\n", c_dtostr (COORD_TO_MIL (COORD_TO_MIL (PCB->IsleArea) * 100) * 100)); pcb_fprintf (FP, "Thermal[%s]\n", c_dtostr (PCB->ThermScale)); pcb_fprintf (FP, "DRC[%mr %mr %mr %mr %mr %mr]\n", PCB->Bloat, PCB->Shrink, PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); fprintf (FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); fprintf (FP, "Groups(\"%s\")\n", LayerGroupsToString (&PCB->LayerGroups)); fputs ("Styles[\"", FP); for (group = 0; group < NUM_STYLES - 1; group++) pcb_fprintf (FP, "%s,%mr,%mr,%mr,%mr:", PCB->RouteStyle[group].Name, PCB->RouteStyle[group].Thick, PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); pcb_fprintf (FP, "%s,%mr,%mr,%mr,%mr\"]\n\n", PCB->RouteStyle[group].Name, PCB->RouteStyle[group].Thick, PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); }
int main () { time_t now; int i; int errors = 0, count = 0; time (&now); srandom ((unsigned int) now + getpid ()); grow_layer_list (0); for (i = 0; i < 16; i++) { int j; char *p; if (i != 1 && i != 4 && i != 5 && i != 9) set_layer_list (i, 1); else set_layer_list (i, 0); p = print_layer_list (); printf ("%2d : %20s =", i, p); parse_layer_list (p + 1, 0); for (j = 0; j < num_layers; j++) printf (" %d", layers[j]); printf ("\n"); } while (count < 1000000) { FlagHolder fh; char *str; FlagType new_flags; int i; int otype; otype = ALL_TYPES; fh.Flags = empty_flags; for (i = 0; i < ENTRIES (object_flagbits); i++) { if (TEST_FLAG (object_flagbits[i].mask, &fh)) continue; if ((otype & object_flagbits[i].object_types) == 0) continue; if ((random () & 4) == 0) continue; otype &= object_flagbits[i].object_types; SET_FLAG (object_flagbits[i].mask, &fh); } if (otype & PIN_TYPES) for (i = 0; i < MAX_LAYER; i++) if (random () & 4) ASSIGN_THERM (i, 3, &fh); str = flags_to_string (fh.Flags, otype); new_flags = string_to_flags (str, 0); count++; if (FLAGS_EQUAL (fh.Flags, new_flags)) continue; dump_flag (&fh.Flags); printf (" "); dump_flag (&new_flags); printf ("\n"); if (++errors == 5) exit (1); } while (count < 1000000) { FlagHolder fh; char *str; FlagType new_flags; int i; int otype; otype = ALL_TYPES; fh.Flags = empty_flags; for (i = 0; i < ENTRIES (pcb_flagbits); i++) { if (TEST_FLAG (pcb_flagbits[i].mask, &fh)) continue; if ((random () & 4) == 0) continue; otype &= pcb_flagbits[i].object_types; SET_FLAG (pcb_flagbits[i].mask, &fh); } str = pcbflags_to_string (fh.Flags); new_flags = string_to_pcbflags (str, 0); count++; if (FLAGS_EQUAL (fh.Flags, new_flags)) continue; dump_flag (&fh.Flags); printf (" "); dump_flag (&new_flags); printf ("\n"); if (++errors == 5) exit (1); } printf ("%d out of %d failed\n", errors, count); return errors; }