4 * \brief Main program, initializes some stuff and handles user input.
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996, 2004 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
29 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
30 * Thomas.Nau@rz.uni-ulm.de
45 #include <time.h> /* Seed for srand() */
51 #include "crosshair.h"
58 #include "lrealpath.h"
59 #include "free_atexit.h"
62 #include "pcb-printf.h"
64 #include "hid/common/actions.h"
66 /* This next one is so we can print the help messages. */
67 #include "hid/hidint.h"
73 #ifdef HAVE_LIBDMALLOC
77 #define PCBLIBPATH ".:" PCBLIBDIR
81 extern void stroke_init (void);
86 * \brief Initialize signal and error handlers.
92 signal(SIGHUP, CatchSignal);
93 signal(SIGQUIT, CatchSignal);
94 signal(SIGABRT, CatchSignal);
95 signal(SIGSEGV, CatchSignal);
96 signal(SIGTERM, CatchSignal);
97 signal(SIGINT, CatchSignal);
100 /* calling external program by popen() may cause a PIPE signal,
104 signal (SIGPIPE
, SIG_IGN
);
109 /* ----------------------------------------------------------------------
110 | command line and rc file processing.
112 static char *command_line_pcb
;
115 * \brief Print the copyright notice.
121 " COPYRIGHT for %s version %s\n\n"
122 " PCB, interactive printed circuit board design\n"
123 " Copyright (C) 1994,1995,1996,1997 Thomas Nau\n"
124 " Copyright (C) 1998, 1999, 2000 Harry Eaton\n\n"
125 " This program is free software; you can redistribute it and/or modify\n"
126 " it under the terms of the GNU General Public License as published by\n"
127 " the Free Software Foundation; either version 2 of the License, or\n"
128 " (at your option) any later version.\n\n"
129 " This program is distributed in the hope that it will be useful,\n"
130 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
131 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
132 " GNU General Public License for more details.\n\n"
133 " You should have received a copy of the GNU General Public License\n"
134 " along with this program; if not, write to the Free Software\n"
135 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n",
141 u (const char *fmt
, ...)
145 vfprintf (stderr
, fmt
, ap
);
146 fputc ('\n', stderr
);
150 typedef struct UsageNotes
{
151 struct UsageNotes
*next
;
155 static UsageNotes
*usage_notes
= NULL
;
158 usage_attr (HID_Attribute
* a
)
161 const Unit
*unit_list
;
162 static char buf
[200];
164 if (a
->help_text
== ATTR_UNDOCUMENTED
)
173 sprintf (buf
, "--%s <num>", a
->name
);
176 sprintf (buf
, "--%s <measure>", a
->name
);
179 sprintf (buf
, "--%s <string>", a
->name
);
182 sprintf (buf
, "--%s", a
->name
);
186 sprintf (buf
, "--%s ", a
->name
);
187 if (a
->type
== HID_Mixed
)
188 strcat (buf
, " <val>");
189 for (i
= 0; a
->enumerations
[i
]; i
++)
191 strcat (buf
, i
? "|" : "<");
192 strcat (buf
, a
->enumerations
[i
]);
197 sprintf (buf
, "--%s <path>", a
->name
);
200 unit_list
= get_unit_list ();
202 sprintf (buf
, "--%s ", a
->name
);
203 for (i
= 0; i
< n
; i
++)
205 strcat (buf
, i
? "|" : "<");
206 strcat (buf
, unit_list
[i
].suffix
);
212 if (strlen (buf
) <= 30)
215 fprintf (stderr
, " %-30s\t%s\n", buf
, a
->help_text
);
217 fprintf (stderr
, " %-30s\n", buf
);
219 else if (a
->help_text
&& strlen (a
->help_text
) + strlen (buf
) < 72)
220 fprintf (stderr
, " %s\t%s\n", buf
, a
->help_text
);
221 else if (a
->help_text
)
222 fprintf (stderr
, " %s\n\t\t\t%s\n", buf
, a
->help_text
);
224 fprintf (stderr
, " %s\n", buf
);
230 HID_Attribute
*attributes
;
231 int i
, n_attributes
= 0;
236 fprintf (stderr
, "\n%s gui options:\n", h
->name
);
237 attributes
= h
->get_export_options (&n_attributes
);
241 fprintf (stderr
, "\n%s options:\n", h
->name
);
243 attributes
= exporter
->get_export_options (&n_attributes
);
247 note
= (UsageNotes
*)malloc (sizeof (UsageNotes
));
248 note
->next
= usage_notes
;
249 note
->seen
= attributes
;
252 for (i
= 0; i
< n_attributes
; i
++)
253 usage_attr (attributes
+ i
);
259 HID
**hl
= hid_enumerate ();
263 int n_printer
= 0, n_gui
= 0, n_exporter
= 0;
265 for (i
= 0; hl
[i
]; i
++)
275 u ("PCB Printed Circuit Board editing program, http://pcb.geda-project.org");
276 u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname
);
277 u ("%s [gui options] <pcb file>\t\tto edit", Progname
);
278 u ("Available GUI hid%s:", n_gui
== 1 ? "" : "s");
279 for (i
= 0; hl
[i
]; i
++)
281 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
282 u ("%s -p [printing options] <pcb file>\tto print", Progname
);
283 u ("Available printing hid%s:", n_printer
== 1 ? "" : "s");
284 for (i
= 0; hl
[i
]; i
++)
286 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
287 u ("%s -x hid [export options] <pcb file>\tto export", Progname
);
288 u ("Available export hid%s:", n_exporter
== 1 ? "" : "s");
289 for (i
= 0; hl
[i
]; i
++)
291 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
293 for (i
= 0; hl
[i
]; i
++)
296 for (i
= 0; hl
[i
]; i
++)
299 for (i
= 0; hl
[i
]; i
++)
303 u ("\nCommon options:");
304 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
306 for (note
= usage_notes
; note
&& note
->seen
!= ha
->attributes
; note
= note
->next
)
310 for (i
= 0; i
< ha
->n
; i
++)
312 usage_attr (ha
->attributes
+ i
);
320 print_defaults_1 (HID_Attribute
* a
, void *value
)
327 /* Remember, at this point we've parsed the command line, so they
328 may be in the global variable instead of the default_val. */
332 i
= value
? *(int *) value
: a
->default_val
.int_value
;
333 fprintf (stderr
, "%s %d\n", a
->name
, i
);
336 i
= value
? *(char *) value
: a
->default_val
.int_value
;
337 fprintf (stderr
, "%s %s\n", a
->name
, i
? "yes" : "no");
340 d
= value
? *(double *) value
: a
->default_val
.real_value
;
341 fprintf (stderr
, "%s %g\n", a
->name
, d
);
344 c
= value
? *(Coord
*) value
: a
->default_val
.coord_value
;
345 pcb_fprintf (stderr
, "%s %$mS\n", a
->name
, c
);
349 s
= value
? *(char **) value
: a
->default_val
.str_value
;
350 fprintf (stderr
, "%s \"%s\"\n", a
->name
, s
);
353 i
= value
? *(int *) value
: a
->default_val
.int_value
;
354 fprintf (stderr
, "%s %s\n", a
->name
, a
->enumerations
[i
]);
358 ((HID_Attr_Val
*)value
)->int_value
: a
->default_val
.int_value
;
360 ((HID_Attr_Val
*)value
)->real_value
: a
->default_val
.real_value
;
361 fprintf (stderr
, "%s %g%s\n", a
->name
, d
, a
->enumerations
[i
]);
366 i
= value
? *(int *) value
: a
->default_val
.int_value
;
367 fprintf (stderr
, "%s %s\n", a
->name
, get_unit_list()[i
].suffix
);
374 HID
**hl
= hid_enumerate ();
378 for (hi
= 0; hl
[hi
]; hi
++)
384 fprintf (stderr
, "\ngui defaults:\n");
385 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
386 for (i
= 0; i
< ha
->n
; i
++)
387 print_defaults_1 (ha
->attributes
+ i
, ha
->attributes
[i
].value
);
391 fprintf (stderr
, "\n%s defaults:\n", h
->name
);
393 e
= exporter
->get_export_options (&n
);
396 for (i
= 0; i
< n
; i
++)
397 print_defaults_1 (e
+ i
, 0);
403 #define SSET(F,D,N,H) { N, H, \
404 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
405 #define ISET(F,D,N,H) { N, H, \
406 HID_Integer, 0, 0, { D, 0, 0 }, 0, &Settings.F }
407 #define BSET(F,D,N,H) { N, H, \
408 HID_Boolean, 0, 0, { D, 0, 0 }, 0, &Settings.F }
409 #define RSET(F,D,N,H) { N, H, \
410 HID_Real, 0, 0, { 0, 0, D }, 0, &Settings.F }
411 #define CSET(F,D,N,H) { N, H, \
412 HID_Coord, 0, 0, { 0, 0, 0, D }, 0, &Settings.F }
414 #define COLOR(F,D,N,H) { N, H, \
415 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
416 #define LAYERCOLOR(N,D) { "layer-color-" #N, "Color for layer " #N, \
417 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.LayerColor[N-1] }
418 #define LAYERNAME(N,D) { "layer-name-" #N, "Name for layer " #N, \
419 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.DefaultLayerName[N-1] }
420 #define LAYERSELCOLOR(N) { "layer-selected-color-" #N, "Color for layer " #N " when selected", \
421 HID_String, 0, 0, { 0, "#00ffff", 0 }, 0, &Settings.LayerSelectedColor[N-1] }
423 static int show_help
= 0;
424 static int show_version
= 0;
425 static int show_copyright
= 0;
426 static int show_defaults
= 0;
427 static int show_actions
= 0;
428 static int do_dump_actions
= 0;
429 static char *grid_units
;
430 static Increments increment_mm
= { 0 };
431 static Increments increment_mil
= { 0 };
433 void save_increments (const Increments
*mm
, const Increments
*mil
)
435 memcpy (&increment_mm
, mm
, sizeof (*mm
));
436 memcpy (&increment_mil
, mil
, sizeof (*mil
));
439 HID_Attribute main_attribute_list
[] = {
441 /* %start-doc options "1 General Options"
444 Show help on command line options.
448 {"help", "Show help on command line options", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
451 /* %start-doc options "1 General Options"
458 {"version", "Show version", HID_Boolean
, 0, 0, {0, 0, 0}, 0, &show_version
},
460 /* %start-doc options "1 General Options"
463 Be verbose on stdout.
467 {"verbose", "Be verbose on stdout", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
470 /* %start-doc options "1 General Options"
477 {"copyright", "Show Copyright", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
480 /* %start-doc options "1 General Options"
482 @item --show-defaults
483 Show option defaults.
487 {"show-defaults", "Show option defaults", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
490 /* %start-doc options "1 General Options"
493 Show available actions and exit.
497 {"show-actions", "Show available actions", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
500 /* %start-doc options "1 General Options"
503 Dump actions (for documentation).
507 {"dump-actions", "Dump actions (for documentation)", HID_Boolean
, 0, 0,
508 {0, 0, 0}, 0, &do_dump_actions
},
510 /* %start-doc options "1 General Options"
512 @item --grid-units-mm <string>
513 Set default grid units. Can be mm or mil. Defaults to mil.
517 {"grid-units", "Default grid units (mm|mil)", HID_String
, 0, 0, {0, "mil", 0},
520 /* %start-doc options "1 General Options"
522 @item --clear-increment-mm <string>
523 Set default clear increment (amount to change when user presses k or K)
524 when user is using a metric grid unit.
528 {"clear-increment-mm", "Default clear increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
529 0, &increment_mm
.clear
},
531 /* %start-doc options "1 General Options"
533 @item --grid-increment-mm <string>
534 Set default grid increment (amount to change when user presses g or G)
535 when user is using a metric grid unit.
539 {"grid-increment-mm", "Default grid increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
540 0, &increment_mm
.grid
},
542 /* %start-doc options "1 General Options"
544 @item --line-increment-mm <string>
545 Set default line increment (amount to change when user presses l or L)
546 when user is using a metric grid unit.
550 {"line-increment-mm", "Default line increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
551 0, &increment_mm
.line
},
553 /* %start-doc options "1 General Options"
555 @item --size-increment-mm <string>
556 Set default size increment (amount to change when user presses s or S)
557 when user is using a metric grid unit.
561 {"size-increment-mm", "Default size increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
562 0, &increment_mm
.size
},
564 /* %start-doc options "1 General Options"
566 @item --clear-increment-mil <string>
567 Set default clear increment (amount to change when user presses k or K)
568 when user is using an imperial grid unit.
572 {"clear-increment-mil", "Default clear increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
573 0, &increment_mil
.clear
},
575 /* %start-doc options "1 General Options"
577 @item --grid-increment-mil <string>
578 Set default grid increment (amount to change when user presses g or G)
579 when user is using a imperial grid unit.
583 {"grid-increment-mil", "Default grid increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
584 0, &increment_mil
.grid
},
586 /* %start-doc options "1 General Options"
588 @item --line-increment-mil <string>
589 Set default line increment (amount to change when user presses l or L)
590 when user is using a imperial grid unit.
594 {"line-increment-mil", "Default line increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
595 0, &increment_mil
.line
},
597 /* %start-doc options "1 General Options"
599 @item --size-increment-mil <string>
600 Set default size increment (amount to change when user presses s or S)
601 when user is using a imperial grid unit.
605 {"size-increment-mil", "Default size increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
606 0, &increment_mil
.size
},
608 /* %start-doc options "3 Colors"
610 @item --black-color <string>
611 Color value for black. Default: @samp{#000000}
615 COLOR (BlackColor
, "#000000", "black-color", "color value of 'black'"),
617 /* %start-doc options "3 Colors"
619 @item --black-color <string>
620 Color value for white. Default: @samp{#ffffff}
624 COLOR (WhiteColor
, "#ffffff", "white-color", "color value of 'white'"),
626 /* %start-doc options "3 Colors"
628 @item --background-color <string>
629 Background color of the canvas. Default: @samp{#e5e5e5}
633 COLOR (BackgroundColor
, "#e5e5e5", "background-color",
634 "color for background"),
636 /* %start-doc options "3 Colors"
638 @item --crosshair-color <string>
639 Color of the crosshair. Default: @samp{#ff0000}
643 COLOR (CrosshairColor
, "#ff0000", "crosshair-color",
644 "color for the crosshair"),
646 /* %start-doc options "3 Colors"
648 @item --cross-color <string>
649 Color of the cross. Default: @samp{#cdcd00}
653 COLOR (CrossColor
, "#cdcd00", "cross-color", "color of the cross"),
655 /* %start-doc options "3 Colors"
657 @item --via-color <string>
658 Color of vias. Default: @samp{#7f7f7f}
662 COLOR (ViaColor
, "#7f7f7f", "via-color", "color of vias"),
664 /* %start-doc options "3 Colors"
666 @item --via-selected-color <string>
667 Color of selected vias. Default: @samp{#00ffff}
671 COLOR (ViaSelectedColor
, "#00ffff", "via-selected-color",
672 "color for selected vias"),
674 /* %start-doc options "3 Colors"
676 @item --pin-color <string>
677 Color of pins. Default: @samp{#4d4d4d}
681 COLOR (PinColor
, "#4d4d4d", "pin-color", "color of pins"),
683 /* %start-doc options "3 Colors"
685 @item --pin-selected-color <string>
686 Color of selected pins. Default: @samp{#00ffff}
690 COLOR (PinSelectedColor
, "#00ffff", "pin-selected-color",
691 "color of selected pins"),
693 /* %start-doc options "3 Colors"
695 @item --pin-name-color <string>
696 Color of pin names and pin numbers. Default: @samp{#ff0000}
700 COLOR (PinNameColor
, "#ff0000", "pin-name-color",
701 "color for pin names and pin numbers"),
703 /* %start-doc options "3 Colors"
705 @item --element-color <string>
706 Color of components. Default: @samp{#000000}
710 COLOR (ElementColor
, "#000000", "element-color", "color of components"),
712 /* %start-doc options "3 Colors"
714 @item --rat-color <string>
715 Color of ratlines. Default: @samp{#b8860b}
719 COLOR (RatColor
, "#b8860b", "rat-color", "color of ratlines"),
721 /* %start-doc options "3 Colors"
723 @item --invisible-objects-color <string>
724 Color of invisible objects. Default: @samp{#cccccc}
728 COLOR (InvisibleObjectsColor
, "#cccccc", "invisible-objects-color",
729 "color of invisible objects"),
731 /* %start-doc options "3 Colors"
733 @item --invisible-mark-color <string>
734 Color of invisible marks. Default: @samp{#cccccc}
738 COLOR (InvisibleMarkColor
, "#cccccc", "invisible-mark-color",
739 "color of invisible marks"),
741 /* %start-doc options "3 Colors"
743 @item --element-selected-color <string>
744 Color of selected components. Default: @samp{#00ffff}
748 COLOR (ElementSelectedColor
, "#00ffff", "element-selected-color",
749 "color of selected components"),
751 /* %start-doc options "3 Colors"
753 @item --rat-selected-color <string>
754 Color of selected rats. Default: @samp{#00ffff}
758 COLOR (RatSelectedColor
, "#00ffff", "rat-selected-color",
759 "color of selected rats"),
761 /* %start-doc options "3 Colors"
763 @item --connected-color <string>
764 Color to indicate physical connections. Default: @samp{#00ff00}
768 COLOR (ConnectedColor
, "#00ff00", "connected-color",
769 "color to indicate physically connected objects"),
771 /* %start-doc options "3 Colors"
773 @item --found-color <string>
774 Color to indicate logical connections. Default: @samp{#ff00ff}
778 COLOR (FoundColor
, "#ff00ff", "found-color",
779 "color to indicate logically connected objects"),
781 /* %start-doc options "3 Colors"
783 @item --off-limit-color <string>
784 Color of off-canvas area. Default: @samp{#cccccc}
788 COLOR (OffLimitColor
, "#cccccc", "off-limit-color",
789 "color of off-canvas area"),
791 /* %start-doc options "3 Colors"
793 @item --grid-color <string>
794 Color of the grid. Default: @samp{#ff0000}
798 COLOR (GridColor
, "#ff0000", "grid-color", "color of the grid"),
800 /* %start-doc options "3 Colors"
802 @item --layer-color-<n> <string>
803 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
807 LAYERCOLOR (1, "#8b2323"),
808 LAYERCOLOR (2, "#3a5fcd"),
809 LAYERCOLOR (3, "#104e8b"),
810 LAYERCOLOR (4, "#cd3700"),
811 LAYERCOLOR (5, "#548b54"),
812 LAYERCOLOR (6, "#8b7355"),
813 LAYERCOLOR (7, "#00868b"),
814 LAYERCOLOR (8, "#228b22"),
815 LAYERCOLOR (9, "#8b2323"),
816 LAYERCOLOR (10, "#3a5fcd"),
817 LAYERCOLOR (11, "#104e8b"),
818 LAYERCOLOR (12, "#cd3700"),
819 LAYERCOLOR (13, "#548b54"),
820 LAYERCOLOR (14, "#8b7355"),
821 LAYERCOLOR (15, "#00868b"),
822 LAYERCOLOR (16, "#228b22"),
823 /* %start-doc options "3 Colors"
825 @item --layer-selected-color-<n> <string>
826 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
847 /* %start-doc options "3 Colors"
849 @item --warn-color <string>
850 Color of offending objects during DRC. Default value is @code{"#ff8000"}
854 COLOR (WarnColor
, "#ff8000", "warn-color", "color of offending objects during DRC"),
856 /* %start-doc options "3 Colors"
858 @item --mask-color <string>
859 Color of the mask layer. Default value is @code{"#ff0000"}
863 COLOR (MaskColor
, "#ff0000", "mask-color", "color for solder mask"),
866 /* %start-doc options "5 Sizes"
867 All parameters should be given with an unit. If no unit is given, 1/100 mil
868 (cmil) will be used. Write units without space to the
869 number like @code{3mm}, not @code{3 mm}.
893 @item --via-thickness <num>
894 Default diameter of vias. Default value is @code{60mil}.
898 CSET (ViaThickness
, MIL_TO_COORD(60), "via-thickness",
899 "default diameter of vias in 1/100 mil"),
901 /* %start-doc options "5 Sizes"
903 @item --via-drilling-hole <num>
904 Default diameter of holes. Default value is @code{28mil}.
908 CSET (ViaDrillingHole
, MIL_TO_COORD(28), "via-drilling-hole",
909 "default diameter of holes"),
911 /* %start-doc options "5 Sizes"
913 @item --line-thickness <num>
914 Default thickness of new lines. Default value is @code{10mil}.
918 CSET (LineThickness
, MIL_TO_COORD(10), "line-thickness",
919 "initial thickness of new lines"),
921 /* %start-doc options "5 Sizes"
923 @item --rat-thickness <num><unit>
924 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100
925 means "1 nm"). This option allows for a special unit @code{px} which
926 sets the rat thickness to a fixed value in terms of screen pixels.
927 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.
928 Default value is @code{10mil}.
932 CSET (RatThickness
, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
934 /* %start-doc options "5 Sizes"
936 @item --keepaway <num>
937 Default minimum distance between a track and adjacent copper.
938 Default value is @code{10mil}.
942 CSET (Keepaway
, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
944 /* %start-doc options "5 Sizes"
946 @item --default-PCB-width <num>
947 Default width of the canvas. Default value is @code{6000mil}.
951 CSET (MaxWidth
, MIL_TO_COORD(6000), "default-PCB-width",
952 "default width of the canvas"),
954 /* %start-doc options "5 Sizes"
956 @item --default-PCB-height <num>
957 Default height of the canvas. Default value is @code{5000mil}.
961 CSET (MaxHeight
, MIL_TO_COORD(5000), "default-PCB-height",
962 "default height of the canvas"),
964 /* %start-doc options "5 Sizes"
966 @item --text-scale <num>
967 Default text scale. This value is in percent. Default value is @code{100}.
971 ISET (TextScale
, 100, "text-scale", "default text scale in percent"),
973 /* %start-doc options "5 Sizes"
975 @item --alignment-distance <num>
976 Specifies the distance between the board outline and alignment targets.
977 Default value is @code{2mil}.
981 CSET (AlignmentDistance
, MIL_TO_COORD(2), "alignment-distance",
982 "distance between the boards outline and alignment targets"),
984 /* %start-doc options "7 DRC Options"
985 All parameters should be given with an unit. If no unit is given, 1/100 mil
986 (cmil) will be used for backward compability. Valid units are given in section
992 /* %start-doc options "7 DRC Options"
995 Minimum spacing. Default value is @code{10mil}.
999 CSET (Bloat
, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
1001 /* %start-doc options "7 DRC Options"
1003 @item --shrink <num>
1004 Minimum touching overlap. Default value is @code{10mil}.
1008 CSET (Shrink
, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
1010 /* %start-doc options "7 DRC Options"
1012 @item --min-width <num>
1013 Minimum width of copper. Default value is @code{10mil}.
1017 CSET (minWid
, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1019 /* %start-doc options "7 DRC Options"
1021 @item --min-silk <num>
1022 Minimum width of lines in silk. Default value is @code{10mil}.
1026 CSET (minSlk
, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1028 /* %start-doc options "7 DRC Options"
1030 @item --min-drill <num>
1031 Minimum diameter of holes. Default value is @code{15mil}.
1035 CSET (minDrill
, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1037 /* %start-doc options "7 DRC Options"
1039 @item --min-ring <num>
1040 Minimum width of annular ring. Default value is @code{10mil}.
1044 CSET (minRing
, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1047 /* %start-doc options "5 Sizes"
1050 Initial grid size. Default value is @code{10mil}.
1054 CSET (Grid
, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1056 /* %start-doc options "5 Sizes"
1058 @item --minimum polygon area <num>
1059 Minimum polygon area.
1063 RSET (IsleArea
, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1066 /* %start-doc options "1 General Options"
1068 @item --backup-interval
1069 Time between automatic backups in seconds. Set to @code{0} to disable.
1070 The default value is @code{60}.
1074 ISET (BackupInterval
, 60, "backup-interval",
1075 "Time between automatic backups in seconds. Set to 0 to disable"),
1077 /* %start-doc options "4 Layer Names"
1079 @item --layer-name-1 <string>
1080 Name of the 1st Layer. Default is @code{"top"}.
1084 LAYERNAME (1, "top"),
1086 /* %start-doc options "4 Layer Names"
1088 @item --layer-name-2 <string>
1089 Name of the 2nd Layer. Default is @code{"ground"}.
1093 LAYERNAME (2, "ground"),
1095 /* %start-doc options "4 Layer Names"
1097 @item --layer-name-3 <string>
1098 Name of the 3nd Layer. Default is @code{"signal2"}.
1102 LAYERNAME (3, "signal2"),
1104 /* %start-doc options "4 Layer Names"
1106 @item --layer-name-4 <string>
1107 Name of the 4rd Layer. Default is @code{"signal3"}.
1111 LAYERNAME (4, "signal3"),
1113 /* %start-doc options "4 Layer Names"
1115 @item --layer-name-5 <string>
1116 Name of the 5rd Layer. Default is @code{"power"}.
1120 LAYERNAME (5, "power"),
1122 /* %start-doc options "4 Layer Names"
1124 @item --layer-name-6 <string>
1125 Name of the 6rd Layer. Default is @code{"bottom"}.
1129 LAYERNAME (6, "bottom"),
1131 /* %start-doc options "4 Layer Names"
1133 @item --layer-name-7 <string>
1134 Name of the 7rd Layer. Default is @code{"outline"}.
1138 LAYERNAME (7, "outline"),
1140 /* %start-doc options "4 Layer Names"
1142 @item --layer-name-8 <string>
1143 Name of the 8rd Layer. Default is @code{"spare"}.
1147 LAYERNAME (8, "spare"),
1149 /* %start-doc options "1 General Options"
1151 @item --groups <string>
1152 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1156 SSET (Groups
, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
1159 /* %start-doc options "6 Commands"
1160 pcb uses external commands for input output operations. These commands can be
1161 configured at start-up to meet local requirements. The command string may include
1162 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
1163 command is called. The sequence @code{%f} is replaced by the file name,
1164 @code{%p} gets the path and @code{%a} indicates a package name.
1168 /* %start-doc options "6 Commands"
1170 @item --font-command <string>
1171 Command to load a font.
1175 SSET (FontCommand
, "", "font-command", "Command to load a font"),
1177 /* %start-doc options "6 Commands"
1179 @item --file-command <string>
1180 Command to read a file.
1184 SSET (FileCommand
, "", "file-command", "Command to read a file"),
1186 /* %start-doc options "6 Commands"
1188 @item --element-command <string>
1189 Command to read a footprint. @*
1190 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1194 SSET (ElementCommand
,
1195 "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4
,
1196 "element-command", "Command to read a footprint"),
1198 /* %start-doc options "6 Commands"
1200 @item --print-file <string>
1201 Command to print to a file.
1205 SSET (PrintFile
, "%f.output", "print-file", "Command to print to a file"),
1207 /* %start-doc options "6 Commands"
1209 @item --lib-command-dir <string>
1210 Path to the command that queries the library.
1214 SSET (LibraryCommandDir
, PCBLIBDIR
, "lib-command-dir",
1215 "Path to the command that queries the library"),
1217 /* %start-doc options "6 Commands"
1219 @item --lib-command <string>
1220 Command to query the library. @*
1221 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1225 SSET (LibraryCommand
, "QueryLibrary.sh '%p' '%f' %a",
1226 "lib-command", "Command to query the library"),
1228 /* %start-doc options "6 Commands"
1230 @item --lib-contents-command <string>
1231 Command to query the contents of the library. @*
1232 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
1233 on Windows builds, an empty string (to disable this feature).
1237 SSET (LibraryContentsCommand
,
1241 "ListLibraryContents.sh '%p' '%f'",
1243 "lib-contents-command", "Command to query the contents of the library"),
1245 /* %start-doc options "5 Paths"
1247 @item --lib-newlib <string>
1248 Top level directory for the newlib style library.
1252 SSET (LibraryTree
, PCBTREEPATH
, "lib-newlib",
1253 "Top level directory for the newlib style library"),
1255 /* %start-doc options "6 Commands"
1257 @item --save-command <string>
1258 Command to save to a file.
1262 SSET (SaveCommand
, "", "save-command", "Command to save to a file"),
1264 /* %start-doc options "5 Paths"
1266 @item --lib-name <string>
1267 The default filename for the library.
1271 SSET (LibraryFilename
, LIBRARYFILENAME
, "lib-name",
1272 "The default filename for the library"),
1274 /* %start-doc options "5 Paths"
1276 @item --default-font <string>
1277 The name of the default font.
1281 SSET (FontFile
, "default_font", "default-font",
1282 "File name of default font"),
1284 /* %start-doc options "1 General Options"
1286 @item --route-styles <string>
1287 A string that defines the route styles. Defaults to @*
1288 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
1289 :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
1293 SSET (Routes
, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
1294 ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
1295 "A string that defines the route styles"),
1297 /* %start-doc options "5 Paths"
1299 @item --file-path <string>
1300 A colon separated list of directories or commands (starts with '|'). The path
1301 is passed to the program specified in @option{--file-command} together with the selected
1306 SSET (FilePath
, "", "file-path", 0),
1308 /* %start-doc options "6 Commands"
1310 @item --rat-command <string>
1311 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1315 SSET (RatCommand
, "", "rat-command", "Command for reading a netlist"),
1317 /* %start-doc options "5 Paths"
1319 @item --font-path <string>
1320 A colon separated list of directories to search the default font. Defaults to
1321 the default library path.
1325 SSET (FontPath
, PCBLIBPATH
, "font-path",
1326 "Colon separated list of directories to search the default font"),
1328 /* %start-doc options "1 General Options"
1330 @item --element-path <string>
1331 A colon separated list of directories or commands (starts with '|').
1332 The path is passed to the program specified in @option{--element-command}.
1336 SSET(ElementPath
, PCBLIBPATH
, "element-path",
1337 "A colon separated list of directories or commands (starts with '|')"),
1339 /* %start-doc options "5 Paths"
1341 @item --lib-path <string>
1342 A colon separated list of directories that will be passed to the commands specified
1343 by @option{--element-command} and @option{--element-contents-command}.
1347 SSET (LibraryPath
, PCBLIBPATH
, "lib-path",
1348 "A colon separated list of directories"),
1350 /* %start-doc options "1 General Options"
1352 @item --action-script <string>
1353 If set, this file is executed at startup.
1357 SSET (ScriptFilename
, 0, "action-script",
1358 "If set, this file is executed at startup"),
1360 /* %start-doc options "1 General Options"
1362 @item --action-string <string>
1363 If set, this string of actions is executed at startup.
1367 SSET (ActionString
, 0, "action-string",
1368 "If set, this is executed at startup"),
1370 /* %start-doc options "1 General Options"
1372 @item --fab-author <string>
1373 Name of author to be put in the Gerber files.
1377 SSET (FabAuthor
, "", "fab-author",
1378 "Name of author to be put in the Gerber files"),
1380 /* %start-doc options "1 General Options"
1382 @item --layer-stack <string>
1383 Initial layer stackup, for setting up an export. A comma separated list of layer
1384 names, layer numbers and layer groups.
1388 SSET (InitialLayerStack
, "", "layer-stack",
1389 "Initial layer stackup, for setting up an export."),
1391 SSET (MakeProgram
, NULL
, "make-program",
1392 "Sets the name and optionally full path to a make(3) program"),
1393 SSET (GnetlistProgram
, NULL
, "gnetlist",
1394 "Sets the name and optionally full path to the gnetlist(3) program"),
1396 /* %start-doc options "2 General GUI Options"
1398 @item --pinout-offset-x <num>
1399 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1403 CSET (PinoutOffsetX
, MIL_TO_COORD(1), "pinout-offset-x",
1404 "Horizontal offset of the pin number display in mil"),
1406 /* %start-doc options "2 General GUI Options"
1408 @item --pinout-offset-y <num>
1409 Vertical offset of the pin number display. Defaults to @code{100mil}.
1413 CSET (PinoutOffsetY
, MIL_TO_COORD(1), "pinout-offset-y",
1414 "Vertical offset of the pin number display in mil"),
1416 /* %start-doc options "2 General GUI Options"
1418 @item --pinout-text-offset-x <num>
1419 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1423 CSET (PinoutTextOffsetX
, MIL_TO_COORD(8), "pinout-text-offset-x",
1424 "Horizontal offset of the pin name display in mil"),
1426 /* %start-doc options "2 General GUI Options"
1428 @item --pinout-text-offset-y <num>
1429 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1433 CSET (PinoutTextOffsetY
, MIL_TO_COORD(-1), "pinout-text-offset-y",
1434 "Vertical offset of the pin name display in mil"),
1436 /* %start-doc options "2 General GUI Options"
1439 If set, draw the grid at start-up.
1443 BSET (DrawGrid
, 0, "draw-grid", "If set, draw the grid at start-up"),
1445 /* %start-doc options "2 General GUI Options"
1448 If set, new lines clear polygons.
1452 BSET (ClearLine
, 1, "clear-line", "If set, new lines clear polygons"),
1454 /* %start-doc options "2 General GUI Options"
1457 If set, new polygons are full ones.
1461 BSET (FullPoly
, 0, "full-poly", 0),
1463 /* %start-doc options "2 General GUI Options"
1465 @item --unique-names
1466 If set, you will not be permitted to change the name of an component to match that
1467 of another component.
1471 BSET (UniqueNames
, 1, "unique-names", "Prevents identical component names"),
1473 /* %start-doc options "2 General GUI Options"
1476 If set, pin centers and pad end points are treated as additional grid points
1477 that the cursor can snap to.
1481 BSET (SnapPin
, 1, "snap-pin",
1482 "If set, the cursor snaps to pads and pin centers"),
1484 /* %start-doc options "1 General Options"
1486 @item --save-last-command
1487 If set, the last user command is saved.
1491 BSET (SaveLastCommand
, 0, "save-last-command", 0),
1493 /* %start-doc options "1 General Options"
1496 If set, all data which would otherwise be lost are saved in a temporary file
1497 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
1501 BSET (SaveInTMP
, 0, "save-in-tmp",
1502 "When set, all data which would otherwise be lost are saved in /tmp"),
1504 /* %start-doc options "1 General Options"
1506 @item --save-metric-only
1507 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
1511 BSET (SaveMetricOnly
, 0, "save-metric-only",
1512 "If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm."),
1514 /* %start-doc options "2 General GUI Options"
1516 @item --all-direction-lines
1517 Allow all directions, when drawing new lines.
1521 BSET (AllDirectionLines
, 0, "all-direction-lines",
1522 "Allow all directions, when drawing new lines"),
1524 /* %start-doc options "2 General GUI Options"
1527 Pinout shows number.
1531 BSET (ShowNumber
, 0, "show-number", "Pinout shows number"),
1533 /* %start-doc options "1 General Options"
1535 @item --reset-after-element
1536 If set, all found connections are reset before a new component is scanned.
1540 BSET (ResetAfterElement
, 1, "reset-after-element",
1541 "If set, all found connections are reset before a new component is scanned"),
1543 /* %start-doc options "1 General Options"
1545 @item --ring-bell-finished
1546 Execute the bell command when all rats are routed.
1550 BSET (RingBellWhenFinished
, 0, "ring-bell-finished",
1551 "Execute the bell command when all rats are routed"),
1554 REGISTER_ATTRIBUTES (main_attribute_list
)
1555 /* ----------------------------------------------------------------------
1556 * post-process settings.
1558 static void settings_post_process ()
1562 if (Settings
.LibraryCommand
!= NULL
&&
1563 Settings
.LibraryCommand
[0] != '\0' &&
1564 Settings
.LibraryCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1565 Settings
.LibraryCommand
[0] != '.')
1567 Settings
.LibraryCommand
1569 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1570 Settings
.LibraryCommand
,
1573 if (Settings
.LibraryContentsCommand
!= NULL
&&
1574 Settings
.LibraryContentsCommand
[0] != '\0' &&
1575 Settings
.LibraryContentsCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1576 Settings
.LibraryContentsCommand
[0] != '.')
1578 Settings
.LibraryContentsCommand
1580 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1581 Settings
.LibraryContentsCommand
, NULL
);
1584 if (Settings
.LineThickness
> MAX_LINESIZE
1585 || Settings
.LineThickness
< MIN_LINESIZE
)
1586 Settings
.LineThickness
= MIL_TO_COORD(10);
1588 if (Settings
.ViaThickness
> MAX_PINORVIASIZE
1589 || Settings
.ViaThickness
< MIN_PINORVIASIZE
)
1590 Settings
.ViaThickness
= MIL_TO_COORD(40);
1592 if (Settings
.ViaDrillingHole
<= 0)
1593 Settings
.ViaDrillingHole
=
1594 DEFAULT_DRILLINGHOLE
* Settings
.ViaThickness
/ 100;
1596 Settings
.MaxWidth
= CLAMP (Settings
.MaxWidth
, MIN_SIZE
, MAX_COORD
);
1597 Settings
.MaxHeight
= CLAMP (Settings
.MaxHeight
, MIN_SIZE
, MAX_COORD
);
1599 ParseRouteString (Settings
.Routes
, &Settings
.RouteStyle
[0], "cmil");
1602 * Make sure we have settings for some various programs we may wish
1605 if (Settings
.MakeProgram
== NULL
) {
1606 tmps
= getenv ("PCB_MAKE_PROGRAM");
1608 Settings
.MakeProgram
= strdup (tmps
);
1610 if (Settings
.MakeProgram
== NULL
) {
1611 Settings
.MakeProgram
= strdup ("make");
1614 if (Settings
.GnetlistProgram
== NULL
) {
1615 tmps
= getenv ("PCB_GNETLIST");
1617 Settings
.GnetlistProgram
= strdup (tmps
);
1619 if (Settings
.GnetlistProgram
== NULL
) {
1620 Settings
.GnetlistProgram
= strdup ("gnetlist");
1624 Settings
.grid_unit
= get_unit_struct (grid_units
);
1625 if (!grid_units
|| Settings
.grid_unit
== NULL
)
1626 Settings
.grid_unit
= get_unit_struct ("mil");
1628 copy_nonzero_increments (get_increments_struct (METRIC
), &increment_mm
);
1629 copy_nonzero_increments (get_increments_struct (IMPERIAL
), &increment_mil
);
1631 Settings
.increments
= get_increments_struct (Settings
.grid_unit
->family
);
1635 * \brief Print help or version messages.
1640 printf ("PCB version %s\n", VERSION
);
1644 /* ----------------------------------------------------------------------
1645 * Figure out the canonical name of the executed program
1646 * and fix up the defaults for various paths
1648 char *bindir
= NULL
;
1649 char *exec_prefix
= NULL
;
1650 char *pcblibdir
= NULL
;
1651 char *pcblibpath
= NULL
;
1652 char *pcbtreedir
= NULL
;
1653 char *pcbtreepath
= NULL
;
1654 char *homedir
= NULL
;
1657 * \brief See if argv0 has enough of a path to let lrealpath give the
1660 * This should be the case if you invoke pcb with something like
1661 * /usr/local/bin/pcb or ./pcb or ./foo/pcb but if you just use pcb and
1662 * it exists in your path, you'll just get back pcb again.
1665 InitPaths (char *argv0
)
1671 int found_bindir
= 0;
1674 for (i
= 0; i
< strlen (argv0
) ; i
++)
1676 if (argv0
[i
] == PCB_DIR_SEPARATOR_C
)
1681 printf ("InitPaths (%s): haspath = %d\n", argv0
, haspath
);
1686 bindir
= strdup (lrealpath (argv0
));
1691 char *path
, *p
, *tmps
;
1695 tmps
= getenv ("PATH");
1699 path
= strdup (tmps
);
1701 /* search through the font path for a font file */
1702 for (p
= strtok (path
, PCB_PATH_DELIMETER
); p
&& *p
;
1703 p
= strtok (NULL
, PCB_PATH_DELIMETER
))
1706 printf ("Looking for %s in %s\n", argv0
, p
);
1708 if ( (tmps
= (char *)malloc ( (strlen (argv0
) + strlen (p
) + 2) * sizeof (char))) == NULL
)
1710 fprintf (stderr
, "InitPaths(): malloc failed\n");
1713 sprintf (tmps
, "%s%s%s", p
, PCB_DIR_SEPARATOR_S
, argv0
);
1714 r
= stat (tmps
, &sb
);
1718 printf ("Found it: \"%s\"\n", tmps
);
1720 bindir
= lrealpath (tmps
);
1732 printf ("InitPaths(): bindir = \"%s\"\n", bindir
);
1737 /* strip off the executible name leaving only the path */
1739 t1
= strchr (bindir
, PCB_DIR_SEPARATOR_C
);
1740 while (t1
!= NULL
&& *t1
!= '\0')
1743 t1
= strchr (t2
+ 1, PCB_DIR_SEPARATOR_C
);
1749 printf ("After stripping off the executible name, we found\n");
1750 printf ("bindir = \"%s\"\n", bindir
);
1755 /* we have failed to find out anything from argv[0] so fall back to the original
1758 bindir
= strdup (BINDIR
);
1761 /* now find the path to exec_prefix */
1762 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_EXECPREFIX
) + 1;
1763 if ( (exec_prefix
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1765 fprintf (stderr
, "InitPaths(): malloc failed\n");
1768 sprintf (exec_prefix
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1769 BINDIR_TO_EXECPREFIX
);
1771 /* now find the path to PCBLIBDIR */
1772 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBLIBDIR
) + 1;
1773 if ( (pcblibdir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1775 fprintf (stderr
, "InitPaths(): malloc failed\n");
1778 sprintf (pcblibdir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1779 BINDIR_TO_PCBLIBDIR
);
1781 /* and the path to PCBTREEDIR */
1782 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBTREEDIR
) + 1;
1783 if ( (pcbtreedir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1785 fprintf (stderr
, "InitPaths(): malloc failed\n");
1788 sprintf (pcbtreedir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1789 BINDIR_TO_PCBTREEDIR
);
1791 /* and the search path including PCBLIBDIR */
1792 l
= strlen (pcblibdir
) + 3;
1793 if ( (pcblibpath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1795 fprintf (stderr
, "InitPaths(): malloc failed\n");
1798 sprintf (pcblibpath
, ".%s%s", PCB_PATH_DELIMETER
, pcblibdir
);
1800 /* and the newlib search path */
1801 l
= strlen (pcblibdir
) + 1 + strlen (pcbtreedir
)
1802 + strlen ("pcblib-newlib") + 2;
1803 if ( (pcbtreepath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1805 fprintf (stderr
, "InitPaths(): malloc failed\n");
1808 sprintf (pcbtreepath
, "%s%s%s%spcblib-newlib", pcbtreedir
,
1809 PCB_PATH_DELIMETER
, pcblibdir
,
1810 PCB_DIR_SEPARATOR_S
);
1813 printf ("bindir = %s\n", bindir
);
1814 printf ("pcblibdir = %s\n", pcblibdir
);
1815 printf ("pcblibpath = %s\n", pcblibpath
);
1816 printf ("pcbtreedir = %s\n", pcbtreedir
);
1817 printf ("pcbtreepath = %s\n", pcbtreepath
);
1820 l
= sizeof (main_attribute_list
) / sizeof (main_attribute_list
[0]);
1821 for (i
= 0; i
< l
; i
++)
1823 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-command-dir") == 0)
1825 main_attribute_list
[i
].default_val
.str_value
= pcblibdir
;
1828 if ( (NSTRCMP (main_attribute_list
[i
].name
, "font-path") == 0)
1829 || (NSTRCMP (main_attribute_list
[i
].name
, "element-path") == 0)
1830 || (NSTRCMP (main_attribute_list
[i
].name
, "lib-path") == 0) )
1832 main_attribute_list
[i
].default_val
.str_value
= pcblibpath
;
1835 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-newlib") == 0)
1837 main_attribute_list
[i
].default_val
.str_value
= pcbtreepath
;
1845 tmps
= getenv ("HOME");
1848 tmps
= getenv ("USERPROFILE");
1852 homedir
= strdup (tmps
);
1860 /* ----------------------------------------------------------------------
1864 char *program_name
= 0;
1865 char *program_basename
= 0;
1866 char *program_directory
= 0;
1868 #include "dolists.h"
1871 * \brief Main program.
1875 * - make program name available for error handlers
1876 * - evaluate special options
1877 * - initialize toplevel shell and resources
1878 * - create an empty PCB with default symbols
1879 * - initialize all other widgets
1880 * - update screen and get size of drawing area
1881 * - evaluate command-line arguments
1882 * - register 'call on exit()' function
1885 main (int argc
, char *argv
[])
1889 #include "core_lists.h"
1891 InitPaths (argv
[0]);
1893 bindtextdomain (GETTEXT_PACKAGE
, LOCALEDIR
);
1894 textdomain (GETTEXT_PACKAGE
);
1895 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
1898 setlocale (LC_ALL
, "");
1899 setlocale (LC_NUMERIC
, "C");
1902 srand ( time(NULL
) ); /* Set seed for rand() */
1908 hid_load_settings ();
1910 program_name
= argv
[0];
1911 program_basename
= strrchr (program_name
, PCB_DIR_SEPARATOR_C
);
1912 if (program_basename
)
1914 program_directory
= strdup (program_name
);
1915 *strrchr (program_directory
, PCB_DIR_SEPARATOR_C
) = 0;
1920 program_directory
= ".";
1921 program_basename
= program_name
;
1923 Progname
= program_basename
;
1925 /* Print usage or version if requested. Then exit. */
1927 (strcmp (argv
[1], "-h") == 0 ||
1928 strcmp (argv
[1], "-?") == 0 ||
1929 strcmp (argv
[1], "--help") == 0))
1931 if (argc
> 1 && strcmp (argv
[1], "-V") == 0)
1933 /* Export pcb from command line if requested. */
1934 if (argc
> 1 && strcmp (argv
[1], "-p") == 0)
1936 exporter
= gui
= hid_find_printer ();
1940 else if (argc
> 2 && strcmp (argv
[1], "-x") == 0)
1942 exporter
= gui
= hid_find_exporter (argv
[2]);
1946 /* Otherwise start GUI. */
1948 gui
= hid_find_gui ();
1950 /* Exit with error if GUI failed to start. */
1954 /* Set up layers. */
1955 for (i
= 0; i
< MAX_LAYER
; i
++)
1958 sprintf (buf
, "signal%d", i
+ 1);
1959 Settings
.DefaultLayerName
[i
] = strdup (buf
);
1960 Settings
.LayerColor
[i
] = "#c49350";
1961 Settings
.LayerSelectedColor
[i
] = "#00ffff";
1964 gui
->parse_arguments (&argc
, &argv
);
1966 if (show_help
|| (argc
> 1 && argv
[1][0] == '-'))
1975 settings_post_process ();
1984 if (do_dump_actions
)
1986 extern void dump_actions (void);
1991 /* Create a new PCB object in memory */
1992 PCB
= CreateNewPCB ();
1993 ParseGroupString (Settings
.Groups
, &PCB
->LayerGroups
, &PCB
->Data
->LayerN
);
1994 /* Add silk layers to newly created PCB */
1995 CreateNewPCBPost (PCB
, 1);
1997 command_line_pcb
= argv
[1];
1999 ResetStackAndVisibility ();
2005 SetMode (ARROW_MODE
);
2007 if (command_line_pcb
)
2009 /* keep filename even if initial load command failed;
2010 * file might not exist
2012 if (LoadPCB (command_line_pcb
))
2013 PCB
->Filename
= strdup (command_line_pcb
);
2016 if (Settings
.InitialLayerStack
2017 && Settings
.InitialLayerStack
[0])
2019 LayerStringToLayerStack (Settings
.InitialLayerStack
);
2022 /* This must be called before any other atexit functions
2023 * are registered, as it configures an atexit function to
2024 * clean up and free various items of allocated memory,
2025 * and must be the last last atexit function to run.
2029 /* Register a function to be called when the program terminates.
2030 * This makes sure that data is saved even if LEX/YACC routines
2031 * abort the program.
2032 * If the OS doesn't have at least one of them,
2033 * the critical sections will be handled by parse_l.l
2035 atexit (EmergencySave
);
2037 /* read the library file and display it if it's not empty
2039 if (!ReadLibraryContents () && Library
.MenuN
)
2040 hid_action ("LibraryChanged");
2042 #ifdef HAVE_LIBSTROKE
2046 if (Settings
.ScriptFilename
)
2048 Message (_("Executing startup script file %s\n"),
2049 Settings
.ScriptFilename
);
2050 hid_actionl ("ExecuteFile", Settings
.ScriptFilename
, NULL
);
2052 if (Settings
.ActionString
)
2054 Message (_("Executing startup action %s\n"), Settings
.ActionString
);
2055 hid_parse_actions (Settings
.ActionString
);
2058 if (gui
->printer
|| gui
->exporter
)
2071 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2072 Settings
.LibraryCommandDir
);
2073 printf ("Settings.FontPath = \"%s\"\n",
2075 printf ("Settings.ElementPath = \"%s\"\n",
2076 Settings
.ElementPath
);
2077 printf ("Settings.LibraryPath = \"%s\"\n",
2078 Settings
.LibraryPath
);
2079 printf ("Settings.LibraryTree = \"%s\"\n",
2080 Settings
.LibraryTree
);
2081 printf ("Settings.MakeProgram = \"%s\"\n",
2082 UNKNOWN (Settings
.MakeProgram
));
2083 printf ("Settings.GnetlistProgram = \"%s\"\n",
2084 UNKNOWN (Settings
.GnetlistProgram
));