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
41 #include <time.h> /* Seed for srand() */
47 #include "crosshair.h"
54 #include "lrealpath.h"
55 #include "free_atexit.h"
58 #include "pcb-printf.h"
60 #include "hid/common/actions.h"
62 /* This next one is so we can print the help messages. */
63 #include "hid/hidint.h"
69 #ifdef HAVE_LIBDMALLOC
73 #define PCBLIBPATH ".:" PCBLIBDIR
77 extern void stroke_init (void);
81 /* ----------------------------------------------------------------------
82 * initialize signal and error handlers
88 signal(SIGHUP, CatchSignal);
89 signal(SIGQUIT, CatchSignal);
90 signal(SIGABRT, CatchSignal);
91 signal(SIGSEGV, CatchSignal);
92 signal(SIGTERM, CatchSignal);
93 signal(SIGINT, CatchSignal);
96 /* calling external program by popen() may cause a PIPE signal,
100 signal (SIGPIPE
, SIG_IGN
);
105 /* ----------------------------------------------------------------------
106 | command line and rc file processing.
108 static char *command_line_pcb
;
114 " COPYRIGHT for %s version %s\n\n"
115 " PCB, interactive printed circuit board design\n"
116 " Copyright (C) 1994,1995,1996,1997 Thomas Nau\n"
117 " Copyright (C) 1998, 1999, 2000 Harry Eaton\n\n"
118 " This program is free software; you can redistribute it and/or modify\n"
119 " it under the terms of the GNU General Public License as published by\n"
120 " the Free Software Foundation; either version 2 of the License, or\n"
121 " (at your option) any later version.\n\n"
122 " This program is distributed in the hope that it will be useful,\n"
123 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
124 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
125 " GNU General Public License for more details.\n\n"
126 " You should have received a copy of the GNU General Public License\n"
127 " along with this program; if not, write to the Free Software\n"
128 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n",
134 u (const char *fmt
, ...)
138 vfprintf (stderr
, fmt
, ap
);
139 fputc ('\n', stderr
);
143 typedef struct UsageNotes
{
144 struct UsageNotes
*next
;
148 static UsageNotes
*usage_notes
= NULL
;
151 usage_attr (HID_Attribute
* a
)
154 const Unit
*unit_list
;
155 static char buf
[200];
157 if (a
->help_text
== ATTR_UNDOCUMENTED
)
166 sprintf (buf
, "--%s <num>", a
->name
);
169 sprintf (buf
, "--%s <measure>", a
->name
);
172 sprintf (buf
, "--%s <string>", a
->name
);
175 sprintf (buf
, "--%s", a
->name
);
179 sprintf (buf
, "--%s ", a
->name
);
180 if (a
->type
== HID_Mixed
)
181 strcat (buf
, " <val>");
182 for (i
= 0; a
->enumerations
[i
]; i
++)
184 strcat (buf
, i
? "|" : "<");
185 strcat (buf
, a
->enumerations
[i
]);
190 sprintf (buf
, "--%s <path>", a
->name
);
193 unit_list
= get_unit_list ();
195 sprintf (buf
, "--%s ", a
->name
);
196 for (i
= 0; i
< n
; i
++)
198 strcat (buf
, i
? "|" : "<");
199 strcat (buf
, unit_list
[i
].suffix
);
205 if (strlen (buf
) <= 30)
208 fprintf (stderr
, " %-30s\t%s\n", buf
, a
->help_text
);
210 fprintf (stderr
, " %-30s\n", buf
);
212 else if (a
->help_text
&& strlen (a
->help_text
) + strlen (buf
) < 72)
213 fprintf (stderr
, " %s\t%s\n", buf
, a
->help_text
);
214 else if (a
->help_text
)
215 fprintf (stderr
, " %s\n\t\t\t%s\n", buf
, a
->help_text
);
217 fprintf (stderr
, " %s\n", buf
);
223 HID_Attribute
*attributes
;
224 int i
, n_attributes
= 0;
229 fprintf (stderr
, "\n%s gui options:\n", h
->name
);
230 attributes
= h
->get_export_options (&n_attributes
);
234 fprintf (stderr
, "\n%s options:\n", h
->name
);
236 attributes
= exporter
->get_export_options (&n_attributes
);
240 note
= (UsageNotes
*)malloc (sizeof (UsageNotes
));
241 note
->next
= usage_notes
;
242 note
->seen
= attributes
;
245 for (i
= 0; i
< n_attributes
; i
++)
246 usage_attr (attributes
+ i
);
252 HID
**hl
= hid_enumerate ();
256 int n_printer
= 0, n_gui
= 0, n_exporter
= 0;
258 for (i
= 0; hl
[i
]; i
++)
268 u ("PCB Printed Circuit Board editing program, http://pcb.geda-project.org");
269 u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname
);
270 u ("%s [gui options] <pcb file>\t\tto edit", Progname
);
271 u ("Available GUI hid%s:", n_gui
== 1 ? "" : "s");
272 for (i
= 0; hl
[i
]; i
++)
274 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
275 u ("%s -p [printing options] <pcb file>\tto print", Progname
);
276 u ("Available printing hid%s:", n_printer
== 1 ? "" : "s");
277 for (i
= 0; hl
[i
]; i
++)
279 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
280 u ("%s -x hid [export options] <pcb file>\tto export", Progname
);
281 u ("Available export hid%s:", n_exporter
== 1 ? "" : "s");
282 for (i
= 0; hl
[i
]; i
++)
284 fprintf (stderr
, "\t%-8s %s\n", hl
[i
]->name
, hl
[i
]->description
);
286 for (i
= 0; hl
[i
]; i
++)
289 for (i
= 0; hl
[i
]; i
++)
292 for (i
= 0; hl
[i
]; i
++)
296 u ("\nCommon options:");
297 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
299 for (note
= usage_notes
; note
&& note
->seen
!= ha
->attributes
; note
= note
->next
)
303 for (i
= 0; i
< ha
->n
; i
++)
305 usage_attr (ha
->attributes
+ i
);
313 print_defaults_1 (HID_Attribute
* a
, void *value
)
320 /* Remember, at this point we've parsed the command line, so they
321 may be in the global variable instead of the default_val. */
325 i
= value
? *(int *) value
: a
->default_val
.int_value
;
326 fprintf (stderr
, "%s %d\n", a
->name
, i
);
329 i
= value
? *(char *) value
: a
->default_val
.int_value
;
330 fprintf (stderr
, "%s %s\n", a
->name
, i
? "yes" : "no");
333 d
= value
? *(double *) value
: a
->default_val
.real_value
;
334 fprintf (stderr
, "%s %g\n", a
->name
, d
);
337 c
= value
? *(Coord
*) value
: a
->default_val
.coord_value
;
338 pcb_fprintf (stderr
, "%s %$mS\n", a
->name
, c
);
342 s
= value
? *(char **) value
: a
->default_val
.str_value
;
343 fprintf (stderr
, "%s \"%s\"\n", a
->name
, s
);
346 i
= value
? *(int *) value
: a
->default_val
.int_value
;
347 fprintf (stderr
, "%s %s\n", a
->name
, a
->enumerations
[i
]);
351 ((HID_Attr_Val
*)value
)->int_value
: a
->default_val
.int_value
;
353 ((HID_Attr_Val
*)value
)->real_value
: a
->default_val
.real_value
;
354 fprintf (stderr
, "%s %g%s\n", a
->name
, d
, a
->enumerations
[i
]);
359 i
= value
? *(int *) value
: a
->default_val
.int_value
;
360 fprintf (stderr
, "%s %s\n", a
->name
, get_unit_list()[i
].suffix
);
367 HID
**hl
= hid_enumerate ();
371 for (hi
= 0; hl
[hi
]; hi
++)
377 fprintf (stderr
, "\ngui defaults:\n");
378 for (ha
= hid_attr_nodes
; ha
; ha
= ha
->next
)
379 for (i
= 0; i
< ha
->n
; i
++)
380 print_defaults_1 (ha
->attributes
+ i
, ha
->attributes
[i
].value
);
384 fprintf (stderr
, "\n%s defaults:\n", h
->name
);
386 e
= exporter
->get_export_options (&n
);
389 for (i
= 0; i
< n
; i
++)
390 print_defaults_1 (e
+ i
, 0);
396 #define SSET(F,D,N,H) { N, H, \
397 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
398 #define ISET(F,D,N,H) { N, H, \
399 HID_Integer, 0, 0, { D, 0, 0 }, 0, &Settings.F }
400 #define BSET(F,D,N,H) { N, H, \
401 HID_Boolean, 0, 0, { D, 0, 0 }, 0, &Settings.F }
402 #define RSET(F,D,N,H) { N, H, \
403 HID_Real, 0, 0, { 0, 0, D }, 0, &Settings.F }
404 #define CSET(F,D,N,H) { N, H, \
405 HID_Coord, 0, 0, { 0, 0, 0, D }, 0, &Settings.F }
407 #define COLOR(F,D,N,H) { N, H, \
408 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
409 #define LAYERCOLOR(N,D) { "layer-color-" #N, "Color for layer " #N, \
410 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.LayerColor[N-1] }
411 #define LAYERNAME(N,D) { "layer-name-" #N, "Name for layer " #N, \
412 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.DefaultLayerName[N-1] }
413 #define LAYERSELCOLOR(N) { "layer-selected-color-" #N, "Color for layer " #N " when selected", \
414 HID_String, 0, 0, { 0, "#00ffff", 0 }, 0, &Settings.LayerSelectedColor[N-1] }
416 static int show_help
= 0;
417 static int show_version
= 0;
418 static int show_copyright
= 0;
419 static int show_defaults
= 0;
420 static int show_actions
= 0;
421 static int do_dump_actions
= 0;
422 static char *grid_units
;
423 static Increments increment_mm
= { 0 };
424 static Increments increment_mil
= { 0 };
426 void save_increments (const Increments
*mm
, const Increments
*mil
)
428 memcpy (&increment_mm
, mm
, sizeof (*mm
));
429 memcpy (&increment_mil
, mil
, sizeof (*mil
));
432 HID_Attribute main_attribute_list
[] = {
434 /* %start-doc options "1 General Options"
437 Show help on command line options.
441 {"help", "Show help on command line options", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
444 /* %start-doc options "1 General Options"
451 {"version", "Show version", HID_Boolean
, 0, 0, {0, 0, 0}, 0, &show_version
},
453 /* %start-doc options "1 General Options"
456 Be verbose on stdout.
460 {"verbose", "Be verbose on stdout", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
463 /* %start-doc options "1 General Options"
470 {"copyright", "Show Copyright", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
473 /* %start-doc options "1 General Options"
475 @item --show-defaults
476 Show option defaults.
480 {"show-defaults", "Show option defaults", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
483 /* %start-doc options "1 General Options"
486 Show available actions and exit.
490 {"show-actions", "Show available actions", HID_Boolean
, 0, 0, {0, 0, 0}, 0,
493 /* %start-doc options "1 General Options"
496 Dump actions (for documentation).
500 {"dump-actions", "Dump actions (for documentation)", HID_Boolean
, 0, 0,
501 {0, 0, 0}, 0, &do_dump_actions
},
503 /* %start-doc options "1 General Options"
505 @item --grid-units-mm <string>
506 Set default grid units. Can be mm or mil. Defaults to mil.
510 {"grid-units", "Default grid units (mm|mil)", HID_String
, 0, 0, {0, "mil", 0},
513 /* %start-doc options "1 General Options"
515 @item --clear-increment-mm <string>
516 Set default clear increment (amount to change when user presses k or K)
517 when user is using a metric grid unit.
521 {"clear-increment-mm", "Default clear increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
522 0, &increment_mm
.clear
},
524 /* %start-doc options "1 General Options"
526 @item --grid-increment-mm <string>
527 Set default grid increment (amount to change when user presses g or G)
528 when user is using a metric grid unit.
532 {"grid-increment-mm", "Default grid increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
533 0, &increment_mm
.grid
},
535 /* %start-doc options "1 General Options"
537 @item --line-increment-mm <string>
538 Set default line increment (amount to change when user presses l or L)
539 when user is using a metric grid unit.
543 {"line-increment-mm", "Default line increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
544 0, &increment_mm
.line
},
546 /* %start-doc options "1 General Options"
548 @item --size-increment-mm <string>
549 Set default size increment (amount to change when user presses s or S)
550 when user is using a metric grid unit.
554 {"size-increment-mm", "Default size increment amount (metric)", HID_Coord
, 0, 0, {0, 0, 0},
555 0, &increment_mm
.size
},
557 /* %start-doc options "1 General Options"
559 @item --clear-increment-mil <string>
560 Set default clear increment (amount to change when user presses k or K)
561 when user is using an imperial grid unit.
565 {"clear-increment-mil", "Default clear increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
566 0, &increment_mil
.clear
},
568 /* %start-doc options "1 General Options"
570 @item --grid-increment-mil <string>
571 Set default grid increment (amount to change when user presses g or G)
572 when user is using a imperial grid unit.
576 {"grid-increment-mil", "Default grid increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
577 0, &increment_mil
.grid
},
579 /* %start-doc options "1 General Options"
581 @item --line-increment-mil <string>
582 Set default line increment (amount to change when user presses l or L)
583 when user is using a imperial grid unit.
587 {"line-increment-mil", "Default line increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
588 0, &increment_mil
.line
},
590 /* %start-doc options "1 General Options"
592 @item --size-increment-mil <string>
593 Set default size increment (amount to change when user presses s or S)
594 when user is using a imperial grid unit.
598 {"size-increment-mil", "Default size increment amount (imperial)", HID_Coord
, 0, 0, {0, 0, 0},
599 0, &increment_mil
.size
},
601 /* %start-doc options "3 Colors"
603 @item --black-color <string>
604 Color value for black. Default: @samp{#000000}
608 COLOR (BlackColor
, "#000000", "black-color", "color value of 'black'"),
610 /* %start-doc options "3 Colors"
612 @item --black-color <string>
613 Color value for white. Default: @samp{#ffffff}
617 COLOR (WhiteColor
, "#ffffff", "white-color", "color value of 'white'"),
619 /* %start-doc options "3 Colors"
621 @item --background-color <string>
622 Background color of the canvas. Default: @samp{#e5e5e5}
626 COLOR (BackgroundColor
, "#e5e5e5", "background-color",
627 "color for background"),
629 /* %start-doc options "3 Colors"
631 @item --crosshair-color <string>
632 Color of the crosshair. Default: @samp{#ff0000}
636 COLOR (CrosshairColor
, "#ff0000", "crosshair-color",
637 "color for the crosshair"),
639 /* %start-doc options "3 Colors"
641 @item --cross-color <string>
642 Color of the cross. Default: @samp{#cdcd00}
646 COLOR (CrossColor
, "#cdcd00", "cross-color", "color of the cross"),
648 /* %start-doc options "3 Colors"
650 @item --via-color <string>
651 Color of vias. Default: @samp{#7f7f7f}
655 COLOR (ViaColor
, "#7f7f7f", "via-color", "color of vias"),
657 /* %start-doc options "3 Colors"
659 @item --via-selected-color <string>
660 Color of selected vias. Default: @samp{#00ffff}
664 COLOR (ViaSelectedColor
, "#00ffff", "via-selected-color",
665 "color for selected vias"),
667 /* %start-doc options "3 Colors"
669 @item --pin-color <string>
670 Color of pins. Default: @samp{#4d4d4d}
674 COLOR (PinColor
, "#4d4d4d", "pin-color", "color of pins"),
676 /* %start-doc options "3 Colors"
678 @item --pin-selected-color <string>
679 Color of selected pins. Default: @samp{#00ffff}
683 COLOR (PinSelectedColor
, "#00ffff", "pin-selected-color",
684 "color of selected pins"),
686 /* %start-doc options "3 Colors"
688 @item --pin-name-color <string>
689 Color of pin names and pin numbers. Default: @samp{#ff0000}
693 COLOR (PinNameColor
, "#ff0000", "pin-name-color",
694 "color for pin names and pin numbers"),
696 /* %start-doc options "3 Colors"
698 @item --element-color <string>
699 Color of components. Default: @samp{#000000}
703 COLOR (ElementColor
, "#000000", "element-color", "color of components"),
705 /* %start-doc options "3 Colors"
707 @item --rat-color <string>
708 Color of ratlines. Default: @samp{#b8860b}
712 COLOR (RatColor
, "#b8860b", "rat-color", "color of ratlines"),
714 /* %start-doc options "3 Colors"
716 @item --invisible-objects-color <string>
717 Color of invisible objects. Default: @samp{#cccccc}
721 COLOR (InvisibleObjectsColor
, "#cccccc", "invisible-objects-color",
722 "color of invisible objects"),
724 /* %start-doc options "3 Colors"
726 @item --invisible-mark-color <string>
727 Color of invisible marks. Default: @samp{#cccccc}
731 COLOR (InvisibleMarkColor
, "#cccccc", "invisible-mark-color",
732 "color of invisible marks"),
734 /* %start-doc options "3 Colors"
736 @item --element-selected-color <string>
737 Color of selected components. Default: @samp{#00ffff}
741 COLOR (ElementSelectedColor
, "#00ffff", "element-selected-color",
742 "color of selected components"),
744 /* %start-doc options "3 Colors"
746 @item --rat-selected-color <string>
747 Color of selected rats. Default: @samp{#00ffff}
751 COLOR (RatSelectedColor
, "#00ffff", "rat-selected-color",
752 "color of selected rats"),
754 /* %start-doc options "3 Colors"
756 @item --connected-color <string>
757 Color to indicate physical connections. Default: @samp{#00ff00}
761 COLOR (ConnectedColor
, "#00ff00", "connected-color",
762 "color to indicate physically connected objects"),
764 /* %start-doc options "3 Colors"
766 @item --found-color <string>
767 Color to indicate logical connections. Default: @samp{#ff00ff}
771 COLOR (FoundColor
, "#ff00ff", "found-color",
772 "color to indicate logically connected objects"),
774 /* %start-doc options "3 Colors"
776 @item --off-limit-color <string>
777 Color of off-canvas area. Default: @samp{#cccccc}
781 COLOR (OffLimitColor
, "#cccccc", "off-limit-color",
782 "color of off-canvas area"),
784 /* %start-doc options "3 Colors"
786 @item --grid-color <string>
787 Color of the grid. Default: @samp{#ff0000}
791 COLOR (GridColor
, "#ff0000", "grid-color", "color of the grid"),
793 /* %start-doc options "3 Colors"
795 @item --layer-color-<n> <string>
796 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
800 LAYERCOLOR (1, "#8b2323"),
801 LAYERCOLOR (2, "#3a5fcd"),
802 LAYERCOLOR (3, "#104e8b"),
803 LAYERCOLOR (4, "#cd3700"),
804 LAYERCOLOR (5, "#548b54"),
805 LAYERCOLOR (6, "#8b7355"),
806 LAYERCOLOR (7, "#00868b"),
807 LAYERCOLOR (8, "#228b22"),
808 LAYERCOLOR (9, "#8b2323"),
809 LAYERCOLOR (10, "#3a5fcd"),
810 LAYERCOLOR (11, "#104e8b"),
811 LAYERCOLOR (12, "#cd3700"),
812 LAYERCOLOR (13, "#548b54"),
813 LAYERCOLOR (14, "#8b7355"),
814 LAYERCOLOR (15, "#00868b"),
815 LAYERCOLOR (16, "#228b22"),
816 /* %start-doc options "3 Colors"
818 @item --layer-selected-color-<n> <string>
819 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
840 /* %start-doc options "3 Colors"
842 @item --warn-color <string>
843 Color of offending objects during DRC. Default value is @code{"#ff8000"}
847 COLOR (WarnColor
, "#ff8000", "warn-color", "color of offending objects during DRC"),
849 /* %start-doc options "3 Colors"
851 @item --mask-color <string>
852 Color of the mask layer. Default value is @code{"#ff0000"}
856 COLOR (MaskColor
, "#ff0000", "mask-color", "color for solder mask"),
858 /* %start-doc options "3 Colors"
860 @item --mask-color <string>
861 Color of the mask layer. Default value is @code{"#ff0000"}
865 COLOR (MaskSelectedColor
, "#00ffff", "mask-selected-color", "color of selected solder mask cutouts"),
868 /* %start-doc options "5 Sizes"
869 All parameters should be given with an unit. If no unit is given, 1/100 mil
870 (cmil) will be used. Write units without space to the
871 number like @code{3mm}, not @code{3 mm}.
895 @item --via-thickness <num>
896 Default diameter of vias. Default value is @code{60mil}.
900 CSET (ViaThickness
, MIL_TO_COORD(60), "via-thickness",
901 "default diameter of vias in 1/100 mil"),
903 /* %start-doc options "5 Sizes"
905 @item --via-drilling-hole <num>
906 Default diameter of holes. Default value is @code{28mil}.
910 CSET (ViaDrillingHole
, MIL_TO_COORD(28), "via-drilling-hole",
911 "default diameter of holes"),
913 /* %start-doc options "5 Sizes"
915 @item --line-thickness <num>
916 Default thickness of new lines. Default value is @code{10mil}.
920 CSET (LineThickness
, MIL_TO_COORD(10), "line-thickness",
921 "initial thickness of new lines"),
923 /* %start-doc options "5 Sizes"
925 @item --rat-thickness <num><unit>
926 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100
927 means "1 nm"). This option allows for a special unit @code{px} which
928 sets the rat thickness to a fixed value in terms of screen pixels.
929 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.
930 Default value is @code{10mil}.
934 CSET (RatThickness
, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
936 /* %start-doc options "5 Sizes"
938 @item --keepaway <num>
939 Default minimum distance between a track and adjacent copper.
940 Default value is @code{10mil}.
944 CSET (Keepaway
, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
946 /* %start-doc options "5 Sizes"
948 @item --default-PCB-width <num>
949 Default width of the canvas. Default value is @code{6000mil}.
953 CSET (MaxWidth
, MIL_TO_COORD(6000), "default-PCB-width",
954 "default width of the canvas"),
956 /* %start-doc options "5 Sizes"
958 @item --default-PCB-height <num>
959 Default height of the canvas. Default value is @code{5000mil}.
963 CSET (MaxHeight
, MIL_TO_COORD(5000), "default-PCB-height",
964 "default height of the canvas"),
966 /* %start-doc options "5 Sizes"
968 @item --text-scale <num>
969 Default text scale. This value is in percent. Default value is @code{100}.
973 ISET (TextScale
, 100, "text-scale", "default text scale in percent"),
975 /* %start-doc options "5 Sizes"
977 @item --alignment-distance <num>
978 Specifies the distance between the board outline and alignment targets.
979 Default value is @code{2mil}.
983 CSET (AlignmentDistance
, MIL_TO_COORD(2), "alignment-distance",
984 "distance between the boards outline and alignment targets"),
986 /* %start-doc options "7 DRC Options"
987 All parameters should be given with an unit. If no unit is given, 1/100 mil
988 (cmil) will be used for backward compability. Valid units are given in section
994 /* %start-doc options "7 DRC Options"
997 Minimum spacing. Default value is @code{10mil}.
1001 CSET (Bloat
, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
1003 /* %start-doc options "7 DRC Options"
1005 @item --shrink <num>
1006 Minimum touching overlap. Default value is @code{10mil}.
1010 CSET (Shrink
, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
1012 /* %start-doc options "7 DRC Options"
1014 @item --min-width <num>
1015 Minimum width of copper. Default value is @code{10mil}.
1019 CSET (minWid
, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1021 /* %start-doc options "7 DRC Options"
1023 @item --min-silk <num>
1024 Minimum width of lines in silk. Default value is @code{10mil}.
1028 CSET (minSlk
, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1030 /* %start-doc options "7 DRC Options"
1032 @item --min-drill <num>
1033 Minimum diameter of holes. Default value is @code{15mil}.
1037 CSET (minDrill
, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1039 /* %start-doc options "7 DRC Options"
1041 @item --min-ring <num>
1042 Minimum width of annular ring. Default value is @code{10mil}.
1046 CSET (minRing
, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1049 /* %start-doc options "5 Sizes"
1052 Initial grid size. Default value is @code{10mil}.
1056 CSET (Grid
, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1058 /* %start-doc options "5 Sizes"
1060 @item --minimum polygon area <num>
1061 Minimum polygon area.
1065 RSET (IsleArea
, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1068 /* %start-doc options "1 General Options"
1070 @item --backup-interval
1071 Time between automatic backups in seconds. Set to @code{0} to disable.
1072 The default value is @code{60}.
1076 ISET (BackupInterval
, 60, "backup-interval",
1077 "Time between automatic backups in seconds. Set to 0 to disable"),
1079 /* %start-doc options "4 Layer Names"
1081 @item --layer-name-1 <string>
1082 Name of the 1st Layer. Default is @code{"top"}.
1086 LAYERNAME (1, "top"),
1088 /* %start-doc options "4 Layer Names"
1090 @item --layer-name-2 <string>
1091 Name of the 2nd Layer. Default is @code{"ground"}.
1095 LAYERNAME (2, "ground"),
1097 /* %start-doc options "4 Layer Names"
1099 @item --layer-name-3 <string>
1100 Name of the 3nd Layer. Default is @code{"signal2"}.
1104 LAYERNAME (3, "signal2"),
1106 /* %start-doc options "4 Layer Names"
1108 @item --layer-name-4 <string>
1109 Name of the 4rd Layer. Default is @code{"signal3"}.
1113 LAYERNAME (4, "signal3"),
1115 /* %start-doc options "4 Layer Names"
1117 @item --layer-name-5 <string>
1118 Name of the 5rd Layer. Default is @code{"power"}.
1122 LAYERNAME (5, "power"),
1124 /* %start-doc options "4 Layer Names"
1126 @item --layer-name-6 <string>
1127 Name of the 6rd Layer. Default is @code{"bottom"}.
1131 LAYERNAME (6, "bottom"),
1133 /* %start-doc options "4 Layer Names"
1135 @item --layer-name-7 <string>
1136 Name of the 7rd Layer. Default is @code{"outline"}.
1140 LAYERNAME (7, "outline"),
1142 /* %start-doc options "4 Layer Names"
1144 @item --layer-name-8 <string>
1145 Name of the 8rd Layer. Default is @code{"spare"}.
1149 LAYERNAME (8, "spare"),
1151 /* %start-doc options "1 General Options"
1153 @item --groups <string>
1154 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1158 SSET (Groups
, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
1161 /* %start-doc options "6 Commands"
1162 pcb uses external commands for input output operations. These commands can be
1163 configured at start-up to meet local requirements. The command string may include
1164 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
1165 command is called. The sequence @code{%f} is replaced by the file name,
1166 @code{%p} gets the path and @code{%a} indicates a package name.
1170 /* %start-doc options "6 Commands"
1172 @item --font-command <string>
1173 Command to load a font.
1177 SSET (FontCommand
, "", "font-command", "Command to load a font"),
1179 /* %start-doc options "6 Commands"
1181 @item --file-command <string>
1182 Command to read a file.
1186 SSET (FileCommand
, "", "file-command", "Command to read a file"),
1188 /* %start-doc options "6 Commands"
1190 @item --element-command <string>
1191 Command to read a footprint. @*
1192 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1196 SSET (ElementCommand
,
1197 "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4
,
1198 "element-command", "Command to read a footprint"),
1200 /* %start-doc options "6 Commands"
1202 @item --print-file <string>
1203 Command to print to a file.
1207 SSET (PrintFile
, "%f.output", "print-file", "Command to print to a file"),
1209 /* %start-doc options "6 Commands"
1211 @item --lib-command-dir <string>
1212 Path to the command that queries the library.
1216 SSET (LibraryCommandDir
, PCBLIBDIR
, "lib-command-dir",
1217 "Path to the command that queries the library"),
1219 /* %start-doc options "6 Commands"
1221 @item --lib-command <string>
1222 Command to query the library. @*
1223 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1227 SSET (LibraryCommand
, "QueryLibrary.sh '%p' '%f' %a",
1228 "lib-command", "Command to query the library"),
1230 /* %start-doc options "6 Commands"
1232 @item --lib-contents-command <string>
1233 Command to query the contents of the library. @*
1234 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
1235 on Windows builds, an empty string (to disable this feature).
1239 SSET (LibraryContentsCommand
,
1243 "ListLibraryContents.sh '%p' '%f'",
1245 "lib-contents-command", "Command to query the contents of the library"),
1247 /* %start-doc options "5 Paths"
1249 @item --lib-newlib <string>
1250 Top level directory for the newlib style library.
1254 SSET (LibraryTree
, PCBTREEPATH
, "lib-newlib",
1255 "Top level directory for the newlib style library"),
1257 /* %start-doc options "6 Commands"
1259 @item --save-command <string>
1260 Command to save to a file.
1264 SSET (SaveCommand
, "", "save-command", "Command to save to a file"),
1266 /* %start-doc options "5 Paths"
1268 @item --lib-name <string>
1269 The default filename for the library.
1273 SSET (LibraryFilename
, LIBRARYFILENAME
, "lib-name",
1274 "The default filename for the library"),
1276 /* %start-doc options "5 Paths"
1278 @item --default-font <string>
1279 The name of the default font.
1283 SSET (FontFile
, "default_font", "default-font",
1284 "File name of default font"),
1286 /* %start-doc options "1 General Options"
1288 @item --route-styles <string>
1289 A string that defines the route styles. Defaults to @*
1290 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
1291 :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
1295 SSET (Routes
, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
1296 ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
1297 "A string that defines the route styles"),
1299 /* %start-doc options "5 Paths"
1301 @item --file-path <string>
1302 A colon separated list of directories or commands (starts with '|'). The path
1303 is passed to the program specified in @option{--file-command} together with the selected
1308 SSET (FilePath
, "", "file-path", 0),
1310 /* %start-doc options "6 Commands"
1312 @item --rat-command <string>
1313 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1317 SSET (RatCommand
, "", "rat-command", "Command for reading a netlist"),
1319 /* %start-doc options "5 Paths"
1321 @item --font-path <string>
1322 A colon separated list of directories to search the default font. Defaults to
1323 the default library path.
1327 SSET (FontPath
, PCBLIBPATH
, "font-path",
1328 "Colon separated list of directories to search the default font"),
1330 /* %start-doc options "1 General Options"
1332 @item --element-path <string>
1333 A colon separated list of directories or commands (starts with '|').
1334 The path is passed to the program specified in @option{--element-command}.
1338 SSET(ElementPath
, PCBLIBPATH
, "element-path",
1339 "A colon separated list of directories or commands (starts with '|')"),
1341 /* %start-doc options "5 Paths"
1343 @item --lib-path <string>
1344 A colon separated list of directories that will be passed to the commands specified
1345 by @option{--element-command} and @option{--element-contents-command}.
1349 SSET (LibraryPath
, PCBLIBPATH
, "lib-path",
1350 "A colon separated list of directories"),
1352 /* %start-doc options "1 General Options"
1354 @item --action-script <string>
1355 If set, this file is executed at startup.
1359 SSET (ScriptFilename
, 0, "action-script",
1360 "If set, this file is executed at startup"),
1362 /* %start-doc options "1 General Options"
1364 @item --action-string <string>
1365 If set, this string of actions is executed at startup.
1369 SSET (ActionString
, 0, "action-string",
1370 "If set, this is executed at startup"),
1372 /* %start-doc options "1 General Options"
1374 @item --fab-author <string>
1375 Name of author to be put in the Gerber files.
1379 SSET (FabAuthor
, "", "fab-author",
1380 "Name of author to be put in the Gerber files"),
1382 /* %start-doc options "1 General Options"
1384 @item --layer-stack <string>
1385 Initial layer stackup, for setting up an export. A comma separated list of layer
1386 names, layer numbers and layer groups.
1390 SSET (InitialLayerStack
, "", "layer-stack",
1391 "Initial layer stackup, for setting up an export."),
1393 SSET (MakeProgram
, NULL
, "make-program",
1394 "Sets the name and optionally full path to a make(3) program"),
1395 SSET (GnetlistProgram
, NULL
, "gnetlist",
1396 "Sets the name and optionally full path to the gnetlist(3) program"),
1398 /* %start-doc options "2 General GUI Options"
1400 @item --pinout-offset-x <num>
1401 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1405 CSET (PinoutOffsetX
, MIL_TO_COORD(1), "pinout-offset-x",
1406 "Horizontal offset of the pin number display in mil"),
1408 /* %start-doc options "2 General GUI Options"
1410 @item --pinout-offset-y <num>
1411 Vertical offset of the pin number display. Defaults to @code{100mil}.
1415 CSET (PinoutOffsetY
, MIL_TO_COORD(1), "pinout-offset-y",
1416 "Vertical offset of the pin number display in mil"),
1418 /* %start-doc options "2 General GUI Options"
1420 @item --pinout-text-offset-x <num>
1421 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1425 CSET (PinoutTextOffsetX
, MIL_TO_COORD(8), "pinout-text-offset-x",
1426 "Horizontal offset of the pin name display in mil"),
1428 /* %start-doc options "2 General GUI Options"
1430 @item --pinout-text-offset-y <num>
1431 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1435 CSET (PinoutTextOffsetY
, MIL_TO_COORD(-1), "pinout-text-offset-y",
1436 "Vertical offset of the pin name display in mil"),
1438 /* %start-doc options "2 General GUI Options"
1441 If set, draw the grid at start-up.
1445 BSET (DrawGrid
, 0, "draw-grid", "If set, draw the grid at start-up"),
1447 /* %start-doc options "2 General GUI Options"
1450 If set, new lines clear polygons.
1454 BSET (ClearLine
, 1, "clear-line", "If set, new lines clear polygons"),
1456 /* %start-doc options "2 General GUI Options"
1459 If set, new polygons are full ones.
1463 BSET (FullPoly
, 0, "full-poly", 0),
1465 /* %start-doc options "2 General GUI Options"
1467 @item --unique-names
1468 If set, you will not be permitted to change the name of an component to match that
1469 of another component.
1473 BSET (UniqueNames
, 1, "unique-names", "Prevents identical component names"),
1475 /* %start-doc options "2 General GUI Options"
1478 If set, pin centers and pad end points are treated as additional grid points
1479 that the cursor can snap to.
1483 BSET (SnapPin
, 1, "snap-pin",
1484 "If set, the cursor snaps to pads and pin centers"),
1486 /* %start-doc options "1 General Options"
1488 @item --save-last-command
1489 If set, the last user command is saved.
1493 BSET (SaveLastCommand
, 0, "save-last-command", 0),
1495 /* %start-doc options "1 General Options"
1498 If set, all data which would otherwise be lost are saved in a temporary file
1499 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
1503 BSET (SaveInTMP
, 0, "save-in-tmp",
1504 "When set, all data which would otherwise be lost are saved in /tmp"),
1506 /* %start-doc options "1 General Options"
1508 @item --save-metric-only
1509 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
1513 BSET (SaveMetricOnly
, 0, "save-metric-only",
1514 "If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm."),
1516 /* %start-doc options "2 General GUI Options"
1518 @item --all-direction-lines
1519 Allow all directions, when drawing new lines.
1523 BSET (AllDirectionLines
, 0, "all-direction-lines",
1524 "Allow all directions, when drawing new lines"),
1526 /* %start-doc options "2 General GUI Options"
1529 Pinout shows number.
1533 BSET (ShowNumber
, 0, "show-number", "Pinout shows number"),
1535 /* %start-doc options "1 General Options"
1537 @item --reset-after-element
1538 If set, all found connections are reset before a new component is scanned.
1542 BSET (ResetAfterElement
, 1, "reset-after-element",
1543 "If set, all found connections are reset before a new component is scanned"),
1545 /* %start-doc options "1 General Options"
1547 @item --ring-bell-finished
1548 Execute the bell command when all rats are routed.
1552 BSET (RingBellWhenFinished
, 0, "ring-bell-finished",
1553 "Execute the bell command when all rats are routed"),
1556 REGISTER_ATTRIBUTES (main_attribute_list
)
1557 /* ----------------------------------------------------------------------
1558 * post-process settings.
1560 static void settings_post_process ()
1564 if (Settings
.LibraryCommand
!= NULL
&&
1565 Settings
.LibraryCommand
[0] != '\0' &&
1566 Settings
.LibraryCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1567 Settings
.LibraryCommand
[0] != '.')
1569 Settings
.LibraryCommand
1571 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1572 Settings
.LibraryCommand
,
1575 if (Settings
.LibraryContentsCommand
!= NULL
&&
1576 Settings
.LibraryContentsCommand
[0] != '\0' &&
1577 Settings
.LibraryContentsCommand
[0] != PCB_DIR_SEPARATOR_C
&&
1578 Settings
.LibraryContentsCommand
[0] != '.')
1580 Settings
.LibraryContentsCommand
1582 Concat (Settings
.LibraryCommandDir
, PCB_DIR_SEPARATOR_S
,
1583 Settings
.LibraryContentsCommand
, NULL
);
1586 if (Settings
.LineThickness
> MAX_LINESIZE
1587 || Settings
.LineThickness
< MIN_LINESIZE
)
1588 Settings
.LineThickness
= MIL_TO_COORD(10);
1590 if (Settings
.ViaThickness
> MAX_PINORVIASIZE
1591 || Settings
.ViaThickness
< MIN_PINORVIASIZE
)
1592 Settings
.ViaThickness
= MIL_TO_COORD(40);
1594 if (Settings
.ViaDrillingHole
<= 0)
1595 Settings
.ViaDrillingHole
=
1596 DEFAULT_DRILLINGHOLE
* Settings
.ViaThickness
/ 100;
1598 Settings
.MaxWidth
= CLAMP (Settings
.MaxWidth
, MIN_SIZE
, MAX_COORD
);
1599 Settings
.MaxHeight
= CLAMP (Settings
.MaxHeight
, MIN_SIZE
, MAX_COORD
);
1601 ParseRouteString (Settings
.Routes
, &Settings
.RouteStyle
[0], "cmil");
1604 * Make sure we have settings for some various programs we may wish
1607 if (Settings
.MakeProgram
== NULL
) {
1608 tmps
= getenv ("PCB_MAKE_PROGRAM");
1610 Settings
.MakeProgram
= strdup (tmps
);
1612 if (Settings
.MakeProgram
== NULL
) {
1613 Settings
.MakeProgram
= strdup ("make");
1616 if (Settings
.GnetlistProgram
== NULL
) {
1617 tmps
= getenv ("PCB_GNETLIST");
1619 Settings
.GnetlistProgram
= strdup (tmps
);
1621 if (Settings
.GnetlistProgram
== NULL
) {
1622 Settings
.GnetlistProgram
= strdup ("gnetlist");
1626 Settings
.grid_unit
= get_unit_struct (grid_units
);
1627 if (!grid_units
|| Settings
.grid_unit
== NULL
)
1628 Settings
.grid_unit
= get_unit_struct ("mil");
1630 copy_nonzero_increments (get_increments_struct (METRIC
), &increment_mm
);
1631 copy_nonzero_increments (get_increments_struct (IMPERIAL
), &increment_mil
);
1633 Settings
.increments
= get_increments_struct (Settings
.grid_unit
->family
);
1636 /* ----------------------------------------------------------------------
1637 * Print help or version messages.
1643 printf ("PCB version %s\n", VERSION
);
1647 /* ----------------------------------------------------------------------
1648 * Figure out the canonical name of the executed program
1649 * and fix up the defaults for various paths
1651 char *bindir
= NULL
;
1652 char *exec_prefix
= NULL
;
1653 char *pcblibdir
= NULL
;
1654 char *pcblibpath
= NULL
;
1655 char *pcbtreedir
= NULL
;
1656 char *pcbtreepath
= NULL
;
1657 char *homedir
= NULL
;
1660 InitPaths (char *argv0
)
1666 int found_bindir
= 0;
1668 /* see if argv0 has enough of a path to let lrealpath give the
1669 * real path. This should be the case if you invoke pcb with
1670 * something like /usr/local/bin/pcb or ./pcb or ./foo/pcb
1671 * but if you just use pcb and it exists in your path, you'll
1672 * just get back pcb again.
1676 for (i
= 0; i
< strlen (argv0
) ; i
++)
1678 if (argv0
[i
] == PCB_DIR_SEPARATOR_C
)
1683 printf ("InitPaths (%s): haspath = %d\n", argv0
, haspath
);
1688 bindir
= strdup (lrealpath (argv0
));
1693 char *path
, *p
, *tmps
;
1697 tmps
= getenv ("PATH");
1701 path
= strdup (tmps
);
1703 /* search through the font path for a font file */
1704 for (p
= strtok (path
, PCB_PATH_DELIMETER
); p
&& *p
;
1705 p
= strtok (NULL
, PCB_PATH_DELIMETER
))
1708 printf ("Looking for %s in %s\n", argv0
, p
);
1710 if ( (tmps
= (char *)malloc ( (strlen (argv0
) + strlen (p
) + 2) * sizeof (char))) == NULL
)
1712 fprintf (stderr
, "InitPaths(): malloc failed\n");
1715 sprintf (tmps
, "%s%s%s", p
, PCB_DIR_SEPARATOR_S
, argv0
);
1716 r
= stat (tmps
, &sb
);
1720 printf ("Found it: \"%s\"\n", tmps
);
1722 bindir
= lrealpath (tmps
);
1734 printf ("InitPaths(): bindir = \"%s\"\n", bindir
);
1739 /* strip off the executible name leaving only the path */
1741 t1
= strchr (bindir
, PCB_DIR_SEPARATOR_C
);
1742 while (t1
!= NULL
&& *t1
!= '\0')
1745 t1
= strchr (t2
+ 1, PCB_DIR_SEPARATOR_C
);
1751 printf ("After stripping off the executible name, we found\n");
1752 printf ("bindir = \"%s\"\n", bindir
);
1757 /* we have failed to find out anything from argv[0] so fall back to the original
1760 bindir
= strdup (BINDIR
);
1763 /* now find the path to exec_prefix */
1764 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_EXECPREFIX
) + 1;
1765 if ( (exec_prefix
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1767 fprintf (stderr
, "InitPaths(): malloc failed\n");
1770 sprintf (exec_prefix
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1771 BINDIR_TO_EXECPREFIX
);
1773 /* now find the path to PCBLIBDIR */
1774 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBLIBDIR
) + 1;
1775 if ( (pcblibdir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1777 fprintf (stderr
, "InitPaths(): malloc failed\n");
1780 sprintf (pcblibdir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1781 BINDIR_TO_PCBLIBDIR
);
1783 /* and the path to PCBTREEDIR */
1784 l
= strlen (bindir
) + 1 + strlen (BINDIR_TO_PCBTREEDIR
) + 1;
1785 if ( (pcbtreedir
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1787 fprintf (stderr
, "InitPaths(): malloc failed\n");
1790 sprintf (pcbtreedir
, "%s%s%s", bindir
, PCB_DIR_SEPARATOR_S
,
1791 BINDIR_TO_PCBTREEDIR
);
1793 /* and the search path including PCBLIBDIR */
1794 l
= strlen (pcblibdir
) + 3;
1795 if ( (pcblibpath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1797 fprintf (stderr
, "InitPaths(): malloc failed\n");
1800 sprintf (pcblibpath
, ".%s%s", PCB_PATH_DELIMETER
, pcblibdir
);
1802 /* and the newlib search path */
1803 l
= strlen (pcblibdir
) + 1 + strlen (pcbtreedir
)
1804 + strlen ("pcblib-newlib") + 2;
1805 if ( (pcbtreepath
= (char *) malloc (l
* sizeof (char) )) == NULL
)
1807 fprintf (stderr
, "InitPaths(): malloc failed\n");
1810 sprintf (pcbtreepath
, "%s%s%s%spcblib-newlib", pcbtreedir
,
1811 PCB_PATH_DELIMETER
, pcblibdir
,
1812 PCB_DIR_SEPARATOR_S
);
1815 printf ("bindir = %s\n", bindir
);
1816 printf ("pcblibdir = %s\n", pcblibdir
);
1817 printf ("pcblibpath = %s\n", pcblibpath
);
1818 printf ("pcbtreedir = %s\n", pcbtreedir
);
1819 printf ("pcbtreepath = %s\n", pcbtreepath
);
1822 l
= sizeof (main_attribute_list
) / sizeof (main_attribute_list
[0]);
1823 for (i
= 0; i
< l
; i
++)
1825 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-command-dir") == 0)
1827 main_attribute_list
[i
].default_val
.str_value
= pcblibdir
;
1830 if ( (NSTRCMP (main_attribute_list
[i
].name
, "font-path") == 0)
1831 || (NSTRCMP (main_attribute_list
[i
].name
, "element-path") == 0)
1832 || (NSTRCMP (main_attribute_list
[i
].name
, "lib-path") == 0) )
1834 main_attribute_list
[i
].default_val
.str_value
= pcblibpath
;
1837 if (NSTRCMP (main_attribute_list
[i
].name
, "lib-newlib") == 0)
1839 main_attribute_list
[i
].default_val
.str_value
= pcbtreepath
;
1847 tmps
= getenv ("HOME");
1850 tmps
= getenv ("USERPROFILE");
1854 homedir
= strdup (tmps
);
1862 /* ----------------------------------------------------------------------
1866 char *program_name
= 0;
1867 char *program_basename
= 0;
1868 char *program_directory
= 0;
1870 #include "dolists.h"
1873 main (int argc
, char *argv
[])
1877 /* init application:
1878 * - make program name available for error handlers
1879 * - evaluate special options
1880 * - initialize toplevel shell and resources
1881 * - create an empty PCB with default symbols
1882 * - initialize all other widgets
1883 * - update screen and get size of drawing area
1884 * - evaluate command-line arguments
1885 * - register 'call on exit()' function
1888 #include "core_lists.h"
1890 InitPaths (argv
[0]);
1892 bindtextdomain (GETTEXT_PACKAGE
, LOCALEDIR
);
1893 textdomain (GETTEXT_PACKAGE
);
1894 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
1897 setlocale (LC_ALL
, "");
1898 setlocale (LC_NUMERIC
, "C");
1901 srand ( time(NULL
) ); /* Set seed for rand() */
1907 hid_load_settings ();
1909 program_name
= argv
[0];
1910 program_basename
= strrchr (program_name
, PCB_DIR_SEPARATOR_C
);
1911 if (program_basename
)
1913 program_directory
= strdup (program_name
);
1914 *strrchr (program_directory
, PCB_DIR_SEPARATOR_C
) = 0;
1919 program_directory
= ".";
1920 program_basename
= program_name
;
1922 Progname
= program_basename
;
1924 /* Print usage or version if requested. Then exit. */
1926 (strcmp (argv
[1], "-h") == 0 ||
1927 strcmp (argv
[1], "-?") == 0 ||
1928 strcmp (argv
[1], "--help") == 0))
1930 if (argc
> 1 && strcmp (argv
[1], "-V") == 0)
1932 /* Export pcb from command line if requested. */
1933 if (argc
> 1 && strcmp (argv
[1], "-p") == 0)
1935 exporter
= gui
= hid_find_printer ();
1939 else if (argc
> 2 && strcmp (argv
[1], "-x") == 0)
1941 exporter
= gui
= hid_find_exporter (argv
[2]);
1945 /* Otherwise start GUI. */
1947 gui
= hid_find_gui ();
1949 /* Exit with error if GUI failed to start. */
1953 /* Set up layers. */
1954 for (i
= 0; i
< MAX_LAYER
; i
++)
1957 sprintf (buf
, "signal%d", i
+ 1);
1958 Settings
.DefaultLayerName
[i
] = strdup (buf
);
1959 Settings
.LayerColor
[i
] = "#c49350";
1960 Settings
.LayerSelectedColor
[i
] = "#00ffff";
1963 gui
->parse_arguments (&argc
, &argv
);
1965 if (show_help
|| (argc
> 1 && argv
[1][0] == '-'))
1974 settings_post_process ();
1983 if (do_dump_actions
)
1985 extern void dump_actions (void);
1990 /* Create a new PCB object in memory */
1991 PCB
= CreateNewPCB ();
1992 ParseGroupString (Settings
.Groups
, &PCB
->LayerGroups
, &PCB
->Data
->LayerN
);
1993 /* Add silk layers to newly created PCB */
1994 CreateNewPCBPost (PCB
, 1);
1996 command_line_pcb
= argv
[1];
1998 ResetStackAndVisibility ();
2003 SetMode (ARROW_MODE
);
2005 if (command_line_pcb
)
2007 /* keep filename even if initial load command failed;
2008 * file might not exist
2010 if (LoadPCB (command_line_pcb
))
2011 PCB
->Filename
= strdup (command_line_pcb
);
2014 if (Settings
.InitialLayerStack
2015 && Settings
.InitialLayerStack
[0])
2017 LayerStringToLayerStack (Settings
.InitialLayerStack
);
2020 /* This must be called before any other atexit functions
2021 * are registered, as it configures an atexit function to
2022 * clean up and free various items of allocated memory,
2023 * and must be the last last atexit function to run.
2027 /* Register a function to be called when the program terminates.
2028 * This makes sure that data is saved even if LEX/YACC routines
2029 * abort the program.
2030 * If the OS doesn't have at least one of them,
2031 * the critical sections will be handled by parse_l.l
2033 atexit (EmergencySave
);
2035 /* read the library file and display it if it's not empty
2037 if (!ReadLibraryContents () && Library
.MenuN
)
2038 hid_action ("LibraryChanged");
2040 #ifdef HAVE_LIBSTROKE
2044 if (Settings
.ScriptFilename
)
2046 Message (_("Executing startup script file %s\n"),
2047 Settings
.ScriptFilename
);
2048 hid_actionl ("ExecuteFile", Settings
.ScriptFilename
, NULL
);
2050 if (Settings
.ActionString
)
2052 Message (_("Executing startup action %s\n"), Settings
.ActionString
);
2053 hid_parse_actions (Settings
.ActionString
);
2056 if (gui
->printer
|| gui
->exporter
)
2069 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2070 Settings
.LibraryCommandDir
);
2071 printf ("Settings.FontPath = \"%s\"\n",
2073 printf ("Settings.ElementPath = \"%s\"\n",
2074 Settings
.ElementPath
);
2075 printf ("Settings.LibraryPath = \"%s\"\n",
2076 Settings
.LibraryPath
);
2077 printf ("Settings.LibraryTree = \"%s\"\n",
2078 Settings
.LibraryTree
);
2079 printf ("Settings.MakeProgram = \"%s\"\n",
2080 UNKNOWN (Settings
.MakeProgram
));
2081 printf ("Settings.GnetlistProgram = \"%s\"\n",
2082 UNKNOWN (Settings
.GnetlistProgram
));