Shiny 3D eye-candy
[geda-pcb/pcjc2.git] / src / main.c
blob3c3b4d0d321d569cd040d4a18d2c0e692e81d80d
1 /*
2 * COPYRIGHT
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
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif
34 #include <stdlib.h>
35 #ifdef HAVE_STRING_H
36 #include <string.h>
37 #endif
38 #include <signal.h>
39 #include <unistd.h>
40 #include <sys/stat.h>
41 #include <time.h> /* Seed for srand() */
43 #include "global.h"
44 #include "data.h"
45 #include "buffer.h"
46 #include "create.h"
47 #include "crosshair.h"
48 #include "draw.h"
49 #include "error.h"
50 #include "file.h"
51 #include "set.h"
52 #include "action.h"
53 #include "misc.h"
54 #include "lrealpath.h"
55 #include "free_atexit.h"
56 #include "polygon.h"
57 #include "gettext.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"
65 #ifdef HAVE_DBUS
66 #include "dbus.h"
67 #endif
69 #ifdef HAVE_LIBDMALLOC
70 #include <dmalloc.h>
71 #endif
73 #define PCBLIBPATH ".:" PCBLIBDIR
76 #ifdef HAVE_LIBSTROKE
77 extern void stroke_init (void);
78 #endif
81 /* ----------------------------------------------------------------------
82 * initialize signal and error handlers
84 static void
85 InitHandler (void)
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,
97 * so we ignore it
99 #ifdef SIGPIPE
100 signal (SIGPIPE, SIG_IGN);
101 #endif
105 /* ----------------------------------------------------------------------
106 | command line and rc file processing.
108 static char *command_line_pcb;
110 void
111 copyright (void)
113 printf ("\n"
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",
129 Progname, VERSION);
130 exit (0);
133 static inline void
134 u (const char *fmt, ...)
136 va_list ap;
137 va_start (ap, fmt);
138 vfprintf (stderr, fmt, ap);
139 fputc ('\n', stderr);
140 va_end (ap);
143 typedef struct UsageNotes {
144 struct UsageNotes *next;
145 HID_Attribute *seen;
146 } UsageNotes;
148 static UsageNotes *usage_notes = NULL;
150 static void
151 usage_attr (HID_Attribute * a)
153 int i, n;
154 const Unit *unit_list;
155 static char buf[200];
157 if (a->help_text == ATTR_UNDOCUMENTED)
158 return;
160 switch (a->type)
162 case HID_Label:
163 return;
164 case HID_Integer:
165 case HID_Real:
166 sprintf (buf, "--%s <num>", a->name);
167 break;
168 case HID_Coord:
169 sprintf (buf, "--%s <measure>", a->name);
170 break;
171 case HID_String:
172 sprintf (buf, "--%s <string>", a->name);
173 break;
174 case HID_Boolean:
175 sprintf (buf, "--%s", a->name);
176 break;
177 case HID_Mixed:
178 case HID_Enum:
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]);
187 strcat (buf, ">");
188 break;
189 case HID_Path:
190 sprintf (buf, "--%s <path>", a->name);
191 break;
192 case HID_Unit:
193 unit_list = get_unit_list ();
194 n = get_n_units ();
195 sprintf (buf, "--%s ", a->name);
196 for (i = 0; i < n; i++)
198 strcat (buf, i ? "|" : "<");
199 strcat (buf, unit_list[i].suffix);
201 strcat (buf, ">");
202 break;
205 if (strlen (buf) <= 30)
207 if (a->help_text)
208 fprintf (stderr, " %-30s\t%s\n", buf, a->help_text);
209 else
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);
216 else
217 fprintf (stderr, " %s\n", buf);
220 static void
221 usage_hid (HID * h)
223 HID_Attribute *attributes;
224 int i, n_attributes = 0;
225 UsageNotes *note;
227 if (h->gui)
229 fprintf (stderr, "\n%s gui options:\n", h->name);
230 attributes = h->get_export_options (&n_attributes);
232 else
234 fprintf (stderr, "\n%s options:\n", h->name);
235 exporter = h;
236 attributes = exporter->get_export_options (&n_attributes);
237 exporter = NULL;
240 note = (UsageNotes *)malloc (sizeof (UsageNotes));
241 note->next = usage_notes;
242 note->seen = attributes;
243 usage_notes = note;
245 for (i = 0; i < n_attributes; i++)
246 usage_attr (attributes + i);
249 static void
250 usage (void)
252 HID **hl = hid_enumerate ();
253 HID_AttrNode *ha;
254 UsageNotes *note;
255 int i;
256 int n_printer = 0, n_gui = 0, n_exporter = 0;
258 for (i = 0; hl[i]; i++)
260 if (hl[i]->gui)
261 n_gui++;
262 if (hl[i]->printer)
263 n_printer++;
264 if (hl[i]->exporter)
265 n_exporter++;
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++)
273 if (hl[i]->gui)
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++)
278 if (hl[i]->printer)
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++)
283 if (hl[i]->exporter)
284 fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
286 for (i = 0; hl[i]; i++)
287 if (hl[i]->gui)
288 usage_hid (hl[i]);
289 for (i = 0; hl[i]; i++)
290 if (hl[i]->printer)
291 usage_hid (hl[i]);
292 for (i = 0; hl[i]; i++)
293 if (hl[i]->exporter)
294 usage_hid (hl[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)
301 if (note)
302 continue;
303 for (i = 0; i < ha->n; i++)
305 usage_attr (ha->attributes + i);
309 exit (1);
312 static void
313 print_defaults_1 (HID_Attribute * a, void *value)
315 int i;
316 Coord c;
317 double d;
318 const char *s;
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. */
322 switch (a->type)
324 case HID_Integer:
325 i = value ? *(int *) value : a->default_val.int_value;
326 fprintf (stderr, "%s %d\n", a->name, i);
327 break;
328 case HID_Boolean:
329 i = value ? *(char *) value : a->default_val.int_value;
330 fprintf (stderr, "%s %s\n", a->name, i ? "yes" : "no");
331 break;
332 case HID_Real:
333 d = value ? *(double *) value : a->default_val.real_value;
334 fprintf (stderr, "%s %g\n", a->name, d);
335 break;
336 case HID_Coord:
337 c = value ? *(Coord *) value : a->default_val.coord_value;
338 pcb_fprintf (stderr, "%s %$mS\n", a->name, c);
339 break;
340 case HID_String:
341 case HID_Path:
342 s = value ? *(char **) value : a->default_val.str_value;
343 fprintf (stderr, "%s \"%s\"\n", a->name, s);
344 break;
345 case HID_Enum:
346 i = value ? *(int *) value : a->default_val.int_value;
347 fprintf (stderr, "%s %s\n", a->name, a->enumerations[i]);
348 break;
349 case HID_Mixed:
350 i = value ?
351 ((HID_Attr_Val*)value)->int_value : a->default_val.int_value;
352 d = 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]);
355 break;
356 case HID_Label:
357 break;
358 case HID_Unit:
359 i = value ? *(int *) value : a->default_val.int_value;
360 fprintf (stderr, "%s %s\n", a->name, get_unit_list()[i].suffix);
364 static void
365 print_defaults ()
367 HID **hl = hid_enumerate ();
368 HID_Attribute *e;
369 int i, n, hi;
371 for (hi = 0; hl[hi]; hi++)
373 HID *h = hl[hi];
374 if (h->gui)
376 HID_AttrNode *ha;
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);
382 else
384 fprintf (stderr, "\n%s defaults:\n", h->name);
385 exporter = h;
386 e = exporter->get_export_options (&n);
387 exporter = NULL;
388 if (e)
389 for (i = 0; i < n; i++)
390 print_defaults_1 (e + i, 0);
393 exit (1);
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"
435 @ftable @code
436 @item --help
437 Show help on command line options.
438 @end ftable
439 %end-doc
441 {"help", "Show help on command line options", HID_Boolean, 0, 0, {0, 0, 0}, 0,
442 &show_help},
444 /* %start-doc options "1 General Options"
445 @ftable @code
446 @item --version
447 Show version.
448 @end ftable
449 %end-doc
451 {"version", "Show version", HID_Boolean, 0, 0, {0, 0, 0}, 0, &show_version},
453 /* %start-doc options "1 General Options"
454 @ftable @code
455 @item --verbose
456 Be verbose on stdout.
457 @end ftable
458 %end-doc
460 {"verbose", "Be verbose on stdout", HID_Boolean, 0, 0, {0, 0, 0}, 0,
461 &Settings.verbose},
463 /* %start-doc options "1 General Options"
464 @ftable @code
465 @item --copyright
466 Show copyright.
467 @end ftable
468 %end-doc
470 {"copyright", "Show Copyright", HID_Boolean, 0, 0, {0, 0, 0}, 0,
471 &show_copyright},
473 /* %start-doc options "1 General Options"
474 @ftable @code
475 @item --show-defaults
476 Show option defaults.
477 @end ftable
478 %end-doc
480 {"show-defaults", "Show option defaults", HID_Boolean, 0, 0, {0, 0, 0}, 0,
481 &show_defaults},
483 /* %start-doc options "1 General Options"
484 @ftable @code
485 @item --show-actions
486 Show available actions and exit.
487 @end ftable
488 %end-doc
490 {"show-actions", "Show available actions", HID_Boolean, 0, 0, {0, 0, 0}, 0,
491 &show_actions},
493 /* %start-doc options "1 General Options"
494 @ftable @code
495 @item --dump-actions
496 Dump actions (for documentation).
497 @end ftable
498 %end-doc
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"
504 @ftable @code
505 @item --grid-units-mm <string>
506 Set default grid units. Can be mm or mil. Defaults to mil.
507 @end ftable
508 %end-doc
510 {"grid-units", "Default grid units (mm|mil)", HID_String, 0, 0, {0, "mil", 0},
511 0, &grid_units},
513 /* %start-doc options "1 General Options"
514 @ftable @code
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.
518 @end ftable
519 %end-doc
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"
525 @ftable @code
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.
529 @end ftable
530 %end-doc
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"
536 @ftable @code
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.
540 @end ftable
541 %end-doc
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"
547 @ftable @code
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.
551 @end ftable
552 %end-doc
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"
558 @ftable @code
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.
562 @end ftable
563 %end-doc
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"
569 @ftable @code
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.
573 @end ftable
574 %end-doc
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"
580 @ftable @code
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.
584 @end ftable
585 %end-doc
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"
591 @ftable @code
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.
595 @end ftable
596 %end-doc
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"
602 @ftable @code
603 @item --black-color <string>
604 Color value for black. Default: @samp{#000000}
605 @end ftable
606 %end-doc
608 COLOR (BlackColor, "#000000", "black-color", "color value of 'black'"),
610 /* %start-doc options "3 Colors"
611 @ftable @code
612 @item --black-color <string>
613 Color value for white. Default: @samp{#ffffff}
614 @end ftable
615 %end-doc
617 COLOR (WhiteColor, "#ffffff", "white-color", "color value of 'white'"),
619 /* %start-doc options "3 Colors"
620 @ftable @code
621 @item --background-color <string>
622 Background color of the canvas. Default: @samp{#e5e5e5}
623 @end ftable
624 %end-doc
626 COLOR (BackgroundColor, "#e5e5e5", "background-color",
627 "color for background"),
629 /* %start-doc options "3 Colors"
630 @ftable @code
631 @item --crosshair-color <string>
632 Color of the crosshair. Default: @samp{#ff0000}
633 @end ftable
634 %end-doc
636 COLOR (CrosshairColor, "#ff0000", "crosshair-color",
637 "color for the crosshair"),
639 /* %start-doc options "3 Colors"
640 @ftable @code
641 @item --cross-color <string>
642 Color of the cross. Default: @samp{#cdcd00}
643 @end ftable
644 %end-doc
646 COLOR (CrossColor, "#cdcd00", "cross-color", "color of the cross"),
648 /* %start-doc options "3 Colors"
649 @ftable @code
650 @item --via-color <string>
651 Color of vias. Default: @samp{#7f7f7f}
652 @end ftable
653 %end-doc
655 COLOR (ViaColor, "#7f7f7f", "via-color", "color of vias"),
657 /* %start-doc options "3 Colors"
658 @ftable @code
659 @item --via-selected-color <string>
660 Color of selected vias. Default: @samp{#00ffff}
661 @end ftable
662 %end-doc
664 COLOR (ViaSelectedColor, "#00ffff", "via-selected-color",
665 "color for selected vias"),
667 /* %start-doc options "3 Colors"
668 @ftable @code
669 @item --pin-color <string>
670 Color of pins. Default: @samp{#4d4d4d}
671 @end ftable
672 %end-doc
674 COLOR (PinColor, "#4d4d4d", "pin-color", "color of pins"),
676 /* %start-doc options "3 Colors"
677 @ftable @code
678 @item --pin-selected-color <string>
679 Color of selected pins. Default: @samp{#00ffff}
680 @end ftable
681 %end-doc
683 COLOR (PinSelectedColor, "#00ffff", "pin-selected-color",
684 "color of selected pins"),
686 /* %start-doc options "3 Colors"
687 @ftable @code
688 @item --pin-name-color <string>
689 Color of pin names and pin numbers. Default: @samp{#ff0000}
690 @end ftable
691 %end-doc
693 COLOR (PinNameColor, "#ff0000", "pin-name-color",
694 "color for pin names and pin numbers"),
696 /* %start-doc options "3 Colors"
697 @ftable @code
698 @item --element-color <string>
699 Color of components. Default: @samp{#000000}
700 @end ftable
701 %end-doc
703 COLOR (ElementColor, "#000000", "element-color", "color of components"),
705 /* %start-doc options "3 Colors"
706 @ftable @code
707 @item --rat-color <string>
708 Color of ratlines. Default: @samp{#b8860b}
709 @end ftable
710 %end-doc
712 COLOR (RatColor, "#b8860b", "rat-color", "color of ratlines"),
714 /* %start-doc options "3 Colors"
715 @ftable @code
716 @item --invisible-objects-color <string>
717 Color of invisible objects. Default: @samp{#cccccc}
718 @end ftable
719 %end-doc
721 COLOR (InvisibleObjectsColor, "#cccccc", "invisible-objects-color",
722 "color of invisible objects"),
724 /* %start-doc options "3 Colors"
725 @ftable @code
726 @item --invisible-mark-color <string>
727 Color of invisible marks. Default: @samp{#cccccc}
728 @end ftable
729 %end-doc
731 COLOR (InvisibleMarkColor, "#cccccc", "invisible-mark-color",
732 "color of invisible marks"),
734 /* %start-doc options "3 Colors"
735 @ftable @code
736 @item --element-selected-color <string>
737 Color of selected components. Default: @samp{#00ffff}
738 @end ftable
739 %end-doc
741 COLOR (ElementSelectedColor, "#00ffff", "element-selected-color",
742 "color of selected components"),
744 /* %start-doc options "3 Colors"
745 @ftable @code
746 @item --rat-selected-color <string>
747 Color of selected rats. Default: @samp{#00ffff}
748 @end ftable
749 %end-doc
751 COLOR (RatSelectedColor, "#00ffff", "rat-selected-color",
752 "color of selected rats"),
754 /* %start-doc options "3 Colors"
755 @ftable @code
756 @item --connected-color <string>
757 Color to indicate physical connections. Default: @samp{#00ff00}
758 @end ftable
759 %end-doc
761 COLOR (ConnectedColor, "#00ff00", "connected-color",
762 "color to indicate physically connected objects"),
764 /* %start-doc options "3 Colors"
765 @ftable @code
766 @item --found-color <string>
767 Color to indicate logical connections. Default: @samp{#ff00ff}
768 @end ftable
769 %end-doc
771 COLOR (FoundColor, "#ff00ff", "found-color",
772 "color to indicate logically connected objects"),
774 /* %start-doc options "3 Colors"
775 @ftable @code
776 @item --off-limit-color <string>
777 Color of off-canvas area. Default: @samp{#cccccc}
778 @end ftable
779 %end-doc
781 COLOR (OffLimitColor, "#cccccc", "off-limit-color",
782 "color of off-canvas area"),
784 /* %start-doc options "3 Colors"
785 @ftable @code
786 @item --grid-color <string>
787 Color of the grid. Default: @samp{#ff0000}
788 @end ftable
789 %end-doc
791 COLOR (GridColor, "#ff0000", "grid-color", "color of the grid"),
793 /* %start-doc options "3 Colors"
794 @ftable @code
795 @item --layer-color-<n> <string>
796 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
797 @end ftable
798 %end-doc
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"
817 @ftable @code
818 @item --layer-selected-color-<n> <string>
819 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
820 @end ftable
821 %end-doc
823 LAYERSELCOLOR (1),
824 LAYERSELCOLOR (2),
825 LAYERSELCOLOR (3),
826 LAYERSELCOLOR (4),
827 LAYERSELCOLOR (5),
828 LAYERSELCOLOR (6),
829 LAYERSELCOLOR (7),
830 LAYERSELCOLOR (8),
831 LAYERSELCOLOR (9),
832 LAYERSELCOLOR (10),
833 LAYERSELCOLOR (11),
834 LAYERSELCOLOR (12),
835 LAYERSELCOLOR (13),
836 LAYERSELCOLOR (14),
837 LAYERSELCOLOR (15),
838 LAYERSELCOLOR (16),
840 /* %start-doc options "3 Colors"
841 @ftable @code
842 @item --warn-color <string>
843 Color of offending objects during DRC. Default value is @code{"#ff8000"}
844 @end ftable
845 %end-doc
847 COLOR (WarnColor, "#ff8000", "warn-color", "color of offending objects during DRC"),
849 /* %start-doc options "3 Colors"
850 @ftable @code
851 @item --mask-color <string>
852 Color of the mask layer. Default value is @code{"#ff0000"}
853 @end ftable
854 %end-doc
856 COLOR (MaskColor, "#ff0000", "mask-color", "color for solder mask"),
858 /* %start-doc options "3 Colors"
859 @ftable @code
860 @item --mask-color <string>
861 Color of the mask layer. Default value is @code{"#ff0000"}
862 @end ftable
863 %end-doc
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}.
872 Valid Units are:
873 @table @samp
874 @item km
875 Kilometer
876 @item m
877 Meter
878 @item cm
879 Centimeter
880 @item mm
881 Millimeter
882 @item um
883 Micrometer
884 @item nm
885 Nanometer
886 @item in
887 Inch (1in = 0.0254m)
888 @item mil
889 Mil (1000mil = 1in)
890 @item cmil
891 Centimil (1/100 mil)
892 @end table
894 @ftable @code
895 @item --via-thickness <num>
896 Default diameter of vias. Default value is @code{60mil}.
897 @end ftable
898 %end-doc
900 CSET (ViaThickness, MIL_TO_COORD(60), "via-thickness",
901 "default diameter of vias in 1/100 mil"),
903 /* %start-doc options "5 Sizes"
904 @ftable @code
905 @item --via-drilling-hole <num>
906 Default diameter of holes. Default value is @code{28mil}.
907 @end ftable
908 %end-doc
910 CSET (ViaDrillingHole, MIL_TO_COORD(28), "via-drilling-hole",
911 "default diameter of holes"),
913 /* %start-doc options "5 Sizes"
914 @ftable @code
915 @item --line-thickness <num>
916 Default thickness of new lines. Default value is @code{10mil}.
917 @end ftable
918 %end-doc
920 CSET (LineThickness, MIL_TO_COORD(10), "line-thickness",
921 "initial thickness of new lines"),
923 /* %start-doc options "5 Sizes"
924 @ftable @code
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}.
931 @end ftable
932 %end-doc
934 CSET (RatThickness, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
936 /* %start-doc options "5 Sizes"
937 @ftable @code
938 @item --keepaway <num>
939 Default minimum distance between a track and adjacent copper.
940 Default value is @code{10mil}.
941 @end ftable
942 %end-doc
944 CSET (Keepaway, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
946 /* %start-doc options "5 Sizes"
947 @ftable @code
948 @item --default-PCB-width <num>
949 Default width of the canvas. Default value is @code{6000mil}.
950 @end ftable
951 %end-doc
953 CSET (MaxWidth, MIL_TO_COORD(6000), "default-PCB-width",
954 "default width of the canvas"),
956 /* %start-doc options "5 Sizes"
957 @ftable @code
958 @item --default-PCB-height <num>
959 Default height of the canvas. Default value is @code{5000mil}.
960 @end ftable
961 %end-doc
963 CSET (MaxHeight, MIL_TO_COORD(5000), "default-PCB-height",
964 "default height of the canvas"),
966 /* %start-doc options "5 Sizes"
967 @ftable @code
968 @item --text-scale <num>
969 Default text scale. This value is in percent. Default value is @code{100}.
970 @end ftable
971 %end-doc
973 ISET (TextScale, 100, "text-scale", "default text scale in percent"),
975 /* %start-doc options "5 Sizes"
976 @ftable @code
977 @item --alignment-distance <num>
978 Specifies the distance between the board outline and alignment targets.
979 Default value is @code{2mil}.
980 @end ftable
981 %end-doc
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
989 @ref{Sizes}.
990 %end-doc
994 /* %start-doc options "7 DRC Options"
995 @ftable @code
996 @item --bloat <num>
997 Minimum spacing. Default value is @code{10mil}.
998 @end ftable
999 %end-doc
1001 CSET (Bloat, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
1003 /* %start-doc options "7 DRC Options"
1004 @ftable @code
1005 @item --shrink <num>
1006 Minimum touching overlap. Default value is @code{10mil}.
1007 @end ftable
1008 %end-doc
1010 CSET (Shrink, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
1012 /* %start-doc options "7 DRC Options"
1013 @ftable @code
1014 @item --min-width <num>
1015 Minimum width of copper. Default value is @code{10mil}.
1016 @end ftable
1017 %end-doc
1019 CSET (minWid, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1021 /* %start-doc options "7 DRC Options"
1022 @ftable @code
1023 @item --min-silk <num>
1024 Minimum width of lines in silk. Default value is @code{10mil}.
1025 @end ftable
1026 %end-doc
1028 CSET (minSlk, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1030 /* %start-doc options "7 DRC Options"
1031 @ftable @code
1032 @item --min-drill <num>
1033 Minimum diameter of holes. Default value is @code{15mil}.
1034 @end ftable
1035 %end-doc
1037 CSET (minDrill, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1039 /* %start-doc options "7 DRC Options"
1040 @ftable @code
1041 @item --min-ring <num>
1042 Minimum width of annular ring. Default value is @code{10mil}.
1043 @end ftable
1044 %end-doc
1046 CSET (minRing, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1049 /* %start-doc options "5 Sizes"
1050 @ftable @code
1051 @item --grid <num>
1052 Initial grid size. Default value is @code{10mil}.
1053 @end ftable
1054 %end-doc
1056 CSET (Grid, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1058 /* %start-doc options "5 Sizes"
1059 @ftable @code
1060 @item --minimum polygon area <num>
1061 Minimum polygon area.
1062 @end ftable
1063 %end-doc
1065 RSET (IsleArea, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1068 /* %start-doc options "1 General Options"
1069 @ftable @code
1070 @item --backup-interval
1071 Time between automatic backups in seconds. Set to @code{0} to disable.
1072 The default value is @code{60}.
1073 @end ftable
1074 %end-doc
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"
1080 @ftable @code
1081 @item --layer-name-1 <string>
1082 Name of the 1st Layer. Default is @code{"top"}.
1083 @end ftable
1084 %end-doc
1086 LAYERNAME (1, "top"),
1088 /* %start-doc options "4 Layer Names"
1089 @ftable @code
1090 @item --layer-name-2 <string>
1091 Name of the 2nd Layer. Default is @code{"ground"}.
1092 @end ftable
1093 %end-doc
1095 LAYERNAME (2, "ground"),
1097 /* %start-doc options "4 Layer Names"
1098 @ftable @code
1099 @item --layer-name-3 <string>
1100 Name of the 3nd Layer. Default is @code{"signal2"}.
1101 @end ftable
1102 %end-doc
1104 LAYERNAME (3, "signal2"),
1106 /* %start-doc options "4 Layer Names"
1107 @ftable @code
1108 @item --layer-name-4 <string>
1109 Name of the 4rd Layer. Default is @code{"signal3"}.
1110 @end ftable
1111 %end-doc
1113 LAYERNAME (4, "signal3"),
1115 /* %start-doc options "4 Layer Names"
1116 @ftable @code
1117 @item --layer-name-5 <string>
1118 Name of the 5rd Layer. Default is @code{"power"}.
1119 @end ftable
1120 %end-doc
1122 LAYERNAME (5, "power"),
1124 /* %start-doc options "4 Layer Names"
1125 @ftable @code
1126 @item --layer-name-6 <string>
1127 Name of the 6rd Layer. Default is @code{"bottom"}.
1128 @end ftable
1129 %end-doc
1131 LAYERNAME (6, "bottom"),
1133 /* %start-doc options "4 Layer Names"
1134 @ftable @code
1135 @item --layer-name-7 <string>
1136 Name of the 7rd Layer. Default is @code{"outline"}.
1137 @end ftable
1138 %end-doc
1140 LAYERNAME (7, "outline"),
1142 /* %start-doc options "4 Layer Names"
1143 @ftable @code
1144 @item --layer-name-8 <string>
1145 Name of the 8rd Layer. Default is @code{"spare"}.
1146 @end ftable
1147 %end-doc
1149 LAYERNAME (8, "spare"),
1151 /* %start-doc options "1 General Options"
1152 @ftable @code
1153 @item --groups <string>
1154 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1155 @end ftable
1156 %end-doc
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.
1167 %end-doc
1170 /* %start-doc options "6 Commands"
1171 @ftable @code
1172 @item --font-command <string>
1173 Command to load a font.
1174 @end ftable
1175 %end-doc
1177 SSET (FontCommand, "", "font-command", "Command to load a font"),
1179 /* %start-doc options "6 Commands"
1180 @ftable @code
1181 @item --file-command <string>
1182 Command to read a file.
1183 @end ftable
1184 %end-doc
1186 SSET (FileCommand, "", "file-command", "Command to read a file"),
1188 /* %start-doc options "6 Commands"
1189 @ftable @code
1190 @item --element-command <string>
1191 Command to read a footprint. @*
1192 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1193 @end ftable
1194 %end-doc
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"
1201 @ftable @code
1202 @item --print-file <string>
1203 Command to print to a file.
1204 @end ftable
1205 %end-doc
1207 SSET (PrintFile, "%f.output", "print-file", "Command to print to a file"),
1209 /* %start-doc options "6 Commands"
1210 @ftable @code
1211 @item --lib-command-dir <string>
1212 Path to the command that queries the library.
1213 @end ftable
1214 %end-doc
1216 SSET (LibraryCommandDir, PCBLIBDIR, "lib-command-dir",
1217 "Path to the command that queries the library"),
1219 /* %start-doc options "6 Commands"
1220 @ftable @code
1221 @item --lib-command <string>
1222 Command to query the library. @*
1223 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1224 @end ftable
1225 %end-doc
1227 SSET (LibraryCommand, "QueryLibrary.sh '%p' '%f' %a",
1228 "lib-command", "Command to query the library"),
1230 /* %start-doc options "6 Commands"
1231 @ftable @code
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).
1236 @end ftable
1237 %end-doc
1239 SSET (LibraryContentsCommand,
1240 #ifdef __WIN32__
1242 #else
1243 "ListLibraryContents.sh '%p' '%f'",
1244 #endif
1245 "lib-contents-command", "Command to query the contents of the library"),
1247 /* %start-doc options "5 Paths"
1248 @ftable @code
1249 @item --lib-newlib <string>
1250 Top level directory for the newlib style library.
1251 @end ftable
1252 %end-doc
1254 SSET (LibraryTree, PCBTREEPATH, "lib-newlib",
1255 "Top level directory for the newlib style library"),
1257 /* %start-doc options "6 Commands"
1258 @ftable @code
1259 @item --save-command <string>
1260 Command to save to a file.
1261 @end ftable
1262 %end-doc
1264 SSET (SaveCommand, "", "save-command", "Command to save to a file"),
1266 /* %start-doc options "5 Paths"
1267 @ftable @code
1268 @item --lib-name <string>
1269 The default filename for the library.
1270 @end ftable
1271 %end-doc
1273 SSET (LibraryFilename, LIBRARYFILENAME, "lib-name",
1274 "The default filename for the library"),
1276 /* %start-doc options "5 Paths"
1277 @ftable @code
1278 @item --default-font <string>
1279 The name of the default font.
1280 @end ftable
1281 %end-doc
1283 SSET (FontFile, "default_font", "default-font",
1284 "File name of default font"),
1286 /* %start-doc options "1 General Options"
1287 @ftable @code
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"}
1292 @end ftable
1293 %end-doc
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"
1300 @ftable @code
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
1304 filename.
1305 @end ftable
1306 %end-doc
1308 SSET (FilePath, "", "file-path", 0),
1310 /* %start-doc options "6 Commands"
1311 @ftable @code
1312 @item --rat-command <string>
1313 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1314 @end ftable
1315 %end-doc
1317 SSET (RatCommand, "", "rat-command", "Command for reading a netlist"),
1319 /* %start-doc options "5 Paths"
1320 @ftable @code
1321 @item --font-path <string>
1322 A colon separated list of directories to search the default font. Defaults to
1323 the default library path.
1324 @end ftable
1325 %end-doc
1327 SSET (FontPath, PCBLIBPATH, "font-path",
1328 "Colon separated list of directories to search the default font"),
1330 /* %start-doc options "1 General Options"
1331 @ftable @code
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}.
1335 @end ftable
1336 %end-doc
1338 SSET(ElementPath, PCBLIBPATH, "element-path",
1339 "A colon separated list of directories or commands (starts with '|')"),
1341 /* %start-doc options "5 Paths"
1342 @ftable @code
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}.
1346 @end ftable
1347 %end-doc
1349 SSET (LibraryPath, PCBLIBPATH, "lib-path",
1350 "A colon separated list of directories"),
1352 /* %start-doc options "1 General Options"
1353 @ftable @code
1354 @item --action-script <string>
1355 If set, this file is executed at startup.
1356 @end ftable
1357 %end-doc
1359 SSET (ScriptFilename, 0, "action-script",
1360 "If set, this file is executed at startup"),
1362 /* %start-doc options "1 General Options"
1363 @ftable @code
1364 @item --action-string <string>
1365 If set, this string of actions is executed at startup.
1366 @end ftable
1367 %end-doc
1369 SSET (ActionString, 0, "action-string",
1370 "If set, this is executed at startup"),
1372 /* %start-doc options "1 General Options"
1373 @ftable @code
1374 @item --fab-author <string>
1375 Name of author to be put in the Gerber files.
1376 @end ftable
1377 %end-doc
1379 SSET (FabAuthor, "", "fab-author",
1380 "Name of author to be put in the Gerber files"),
1382 /* %start-doc options "1 General Options"
1383 @ftable @code
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.
1387 @end ftable
1388 %end-doc
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"
1399 @ftable @code
1400 @item --pinout-offset-x <num>
1401 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1402 @end ftable
1403 %end-doc
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"
1409 @ftable @code
1410 @item --pinout-offset-y <num>
1411 Vertical offset of the pin number display. Defaults to @code{100mil}.
1412 @end ftable
1413 %end-doc
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"
1419 @ftable @code
1420 @item --pinout-text-offset-x <num>
1421 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1422 @end ftable
1423 %end-doc
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"
1429 @ftable @code
1430 @item --pinout-text-offset-y <num>
1431 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1432 @end ftable
1433 %end-doc
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"
1439 @ftable @code
1440 @item --draw-grid
1441 If set, draw the grid at start-up.
1442 @end ftable
1443 %end-doc
1445 BSET (DrawGrid, 0, "draw-grid", "If set, draw the grid at start-up"),
1447 /* %start-doc options "2 General GUI Options"
1448 @ftable @code
1449 @item --clear-line
1450 If set, new lines clear polygons.
1451 @end ftable
1452 %end-doc
1454 BSET (ClearLine, 1, "clear-line", "If set, new lines clear polygons"),
1456 /* %start-doc options "2 General GUI Options"
1457 @ftable @code
1458 @item --full-poly
1459 If set, new polygons are full ones.
1460 @end ftable
1461 %end-doc
1463 BSET (FullPoly, 0, "full-poly", 0),
1465 /* %start-doc options "2 General GUI Options"
1466 @ftable @code
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.
1470 @end ftable
1471 %end-doc
1473 BSET (UniqueNames, 1, "unique-names", "Prevents identical component names"),
1475 /* %start-doc options "2 General GUI Options"
1476 @ftable @code
1477 @item --snap-pin
1478 If set, pin centers and pad end points are treated as additional grid points
1479 that the cursor can snap to.
1480 @end ftable
1481 %end-doc
1483 BSET (SnapPin, 1, "snap-pin",
1484 "If set, the cursor snaps to pads and pin centers"),
1486 /* %start-doc options "1 General Options"
1487 @ftable @code
1488 @item --save-last-command
1489 If set, the last user command is saved.
1490 @end ftable
1491 %end-doc
1493 BSET (SaveLastCommand, 0, "save-last-command", 0),
1495 /* %start-doc options "1 General Options"
1496 @ftable @code
1497 @item --save-in-tmp
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.
1500 @end ftable
1501 %end-doc
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"
1507 @ftable @code
1508 @item --save-metric-only
1509 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
1510 @end ftable
1511 %end-doc
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"
1517 @ftable @code
1518 @item --all-direction-lines
1519 Allow all directions, when drawing new lines.
1520 @end ftable
1521 %end-doc
1523 BSET (AllDirectionLines, 0, "all-direction-lines",
1524 "Allow all directions, when drawing new lines"),
1526 /* %start-doc options "2 General GUI Options"
1527 @ftable @code
1528 @item --show-number
1529 Pinout shows number.
1530 @end ftable
1531 %end-doc
1533 BSET (ShowNumber, 0, "show-number", "Pinout shows number"),
1535 /* %start-doc options "1 General Options"
1536 @ftable @code
1537 @item --reset-after-element
1538 If set, all found connections are reset before a new component is scanned.
1539 @end ftable
1540 %end-doc
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"
1546 @ftable @code
1547 @item --ring-bell-finished
1548 Execute the bell command when all rats are routed.
1549 @end ftable
1550 %end-doc
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 ()
1562 char *tmps;
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,
1573 NULL);
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
1605 * to call
1607 if (Settings.MakeProgram == NULL) {
1608 tmps = getenv ("PCB_MAKE_PROGRAM");
1609 if (tmps != NULL)
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");
1618 if (tmps != NULL)
1619 Settings.GnetlistProgram = strdup (tmps);
1621 if (Settings.GnetlistProgram == NULL) {
1622 Settings.GnetlistProgram = strdup ("gnetlist");
1625 if (grid_units)
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.
1640 static void
1641 print_version ()
1643 printf ("PCB version %s\n", VERSION);
1644 exit (0);
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;
1659 static void
1660 InitPaths (char *argv0)
1662 size_t l;
1663 int i;
1664 int haspath;
1665 char *t1, *t2;
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.
1675 haspath = 0;
1676 for (i = 0; i < strlen (argv0) ; i++)
1678 if (argv0[i] == PCB_DIR_SEPARATOR_C)
1679 haspath = 1;
1682 #ifdef DEBUG
1683 printf ("InitPaths (%s): haspath = %d\n", argv0, haspath);
1684 #endif
1686 if (haspath)
1688 bindir = strdup (lrealpath (argv0));
1689 found_bindir = 1;
1691 else
1693 char *path, *p, *tmps;
1694 struct stat sb;
1695 int r;
1697 tmps = getenv ("PATH");
1699 if (tmps != NULL)
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))
1707 #ifdef DEBUG
1708 printf ("Looking for %s in %s\n", argv0, p);
1709 #endif
1710 if ( (tmps = (char *)malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
1712 fprintf (stderr, "InitPaths(): malloc failed\n");
1713 exit (1);
1715 sprintf (tmps, "%s%s%s", p, PCB_DIR_SEPARATOR_S, argv0);
1716 r = stat (tmps, &sb);
1717 if (r == 0)
1719 #ifdef DEBUG
1720 printf ("Found it: \"%s\"\n", tmps);
1721 #endif
1722 bindir = lrealpath (tmps);
1723 found_bindir = 1;
1724 free (tmps);
1725 break;
1727 free (tmps);
1729 free (path);
1733 #ifdef DEBUG
1734 printf ("InitPaths(): bindir = \"%s\"\n", bindir);
1735 #endif
1737 if (found_bindir)
1739 /* strip off the executible name leaving only the path */
1740 t2 = NULL;
1741 t1 = strchr (bindir, PCB_DIR_SEPARATOR_C);
1742 while (t1 != NULL && *t1 != '\0')
1744 t2 = t1;
1745 t1 = strchr (t2 + 1, PCB_DIR_SEPARATOR_C);
1747 if (t2 != NULL)
1748 *t2 = '\0';
1750 #ifdef DEBUG
1751 printf ("After stripping off the executible name, we found\n");
1752 printf ("bindir = \"%s\"\n", bindir);
1753 #endif
1755 else
1757 /* we have failed to find out anything from argv[0] so fall back to the original
1758 * install prefix
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");
1768 exit (1);
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");
1778 exit (1);
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");
1788 exit (1);
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");
1798 exit (1);
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");
1808 exit (1);
1810 sprintf (pcbtreepath, "%s%s%s%spcblib-newlib", pcbtreedir,
1811 PCB_PATH_DELIMETER, pcblibdir,
1812 PCB_DIR_SEPARATOR_S);
1814 #ifdef DEBUG
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);
1820 #endif
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;
1845 char *tmps;
1847 tmps = getenv ("HOME");
1849 if (tmps == NULL) {
1850 tmps = getenv ("USERPROFILE");
1853 if (tmps != NULL) {
1854 homedir = strdup (tmps);
1855 } else {
1856 homedir = NULL;
1862 /* ----------------------------------------------------------------------
1863 * main program
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[])
1875 int i;
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"
1889 setbuf (stdout, 0);
1890 InitPaths (argv[0]);
1892 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1893 textdomain (GETTEXT_PACKAGE);
1894 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1896 #ifdef ENABLE_NLS
1897 setlocale (LC_ALL, "");
1898 setlocale (LC_NUMERIC, "C");
1899 #endif
1901 srand ( time(NULL) ); /* Set seed for rand() */
1903 initialize_units();
1904 polygon_init ();
1905 hid_init ();
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;
1915 program_basename++;
1917 else
1919 program_directory = ".";
1920 program_basename = program_name;
1922 Progname = program_basename;
1924 /* Print usage or version if requested. Then exit. */
1925 if (argc > 1 &&
1926 (strcmp (argv[1], "-h") == 0 ||
1927 strcmp (argv[1], "-?") == 0 ||
1928 strcmp (argv[1], "--help") == 0))
1929 usage ();
1930 if (argc > 1 && strcmp (argv[1], "-V") == 0)
1931 print_version ();
1932 /* Export pcb from command line if requested. */
1933 if (argc > 1 && strcmp (argv[1], "-p") == 0)
1935 exporter = gui = hid_find_printer ();
1936 argc--;
1937 argv++;
1939 else if (argc > 2 && strcmp (argv[1], "-x") == 0)
1941 exporter = gui = hid_find_exporter (argv[2]);
1942 argc -= 2;
1943 argv += 2;
1945 /* Otherwise start GUI. */
1946 else
1947 gui = hid_find_gui ();
1949 /* Exit with error if GUI failed to start. */
1950 if (!gui)
1951 exit (1);
1953 /* Set up layers. */
1954 for (i = 0; i < MAX_LAYER; i++)
1956 char buf[20];
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] == '-'))
1966 usage ();
1967 if (show_version)
1968 print_version ();
1969 if (show_defaults)
1970 print_defaults ();
1971 if (show_copyright)
1972 copyright ();
1974 settings_post_process ();
1977 if (show_actions)
1979 print_actions ();
1980 exit (0);
1983 if (do_dump_actions)
1985 extern void dump_actions (void);
1986 dump_actions ();
1987 exit (0);
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);
1995 if (argc > 1)
1996 command_line_pcb = argv[1];
1998 ResetStackAndVisibility ();
2000 InitCrosshair ();
2001 InitHandler ();
2002 InitBuffers ();
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.
2025 leaky_init ();
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
2041 stroke_init ();
2042 #endif
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)
2058 gui->do_export (0);
2059 exit (0);
2062 #if HAVE_DBUS
2063 pcb_dbus_setup();
2064 #endif
2066 EnableAutosave ();
2068 #ifdef DEBUG
2069 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2070 Settings.LibraryCommandDir);
2071 printf ("Settings.FontPath = \"%s\"\n",
2072 Settings.FontPath);
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));
2083 #endif
2085 gui->do_export (0);
2086 #if HAVE_DBUS
2087 pcb_dbus_finish();
2088 #endif
2090 return (0);