4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996, 2004 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
28 /* main program, initializes some stuff and handles user input
35 #include <locale.h> /* setlocale() and LC_ALL */
44 #include <time.h> /* Seed for srand() */
50 #include "crosshair.h"
57 #include "lrealpath.h"
58 #include "free_atexit.h"
60 #include "pcb-printf.h"
62 #include "hid/common/actions.h"
64 /* This next one is so we can print the help messages. */
65 #include "hid/hidint.h"
75 #ifdef HAVE_LIBDMALLOC
79 #define PCBLIBPATH ".:" PCBLIBDIR
83 extern void stroke_init (void);
87 /* ----------------------------------------------------------------------
88 * initialize signal and error handlers
94 signal(SIGHUP, CatchSignal);
95 signal(SIGQUIT, CatchSignal);
96 signal(SIGABRT, CatchSignal);
97 signal(SIGSEGV, CatchSignal);
98 signal(SIGTERM, CatchSignal);
99 signal(SIGINT, CatchSignal);
102 /* calling external program by popen() may cause a PIPE signal,
106 signal (SIGPIPE
, SIG_IGN
);
111 /* ----------------------------------------------------------------------
112 | command line and rc file processing.
114 static char *command_line_pcb
;
120 " COPYRIGHT for %s version %s\n\n"
121 " PCB, interactive printed circuit board design\n"
122 " Copyright (C) 1994,1995,1996,1997 Thomas Nau\n"
123 " Copyright (C) 1998, 1999, 2000 Harry Eaton\n\n"
124 " This program is free software; you can redistribute it and/or modify\n"
125 " it under the terms of the GNU General Public License as published by\n"
126 " the Free Software Foundation; either version 2 of the License, or\n"
127 " (at your option) any later version.\n\n"
128 " This program is distributed in the hope that it will be useful,\n"
129 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
130 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
131 " GNU General Public License for more details.\n\n"
132 " You should have received a copy of the GNU General Public License\n"
133 " along with this program; if not, write to the Free Software\n"
134 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n",
140 u (const char *fmt
, ...)
144 vfprintf (stderr
, fmt
, ap
);
145 fputc ('\n', stderr
);
149 typedef struct UsageNotes
{
150 struct UsageNotes
*next
;
154 static UsageNotes
*usage_notes
= NULL
;
157 usage_attr (HID_Attribute
* a
)
160 const Unit
*unit_list
;
161 static char buf
[200];
163 if (a
->help_text
== ATTR_UNDOCUMENTED
)
172 sprintf (buf
, "--%s <num>", a
->name
);
175 sprintf (buf
, "--%s <measure>", a
->name
);
178 sprintf (buf
, "--%s <string>", a
->name
);
181 sprintf (buf
, "--%s", a
->name
);
185 sprintf (buf
, "--%s ", a
->name
);
186 if (a
->type
== HID_Mixed
)
187 strcat (buf
, " <val>");
188 for (i
= 0; a
->enumerations
[i
]; i
++)
190 strcat (buf
, i
? "|" : "<");
191 strcat (buf
, a
->enumerations
[i
]);
196 sprintf (buf
, "--%s <path>", a
->name
);
199 unit_list
= get_unit_list ();
201 sprintf (buf
, "--%s ", a
->name
);
202 for (i
= 0; i
< n
; i
++)
204 strcat (buf
, i
? "|" : "<");
205 strcat (buf
, unit_list
[i
].suffix
);
211 if (strlen (buf
) <= 30)
214 fprintf (stderr
, " %-30s\t%s\n", buf
, a
->help_text
);
216 fprintf (stderr
, " %-30s\n", buf
);
218 else if (a
->help_text
&& strlen (a
->help_text
) + strlen (buf
) < 72)
219 fprintf (stderr
, " %s\t%s\n", buf
, a
->help_text
);
220 else if (a
->help_text
)
221 fprintf (stderr
, " %s\n\t\t\t%s\n", buf
, a
->help_text
);
223 fprintf (stderr
, " %s\n", buf
);
229 HID_Attribute
*attributes
;
230 int i
, n_attributes
= 0;
235 fprintf (stderr
, "\n%s gui options:\n", h
->name
);
236 attributes
= h
->get_export_options (&n_attributes
);
240 fprintf (stderr
, "\n%s options:\n", h
->name
);
242 attributes
= exporter
->get_export_options (&n_attributes
);
246 note
= (UsageNotes
*)malloc (sizeof (UsageNotes
));
247 note
->next
= usage_notes
;
248 note
->seen
= attributes
;
251 for (i
= 0; i
< n_attributes
; i
++)
252 usage_attr (attributes
+ i
);
258 HID
**hl
= hid_enumerate ();
262 int n_printer
= 0, n_gui
= 0, n_exporter
= 0;
264 for (i
= 0; hl
[i
]; i
++)
274 u ("PCB Printed Circuit Board editing program, http://pcb.geda-project.org");
275 u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname
);
276 u ("%s [gui options] <pcb file>\t\tto edit", Progname
);
277 u ("Available GUI hid%s:", n_gui
== 1 ? "" : "s");
278 for (i
= 0; hl
[i
]; i
++)
280 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
281 u ("%s -p [printing options] <pcb file>\tto print", Progname
);
282 u ("Available printing hid%s:", n_printer
== 1 ? "" : "s");
283 for (i
= 0; hl
[i
]; i
++)
285 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
286 u ("%s -x hid [export options] <pcb file>\tto export", Progname
);
287 u ("Available export hid%s:", n_exporter
== 1 ? "" : "s");
288 for (i
= 0; hl
[i
]; i
++)
290 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
292 for (i
= 0; hl
[i
]; i
++)
295 for (i
= 0; hl
[i
]; i
++)
298 for (i
= 0; hl
[i
]; i
++)
302 u ("\nCommon options:");
303 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
305 for (note
= usage_notes
; note
&& note
->seen
!= ha
->attributes
; note
= note
->next
)
309 for (i
= 0; i
< ha
->n
; i
++)
311 usage_attr (ha
->attributes
+ i
);
319 print_defaults_1 (HID_Attribute
* a
, void *value
)
326 /* Remember, at this point we've parsed the command line, so they
327 may be in the global variable instead of the default_val. */
331 i
= value
? *(int *) value
: a
->default_val
.int_value
;
332 fprintf (stderr
, "%s %d\n", a
->name
, i
);
335 i
= value
? *(char *) value
: a
->default_val
.int_value
;
336 fprintf (stderr
, "%s %s\n", a
->name
, i
? "yes" : "no");
339 d
= value
? *(double *) value
: a
->default_val
.real_value
;
340 fprintf (stderr
, "%s %g\n", a
->name
, d
);
343 c
= value
? *(Coord
*) value
: a
->default_val
.coord_value
;
344 pcb_fprintf (stderr
, "%s %$mS\n", a
->name
, c
);
348 s
= value
? *(char **) value
: a
->default_val
.str_value
;
349 fprintf (stderr
, "%s \"%s\"\n", a
->name
, s
);
352 i
= value
? *(int *) value
: a
->default_val
.int_value
;
353 fprintf (stderr
, "%s %s\n", a
->name
, a
->enumerations
[i
]);
357 ((HID_Attr_Val
*)value
)->int_value
: a
->default_val
.int_value
;
359 ((HID_Attr_Val
*)value
)->real_value
: a
->default_val
.real_value
;
360 fprintf (stderr
, "%s %g%s\n", a
->name
, d
, a
->enumerations
[i
]);
365 i
= value
? *(int *) value
: a
->default_val
.int_value
;
366 fprintf (stderr
, "%s %s\n", a
->name
, get_unit_list()[i
].suffix
);
373 HID
**hl
= hid_enumerate ();
377 for (hi
= 0; hl
[hi
]; hi
++)
383 fprintf (stderr
, "\ngui defaults:\n");
384 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
385 for (i
= 0; i
< ha
->n
; i
++)
386 print_defaults_1 (ha
->attributes
+ i
, ha
->attributes
[i
].value
);
390 fprintf (stderr
, "\n%s defaults:\n", h
->name
);
392 e
= exporter
->get_export_options (&n
);
395 for (i
= 0; i
< n
; i
++)
396 print_defaults_1 (e
+ i
, 0);
402 #define SSET(F,D,N,H) { N, H, \
403 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
404 #define ISET(F,D,N,H) { N, H, \
405 HID_Integer, 0, 0, { D, 0, 0 }, 0, &Settings.F }
406 #define BSET(F,D,N,H) { N, H, \
407 HID_Boolean, 0, 0, { D, 0, 0 }, 0, &Settings.F }
408 #define RSET(F,D,N,H) { N, H, \
409 HID_Real, 0, 0, { 0, 0, D }, 0, &Settings.F }
410 #define CSET(F,D,N,H) { N, H, \
411 HID_Coord, 0, 0, { 0, 0, 0, D }, 0, &Settings.F }
413 #define COLOR(F,D,N,H) { N, H, \
414 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
415 #define LAYERCOLOR(N,D) { "layer-color-" #N, "Color for layer " #N, \
416 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.LayerColor[N-1] }
417 #define LAYERNAME(N,D) { "layer-name-" #N, "Name for layer " #N, \
418 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.DefaultLayerName[N-1] }
419 #define LAYERSELCOLOR(N) { "layer-selected-color-" #N, "Color for layer " #N " when selected", \
420 HID_String, 0, 0, { 0, "#00ffff", 0 }, 0, &Settings.LayerSelectedColor[N-1] }
422 static int show_help
= 0;
423 static int show_version
= 0;
424 static int show_copyright
= 0;
425 static int show_defaults
= 0;
426 static int show_actions
= 0;
427 static int do_dump_actions
= 0;
428 static char *grid_units
;
429 static Increments increment_mm
= { 0 };
430 static Increments increment_mil
= { 0 };
432 void save_increments (const Increments
*mm
, const Increments
*mil
)
434 memcpy (&increment_mm
, mm
, sizeof (*mm
));
435 memcpy (&increment_mil
, mil
, sizeof (*mil
));
438 HID_Attribute main_attribute_list
[] = {
440 /* %start-doc options "1 General Options"
443 Show help on command line options.
447 {"help", "Show help on command line options", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
450 /* %start-doc options "1 General Options"
457 {"version", "Show version", HID_Boolean
, 0, 0, {0, 0, 0}, 0, &show_version
},
459 /* %start-doc options "1 General Options"
462 Be verbose on stdout.
466 {"verbose", "Be verbose on stdout", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
469 /* %start-doc options "1 General Options"
476 {"copyright", "Show Copyright", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
479 /* %start-doc options "1 General Options"
481 @item --show-defaults
482 Show option defaults.
486 {"show-defaults", "Show option defaults", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
489 /* %start-doc options "1 General Options"
492 Show available actions and exit.
496 {"show-actions", "Show available actions", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
499 /* %start-doc options "1 General Options"
502 Dump actions (for documentation).
506 {"dump-actions", "Dump actions (for documentation)", HID_Boolean
, 0, 0,
507 {0, 0, 0}, 0, &do_dump_actions
},
509 /* %start-doc options "1 General Options"
511 @item --grid-units-mm <string>
512 Set default grid units. Can be mm or mil. Defaults to mil.
516 {"grid-units", "Default grid units (mm|mil)", HID_String
, 0, 0, {0, "mil", 0},
519 /* %start-doc options "1 General Options"
521 @item --clear-increment-mm <string>
522 Set default clear increment (amount to change when user presses k or K)
523 when user is using a metric grid unit.
527 {"clear-increment-mm", "Default clear increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
528 0, &increment_mm
.clear
},
530 /* %start-doc options "1 General Options"
532 @item --grid-increment-mm <string>
533 Set default grid increment (amount to change when user presses g or G)
534 when user is using a metric grid unit.
538 {"grid-increment-mm", "Default grid increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
539 0, &increment_mm
.grid
},
541 /* %start-doc options "1 General Options"
543 @item --line-increment-mm <string>
544 Set default line increment (amount to change when user presses l or L)
545 when user is using a metric grid unit.
549 {"line-increment-mm", "Default line increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
550 0, &increment_mm
.line
},
552 /* %start-doc options "1 General Options"
554 @item --size-increment-mm <string>
555 Set default size increment (amount to change when user presses s or S)
556 when user is using a metric grid unit.
560 {"size-increment-mm", "Default size increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
561 0, &increment_mm
.size
},
563 /* %start-doc options "1 General Options"
565 @item --clear-increment-mil <string>
566 Set default clear increment (amount to change when user presses k or K)
567 when user is using an imperial grid unit.
571 {"clear-increment-mil", "Default clear increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
572 0, &increment_mil
.clear
},
574 /* %start-doc options "1 General Options"
576 @item --grid-increment-mil <string>
577 Set default grid increment (amount to change when user presses g or G)
578 when user is using a imperial grid unit.
582 {"grid-increment-mil", "Default grid increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
583 0, &increment_mil
.grid
},
585 /* %start-doc options "1 General Options"
587 @item --line-increment-mil <string>
588 Set default line increment (amount to change when user presses l or L)
589 when user is using a imperial grid unit.
593 {"line-increment-mil", "Default line increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
594 0, &increment_mil
.line
},
596 /* %start-doc options "1 General Options"
598 @item --size-increment-mil <string>
599 Set default size increment (amount to change when user presses s or S)
600 when user is using a imperial grid unit.
604 {"size-increment-mil", "Default size increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
605 0, &increment_mil
.size
},
607 /* %start-doc options "3 Colors"
609 @item --black-color <string>
610 Color value for black. Default: @samp{#000000}
614 COLOR (BlackColor
, "#000000", "black-color", "color value of 'black'"),
616 /* %start-doc options "3 Colors"
618 @item --black-color <string>
619 Color value for white. Default: @samp{#ffffff}
623 COLOR (WhiteColor
, "#ffffff", "white-color", "color value of 'white'"),
625 /* %start-doc options "3 Colors"
627 @item --background-color <string>
628 Background color of the canvas. Default: @samp{#e5e5e5}
632 COLOR (BackgroundColor
, "#e5e5e5", "background-color",
633 "color for background"),
635 /* %start-doc options "3 Colors"
637 @item --crosshair-color <string>
638 Color of the crosshair. Default: @samp{#ff0000}
642 COLOR (CrosshairColor
, "#ff0000", "crosshair-color",
643 "color for the crosshair"),
645 /* %start-doc options "3 Colors"
647 @item --cross-color <string>
648 Color of the cross. Default: @samp{#cdcd00}
652 COLOR (CrossColor
, "#cdcd00", "cross-color", "color of the cross"),
654 /* %start-doc options "3 Colors"
656 @item --via-color <string>
657 Color of vias. Default: @samp{#7f7f7f}
661 COLOR (ViaColor
, "#7f7f7f", "via-color", "color of vias"),
663 /* %start-doc options "3 Colors"
665 @item --via-selected-color <string>
666 Color of selected vias. Default: @samp{#00ffff}
670 COLOR (ViaSelectedColor
, "#00ffff", "via-selected-color",
671 "color for selected vias"),
673 /* %start-doc options "3 Colors"
675 @item --pin-color <string>
676 Color of pins. Default: @samp{#4d4d4d}
680 COLOR (PinColor
, "#4d4d4d", "pin-color", "color of pins"),
682 /* %start-doc options "3 Colors"
684 @item --pin-selected-color <string>
685 Color of selected pins. Default: @samp{#00ffff}
689 COLOR (PinSelectedColor
, "#00ffff", "pin-selected-color",
690 "color of selected pins"),
692 /* %start-doc options "3 Colors"
694 @item --pin-name-color <string>
695 Color of pin names and pin numbers. Default: @samp{#ff0000}
699 COLOR (PinNameColor
, "#ff0000", "pin-name-color",
700 "color for pin names and pin numbers"),
702 /* %start-doc options "3 Colors"
704 @item --element-color <string>
705 Color of components. Default: @samp{#000000}
709 COLOR (ElementColor
, "#000000", "element-color", "color of components"),
711 /* %start-doc options "3 Colors"
713 @item --rat-color <string>
714 Color of ratlines. Default: @samp{#b8860b}
718 COLOR (RatColor
, "#b8860b", "rat-color", "color of ratlines"),
720 /* %start-doc options "3 Colors"
722 @item --invisible-objects-color <string>
723 Color of invisible objects. Default: @samp{#cccccc}
727 COLOR (InvisibleObjectsColor
, "#cccccc", "invisible-objects-color",
728 "color of invisible objects"),
730 /* %start-doc options "3 Colors"
732 @item --invisible-mark-color <string>
733 Color of invisible marks. Default: @samp{#cccccc}
737 COLOR (InvisibleMarkColor
, "#cccccc", "invisible-mark-color",
738 "color of invisible marks"),
740 /* %start-doc options "3 Colors"
742 @item --element-selected-color <string>
743 Color of selected components. Default: @samp{#00ffff}
747 COLOR (ElementSelectedColor
, "#00ffff", "element-selected-color",
748 "color of selected components"),
750 /* %start-doc options "3 Colors"
752 @item --rat-selected-color <string>
753 Color of selected rats. Default: @samp{#00ffff}
757 COLOR (RatSelectedColor
, "#00ffff", "rat-selected-color",
758 "color of selected rats"),
760 /* %start-doc options "3 Colors"
762 @item --connected-color <string>
763 Color to indicate connections. Default: @samp{#00ff00}
767 COLOR (ConnectedColor
, "#00ff00", "connected-color",
768 "color to indicate connections"),
770 /* %start-doc options "3 Colors"
772 @item --off-limit-color <string>
773 Color of off-canvas area. Default: @samp{#cccccc}
777 COLOR (OffLimitColor
, "#cccccc", "off-limit-color",
778 "color of off-canvas area"),
780 /* %start-doc options "3 Colors"
782 @item --grid-color <string>
783 Color of the grid. Default: @samp{#ff0000}
787 COLOR (GridColor
, "#ff0000", "grid-color", "color of the grid"),
789 /* %start-doc options "3 Colors"
791 @item --layer-color-<n> <string>
792 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
796 LAYERCOLOR (1, "#8b2323"),
797 LAYERCOLOR (2, "#3a5fcd"),
798 LAYERCOLOR (3, "#104e8b"),
799 LAYERCOLOR (4, "#cd3700"),
800 LAYERCOLOR (5, "#548b54"),
801 LAYERCOLOR (6, "#8b7355"),
802 LAYERCOLOR (7, "#00868b"),
803 LAYERCOLOR (8, "#228b22"),
804 LAYERCOLOR (9, "#8b2323"),
805 LAYERCOLOR (10, "#3a5fcd"),
806 LAYERCOLOR (11, "#104e8b"),
807 LAYERCOLOR (12, "#cd3700"),
808 LAYERCOLOR (13, "#548b54"),
809 LAYERCOLOR (14, "#8b7355"),
810 LAYERCOLOR (15, "#00868b"),
811 LAYERCOLOR (16, "#228b22"),
812 /* %start-doc options "3 Colors"
814 @item --layer-selected-color-<n> <string>
815 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
836 /* %start-doc options "3 Colors"
838 @item --warn-color <string>
839 Color of offending objects during DRC. Default value is @code{"#ff8000"}
843 COLOR (WarnColor
, "#ff8000", "warn-color", "color of offending objects during DRC"),
845 /* %start-doc options "3 Colors"
847 @item --mask-color <string>
848 Color of the mask layer. Default value is @code{"#ff0000"}
852 COLOR (MaskColor
, "#ff0000", "mask-color", "color for solder mask"),
855 /* %start-doc options "5 Sizes"
856 All parameters should be given with an unit. If no unit is given, 1/100 mil
857 (cmil) will be used. Write units without space to the
858 number like @code{3mm}, not @code{3 mm}.
882 @item --via-thickness <num>
883 Default diameter of vias. Default value is @code{60mil}.
887 CSET (ViaThickness
, MIL_TO_COORD(60), "via-thickness",
888 "default diameter of vias in 1/100 mil"),
890 /* %start-doc options "5 Sizes"
892 @item --via-drilling-hole <num>
893 Default diameter of holes. Default value is @code{28mil}.
897 CSET (ViaDrillingHole
, MIL_TO_COORD(28), "via-drilling-hole",
898 "default diameter of holes"),
900 /* %start-doc options "5 Sizes"
902 @item --line-thickness <num>
903 Default thickness of new lines. Default value is @code{10mil}.
907 CSET (LineThickness
, MIL_TO_COORD(10), "line-thickness",
908 "initial thickness of new lines"),
910 /* %start-doc options "5 Sizes"
912 @item --rat-thickness <num><unit>
913 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100
914 means "1 nm"). This option allows for a special unit @code{px} which
915 sets the rat thickness to a fixed value in terms of screen pixels.
916 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.
917 Default value is @code{10mil}.
921 CSET (RatThickness
, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
923 /* %start-doc options "5 Sizes"
925 @item --keepaway <num>
926 Default minimum distance between a track and adjacent copper.
927 Default value is @code{10mil}.
931 CSET (Keepaway
, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
933 /* %start-doc options "5 Sizes"
935 @item --default-PCB-width <num>
936 Default width of the canvas. Default value is @code{6000mil}.
940 CSET (MaxWidth
, MIL_TO_COORD(6000), "default-PCB-width",
941 "default width of the canvas"),
943 /* %start-doc options "5 Sizes"
945 @item --default-PCB-height <num>
946 Default height of the canvas. Default value is @code{5000mil}.
950 CSET (MaxHeight
, MIL_TO_COORD(5000), "default-PCB-height",
951 "default height of the canvas"),
953 /* %start-doc options "5 Sizes"
955 @item --text-scale <num>
956 Default text scale. This value is in percent. Default value is @code{100}.
960 ISET (TextScale
, 100, "text-scale", "default text scale in percent"),
962 /* %start-doc options "5 Sizes"
964 @item --alignment-distance <num>
965 Specifies the distance between the board outline and alignment targets.
966 Default value is @code{2mil}.
970 CSET (AlignmentDistance
, MIL_TO_COORD(2), "alignment-distance",
971 "distance between the boards outline and alignment targets"),
973 /* %start-doc options "7 DRC Options"
974 All parameters should be given with an unit. If no unit is given, 1/100 mil
975 (cmil) will be used for backward compability. Valid units are given in section
981 /* %start-doc options "7 DRC Options"
984 Minimum spacing. Default value is @code{10mil}.
988 CSET (Bloat
, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
990 /* %start-doc options "7 DRC Options"
993 Minimum touching overlap. Default value is @code{10mil}.
997 CSET (Shrink
, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
999 /* %start-doc options "7 DRC Options"
1001 @item --min-width <num>
1002 Minimum width of copper. Default value is @code{10mil}.
1006 CSET (minWid
, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1008 /* %start-doc options "7 DRC Options"
1010 @item --min-silk <num>
1011 Minimum width of lines in silk. Default value is @code{10mil}.
1015 CSET (minSlk
, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1017 /* %start-doc options "7 DRC Options"
1019 @item --min-drill <num>
1020 Minimum diameter of holes. Default value is @code{15mil}.
1024 CSET (minDrill
, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1026 /* %start-doc options "7 DRC Options"
1028 @item --min-ring <num>
1029 Minimum width of annular ring. Default value is @code{10mil}.
1033 CSET (minRing
, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1036 /* %start-doc options "5 Sizes"
1039 Initial grid size. Default value is @code{10mil}.
1043 CSET (Grid
, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1045 /* %start-doc options "5 Sizes"
1047 @item --minimum polygon area <num>
1048 Minimum polygon area.
1052 RSET (IsleArea
, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1055 /* %start-doc options "1 General Options"
1057 @item --backup-interval
1058 Time between automatic backups in seconds. Set to @code{0} to disable.
1059 The default value is @code{60}.
1063 ISET (BackupInterval
, 60, "backup-interval",
1064 "Time between automatic backups in seconds. Set to 0 to disable"),
1066 /* %start-doc options "4 Layer Names"
1068 @item --layer-name-1 <string>
1069 Name of the 1st Layer. Default is @code{"top"}.
1073 LAYERNAME (1, "top"),
1075 /* %start-doc options "4 Layer Names"
1077 @item --layer-name-2 <string>
1078 Name of the 2nd Layer. Default is @code{"ground"}.
1082 LAYERNAME (2, "ground"),
1084 /* %start-doc options "4 Layer Names"
1086 @item --layer-name-3 <string>
1087 Name of the 3nd Layer. Default is @code{"signal2"}.
1091 LAYERNAME (3, "signal2"),
1093 /* %start-doc options "4 Layer Names"
1095 @item --layer-name-4 <string>
1096 Name of the 4rd Layer. Default is @code{"signal3"}.
1100 LAYERNAME (4, "signal3"),
1102 /* %start-doc options "4 Layer Names"
1104 @item --layer-name-5 <string>
1105 Name of the 5rd Layer. Default is @code{"power"}.
1109 LAYERNAME (5, "power"),
1111 /* %start-doc options "4 Layer Names"
1113 @item --layer-name-6 <string>
1114 Name of the 6rd Layer. Default is @code{"bottom"}.
1118 LAYERNAME (6, "bottom"),
1120 /* %start-doc options "4 Layer Names"
1122 @item --layer-name-7 <string>
1123 Name of the 7rd Layer. Default is @code{"outline"}.
1127 LAYERNAME (7, "outline"),
1129 /* %start-doc options "4 Layer Names"
1131 @item --layer-name-8 <string>
1132 Name of the 8rd Layer. Default is @code{"spare"}.
1136 LAYERNAME (8, "spare"),
1138 /* %start-doc options "1 General Options"
1140 @item --groups <string>
1141 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1145 SSET (Groups
, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
1148 /* %start-doc options "6 Commands"
1149 pcb uses external commands for input output operations. These commands can be
1150 configured at start-up to meet local requirements. The command string may include
1151 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
1152 command is called. The sequence @code{%f} is replaced by the file name,
1153 @code{%p} gets the path and @code{%a} indicates a package name.
1157 /* %start-doc options "6 Commands"
1159 @item --font-command <string>
1160 Command to load a font.
1164 SSET (FontCommand
, "", "font-command", "Command to load a font"),
1166 /* %start-doc options "6 Commands"
1168 @item --file-command <string>
1169 Command to read a file.
1173 SSET (FileCommand
, "", "file-command", "Command to read a file"),
1175 /* %start-doc options "6 Commands"
1177 @item --element-command <string>
1178 Command to read a footprint. @*
1179 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1183 SSET (ElementCommand
,
1184 "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4
,
1185 "element-command", "Command to read a footprint"),
1187 /* %start-doc options "6 Commands"
1189 @item --print-file <string>
1190 Command to print to a file.
1194 SSET (PrintFile
, "%f.output", "print-file", "Command to print to a file"),
1196 /* %start-doc options "6 Commands"
1198 @item --lib-command-dir <string>
1199 Path to the command that queries the library.
1203 SSET (LibraryCommandDir
, PCBLIBDIR
, "lib-command-dir",
1204 "Path to the command that queries the library"),
1206 /* %start-doc options "6 Commands"
1208 @item --lib-command <string>
1209 Command to query the library. @*
1210 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1214 SSET (LibraryCommand
, "QueryLibrary.sh '%p' '%f' %a",
1215 "lib-command", "Command to query the library"),
1217 /* %start-doc options "6 Commands"
1219 @item --lib-contents-command <string>
1220 Command to query the contents of the library. @*
1221 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
1222 on Windows builds, an empty string (to disable this feature).
1226 SSET (LibraryContentsCommand
,
1230 "ListLibraryContents.sh '%p' '%f'",
1232 "lib-contents-command", "Command to query the contents of the library"),
1234 /* %start-doc options "5 Paths"
1236 @item --lib-newlib <string>
1237 Top level directory for the newlib style library.
1241 SSET (LibraryTree
, PCBTREEPATH
, "lib-newlib",
1242 "Top level directory for the newlib style library"),
1244 /* %start-doc options "6 Commands"
1246 @item --save-command <string>
1247 Command to save to a file.
1251 SSET (SaveCommand
, "", "save-command", "Command to save to a file"),
1253 /* %start-doc options "5 Paths"
1255 @item --lib-name <string>
1256 The default filename for the library.
1260 SSET (LibraryFilename
, LIBRARYFILENAME
, "lib-name",
1261 "The default filename for the library"),
1263 /* %start-doc options "5 Paths"
1265 @item --default-font <string>
1266 The name of the default font.
1270 SSET (FontFile
, "default_font", "default-font",
1271 "File name of default font"),
1273 /* %start-doc options "1 General Options"
1275 @item --route-styles <string>
1276 A string that defines the route styles. Defaults to @*
1277 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
1278 :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
1282 SSET (Routes
, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
1283 ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
1284 "A string that defines the route styles"),
1286 /* %start-doc options "5 Paths"
1288 @item --file-path <string>
1289 A colon separated list of directories or commands (starts with '|'). The path
1290 is passed to the program specified in @option{--file-command} together with the selected
1295 SSET (FilePath
, "", "file-path", 0),
1297 /* %start-doc options "6 Commands"
1299 @item --rat-command <string>
1300 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1304 SSET (RatCommand
, "", "rat-command", "Command for reading a netlist"),
1306 /* %start-doc options "5 Paths"
1308 @item --font-path <string>
1309 A colon separated list of directories to search the default font. Defaults to
1310 the default library path.
1314 SSET (FontPath
, PCBLIBPATH
, "font-path",
1315 "Colon separated list of directories to search the default font"),
1317 /* %start-doc options "1 General Options"
1319 @item --element-path <string>
1320 A colon separated list of directories or commands (starts with '|').
1321 The path is passed to the program specified in @option{--element-command}.
1325 SSET(ElementPath
, PCBLIBPATH
, "element-path",
1326 "A colon separated list of directories or commands (starts with '|')"),
1328 /* %start-doc options "5 Paths"
1330 @item --lib-path <string>
1331 A colon separated list of directories that will be passed to the commands specified
1332 by @option{--element-command} and @option{--element-contents-command}.
1336 SSET (LibraryPath
, PCBLIBPATH
, "lib-path",
1337 "A colon separated list of directories"),
1339 /* %start-doc options "1 General Options"
1341 @item --action-script <string>
1342 If set, this file is executed at startup.
1346 SSET (ScriptFilename
, 0, "action-script",
1347 "If set, this file is executed at startup"),
1349 /* %start-doc options "1 General Options"
1351 @item --action-string <string>
1352 If set, this string of actions is executed at startup.
1356 SSET (ActionString
, 0, "action-string",
1357 "If set, this is executed at startup"),
1359 /* %start-doc options "1 General Options"
1361 @item --fab-author <string>
1362 Name of author to be put in the Gerber files.
1366 SSET (FabAuthor
, "", "fab-author",
1367 "Name of author to be put in the Gerber files"),
1369 /* %start-doc options "1 General Options"
1371 @item --layer-stack <string>
1372 Initial layer stackup, for setting up an export. A comma separated list of layer
1373 names, layer numbers and layer groups.
1377 SSET (InitialLayerStack
, "", "layer-stack",
1378 "Initial layer stackup, for setting up an export."),
1380 SSET (MakeProgram
, NULL
, "make-program",
1381 "Sets the name and optionally full path to a make(3) program"),
1382 SSET (GnetlistProgram
, NULL
, "gnetlist",
1383 "Sets the name and optionally full path to the gnetlist(3) program"),
1385 /* %start-doc options "2 General GUI Options"
1387 @item --pinout-offset-x <num>
1388 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1392 CSET (PinoutOffsetX
, MIL_TO_COORD(1), "pinout-offset-x",
1393 "Horizontal offset of the pin number display in mil"),
1395 /* %start-doc options "2 General GUI Options"
1397 @item --pinout-offset-y <num>
1398 Vertical offset of the pin number display. Defaults to @code{100mil}.
1402 CSET (PinoutOffsetY
, MIL_TO_COORD(1), "pinout-offset-y",
1403 "Vertical offset of the pin number display in mil"),
1405 /* %start-doc options "2 General GUI Options"
1407 @item --pinout-text-offset-x <num>
1408 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1412 CSET (PinoutTextOffsetX
, MIL_TO_COORD(8), "pinout-text-offset-x",
1413 "Horizontal offset of the pin name display in mil"),
1415 /* %start-doc options "2 General GUI Options"
1417 @item --pinout-text-offset-y <num>
1418 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1422 CSET (PinoutTextOffsetY
, MIL_TO_COORD(-1), "pinout-text-offset-y",
1423 "Vertical offset of the pin name display in mil"),
1425 /* %start-doc options "2 General GUI Options"
1428 If set, draw the grid at start-up.
1432 BSET (DrawGrid
, 0, "draw-grid", "If set, draw the grid at start-up"),
1434 /* %start-doc options "2 General GUI Options"
1437 If set, new lines clear polygons.
1441 BSET (ClearLine
, 1, "clear-line", "If set, new lines clear polygons"),
1443 /* %start-doc options "2 General GUI Options"
1446 If set, new polygons are full ones.
1450 BSET (FullPoly
, 0, "full-poly", 0),
1452 /* %start-doc options "2 General GUI Options"
1454 @item --unique-names
1455 If set, you will not be permitted to change the name of an component to match that
1456 of another component.
1460 BSET (UniqueNames
, 1, "unique-names", "Prevents identical component names"),
1462 /* %start-doc options "2 General GUI Options"
1465 If set, pin centers and pad end points are treated as additional grid points
1466 that the cursor can snap to.
1470 BSET (SnapPin
, 1, "snap-pin",
1471 "If set, the cursor snaps to pads and pin centers"),
1473 /* %start-doc options "1 General Options"
1475 @item --save-last-command
1476 If set, the last user command is saved.
1480 BSET (SaveLastCommand
, 0, "save-last-command", 0),
1482 /* %start-doc options "1 General Options"
1485 If set, all data which would otherwise be lost are saved in a temporary file
1486 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
1490 BSET (SaveInTMP
, 0, "save-in-tmp",
1491 "When set, all data which would otherwise be lost are saved in /tmp"),
1493 /* %start-doc options "2 General GUI Options"
1495 @item --all-direction-lines
1496 Allow all directions, when drawing new lines.
1500 BSET (AllDirectionLines
, 0, "all-direction-lines",
1501 "Allow all directions, when drawing new lines"),
1503 /* %start-doc options "2 General GUI Options"
1506 Pinout shows number.
1510 BSET (ShowNumber
, 0, "show-number", "Pinout shows number"),
1512 /* %start-doc options "1 General Options"
1514 @item --reset-after-element
1515 If set, all found connections are reset before a new component is scanned.
1519 BSET (ResetAfterElement
, 1, "reset-after-element",
1520 "If set, all found connections are reset before a new component is scanned"),
1522 /* %start-doc options "1 General Options"
1524 @item --ring-bell-finished
1525 Execute the bell command when all rats are routed.
1529 BSET (RingBellWhenFinished
, 0, "ring-bell-finished",
1530 "Execute the bell command when all rats are routed"),
1533 REGISTER_ATTRIBUTES (main_attribute_list
)
1534 /* ----------------------------------------------------------------------
1535 * post-process settings.
1537 static void settings_post_process ()
1541 if (Settings
.LibraryCommand
!= NULL
&&
1542 Settings
.LibraryCommand
[0] != '\0' &&
1543 Settings
.LibraryCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1544 Settings
.LibraryCommand
[0] != '.')
1546 Settings
.LibraryCommand
1548 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1549 Settings
.LibraryCommand
,
1552 if (Settings
.LibraryContentsCommand
!= NULL
&&
1553 Settings
.LibraryContentsCommand
[0] != '\0' &&
1554 Settings
.LibraryContentsCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1555 Settings
.LibraryContentsCommand
[0] != '.')
1557 Settings
.LibraryContentsCommand
1559 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1560 Settings
.LibraryContentsCommand
, NULL
);
1563 if (Settings
.LineThickness
> MAX_LINESIZE
1564 || Settings
.LineThickness
< MIN_LINESIZE
)
1565 Settings
.LineThickness
= MIL_TO_COORD(10);
1567 if (Settings
.ViaThickness
> MAX_PINORVIASIZE
1568 || Settings
.ViaThickness
< MIN_PINORVIASIZE
)
1569 Settings
.ViaThickness
= MIL_TO_COORD(40);
1571 if (Settings
.ViaDrillingHole
<= 0)
1572 Settings
.ViaDrillingHole
=
1573 DEFAULT_DRILLINGHOLE
* Settings
.ViaThickness
/ 100;
1575 Settings
.MaxWidth
= CLAMP (Settings
.MaxWidth
, MIN_SIZE
, MAX_COORD
);
1576 Settings
.MaxHeight
= CLAMP (Settings
.MaxHeight
, MIN_SIZE
, MAX_COORD
);
1578 ParseRouteString (Settings
.Routes
, &Settings
.RouteStyle
[0], "cmil");
1581 * Make sure we have settings for some various programs we may wish
1584 if (Settings
.MakeProgram
== NULL
) {
1585 tmps
= getenv ("PCB_MAKE_PROGRAM");
1587 Settings
.MakeProgram
= strdup (tmps
);
1589 if (Settings
.MakeProgram
== NULL
) {
1590 Settings
.MakeProgram
= strdup ("make");
1593 if (Settings
.GnetlistProgram
== NULL
) {
1594 tmps
= getenv ("PCB_GNETLIST");
1596 Settings
.GnetlistProgram
= strdup (tmps
);
1598 if (Settings
.GnetlistProgram
== NULL
) {
1599 Settings
.GnetlistProgram
= strdup ("gnetlist");
1603 Settings
.grid_unit
= get_unit_struct (grid_units
);
1604 if (!grid_units
|| Settings
.grid_unit
== NULL
)
1605 Settings
.grid_unit
= get_unit_struct ("mil");
1607 copy_nonzero_increments (get_increments_struct (METRIC
), &increment_mm
);
1608 copy_nonzero_increments (get_increments_struct (IMPERIAL
), &increment_mil
);
1610 Settings
.increments
= get_increments_struct (Settings
.grid_unit
->family
);
1613 /* ----------------------------------------------------------------------
1614 * Print help or version messages.
1620 printf ("PCB version %s\n", VERSION
);
1624 /* ----------------------------------------------------------------------
1625 * Figure out the canonical name of the executed program
1626 * and fix up the defaults for various paths
1628 char *bindir
= NULL
;
1629 char *exec_prefix
= NULL
;
1630 char *pcblibdir
= NULL
;
1631 char *pcblibpath
= NULL
;
1632 char *pcbtreedir
= NULL
;
1633 char *pcbtreepath
= NULL
;
1634 char *homedir
= NULL
;
1637 InitPaths (char *argv0
)
1643 int found_bindir
= 0;
1645 /* see if argv0 has enough of a path to let lrealpath give the
1646 * real path. This should be the case if you invoke pcb with
1647 * something like /usr/local/bin/pcb or ./pcb or ./foo/pcb
1648 * but if you just use pcb and it exists in your path, you'll
1649 * just get back pcb again.
1653 for (i
= 0; i
< strlen (argv0
) ; i
++)
1655 if (argv0
[i
] == PCB_DIR_SEPARATOR_C
)
1660 printf ("InitPaths (%s): haspath = %d\n", argv0
, haspath
);
1665 bindir
= strdup (lrealpath (argv0
));
1670 char *path
, *p
, *tmps
;
1674 tmps
= getenv ("PATH");
1678 path
= strdup (tmps
);
1680 /* search through the font path for a font file */
1681 for (p
= strtok (path
, PCB_PATH_DELIMETER
); p
&& *p
;
1682 p
= strtok (NULL
, PCB_PATH_DELIMETER
))
1685 printf ("Looking for %s in %s\n", argv0
, p
);
1687 if ( (tmps
= (char *)malloc ( (strlen (argv0
) + strlen (p
) + 2) * sizeof (char))) == NULL
)
1689 fprintf (stderr
, "InitPaths(): malloc failed\n");
1692 sprintf (tmps
, "%s%s%s", p
, PCB_DIR_SEPARATOR_S
, argv0
);
1693 r
= stat (tmps
, &sb
);
1697 printf ("Found it: \"%s\"\n", tmps
);
1699 bindir
= lrealpath (tmps
);
1711 printf ("InitPaths(): bindir = \"%s\"\n", bindir
);
1716 /* strip off the executible name leaving only the path */
1718 t1
= strchr (bindir
, PCB_DIR_SEPARATOR_C
);
1719 while (t1
!= NULL
&& *t1
!= '\0')
1722 t1
= strchr (t2
+ 1, PCB_DIR_SEPARATOR_C
);
1728 printf ("After stripping off the executible name, we found\n");
1729 printf ("bindir = \"%s\"\n", bindir
);
1734 /* we have failed to find out anything from argv[0] so fall back to the original
1737 bindir
= strdup (BINDIR
);
1740 /* now find the path to exec_prefix */
1741 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_EXECPREFIX
) + 1;
1742 if ( (exec_prefix
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1744 fprintf (stderr
, "InitPaths(): malloc failed\n");
1747 sprintf (exec_prefix
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1748 BINDIR_TO_EXECPREFIX
);
1750 /* now find the path to PCBLIBDIR */
1751 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBLIBDIR
) + 1;
1752 if ( (pcblibdir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1754 fprintf (stderr
, "InitPaths(): malloc failed\n");
1757 sprintf (pcblibdir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1758 BINDIR_TO_PCBLIBDIR
);
1760 /* and the path to PCBTREEDIR */
1761 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBTREEDIR
) + 1;
1762 if ( (pcbtreedir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1764 fprintf (stderr
, "InitPaths(): malloc failed\n");
1767 sprintf (pcbtreedir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1768 BINDIR_TO_PCBTREEDIR
);
1770 /* and the search path including PCBLIBDIR */
1771 l
= strlen (pcblibdir
) + 3;
1772 if ( (pcblibpath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1774 fprintf (stderr
, "InitPaths(): malloc failed\n");
1777 sprintf (pcblibpath
, ".%s%s", PCB_PATH_DELIMETER
, pcblibdir
);
1779 /* and the newlib search path */
1780 l
= strlen (pcblibdir
) + 1 + strlen (pcbtreedir
)
1781 + strlen ("pcblib-newlib") + 2;
1782 if ( (pcbtreepath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1784 fprintf (stderr
, "InitPaths(): malloc failed\n");
1787 sprintf (pcbtreepath
, "%s%s%s%spcblib-newlib", pcbtreedir
,
1788 PCB_PATH_DELIMETER
, pcblibdir
,
1789 PCB_DIR_SEPARATOR_S
);
1792 printf ("bindir = %s\n", bindir
);
1793 printf ("pcblibdir = %s\n", pcblibdir
);
1794 printf ("pcblibpath = %s\n", pcblibpath
);
1795 printf ("pcbtreedir = %s\n", pcbtreedir
);
1796 printf ("pcbtreepath = %s\n", pcbtreepath
);
1799 l
= sizeof (main_attribute_list
) / sizeof (main_attribute_list
[0]);
1800 for (i
= 0; i
< l
; i
++)
1802 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-command-dir") == 0)
1804 main_attribute_list
[i
].default_val
.str_value
= pcblibdir
;
1807 if ( (NSTRCMP (main_attribute_list
[i
].name
, "font-path") == 0)
1808 || (NSTRCMP (main_attribute_list
[i
].name
, "element-path") == 0)
1809 || (NSTRCMP (main_attribute_list
[i
].name
, "lib-path") == 0) )
1811 main_attribute_list
[i
].default_val
.str_value
= pcblibpath
;
1814 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-newlib") == 0)
1816 main_attribute_list
[i
].default_val
.str_value
= pcbtreepath
;
1824 tmps
= getenv ("HOME");
1827 tmps
= getenv ("USERPROFILE");
1831 homedir
= strdup (tmps
);
1839 /* ----------------------------------------------------------------------
1843 char *program_name
= 0;
1844 char *program_basename
= 0;
1845 char *program_directory
= 0;
1847 #include "dolists.h"
1850 main (int argc
, char *argv
[])
1854 /* init application:
1855 * - make program name available for error handlers
1856 * - evaluate special options
1857 * - initialize toplevel shell and resources
1858 * - create an empty PCB with default symbols
1859 * - initialize all other widgets
1860 * - update screen and get size of drawing area
1861 * - evaluate command-line arguments
1862 * - register 'call on exit()' function
1865 #include "core_lists.h"
1867 InitPaths (argv
[0]);
1869 bindtextdomain (GETTEXT_PACKAGE
, LOCALEDIR
);
1870 textdomain(GETTEXT_PACKAGE
);
1871 bind_textdomain_codeset(GETTEXT_PACKAGE
, "UTF-8");
1872 setlocale(LC_ALL
,"");
1874 srand ( time(NULL
) ); /* Set seed for rand() */
1880 hid_load_settings ();
1882 program_name
= argv
[0];
1883 program_basename
= strrchr (program_name
, PCB_DIR_SEPARATOR_C
);
1884 if (program_basename
)
1886 program_directory
= strdup (program_name
);
1887 *strrchr (program_directory
, PCB_DIR_SEPARATOR_C
) = 0;
1892 program_directory
= ".";
1893 program_basename
= program_name
;
1895 Progname
= program_basename
;
1897 /* Print usage or version if requested. Then exit. */
1899 (strcmp (argv
[1], "-h") == 0 ||
1900 strcmp (argv
[1], "-?") == 0 ||
1901 strcmp (argv
[1], "--help") == 0))
1903 if (argc
> 1 && strcmp (argv
[1], "-V") == 0)
1905 /* Export pcb from command line if requested. */
1906 if (argc
> 1 && strcmp (argv
[1], "-p") == 0)
1908 exporter
= gui
= hid_find_printer ();
1912 else if (argc
> 2 && strcmp (argv
[1], "-x") == 0)
1914 exporter
= gui
= hid_find_exporter (argv
[2]);
1918 /* Otherwise start GUI. */
1920 gui
= hid_find_gui ();
1922 /* Exit with error if GUI failed to start. */
1926 /* Set up layers. */
1927 for (i
= 0; i
< MAX_LAYER
; i
++)
1930 sprintf (buf
, "signal%d", i
+ 1);
1931 Settings
.DefaultLayerName
[i
] = strdup (buf
);
1932 Settings
.LayerColor
[i
] = "#c49350";
1933 Settings
.LayerSelectedColor
[i
] = "#00ffff";
1936 gui
->parse_arguments (&argc
, &argv
);
1938 if (show_help
|| (argc
> 1 && argv
[1][0] == '-'))
1947 settings_post_process ();
1956 if (do_dump_actions
)
1958 extern void dump_actions (void);
1963 /* Create a new PCB object in memory */
1964 PCB
= CreateNewPCB (true);
1965 PCB
->Data
->LayerN
= DEF_LAYER
;
1966 ParseGroupString (Settings
.Groups
, &PCB
->LayerGroups
, DEF_LAYER
);
1967 /* Add silk layers to newly created PCB */
1968 CreateNewPCBPost (PCB
, 1);
1970 command_line_pcb
= argv
[1];
1972 ResetStackAndVisibility ();
1978 SetMode (ARROW_MODE
);
1980 if (command_line_pcb
)
1982 /* keep filename even if initial load command failed;
1983 * file might not exist
1985 if (LoadPCB (command_line_pcb
))
1986 PCB
->Filename
= strdup (command_line_pcb
);
1989 if (Settings
.InitialLayerStack
1990 && Settings
.InitialLayerStack
[0])
1992 LayerStringToLayerStack (Settings
.InitialLayerStack
);
1995 /* This must be called before any other atexit functions
1996 * are registered, as it configures an atexit function to
1997 * clean up and free various items of allocated memory,
1998 * and must be the last last atexit function to run.
2002 /* Register a function to be called when the program terminates.
2003 * This makes sure that data is saved even if LEX/YACC routines
2004 * abort the program.
2005 * If the OS doesn't have at least one of them,
2006 * the critical sections will be handled by parse_l.l
2008 atexit (EmergencySave
);
2010 /* read the library file and display it if it's not empty
2012 if (!ReadLibraryContents () && Library
.MenuN
)
2013 hid_action ("LibraryChanged");
2015 #ifdef HAVE_LIBSTROKE
2019 if (Settings
.ScriptFilename
)
2021 Message (_("Executing startup script file %s\n"),
2022 Settings
.ScriptFilename
);
2023 hid_actionl ("ExecuteFile", Settings
.ScriptFilename
, NULL
);
2025 if (Settings
.ActionString
)
2027 Message (_("Executing startup action %s\n"), Settings
.ActionString
);
2028 hid_parse_actions (Settings
.ActionString
);
2031 if (gui
->printer
|| gui
->exporter
)
2033 // Workaround to fix batch output for non-C locales
2034 setlocale(LC_NUMERIC
,"C");
2046 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2047 Settings
.LibraryCommandDir
);
2048 printf ("Settings.FontPath = \"%s\"\n",
2050 printf ("Settings.ElementPath = \"%s\"\n",
2051 Settings
.ElementPath
);
2052 printf ("Settings.LibraryPath = \"%s\"\n",
2053 Settings
.LibraryPath
);
2054 printf ("Settings.LibraryTree = \"%s\"\n",
2055 Settings
.LibraryTree
);
2056 printf ("Settings.MakeProgram = \"%s\"\n",
2057 UNKNOWN (Settings
.MakeProgram
));
2058 printf ("Settings.GnetlistProgram = \"%s\"\n",
2059 UNKNOWN (Settings
.GnetlistProgram
));