TEMP: Fixup fallout from nogui change
[geda-pcb/pcjc2.git] / src / main.c
blobd3bbce3c1ef332ab776642af898ce9d60f829a1f
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"),
859 /* %start-doc options "5 Sizes"
860 All parameters should be given with an unit. If no unit is given, 1/100 mil
861 (cmil) will be used. Write units without space to the
862 number like @code{3mm}, not @code{3 mm}.
863 Valid Units are:
864 @table @samp
865 @item km
866 Kilometer
867 @item m
868 Meter
869 @item cm
870 Centimeter
871 @item mm
872 Millimeter
873 @item um
874 Micrometer
875 @item nm
876 Nanometer
877 @item in
878 Inch (1in = 0.0254m)
879 @item mil
880 Mil (1000mil = 1in)
881 @item cmil
882 Centimil (1/100 mil)
883 @end table
885 @ftable @code
886 @item --via-thickness <num>
887 Default diameter of vias. Default value is @code{60mil}.
888 @end ftable
889 %end-doc
891 CSET (ViaThickness, MIL_TO_COORD(60), "via-thickness",
892 "default diameter of vias in 1/100 mil"),
894 /* %start-doc options "5 Sizes"
895 @ftable @code
896 @item --via-drilling-hole <num>
897 Default diameter of holes. Default value is @code{28mil}.
898 @end ftable
899 %end-doc
901 CSET (ViaDrillingHole, MIL_TO_COORD(28), "via-drilling-hole",
902 "default diameter of holes"),
904 /* %start-doc options "5 Sizes"
905 @ftable @code
906 @item --line-thickness <num>
907 Default thickness of new lines. Default value is @code{10mil}.
908 @end ftable
909 %end-doc
911 CSET (LineThickness, MIL_TO_COORD(10), "line-thickness",
912 "initial thickness of new lines"),
914 /* %start-doc options "5 Sizes"
915 @ftable @code
916 @item --rat-thickness <num><unit>
917 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100
918 means "1 nm"). This option allows for a special unit @code{px} which
919 sets the rat thickness to a fixed value in terms of screen pixels.
920 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.
921 Default value is @code{10mil}.
922 @end ftable
923 %end-doc
925 CSET (RatThickness, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
927 /* %start-doc options "5 Sizes"
928 @ftable @code
929 @item --keepaway <num>
930 Default minimum distance between a track and adjacent copper.
931 Default value is @code{10mil}.
932 @end ftable
933 %end-doc
935 CSET (Keepaway, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
937 /* %start-doc options "5 Sizes"
938 @ftable @code
939 @item --default-PCB-width <num>
940 Default width of the canvas. Default value is @code{6000mil}.
941 @end ftable
942 %end-doc
944 CSET (MaxWidth, MIL_TO_COORD(6000), "default-PCB-width",
945 "default width of the canvas"),
947 /* %start-doc options "5 Sizes"
948 @ftable @code
949 @item --default-PCB-height <num>
950 Default height of the canvas. Default value is @code{5000mil}.
951 @end ftable
952 %end-doc
954 CSET (MaxHeight, MIL_TO_COORD(5000), "default-PCB-height",
955 "default height of the canvas"),
957 /* %start-doc options "5 Sizes"
958 @ftable @code
959 @item --text-scale <num>
960 Default text scale. This value is in percent. Default value is @code{100}.
961 @end ftable
962 %end-doc
964 ISET (TextScale, 100, "text-scale", "default text scale in percent"),
966 /* %start-doc options "5 Sizes"
967 @ftable @code
968 @item --alignment-distance <num>
969 Specifies the distance between the board outline and alignment targets.
970 Default value is @code{2mil}.
971 @end ftable
972 %end-doc
974 CSET (AlignmentDistance, MIL_TO_COORD(2), "alignment-distance",
975 "distance between the boards outline and alignment targets"),
977 /* %start-doc options "7 DRC Options"
978 All parameters should be given with an unit. If no unit is given, 1/100 mil
979 (cmil) will be used for backward compability. Valid units are given in section
980 @ref{Sizes}.
981 %end-doc
985 /* %start-doc options "7 DRC Options"
986 @ftable @code
987 @item --bloat <num>
988 Minimum spacing. Default value is @code{10mil}.
989 @end ftable
990 %end-doc
992 CSET (Bloat, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
994 /* %start-doc options "7 DRC Options"
995 @ftable @code
996 @item --shrink <num>
997 Minimum touching overlap. Default value is @code{10mil}.
998 @end ftable
999 %end-doc
1001 CSET (Shrink, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
1003 /* %start-doc options "7 DRC Options"
1004 @ftable @code
1005 @item --min-width <num>
1006 Minimum width of copper. Default value is @code{10mil}.
1007 @end ftable
1008 %end-doc
1010 CSET (minWid, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1012 /* %start-doc options "7 DRC Options"
1013 @ftable @code
1014 @item --min-silk <num>
1015 Minimum width of lines in silk. Default value is @code{10mil}.
1016 @end ftable
1017 %end-doc
1019 CSET (minSlk, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1021 /* %start-doc options "7 DRC Options"
1022 @ftable @code
1023 @item --min-drill <num>
1024 Minimum diameter of holes. Default value is @code{15mil}.
1025 @end ftable
1026 %end-doc
1028 CSET (minDrill, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1030 /* %start-doc options "7 DRC Options"
1031 @ftable @code
1032 @item --min-ring <num>
1033 Minimum width of annular ring. Default value is @code{10mil}.
1034 @end ftable
1035 %end-doc
1037 CSET (minRing, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1040 /* %start-doc options "5 Sizes"
1041 @ftable @code
1042 @item --grid <num>
1043 Initial grid size. Default value is @code{10mil}.
1044 @end ftable
1045 %end-doc
1047 CSET (Grid, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1049 /* %start-doc options "5 Sizes"
1050 @ftable @code
1051 @item --minimum polygon area <num>
1052 Minimum polygon area.
1053 @end ftable
1054 %end-doc
1056 RSET (IsleArea, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1059 /* %start-doc options "1 General Options"
1060 @ftable @code
1061 @item --backup-interval
1062 Time between automatic backups in seconds. Set to @code{0} to disable.
1063 The default value is @code{60}.
1064 @end ftable
1065 %end-doc
1067 ISET (BackupInterval, 60, "backup-interval",
1068 "Time between automatic backups in seconds. Set to 0 to disable"),
1070 /* %start-doc options "4 Layer Names"
1071 @ftable @code
1072 @item --layer-name-1 <string>
1073 Name of the 1st Layer. Default is @code{"top"}.
1074 @end ftable
1075 %end-doc
1077 LAYERNAME (1, "top"),
1079 /* %start-doc options "4 Layer Names"
1080 @ftable @code
1081 @item --layer-name-2 <string>
1082 Name of the 2nd Layer. Default is @code{"ground"}.
1083 @end ftable
1084 %end-doc
1086 LAYERNAME (2, "ground"),
1088 /* %start-doc options "4 Layer Names"
1089 @ftable @code
1090 @item --layer-name-3 <string>
1091 Name of the 3nd Layer. Default is @code{"signal2"}.
1092 @end ftable
1093 %end-doc
1095 LAYERNAME (3, "signal2"),
1097 /* %start-doc options "4 Layer Names"
1098 @ftable @code
1099 @item --layer-name-4 <string>
1100 Name of the 4rd Layer. Default is @code{"signal3"}.
1101 @end ftable
1102 %end-doc
1104 LAYERNAME (4, "signal3"),
1106 /* %start-doc options "4 Layer Names"
1107 @ftable @code
1108 @item --layer-name-5 <string>
1109 Name of the 5rd Layer. Default is @code{"power"}.
1110 @end ftable
1111 %end-doc
1113 LAYERNAME (5, "power"),
1115 /* %start-doc options "4 Layer Names"
1116 @ftable @code
1117 @item --layer-name-6 <string>
1118 Name of the 6rd Layer. Default is @code{"bottom"}.
1119 @end ftable
1120 %end-doc
1122 LAYERNAME (6, "bottom"),
1124 /* %start-doc options "4 Layer Names"
1125 @ftable @code
1126 @item --layer-name-7 <string>
1127 Name of the 7rd Layer. Default is @code{"outline"}.
1128 @end ftable
1129 %end-doc
1131 LAYERNAME (7, "outline"),
1133 /* %start-doc options "4 Layer Names"
1134 @ftable @code
1135 @item --layer-name-8 <string>
1136 Name of the 8rd Layer. Default is @code{"spare"}.
1137 @end ftable
1138 %end-doc
1140 LAYERNAME (8, "spare"),
1142 /* %start-doc options "1 General Options"
1143 @ftable @code
1144 @item --groups <string>
1145 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1146 @end ftable
1147 %end-doc
1149 SSET (Groups, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
1152 /* %start-doc options "6 Commands"
1153 pcb uses external commands for input output operations. These commands can be
1154 configured at start-up to meet local requirements. The command string may include
1155 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
1156 command is called. The sequence @code{%f} is replaced by the file name,
1157 @code{%p} gets the path and @code{%a} indicates a package name.
1158 %end-doc
1161 /* %start-doc options "6 Commands"
1162 @ftable @code
1163 @item --font-command <string>
1164 Command to load a font.
1165 @end ftable
1166 %end-doc
1168 SSET (FontCommand, "", "font-command", "Command to load a font"),
1170 /* %start-doc options "6 Commands"
1171 @ftable @code
1172 @item --file-command <string>
1173 Command to read a file.
1174 @end ftable
1175 %end-doc
1177 SSET (FileCommand, "", "file-command", "Command to read a file"),
1179 /* %start-doc options "6 Commands"
1180 @ftable @code
1181 @item --element-command <string>
1182 Command to read a footprint. @*
1183 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1184 @end ftable
1185 %end-doc
1187 SSET (ElementCommand,
1188 "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4,
1189 "element-command", "Command to read a footprint"),
1191 /* %start-doc options "6 Commands"
1192 @ftable @code
1193 @item --print-file <string>
1194 Command to print to a file.
1195 @end ftable
1196 %end-doc
1198 SSET (PrintFile, "%f.output", "print-file", "Command to print to a file"),
1200 /* %start-doc options "6 Commands"
1201 @ftable @code
1202 @item --lib-command-dir <string>
1203 Path to the command that queries the library.
1204 @end ftable
1205 %end-doc
1207 SSET (LibraryCommandDir, PCBLIBDIR, "lib-command-dir",
1208 "Path to the command that queries the library"),
1210 /* %start-doc options "6 Commands"
1211 @ftable @code
1212 @item --lib-command <string>
1213 Command to query the library. @*
1214 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1215 @end ftable
1216 %end-doc
1218 SSET (LibraryCommand, "QueryLibrary.sh '%p' '%f' %a",
1219 "lib-command", "Command to query the library"),
1221 /* %start-doc options "6 Commands"
1222 @ftable @code
1223 @item --lib-contents-command <string>
1224 Command to query the contents of the library. @*
1225 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
1226 on Windows builds, an empty string (to disable this feature).
1227 @end ftable
1228 %end-doc
1230 SSET (LibraryContentsCommand,
1231 #ifdef __WIN32__
1233 #else
1234 "ListLibraryContents.sh '%p' '%f'",
1235 #endif
1236 "lib-contents-command", "Command to query the contents of the library"),
1238 /* %start-doc options "5 Paths"
1239 @ftable @code
1240 @item --lib-newlib <string>
1241 Top level directory for the newlib style library.
1242 @end ftable
1243 %end-doc
1245 SSET (LibraryTree, PCBTREEPATH, "lib-newlib",
1246 "Top level directory for the newlib style library"),
1248 /* %start-doc options "6 Commands"
1249 @ftable @code
1250 @item --save-command <string>
1251 Command to save to a file.
1252 @end ftable
1253 %end-doc
1255 SSET (SaveCommand, "", "save-command", "Command to save to a file"),
1257 /* %start-doc options "5 Paths"
1258 @ftable @code
1259 @item --lib-name <string>
1260 The default filename for the library.
1261 @end ftable
1262 %end-doc
1264 SSET (LibraryFilename, LIBRARYFILENAME, "lib-name",
1265 "The default filename for the library"),
1267 /* %start-doc options "5 Paths"
1268 @ftable @code
1269 @item --default-font <string>
1270 The name of the default font.
1271 @end ftable
1272 %end-doc
1274 SSET (FontFile, "default_font", "default-font",
1275 "File name of default font"),
1277 /* %start-doc options "1 General Options"
1278 @ftable @code
1279 @item --route-styles <string>
1280 A string that defines the route styles. Defaults to @*
1281 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
1282 :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
1283 @end ftable
1284 %end-doc
1286 SSET (Routes, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
1287 ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
1288 "A string that defines the route styles"),
1290 /* %start-doc options "5 Paths"
1291 @ftable @code
1292 @item --file-path <string>
1293 A colon separated list of directories or commands (starts with '|'). The path
1294 is passed to the program specified in @option{--file-command} together with the selected
1295 filename.
1296 @end ftable
1297 %end-doc
1299 SSET (FilePath, "", "file-path", 0),
1301 /* %start-doc options "6 Commands"
1302 @ftable @code
1303 @item --rat-command <string>
1304 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1305 @end ftable
1306 %end-doc
1308 SSET (RatCommand, "", "rat-command", "Command for reading a netlist"),
1310 /* %start-doc options "5 Paths"
1311 @ftable @code
1312 @item --font-path <string>
1313 A colon separated list of directories to search the default font. Defaults to
1314 the default library path.
1315 @end ftable
1316 %end-doc
1318 SSET (FontPath, PCBLIBPATH, "font-path",
1319 "Colon separated list of directories to search the default font"),
1321 /* %start-doc options "1 General Options"
1322 @ftable @code
1323 @item --element-path <string>
1324 A colon separated list of directories or commands (starts with '|').
1325 The path is passed to the program specified in @option{--element-command}.
1326 @end ftable
1327 %end-doc
1329 SSET(ElementPath, PCBLIBPATH, "element-path",
1330 "A colon separated list of directories or commands (starts with '|')"),
1332 /* %start-doc options "5 Paths"
1333 @ftable @code
1334 @item --lib-path <string>
1335 A colon separated list of directories that will be passed to the commands specified
1336 by @option{--element-command} and @option{--element-contents-command}.
1337 @end ftable
1338 %end-doc
1340 SSET (LibraryPath, PCBLIBPATH, "lib-path",
1341 "A colon separated list of directories"),
1343 /* %start-doc options "1 General Options"
1344 @ftable @code
1345 @item --action-script <string>
1346 If set, this file is executed at startup.
1347 @end ftable
1348 %end-doc
1350 SSET (ScriptFilename, 0, "action-script",
1351 "If set, this file is executed at startup"),
1353 /* %start-doc options "1 General Options"
1354 @ftable @code
1355 @item --action-string <string>
1356 If set, this string of actions is executed at startup.
1357 @end ftable
1358 %end-doc
1360 SSET (ActionString, 0, "action-string",
1361 "If set, this is executed at startup"),
1363 /* %start-doc options "1 General Options"
1364 @ftable @code
1365 @item --fab-author <string>
1366 Name of author to be put in the Gerber files.
1367 @end ftable
1368 %end-doc
1370 SSET (FabAuthor, "", "fab-author",
1371 "Name of author to be put in the Gerber files"),
1373 /* %start-doc options "1 General Options"
1374 @ftable @code
1375 @item --layer-stack <string>
1376 Initial layer stackup, for setting up an export. A comma separated list of layer
1377 names, layer numbers and layer groups.
1378 @end ftable
1379 %end-doc
1381 SSET (InitialLayerStack, "", "layer-stack",
1382 "Initial layer stackup, for setting up an export."),
1384 SSET (MakeProgram, NULL, "make-program",
1385 "Sets the name and optionally full path to a make(3) program"),
1386 SSET (GnetlistProgram, NULL, "gnetlist",
1387 "Sets the name and optionally full path to the gnetlist(3) program"),
1389 /* %start-doc options "2 General GUI Options"
1390 @ftable @code
1391 @item --pinout-offset-x <num>
1392 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1393 @end ftable
1394 %end-doc
1396 CSET (PinoutOffsetX, MIL_TO_COORD(1), "pinout-offset-x",
1397 "Horizontal offset of the pin number display in mil"),
1399 /* %start-doc options "2 General GUI Options"
1400 @ftable @code
1401 @item --pinout-offset-y <num>
1402 Vertical offset of the pin number display. Defaults to @code{100mil}.
1403 @end ftable
1404 %end-doc
1406 CSET (PinoutOffsetY, MIL_TO_COORD(1), "pinout-offset-y",
1407 "Vertical offset of the pin number display in mil"),
1409 /* %start-doc options "2 General GUI Options"
1410 @ftable @code
1411 @item --pinout-text-offset-x <num>
1412 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1413 @end ftable
1414 %end-doc
1416 CSET (PinoutTextOffsetX, MIL_TO_COORD(8), "pinout-text-offset-x",
1417 "Horizontal offset of the pin name display in mil"),
1419 /* %start-doc options "2 General GUI Options"
1420 @ftable @code
1421 @item --pinout-text-offset-y <num>
1422 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1423 @end ftable
1424 %end-doc
1426 CSET (PinoutTextOffsetY, MIL_TO_COORD(-1), "pinout-text-offset-y",
1427 "Vertical offset of the pin name display in mil"),
1429 /* %start-doc options "2 General GUI Options"
1430 @ftable @code
1431 @item --draw-grid
1432 If set, draw the grid at start-up.
1433 @end ftable
1434 %end-doc
1436 BSET (DrawGrid, 0, "draw-grid", "If set, draw the grid at start-up"),
1438 /* %start-doc options "2 General GUI Options"
1439 @ftable @code
1440 @item --clear-line
1441 If set, new lines clear polygons.
1442 @end ftable
1443 %end-doc
1445 BSET (ClearLine, 1, "clear-line", "If set, new lines clear polygons"),
1447 /* %start-doc options "2 General GUI Options"
1448 @ftable @code
1449 @item --full-poly
1450 If set, new polygons are full ones.
1451 @end ftable
1452 %end-doc
1454 BSET (FullPoly, 0, "full-poly", 0),
1456 /* %start-doc options "2 General GUI Options"
1457 @ftable @code
1458 @item --unique-names
1459 If set, you will not be permitted to change the name of an component to match that
1460 of another component.
1461 @end ftable
1462 %end-doc
1464 BSET (UniqueNames, 1, "unique-names", "Prevents identical component names"),
1466 /* %start-doc options "2 General GUI Options"
1467 @ftable @code
1468 @item --snap-pin
1469 If set, pin centers and pad end points are treated as additional grid points
1470 that the cursor can snap to.
1471 @end ftable
1472 %end-doc
1474 BSET (SnapPin, 1, "snap-pin",
1475 "If set, the cursor snaps to pads and pin centers"),
1477 /* %start-doc options "1 General Options"
1478 @ftable @code
1479 @item --save-last-command
1480 If set, the last user command is saved.
1481 @end ftable
1482 %end-doc
1484 BSET (SaveLastCommand, 0, "save-last-command", 0),
1486 /* %start-doc options "1 General Options"
1487 @ftable @code
1488 @item --save-in-tmp
1489 If set, all data which would otherwise be lost are saved in a temporary file
1490 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
1491 @end ftable
1492 %end-doc
1494 BSET (SaveInTMP, 0, "save-in-tmp",
1495 "When set, all data which would otherwise be lost are saved in /tmp"),
1497 /* %start-doc options "1 General Options"
1498 @ftable @code
1499 @item --save-metric-only
1500 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
1501 @end ftable
1502 %end-doc
1504 BSET (SaveMetricOnly, 0, "save-metric-only",
1505 "If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm."),
1507 /* %start-doc options "2 General GUI Options"
1508 @ftable @code
1509 @item --all-direction-lines
1510 Allow all directions, when drawing new lines.
1511 @end ftable
1512 %end-doc
1514 BSET (AllDirectionLines, 0, "all-direction-lines",
1515 "Allow all directions, when drawing new lines"),
1517 /* %start-doc options "2 General GUI Options"
1518 @ftable @code
1519 @item --show-number
1520 Pinout shows number.
1521 @end ftable
1522 %end-doc
1524 BSET (ShowNumber, 0, "show-number", "Pinout shows number"),
1526 /* %start-doc options "1 General Options"
1527 @ftable @code
1528 @item --reset-after-element
1529 If set, all found connections are reset before a new component is scanned.
1530 @end ftable
1531 %end-doc
1533 BSET (ResetAfterElement, 1, "reset-after-element",
1534 "If set, all found connections are reset before a new component is scanned"),
1536 /* %start-doc options "1 General Options"
1537 @ftable @code
1538 @item --ring-bell-finished
1539 Execute the bell command when all rats are routed.
1540 @end ftable
1541 %end-doc
1543 BSET (RingBellWhenFinished, 0, "ring-bell-finished",
1544 "Execute the bell command when all rats are routed"),
1547 REGISTER_ATTRIBUTES (main_attribute_list)
1548 /* ----------------------------------------------------------------------
1549 * post-process settings.
1551 static void settings_post_process ()
1553 char *tmps;
1555 if (Settings.LibraryCommand != NULL &&
1556 Settings.LibraryCommand[0] != '\0' &&
1557 Settings.LibraryCommand[0] != PCB_DIR_SEPARATOR_C &&
1558 Settings.LibraryCommand[0] != '.')
1560 Settings.LibraryCommand
1562 Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S,
1563 Settings.LibraryCommand,
1564 NULL);
1566 if (Settings.LibraryContentsCommand != NULL &&
1567 Settings.LibraryContentsCommand[0] != '\0' &&
1568 Settings.LibraryContentsCommand[0] != PCB_DIR_SEPARATOR_C &&
1569 Settings.LibraryContentsCommand[0] != '.')
1571 Settings.LibraryContentsCommand
1573 Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S,
1574 Settings.LibraryContentsCommand, NULL);
1577 if (Settings.LineThickness > MAX_LINESIZE
1578 || Settings.LineThickness < MIN_LINESIZE)
1579 Settings.LineThickness = MIL_TO_COORD(10);
1581 if (Settings.ViaThickness > MAX_PINORVIASIZE
1582 || Settings.ViaThickness < MIN_PINORVIASIZE)
1583 Settings.ViaThickness = MIL_TO_COORD(40);
1585 if (Settings.ViaDrillingHole <= 0)
1586 Settings.ViaDrillingHole =
1587 DEFAULT_DRILLINGHOLE * Settings.ViaThickness / 100;
1589 Settings.MaxWidth = CLAMP (Settings.MaxWidth, MIN_SIZE, MAX_COORD);
1590 Settings.MaxHeight = CLAMP (Settings.MaxHeight, MIN_SIZE, MAX_COORD);
1592 ParseRouteString (Settings.Routes, &Settings.RouteStyle[0], "cmil");
1595 * Make sure we have settings for some various programs we may wish
1596 * to call
1598 if (Settings.MakeProgram == NULL) {
1599 tmps = getenv ("PCB_MAKE_PROGRAM");
1600 if (tmps != NULL)
1601 Settings.MakeProgram = strdup (tmps);
1603 if (Settings.MakeProgram == NULL) {
1604 Settings.MakeProgram = strdup ("make");
1607 if (Settings.GnetlistProgram == NULL) {
1608 tmps = getenv ("PCB_GNETLIST");
1609 if (tmps != NULL)
1610 Settings.GnetlistProgram = strdup (tmps);
1612 if (Settings.GnetlistProgram == NULL) {
1613 Settings.GnetlistProgram = strdup ("gnetlist");
1616 if (grid_units)
1617 Settings.grid_unit = get_unit_struct (grid_units);
1618 if (!grid_units || Settings.grid_unit == NULL)
1619 Settings.grid_unit = get_unit_struct ("mil");
1621 copy_nonzero_increments (get_increments_struct (METRIC), &increment_mm);
1622 copy_nonzero_increments (get_increments_struct (IMPERIAL), &increment_mil);
1624 Settings.increments = get_increments_struct (Settings.grid_unit->family);
1627 /* ----------------------------------------------------------------------
1628 * Print help or version messages.
1631 static void
1632 print_version ()
1634 printf ("PCB version %s\n", VERSION);
1635 exit (0);
1638 /* ----------------------------------------------------------------------
1639 * Figure out the canonical name of the executed program
1640 * and fix up the defaults for various paths
1642 char *bindir = NULL;
1643 char *exec_prefix = NULL;
1644 char *pcblibdir = NULL;
1645 char *pcblibpath = NULL;
1646 char *pcbtreedir = NULL;
1647 char *pcbtreepath = NULL;
1648 char *homedir = NULL;
1650 static void
1651 InitPaths (char *argv0)
1653 size_t l;
1654 int i;
1655 int haspath;
1656 char *t1, *t2;
1657 int found_bindir = 0;
1659 /* see if argv0 has enough of a path to let lrealpath give the
1660 * real path. This should be the case if you invoke pcb with
1661 * something like /usr/local/bin/pcb or ./pcb or ./foo/pcb
1662 * but if you just use pcb and it exists in your path, you'll
1663 * just get back pcb again.
1666 haspath = 0;
1667 for (i = 0; i < strlen (argv0) ; i++)
1669 if (argv0[i] == PCB_DIR_SEPARATOR_C)
1670 haspath = 1;
1673 #ifdef DEBUG
1674 printf ("InitPaths (%s): haspath = %d\n", argv0, haspath);
1675 #endif
1677 if (haspath)
1679 bindir = strdup (lrealpath (argv0));
1680 found_bindir = 1;
1682 else
1684 char *path, *p, *tmps;
1685 struct stat sb;
1686 int r;
1688 tmps = getenv ("PATH");
1690 if (tmps != NULL)
1692 path = strdup (tmps);
1694 /* search through the font path for a font file */
1695 for (p = strtok (path, PCB_PATH_DELIMETER); p && *p;
1696 p = strtok (NULL, PCB_PATH_DELIMETER))
1698 #ifdef DEBUG
1699 printf ("Looking for %s in %s\n", argv0, p);
1700 #endif
1701 if ( (tmps = (char *)malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
1703 fprintf (stderr, "InitPaths(): malloc failed\n");
1704 exit (1);
1706 sprintf (tmps, "%s%s%s", p, PCB_DIR_SEPARATOR_S, argv0);
1707 r = stat (tmps, &sb);
1708 if (r == 0)
1710 #ifdef DEBUG
1711 printf ("Found it: \"%s\"\n", tmps);
1712 #endif
1713 bindir = lrealpath (tmps);
1714 found_bindir = 1;
1715 free (tmps);
1716 break;
1718 free (tmps);
1720 free (path);
1724 #ifdef DEBUG
1725 printf ("InitPaths(): bindir = \"%s\"\n", bindir);
1726 #endif
1728 if (found_bindir)
1730 /* strip off the executible name leaving only the path */
1731 t2 = NULL;
1732 t1 = strchr (bindir, PCB_DIR_SEPARATOR_C);
1733 while (t1 != NULL && *t1 != '\0')
1735 t2 = t1;
1736 t1 = strchr (t2 + 1, PCB_DIR_SEPARATOR_C);
1738 if (t2 != NULL)
1739 *t2 = '\0';
1741 #ifdef DEBUG
1742 printf ("After stripping off the executible name, we found\n");
1743 printf ("bindir = \"%s\"\n", bindir);
1744 #endif
1746 else
1748 /* we have failed to find out anything from argv[0] so fall back to the original
1749 * install prefix
1751 bindir = strdup (BINDIR);
1754 /* now find the path to exec_prefix */
1755 l = strlen (bindir) + 1 + strlen (BINDIR_TO_EXECPREFIX) + 1;
1756 if ( (exec_prefix = (char *) malloc (l * sizeof (char) )) == NULL )
1758 fprintf (stderr, "InitPaths(): malloc failed\n");
1759 exit (1);
1761 sprintf (exec_prefix, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1762 BINDIR_TO_EXECPREFIX);
1764 /* now find the path to PCBLIBDIR */
1765 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBLIBDIR) + 1;
1766 if ( (pcblibdir = (char *) malloc (l * sizeof (char) )) == NULL )
1768 fprintf (stderr, "InitPaths(): malloc failed\n");
1769 exit (1);
1771 sprintf (pcblibdir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1772 BINDIR_TO_PCBLIBDIR);
1774 /* and the path to PCBTREEDIR */
1775 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBTREEDIR) + 1;
1776 if ( (pcbtreedir = (char *) malloc (l * sizeof (char) )) == NULL )
1778 fprintf (stderr, "InitPaths(): malloc failed\n");
1779 exit (1);
1781 sprintf (pcbtreedir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1782 BINDIR_TO_PCBTREEDIR);
1784 /* and the search path including PCBLIBDIR */
1785 l = strlen (pcblibdir) + 3;
1786 if ( (pcblibpath = (char *) malloc (l * sizeof (char) )) == NULL )
1788 fprintf (stderr, "InitPaths(): malloc failed\n");
1789 exit (1);
1791 sprintf (pcblibpath, ".%s%s", PCB_PATH_DELIMETER, pcblibdir);
1793 /* and the newlib search path */
1794 l = strlen (pcblibdir) + 1 + strlen (pcbtreedir)
1795 + strlen ("pcblib-newlib") + 2;
1796 if ( (pcbtreepath = (char *) malloc (l * sizeof (char) )) == NULL )
1798 fprintf (stderr, "InitPaths(): malloc failed\n");
1799 exit (1);
1801 sprintf (pcbtreepath, "%s%s%s%spcblib-newlib", pcbtreedir,
1802 PCB_PATH_DELIMETER, pcblibdir,
1803 PCB_DIR_SEPARATOR_S);
1805 #ifdef DEBUG
1806 printf ("bindir = %s\n", bindir);
1807 printf ("pcblibdir = %s\n", pcblibdir);
1808 printf ("pcblibpath = %s\n", pcblibpath);
1809 printf ("pcbtreedir = %s\n", pcbtreedir);
1810 printf ("pcbtreepath = %s\n", pcbtreepath);
1811 #endif
1813 l = sizeof (main_attribute_list) / sizeof (main_attribute_list[0]);
1814 for (i = 0; i < l ; i++)
1816 if (NSTRCMP (main_attribute_list[i].name, "lib-command-dir") == 0)
1818 main_attribute_list[i].default_val.str_value = pcblibdir;
1821 if ( (NSTRCMP (main_attribute_list[i].name, "font-path") == 0)
1822 || (NSTRCMP (main_attribute_list[i].name, "element-path") == 0)
1823 || (NSTRCMP (main_attribute_list[i].name, "lib-path") == 0) )
1825 main_attribute_list[i].default_val.str_value = pcblibpath;
1828 if (NSTRCMP (main_attribute_list[i].name, "lib-newlib") == 0)
1830 main_attribute_list[i].default_val.str_value = pcbtreepath;
1836 char *tmps;
1838 tmps = getenv ("HOME");
1840 if (tmps == NULL) {
1841 tmps = getenv ("USERPROFILE");
1844 if (tmps != NULL) {
1845 homedir = strdup (tmps);
1846 } else {
1847 homedir = NULL;
1853 /* ----------------------------------------------------------------------
1854 * main program
1857 char *program_name = 0;
1858 char *program_basename = 0;
1859 char *program_directory = 0;
1861 #include "dolists.h"
1864 main (int argc, char *argv[])
1866 int i;
1868 /* init application:
1869 * - make program name available for error handlers
1870 * - evaluate special options
1871 * - initialize toplevel shell and resources
1872 * - create an empty PCB with default symbols
1873 * - initialize all other widgets
1874 * - update screen and get size of drawing area
1875 * - evaluate command-line arguments
1876 * - register 'call on exit()' function
1879 #include "core_lists.h"
1880 setbuf (stdout, 0);
1881 InitPaths (argv[0]);
1883 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1884 textdomain (GETTEXT_PACKAGE);
1885 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1887 #ifdef ENABLE_NLS
1888 setlocale (LC_ALL, "");
1889 setlocale (LC_NUMERIC, "C");
1890 #endif
1892 srand ( time(NULL) ); /* Set seed for rand() */
1894 initialize_units();
1895 polygon_init ();
1896 hid_init ();
1898 hid_load_settings ();
1900 program_name = argv[0];
1901 program_basename = strrchr (program_name, PCB_DIR_SEPARATOR_C);
1902 if (program_basename)
1904 program_directory = strdup (program_name);
1905 *strrchr (program_directory, PCB_DIR_SEPARATOR_C) = 0;
1906 program_basename++;
1908 else
1910 program_directory = ".";
1911 program_basename = program_name;
1913 Progname = program_basename;
1915 /* Print usage or version if requested. Then exit. */
1916 if (argc > 1 &&
1917 (strcmp (argv[1], "-h") == 0 ||
1918 strcmp (argv[1], "-?") == 0 ||
1919 strcmp (argv[1], "--help") == 0))
1920 usage ();
1921 if (argc > 1 && strcmp (argv[1], "-V") == 0)
1922 print_version ();
1923 /* Export pcb from command line if requested. */
1924 if (argc > 1 && strcmp (argv[1], "-p") == 0)
1926 exporter = gui = hid_find_printer ();
1927 argc--;
1928 argv++;
1930 else if (argc > 2 && strcmp (argv[1], "-x") == 0)
1932 exporter = gui = hid_find_exporter (argv[2]);
1933 argc -= 2;
1934 argv += 2;
1936 /* Otherwise start GUI. */
1937 else
1938 gui = hid_find_gui ();
1940 /* Exit with error if GUI failed to start. */
1941 if (!gui)
1942 exit (1);
1944 /* Set up layers. */
1945 for (i = 0; i < MAX_LAYER; i++)
1947 char buf[20];
1948 sprintf (buf, "signal%d", i + 1);
1949 Settings.DefaultLayerName[i] = strdup (buf);
1950 Settings.LayerColor[i] = "#c49350";
1951 Settings.LayerSelectedColor[i] = "#00ffff";
1954 gui->parse_arguments (&argc, &argv);
1956 if (show_help || (argc > 1 && argv[1][0] == '-'))
1957 usage ();
1958 if (show_version)
1959 print_version ();
1960 if (show_defaults)
1961 print_defaults ();
1962 if (show_copyright)
1963 copyright ();
1965 settings_post_process ();
1968 if (show_actions)
1970 print_actions ();
1971 exit (0);
1974 if (do_dump_actions)
1976 extern void dump_actions (void);
1977 dump_actions ();
1978 exit (0);
1981 /* Create a new PCB object in memory */
1982 PCB = CreateNewPCB ();
1983 ParseGroupString (Settings.Groups, &PCB->LayerGroups, &PCB->Data->LayerN);
1984 /* Add silk layers to newly created PCB */
1985 CreateNewPCBPost (PCB, 1);
1986 if (argc > 1)
1987 command_line_pcb = argv[1];
1989 ResetStackAndVisibility ();
1991 InitCrosshair ();
1992 InitHandler ();
1993 InitBuffers ();
1994 SetMode (ARROW_MODE);
1996 if (command_line_pcb)
1998 /* keep filename even if initial load command failed;
1999 * file might not exist
2001 if (LoadPCB (command_line_pcb))
2002 PCB->Filename = strdup (command_line_pcb);
2005 if (Settings.InitialLayerStack
2006 && Settings.InitialLayerStack[0])
2008 LayerStringToLayerStack (Settings.InitialLayerStack);
2011 /* This must be called before any other atexit functions
2012 * are registered, as it configures an atexit function to
2013 * clean up and free various items of allocated memory,
2014 * and must be the last last atexit function to run.
2016 leaky_init ();
2018 /* Register a function to be called when the program terminates.
2019 * This makes sure that data is saved even if LEX/YACC routines
2020 * abort the program.
2021 * If the OS doesn't have at least one of them,
2022 * the critical sections will be handled by parse_l.l
2024 atexit (EmergencySave);
2026 /* read the library file and display it if it's not empty
2028 if (!ReadLibraryContents () && Library.MenuN)
2029 hid_action ("LibraryChanged");
2031 #ifdef HAVE_LIBSTROKE
2032 stroke_init ();
2033 #endif
2035 if (Settings.ScriptFilename)
2037 Message (_("Executing startup script file %s\n"),
2038 Settings.ScriptFilename);
2039 hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
2041 if (Settings.ActionString)
2043 Message (_("Executing startup action %s\n"), Settings.ActionString);
2044 hid_parse_actions (Settings.ActionString);
2047 if (gui->printer || gui->exporter)
2049 gui->do_export (0);
2050 exit (0);
2053 #if HAVE_DBUS
2054 pcb_dbus_setup();
2055 #endif
2057 EnableAutosave ();
2059 #ifdef DEBUG
2060 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2061 Settings.LibraryCommandDir);
2062 printf ("Settings.FontPath = \"%s\"\n",
2063 Settings.FontPath);
2064 printf ("Settings.ElementPath = \"%s\"\n",
2065 Settings.ElementPath);
2066 printf ("Settings.LibraryPath = \"%s\"\n",
2067 Settings.LibraryPath);
2068 printf ("Settings.LibraryTree = \"%s\"\n",
2069 Settings.LibraryTree);
2070 printf ("Settings.MakeProgram = \"%s\"\n",
2071 UNKNOWN (Settings.MakeProgram));
2072 printf ("Settings.GnetlistProgram = \"%s\"\n",
2073 UNKNOWN (Settings.GnetlistProgram));
2074 #endif
2076 gui->do_export (0);
2077 #if HAVE_DBUS
2078 pcb_dbus_finish();
2079 #endif
2081 return (0);