src/main.c: Converted plain comments into doxygen comments.
[geda-pcb/pcjc2.git] / src / main.c
blobeeaf5d2d16de574e11b4cfa8f55a3c3e8068aae7
1 /*!
2 * \file src/main.c
4 * \brief Main program, initializes some stuff and handles user input.
6 * <hr>
8 * <h1><b>Copyright.</b></h1>\n
10 * PCB, interactive printed circuit board design
12 * Copyright (C) 1994,1995,1996, 2004 Thomas Nau
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Contact addresses for paper mail and Email:
29 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
30 * Thomas.Nau@rz.uni-ulm.de
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
38 #include <stdlib.h>
39 #ifdef HAVE_STRING_H
40 #include <string.h>
41 #endif
42 #include <signal.h>
43 #include <unistd.h>
44 #include <sys/stat.h>
45 #include <time.h> /* Seed for srand() */
47 #include "global.h"
48 #include "data.h"
49 #include "buffer.h"
50 #include "create.h"
51 #include "crosshair.h"
52 #include "draw.h"
53 #include "error.h"
54 #include "file.h"
55 #include "set.h"
56 #include "action.h"
57 #include "misc.h"
58 #include "lrealpath.h"
59 #include "free_atexit.h"
60 #include "polygon.h"
61 #include "gettext.h"
62 #include "pcb-printf.h"
64 #include "hid/common/actions.h"
66 /* This next one is so we can print the help messages. */
67 #include "hid/hidint.h"
69 #ifdef HAVE_DBUS
70 #include "dbus.h"
71 #endif
73 #ifdef HAVE_LIBDMALLOC
74 #include <dmalloc.h>
75 #endif
77 #define PCBLIBPATH ".:" PCBLIBDIR
80 #ifdef HAVE_LIBSTROKE
81 extern void stroke_init (void);
82 #endif
85 /*!
86 * \brief Initialize signal and error handlers.
88 static void
89 InitHandler (void)
92 signal(SIGHUP, CatchSignal);
93 signal(SIGQUIT, CatchSignal);
94 signal(SIGABRT, CatchSignal);
95 signal(SIGSEGV, CatchSignal);
96 signal(SIGTERM, CatchSignal);
97 signal(SIGINT, CatchSignal);
100 /* calling external program by popen() may cause a PIPE signal,
101 * so we ignore it
103 #ifdef SIGPIPE
104 signal (SIGPIPE, SIG_IGN);
105 #endif
109 /* ----------------------------------------------------------------------
110 | command line and rc file processing.
112 static char *command_line_pcb;
115 * \brief Print the copyright notice.
117 void
118 copyright (void)
120 printf ("\n"
121 " COPYRIGHT for %s version %s\n\n"
122 " PCB, interactive printed circuit board design\n"
123 " Copyright (C) 1994,1995,1996,1997 Thomas Nau\n"
124 " Copyright (C) 1998, 1999, 2000 Harry Eaton\n\n"
125 " This program is free software; you can redistribute it and/or modify\n"
126 " it under the terms of the GNU General Public License as published by\n"
127 " the Free Software Foundation; either version 2 of the License, or\n"
128 " (at your option) any later version.\n\n"
129 " This program is distributed in the hope that it will be useful,\n"
130 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
131 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
132 " GNU General Public License for more details.\n\n"
133 " You should have received a copy of the GNU General Public License\n"
134 " along with this program; if not, write to the Free Software\n"
135 " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n",
136 Progname, VERSION);
137 exit (0);
140 static inline void
141 u (const char *fmt, ...)
143 va_list ap;
144 va_start (ap, fmt);
145 vfprintf (stderr, fmt, ap);
146 fputc ('\n', stderr);
147 va_end (ap);
150 typedef struct UsageNotes {
151 struct UsageNotes *next;
152 HID_Attribute *seen;
153 } UsageNotes;
155 static UsageNotes *usage_notes = NULL;
157 static void
158 usage_attr (HID_Attribute * a)
160 int i, n;
161 const Unit *unit_list;
162 static char buf[200];
164 if (a->help_text == ATTR_UNDOCUMENTED)
165 return;
167 switch (a->type)
169 case HID_Label:
170 return;
171 case HID_Integer:
172 case HID_Real:
173 sprintf (buf, "--%s <num>", a->name);
174 break;
175 case HID_Coord:
176 sprintf (buf, "--%s <measure>", a->name);
177 break;
178 case HID_String:
179 sprintf (buf, "--%s <string>", a->name);
180 break;
181 case HID_Boolean:
182 sprintf (buf, "--%s", a->name);
183 break;
184 case HID_Mixed:
185 case HID_Enum:
186 sprintf (buf, "--%s ", a->name);
187 if (a->type == HID_Mixed)
188 strcat (buf, " <val>");
189 for (i = 0; a->enumerations[i]; i++)
191 strcat (buf, i ? "|" : "<");
192 strcat (buf, a->enumerations[i]);
194 strcat (buf, ">");
195 break;
196 case HID_Path:
197 sprintf (buf, "--%s <path>", a->name);
198 break;
199 case HID_Unit:
200 unit_list = get_unit_list ();
201 n = get_n_units ();
202 sprintf (buf, "--%s ", a->name);
203 for (i = 0; i < n; i++)
205 strcat (buf, i ? "|" : "<");
206 strcat (buf, unit_list[i].suffix);
208 strcat (buf, ">");
209 break;
212 if (strlen (buf) <= 30)
214 if (a->help_text)
215 fprintf (stderr, " %-30s\t%s\n", buf, a->help_text);
216 else
217 fprintf (stderr, " %-30s\n", buf);
219 else if (a->help_text && strlen (a->help_text) + strlen (buf) < 72)
220 fprintf (stderr, " %s\t%s\n", buf, a->help_text);
221 else if (a->help_text)
222 fprintf (stderr, " %s\n\t\t\t%s\n", buf, a->help_text);
223 else
224 fprintf (stderr, " %s\n", buf);
227 static void
228 usage_hid (HID * h)
230 HID_Attribute *attributes;
231 int i, n_attributes = 0;
232 UsageNotes *note;
234 if (h->gui)
236 fprintf (stderr, "\n%s gui options:\n", h->name);
237 attributes = h->get_export_options (&n_attributes);
239 else
241 fprintf (stderr, "\n%s options:\n", h->name);
242 exporter = h;
243 attributes = exporter->get_export_options (&n_attributes);
244 exporter = NULL;
247 note = (UsageNotes *)malloc (sizeof (UsageNotes));
248 note->next = usage_notes;
249 note->seen = attributes;
250 usage_notes = note;
252 for (i = 0; i < n_attributes; i++)
253 usage_attr (attributes + i);
256 static void
257 usage (void)
259 HID **hl = hid_enumerate ();
260 HID_AttrNode *ha;
261 UsageNotes *note;
262 int i;
263 int n_printer = 0, n_gui = 0, n_exporter = 0;
265 for (i = 0; hl[i]; i++)
267 if (hl[i]->gui)
268 n_gui++;
269 if (hl[i]->printer)
270 n_printer++;
271 if (hl[i]->exporter)
272 n_exporter++;
275 u ("PCB Printed Circuit Board editing program, http://pcb.geda-project.org");
276 u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname);
277 u ("%s [gui options] <pcb file>\t\tto edit", Progname);
278 u ("Available GUI hid%s:", n_gui == 1 ? "" : "s");
279 for (i = 0; hl[i]; i++)
280 if (hl[i]->gui)
281 fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
282 u ("%s -p [printing options] <pcb file>\tto print", Progname);
283 u ("Available printing hid%s:", n_printer == 1 ? "" : "s");
284 for (i = 0; hl[i]; i++)
285 if (hl[i]->printer)
286 fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
287 u ("%s -x hid [export options] <pcb file>\tto export", Progname);
288 u ("Available export hid%s:", n_exporter == 1 ? "" : "s");
289 for (i = 0; hl[i]; i++)
290 if (hl[i]->exporter)
291 fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
293 for (i = 0; hl[i]; i++)
294 if (hl[i]->gui)
295 usage_hid (hl[i]);
296 for (i = 0; hl[i]; i++)
297 if (hl[i]->printer)
298 usage_hid (hl[i]);
299 for (i = 0; hl[i]; i++)
300 if (hl[i]->exporter)
301 usage_hid (hl[i]);
303 u ("\nCommon options:");
304 for (ha = hid_attr_nodes; ha; ha = ha->next)
306 for (note = usage_notes; note && note->seen != ha->attributes; note = note->next)
308 if (note)
309 continue;
310 for (i = 0; i < ha->n; i++)
312 usage_attr (ha->attributes + i);
316 exit (1);
319 static void
320 print_defaults_1 (HID_Attribute * a, void *value)
322 int i;
323 Coord c;
324 double d;
325 const char *s;
327 /* Remember, at this point we've parsed the command line, so they
328 may be in the global variable instead of the default_val. */
329 switch (a->type)
331 case HID_Integer:
332 i = value ? *(int *) value : a->default_val.int_value;
333 fprintf (stderr, "%s %d\n", a->name, i);
334 break;
335 case HID_Boolean:
336 i = value ? *(char *) value : a->default_val.int_value;
337 fprintf (stderr, "%s %s\n", a->name, i ? "yes" : "no");
338 break;
339 case HID_Real:
340 d = value ? *(double *) value : a->default_val.real_value;
341 fprintf (stderr, "%s %g\n", a->name, d);
342 break;
343 case HID_Coord:
344 c = value ? *(Coord *) value : a->default_val.coord_value;
345 pcb_fprintf (stderr, "%s %$mS\n", a->name, c);
346 break;
347 case HID_String:
348 case HID_Path:
349 s = value ? *(char **) value : a->default_val.str_value;
350 fprintf (stderr, "%s \"%s\"\n", a->name, s);
351 break;
352 case HID_Enum:
353 i = value ? *(int *) value : a->default_val.int_value;
354 fprintf (stderr, "%s %s\n", a->name, a->enumerations[i]);
355 break;
356 case HID_Mixed:
357 i = value ?
358 ((HID_Attr_Val*)value)->int_value : a->default_val.int_value;
359 d = value ?
360 ((HID_Attr_Val*)value)->real_value : a->default_val.real_value;
361 fprintf (stderr, "%s %g%s\n", a->name, d, a->enumerations[i]);
362 break;
363 case HID_Label:
364 break;
365 case HID_Unit:
366 i = value ? *(int *) value : a->default_val.int_value;
367 fprintf (stderr, "%s %s\n", a->name, get_unit_list()[i].suffix);
371 static void
372 print_defaults ()
374 HID **hl = hid_enumerate ();
375 HID_Attribute *e;
376 int i, n, hi;
378 for (hi = 0; hl[hi]; hi++)
380 HID *h = hl[hi];
381 if (h->gui)
383 HID_AttrNode *ha;
384 fprintf (stderr, "\ngui defaults:\n");
385 for (ha = hid_attr_nodes; ha; ha = ha->next)
386 for (i = 0; i < ha->n; i++)
387 print_defaults_1 (ha->attributes + i, ha->attributes[i].value);
389 else
391 fprintf (stderr, "\n%s defaults:\n", h->name);
392 exporter = h;
393 e = exporter->get_export_options (&n);
394 exporter = NULL;
395 if (e)
396 for (i = 0; i < n; i++)
397 print_defaults_1 (e + i, 0);
400 exit (1);
403 #define SSET(F,D,N,H) { N, H, \
404 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
405 #define ISET(F,D,N,H) { N, H, \
406 HID_Integer, 0, 0, { D, 0, 0 }, 0, &Settings.F }
407 #define BSET(F,D,N,H) { N, H, \
408 HID_Boolean, 0, 0, { D, 0, 0 }, 0, &Settings.F }
409 #define RSET(F,D,N,H) { N, H, \
410 HID_Real, 0, 0, { 0, 0, D }, 0, &Settings.F }
411 #define CSET(F,D,N,H) { N, H, \
412 HID_Coord, 0, 0, { 0, 0, 0, D }, 0, &Settings.F }
414 #define COLOR(F,D,N,H) { N, H, \
415 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
416 #define LAYERCOLOR(N,D) { "layer-color-" #N, "Color for layer " #N, \
417 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.LayerColor[N-1] }
418 #define LAYERNAME(N,D) { "layer-name-" #N, "Name for layer " #N, \
419 HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.DefaultLayerName[N-1] }
420 #define LAYERSELCOLOR(N) { "layer-selected-color-" #N, "Color for layer " #N " when selected", \
421 HID_String, 0, 0, { 0, "#00ffff", 0 }, 0, &Settings.LayerSelectedColor[N-1] }
423 static int show_help = 0;
424 static int show_version = 0;
425 static int show_copyright = 0;
426 static int show_defaults = 0;
427 static int show_actions = 0;
428 static int do_dump_actions = 0;
429 static char *grid_units;
430 static Increments increment_mm = { 0 };
431 static Increments increment_mil = { 0 };
433 void save_increments (const Increments *mm, const Increments *mil)
435 memcpy (&increment_mm, mm, sizeof (*mm));
436 memcpy (&increment_mil, mil, sizeof (*mil));
439 HID_Attribute main_attribute_list[] = {
441 /* %start-doc options "1 General Options"
442 @ftable @code
443 @item --help
444 Show help on command line options.
445 @end ftable
446 %end-doc
448 {"help", "Show help on command line options", HID_Boolean, 0, 0, {0, 0, 0}, 0,
449 &show_help},
451 /* %start-doc options "1 General Options"
452 @ftable @code
453 @item --version
454 Show version.
455 @end ftable
456 %end-doc
458 {"version", "Show version", HID_Boolean, 0, 0, {0, 0, 0}, 0, &show_version},
460 /* %start-doc options "1 General Options"
461 @ftable @code
462 @item --verbose
463 Be verbose on stdout.
464 @end ftable
465 %end-doc
467 {"verbose", "Be verbose on stdout", HID_Boolean, 0, 0, {0, 0, 0}, 0,
468 &Settings.verbose},
470 /* %start-doc options "1 General Options"
471 @ftable @code
472 @item --copyright
473 Show copyright.
474 @end ftable
475 %end-doc
477 {"copyright", "Show Copyright", HID_Boolean, 0, 0, {0, 0, 0}, 0,
478 &show_copyright},
480 /* %start-doc options "1 General Options"
481 @ftable @code
482 @item --show-defaults
483 Show option defaults.
484 @end ftable
485 %end-doc
487 {"show-defaults", "Show option defaults", HID_Boolean, 0, 0, {0, 0, 0}, 0,
488 &show_defaults},
490 /* %start-doc options "1 General Options"
491 @ftable @code
492 @item --show-actions
493 Show available actions and exit.
494 @end ftable
495 %end-doc
497 {"show-actions", "Show available actions", HID_Boolean, 0, 0, {0, 0, 0}, 0,
498 &show_actions},
500 /* %start-doc options "1 General Options"
501 @ftable @code
502 @item --dump-actions
503 Dump actions (for documentation).
504 @end ftable
505 %end-doc
507 {"dump-actions", "Dump actions (for documentation)", HID_Boolean, 0, 0,
508 {0, 0, 0}, 0, &do_dump_actions},
510 /* %start-doc options "1 General Options"
511 @ftable @code
512 @item --grid-units-mm <string>
513 Set default grid units. Can be mm or mil. Defaults to mil.
514 @end ftable
515 %end-doc
517 {"grid-units", "Default grid units (mm|mil)", HID_String, 0, 0, {0, "mil", 0},
518 0, &grid_units},
520 /* %start-doc options "1 General Options"
521 @ftable @code
522 @item --clear-increment-mm <string>
523 Set default clear increment (amount to change when user presses k or K)
524 when user is using a metric grid unit.
525 @end ftable
526 %end-doc
528 {"clear-increment-mm", "Default clear increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
529 0, &increment_mm.clear},
531 /* %start-doc options "1 General Options"
532 @ftable @code
533 @item --grid-increment-mm <string>
534 Set default grid increment (amount to change when user presses g or G)
535 when user is using a metric grid unit.
536 @end ftable
537 %end-doc
539 {"grid-increment-mm", "Default grid increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
540 0, &increment_mm.grid},
542 /* %start-doc options "1 General Options"
543 @ftable @code
544 @item --line-increment-mm <string>
545 Set default line increment (amount to change when user presses l or L)
546 when user is using a metric grid unit.
547 @end ftable
548 %end-doc
550 {"line-increment-mm", "Default line increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
551 0, &increment_mm.line},
553 /* %start-doc options "1 General Options"
554 @ftable @code
555 @item --size-increment-mm <string>
556 Set default size increment (amount to change when user presses s or S)
557 when user is using a metric grid unit.
558 @end ftable
559 %end-doc
561 {"size-increment-mm", "Default size increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
562 0, &increment_mm.size},
564 /* %start-doc options "1 General Options"
565 @ftable @code
566 @item --clear-increment-mil <string>
567 Set default clear increment (amount to change when user presses k or K)
568 when user is using an imperial grid unit.
569 @end ftable
570 %end-doc
572 {"clear-increment-mil", "Default clear increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
573 0, &increment_mil.clear},
575 /* %start-doc options "1 General Options"
576 @ftable @code
577 @item --grid-increment-mil <string>
578 Set default grid increment (amount to change when user presses g or G)
579 when user is using a imperial grid unit.
580 @end ftable
581 %end-doc
583 {"grid-increment-mil", "Default grid increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
584 0, &increment_mil.grid},
586 /* %start-doc options "1 General Options"
587 @ftable @code
588 @item --line-increment-mil <string>
589 Set default line increment (amount to change when user presses l or L)
590 when user is using a imperial grid unit.
591 @end ftable
592 %end-doc
594 {"line-increment-mil", "Default line increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
595 0, &increment_mil.line},
597 /* %start-doc options "1 General Options"
598 @ftable @code
599 @item --size-increment-mil <string>
600 Set default size increment (amount to change when user presses s or S)
601 when user is using a imperial grid unit.
602 @end ftable
603 %end-doc
605 {"size-increment-mil", "Default size increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
606 0, &increment_mil.size},
608 /* %start-doc options "3 Colors"
609 @ftable @code
610 @item --black-color <string>
611 Color value for black. Default: @samp{#000000}
612 @end ftable
613 %end-doc
615 COLOR (BlackColor, "#000000", "black-color", "color value of 'black'"),
617 /* %start-doc options "3 Colors"
618 @ftable @code
619 @item --black-color <string>
620 Color value for white. Default: @samp{#ffffff}
621 @end ftable
622 %end-doc
624 COLOR (WhiteColor, "#ffffff", "white-color", "color value of 'white'"),
626 /* %start-doc options "3 Colors"
627 @ftable @code
628 @item --background-color <string>
629 Background color of the canvas. Default: @samp{#e5e5e5}
630 @end ftable
631 %end-doc
633 COLOR (BackgroundColor, "#e5e5e5", "background-color",
634 "color for background"),
636 /* %start-doc options "3 Colors"
637 @ftable @code
638 @item --crosshair-color <string>
639 Color of the crosshair. Default: @samp{#ff0000}
640 @end ftable
641 %end-doc
643 COLOR (CrosshairColor, "#ff0000", "crosshair-color",
644 "color for the crosshair"),
646 /* %start-doc options "3 Colors"
647 @ftable @code
648 @item --cross-color <string>
649 Color of the cross. Default: @samp{#cdcd00}
650 @end ftable
651 %end-doc
653 COLOR (CrossColor, "#cdcd00", "cross-color", "color of the cross"),
655 /* %start-doc options "3 Colors"
656 @ftable @code
657 @item --via-color <string>
658 Color of vias. Default: @samp{#7f7f7f}
659 @end ftable
660 %end-doc
662 COLOR (ViaColor, "#7f7f7f", "via-color", "color of vias"),
664 /* %start-doc options "3 Colors"
665 @ftable @code
666 @item --via-selected-color <string>
667 Color of selected vias. Default: @samp{#00ffff}
668 @end ftable
669 %end-doc
671 COLOR (ViaSelectedColor, "#00ffff", "via-selected-color",
672 "color for selected vias"),
674 /* %start-doc options "3 Colors"
675 @ftable @code
676 @item --pin-color <string>
677 Color of pins. Default: @samp{#4d4d4d}
678 @end ftable
679 %end-doc
681 COLOR (PinColor, "#4d4d4d", "pin-color", "color of pins"),
683 /* %start-doc options "3 Colors"
684 @ftable @code
685 @item --pin-selected-color <string>
686 Color of selected pins. Default: @samp{#00ffff}
687 @end ftable
688 %end-doc
690 COLOR (PinSelectedColor, "#00ffff", "pin-selected-color",
691 "color of selected pins"),
693 /* %start-doc options "3 Colors"
694 @ftable @code
695 @item --pin-name-color <string>
696 Color of pin names and pin numbers. Default: @samp{#ff0000}
697 @end ftable
698 %end-doc
700 COLOR (PinNameColor, "#ff0000", "pin-name-color",
701 "color for pin names and pin numbers"),
703 /* %start-doc options "3 Colors"
704 @ftable @code
705 @item --element-color <string>
706 Color of components. Default: @samp{#000000}
707 @end ftable
708 %end-doc
710 COLOR (ElementColor, "#000000", "element-color", "color of components"),
712 /* %start-doc options "3 Colors"
713 @ftable @code
714 @item --rat-color <string>
715 Color of ratlines. Default: @samp{#b8860b}
716 @end ftable
717 %end-doc
719 COLOR (RatColor, "#b8860b", "rat-color", "color of ratlines"),
721 /* %start-doc options "3 Colors"
722 @ftable @code
723 @item --invisible-objects-color <string>
724 Color of invisible objects. Default: @samp{#cccccc}
725 @end ftable
726 %end-doc
728 COLOR (InvisibleObjectsColor, "#cccccc", "invisible-objects-color",
729 "color of invisible objects"),
731 /* %start-doc options "3 Colors"
732 @ftable @code
733 @item --invisible-mark-color <string>
734 Color of invisible marks. Default: @samp{#cccccc}
735 @end ftable
736 %end-doc
738 COLOR (InvisibleMarkColor, "#cccccc", "invisible-mark-color",
739 "color of invisible marks"),
741 /* %start-doc options "3 Colors"
742 @ftable @code
743 @item --element-selected-color <string>
744 Color of selected components. Default: @samp{#00ffff}
745 @end ftable
746 %end-doc
748 COLOR (ElementSelectedColor, "#00ffff", "element-selected-color",
749 "color of selected components"),
751 /* %start-doc options "3 Colors"
752 @ftable @code
753 @item --rat-selected-color <string>
754 Color of selected rats. Default: @samp{#00ffff}
755 @end ftable
756 %end-doc
758 COLOR (RatSelectedColor, "#00ffff", "rat-selected-color",
759 "color of selected rats"),
761 /* %start-doc options "3 Colors"
762 @ftable @code
763 @item --connected-color <string>
764 Color to indicate physical connections. Default: @samp{#00ff00}
765 @end ftable
766 %end-doc
768 COLOR (ConnectedColor, "#00ff00", "connected-color",
769 "color to indicate physically connected objects"),
771 /* %start-doc options "3 Colors"
772 @ftable @code
773 @item --found-color <string>
774 Color to indicate logical connections. Default: @samp{#ff00ff}
775 @end ftable
776 %end-doc
778 COLOR (FoundColor, "#ff00ff", "found-color",
779 "color to indicate logically connected objects"),
781 /* %start-doc options "3 Colors"
782 @ftable @code
783 @item --off-limit-color <string>
784 Color of off-canvas area. Default: @samp{#cccccc}
785 @end ftable
786 %end-doc
788 COLOR (OffLimitColor, "#cccccc", "off-limit-color",
789 "color of off-canvas area"),
791 /* %start-doc options "3 Colors"
792 @ftable @code
793 @item --grid-color <string>
794 Color of the grid. Default: @samp{#ff0000}
795 @end ftable
796 %end-doc
798 COLOR (GridColor, "#ff0000", "grid-color", "color of the grid"),
800 /* %start-doc options "3 Colors"
801 @ftable @code
802 @item --layer-color-<n> <string>
803 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
804 @end ftable
805 %end-doc
807 LAYERCOLOR (1, "#8b2323"),
808 LAYERCOLOR (2, "#3a5fcd"),
809 LAYERCOLOR (3, "#104e8b"),
810 LAYERCOLOR (4, "#cd3700"),
811 LAYERCOLOR (5, "#548b54"),
812 LAYERCOLOR (6, "#8b7355"),
813 LAYERCOLOR (7, "#00868b"),
814 LAYERCOLOR (8, "#228b22"),
815 LAYERCOLOR (9, "#8b2323"),
816 LAYERCOLOR (10, "#3a5fcd"),
817 LAYERCOLOR (11, "#104e8b"),
818 LAYERCOLOR (12, "#cd3700"),
819 LAYERCOLOR (13, "#548b54"),
820 LAYERCOLOR (14, "#8b7355"),
821 LAYERCOLOR (15, "#00868b"),
822 LAYERCOLOR (16, "#228b22"),
823 /* %start-doc options "3 Colors"
824 @ftable @code
825 @item --layer-selected-color-<n> <string>
826 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
827 @end ftable
828 %end-doc
830 LAYERSELCOLOR (1),
831 LAYERSELCOLOR (2),
832 LAYERSELCOLOR (3),
833 LAYERSELCOLOR (4),
834 LAYERSELCOLOR (5),
835 LAYERSELCOLOR (6),
836 LAYERSELCOLOR (7),
837 LAYERSELCOLOR (8),
838 LAYERSELCOLOR (9),
839 LAYERSELCOLOR (10),
840 LAYERSELCOLOR (11),
841 LAYERSELCOLOR (12),
842 LAYERSELCOLOR (13),
843 LAYERSELCOLOR (14),
844 LAYERSELCOLOR (15),
845 LAYERSELCOLOR (16),
847 /* %start-doc options "3 Colors"
848 @ftable @code
849 @item --warn-color <string>
850 Color of offending objects during DRC. Default value is @code{"#ff8000"}
851 @end ftable
852 %end-doc
854 COLOR (WarnColor, "#ff8000", "warn-color", "color of offending objects during DRC"),
856 /* %start-doc options "3 Colors"
857 @ftable @code
858 @item --mask-color <string>
859 Color of the mask layer. Default value is @code{"#ff0000"}
860 @end ftable
861 %end-doc
863 COLOR (MaskColor, "#ff0000", "mask-color", "color for solder mask"),
866 /* %start-doc options "5 Sizes"
867 All parameters should be given with an unit. If no unit is given, 1/100 mil
868 (cmil) will be used. Write units without space to the
869 number like @code{3mm}, not @code{3 mm}.
870 Valid Units are:
871 @table @samp
872 @item km
873 Kilometer
874 @item m
875 Meter
876 @item cm
877 Centimeter
878 @item mm
879 Millimeter
880 @item um
881 Micrometer
882 @item nm
883 Nanometer
884 @item in
885 Inch (1in = 0.0254m)
886 @item mil
887 Mil (1000mil = 1in)
888 @item cmil
889 Centimil (1/100 mil)
890 @end table
892 @ftable @code
893 @item --via-thickness <num>
894 Default diameter of vias. Default value is @code{60mil}.
895 @end ftable
896 %end-doc
898 CSET (ViaThickness, MIL_TO_COORD(60), "via-thickness",
899 "default diameter of vias in 1/100 mil"),
901 /* %start-doc options "5 Sizes"
902 @ftable @code
903 @item --via-drilling-hole <num>
904 Default diameter of holes. Default value is @code{28mil}.
905 @end ftable
906 %end-doc
908 CSET (ViaDrillingHole, MIL_TO_COORD(28), "via-drilling-hole",
909 "default diameter of holes"),
911 /* %start-doc options "5 Sizes"
912 @ftable @code
913 @item --line-thickness <num>
914 Default thickness of new lines. Default value is @code{10mil}.
915 @end ftable
916 %end-doc
918 CSET (LineThickness, MIL_TO_COORD(10), "line-thickness",
919 "initial thickness of new lines"),
921 /* %start-doc options "5 Sizes"
922 @ftable @code
923 @item --rat-thickness <num><unit>
924 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100
925 means "1 nm"). This option allows for a special unit @code{px} which
926 sets the rat thickness to a fixed value in terms of screen pixels.
927 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.
928 Default value is @code{10mil}.
929 @end ftable
930 %end-doc
932 CSET (RatThickness, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
934 /* %start-doc options "5 Sizes"
935 @ftable @code
936 @item --keepaway <num>
937 Default minimum distance between a track and adjacent copper.
938 Default value is @code{10mil}.
939 @end ftable
940 %end-doc
942 CSET (Keepaway, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
944 /* %start-doc options "5 Sizes"
945 @ftable @code
946 @item --default-PCB-width <num>
947 Default width of the canvas. Default value is @code{6000mil}.
948 @end ftable
949 %end-doc
951 CSET (MaxWidth, MIL_TO_COORD(6000), "default-PCB-width",
952 "default width of the canvas"),
954 /* %start-doc options "5 Sizes"
955 @ftable @code
956 @item --default-PCB-height <num>
957 Default height of the canvas. Default value is @code{5000mil}.
958 @end ftable
959 %end-doc
961 CSET (MaxHeight, MIL_TO_COORD(5000), "default-PCB-height",
962 "default height of the canvas"),
964 /* %start-doc options "5 Sizes"
965 @ftable @code
966 @item --text-scale <num>
967 Default text scale. This value is in percent. Default value is @code{100}.
968 @end ftable
969 %end-doc
971 ISET (TextScale, 100, "text-scale", "default text scale in percent"),
973 /* %start-doc options "5 Sizes"
974 @ftable @code
975 @item --alignment-distance <num>
976 Specifies the distance between the board outline and alignment targets.
977 Default value is @code{2mil}.
978 @end ftable
979 %end-doc
981 CSET (AlignmentDistance, MIL_TO_COORD(2), "alignment-distance",
982 "distance between the boards outline and alignment targets"),
984 /* %start-doc options "7 DRC Options"
985 All parameters should be given with an unit. If no unit is given, 1/100 mil
986 (cmil) will be used for backward compability. Valid units are given in section
987 @ref{Sizes}.
988 %end-doc
992 /* %start-doc options "7 DRC Options"
993 @ftable @code
994 @item --bloat <num>
995 Minimum spacing. Default value is @code{10mil}.
996 @end ftable
997 %end-doc
999 CSET (Bloat, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
1001 /* %start-doc options "7 DRC Options"
1002 @ftable @code
1003 @item --shrink <num>
1004 Minimum touching overlap. Default value is @code{10mil}.
1005 @end ftable
1006 %end-doc
1008 CSET (Shrink, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
1010 /* %start-doc options "7 DRC Options"
1011 @ftable @code
1012 @item --min-width <num>
1013 Minimum width of copper. Default value is @code{10mil}.
1014 @end ftable
1015 %end-doc
1017 CSET (minWid, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
1019 /* %start-doc options "7 DRC Options"
1020 @ftable @code
1021 @item --min-silk <num>
1022 Minimum width of lines in silk. Default value is @code{10mil}.
1023 @end ftable
1024 %end-doc
1026 CSET (minSlk, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
1028 /* %start-doc options "7 DRC Options"
1029 @ftable @code
1030 @item --min-drill <num>
1031 Minimum diameter of holes. Default value is @code{15mil}.
1032 @end ftable
1033 %end-doc
1035 CSET (minDrill, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
1037 /* %start-doc options "7 DRC Options"
1038 @ftable @code
1039 @item --min-ring <num>
1040 Minimum width of annular ring. Default value is @code{10mil}.
1041 @end ftable
1042 %end-doc
1044 CSET (minRing, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
1047 /* %start-doc options "5 Sizes"
1048 @ftable @code
1049 @item --grid <num>
1050 Initial grid size. Default value is @code{10mil}.
1051 @end ftable
1052 %end-doc
1054 CSET (Grid, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
1056 /* %start-doc options "5 Sizes"
1057 @ftable @code
1058 @item --minimum polygon area <num>
1059 Minimum polygon area.
1060 @end ftable
1061 %end-doc
1063 RSET (IsleArea, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
1066 /* %start-doc options "1 General Options"
1067 @ftable @code
1068 @item --backup-interval
1069 Time between automatic backups in seconds. Set to @code{0} to disable.
1070 The default value is @code{60}.
1071 @end ftable
1072 %end-doc
1074 ISET (BackupInterval, 60, "backup-interval",
1075 "Time between automatic backups in seconds. Set to 0 to disable"),
1077 /* %start-doc options "4 Layer Names"
1078 @ftable @code
1079 @item --layer-name-1 <string>
1080 Name of the 1st Layer. Default is @code{"top"}.
1081 @end ftable
1082 %end-doc
1084 LAYERNAME (1, "top"),
1086 /* %start-doc options "4 Layer Names"
1087 @ftable @code
1088 @item --layer-name-2 <string>
1089 Name of the 2nd Layer. Default is @code{"ground"}.
1090 @end ftable
1091 %end-doc
1093 LAYERNAME (2, "ground"),
1095 /* %start-doc options "4 Layer Names"
1096 @ftable @code
1097 @item --layer-name-3 <string>
1098 Name of the 3nd Layer. Default is @code{"signal2"}.
1099 @end ftable
1100 %end-doc
1102 LAYERNAME (3, "signal2"),
1104 /* %start-doc options "4 Layer Names"
1105 @ftable @code
1106 @item --layer-name-4 <string>
1107 Name of the 4rd Layer. Default is @code{"signal3"}.
1108 @end ftable
1109 %end-doc
1111 LAYERNAME (4, "signal3"),
1113 /* %start-doc options "4 Layer Names"
1114 @ftable @code
1115 @item --layer-name-5 <string>
1116 Name of the 5rd Layer. Default is @code{"power"}.
1117 @end ftable
1118 %end-doc
1120 LAYERNAME (5, "power"),
1122 /* %start-doc options "4 Layer Names"
1123 @ftable @code
1124 @item --layer-name-6 <string>
1125 Name of the 6rd Layer. Default is @code{"bottom"}.
1126 @end ftable
1127 %end-doc
1129 LAYERNAME (6, "bottom"),
1131 /* %start-doc options "4 Layer Names"
1132 @ftable @code
1133 @item --layer-name-7 <string>
1134 Name of the 7rd Layer. Default is @code{"outline"}.
1135 @end ftable
1136 %end-doc
1138 LAYERNAME (7, "outline"),
1140 /* %start-doc options "4 Layer Names"
1141 @ftable @code
1142 @item --layer-name-8 <string>
1143 Name of the 8rd Layer. Default is @code{"spare"}.
1144 @end ftable
1145 %end-doc
1147 LAYERNAME (8, "spare"),
1149 /* %start-doc options "1 General Options"
1150 @ftable @code
1151 @item --groups <string>
1152 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
1153 @end ftable
1154 %end-doc
1156 SSET (Groups, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
1159 /* %start-doc options "6 Commands"
1160 pcb uses external commands for input output operations. These commands can be
1161 configured at start-up to meet local requirements. The command string may include
1162 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
1163 command is called. The sequence @code{%f} is replaced by the file name,
1164 @code{%p} gets the path and @code{%a} indicates a package name.
1165 %end-doc
1168 /* %start-doc options "6 Commands"
1169 @ftable @code
1170 @item --font-command <string>
1171 Command to load a font.
1172 @end ftable
1173 %end-doc
1175 SSET (FontCommand, "", "font-command", "Command to load a font"),
1177 /* %start-doc options "6 Commands"
1178 @ftable @code
1179 @item --file-command <string>
1180 Command to read a file.
1181 @end ftable
1182 %end-doc
1184 SSET (FileCommand, "", "file-command", "Command to read a file"),
1186 /* %start-doc options "6 Commands"
1187 @ftable @code
1188 @item --element-command <string>
1189 Command to read a footprint. @*
1190 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
1191 @end ftable
1192 %end-doc
1194 SSET (ElementCommand,
1195 "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4,
1196 "element-command", "Command to read a footprint"),
1198 /* %start-doc options "6 Commands"
1199 @ftable @code
1200 @item --print-file <string>
1201 Command to print to a file.
1202 @end ftable
1203 %end-doc
1205 SSET (PrintFile, "%f.output", "print-file", "Command to print to a file"),
1207 /* %start-doc options "6 Commands"
1208 @ftable @code
1209 @item --lib-command-dir <string>
1210 Path to the command that queries the library.
1211 @end ftable
1212 %end-doc
1214 SSET (LibraryCommandDir, PCBLIBDIR, "lib-command-dir",
1215 "Path to the command that queries the library"),
1217 /* %start-doc options "6 Commands"
1218 @ftable @code
1219 @item --lib-command <string>
1220 Command to query the library. @*
1221 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
1222 @end ftable
1223 %end-doc
1225 SSET (LibraryCommand, "QueryLibrary.sh '%p' '%f' %a",
1226 "lib-command", "Command to query the library"),
1228 /* %start-doc options "6 Commands"
1229 @ftable @code
1230 @item --lib-contents-command <string>
1231 Command to query the contents of the library. @*
1232 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
1233 on Windows builds, an empty string (to disable this feature).
1234 @end ftable
1235 %end-doc
1237 SSET (LibraryContentsCommand,
1238 #ifdef __WIN32__
1240 #else
1241 "ListLibraryContents.sh '%p' '%f'",
1242 #endif
1243 "lib-contents-command", "Command to query the contents of the library"),
1245 /* %start-doc options "5 Paths"
1246 @ftable @code
1247 @item --lib-newlib <string>
1248 Top level directory for the newlib style library.
1249 @end ftable
1250 %end-doc
1252 SSET (LibraryTree, PCBTREEPATH, "lib-newlib",
1253 "Top level directory for the newlib style library"),
1255 /* %start-doc options "6 Commands"
1256 @ftable @code
1257 @item --save-command <string>
1258 Command to save to a file.
1259 @end ftable
1260 %end-doc
1262 SSET (SaveCommand, "", "save-command", "Command to save to a file"),
1264 /* %start-doc options "5 Paths"
1265 @ftable @code
1266 @item --lib-name <string>
1267 The default filename for the library.
1268 @end ftable
1269 %end-doc
1271 SSET (LibraryFilename, LIBRARYFILENAME, "lib-name",
1272 "The default filename for the library"),
1274 /* %start-doc options "5 Paths"
1275 @ftable @code
1276 @item --default-font <string>
1277 The name of the default font.
1278 @end ftable
1279 %end-doc
1281 SSET (FontFile, "default_font", "default-font",
1282 "File name of default font"),
1284 /* %start-doc options "1 General Options"
1285 @ftable @code
1286 @item --route-styles <string>
1287 A string that defines the route styles. Defaults to @*
1288 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
1289 :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
1290 @end ftable
1291 %end-doc
1293 SSET (Routes, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
1294 ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
1295 "A string that defines the route styles"),
1297 /* %start-doc options "5 Paths"
1298 @ftable @code
1299 @item --file-path <string>
1300 A colon separated list of directories or commands (starts with '|'). The path
1301 is passed to the program specified in @option{--file-command} together with the selected
1302 filename.
1303 @end ftable
1304 %end-doc
1306 SSET (FilePath, "", "file-path", 0),
1308 /* %start-doc options "6 Commands"
1309 @ftable @code
1310 @item --rat-command <string>
1311 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
1312 @end ftable
1313 %end-doc
1315 SSET (RatCommand, "", "rat-command", "Command for reading a netlist"),
1317 /* %start-doc options "5 Paths"
1318 @ftable @code
1319 @item --font-path <string>
1320 A colon separated list of directories to search the default font. Defaults to
1321 the default library path.
1322 @end ftable
1323 %end-doc
1325 SSET (FontPath, PCBLIBPATH, "font-path",
1326 "Colon separated list of directories to search the default font"),
1328 /* %start-doc options "1 General Options"
1329 @ftable @code
1330 @item --element-path <string>
1331 A colon separated list of directories or commands (starts with '|').
1332 The path is passed to the program specified in @option{--element-command}.
1333 @end ftable
1334 %end-doc
1336 SSET(ElementPath, PCBLIBPATH, "element-path",
1337 "A colon separated list of directories or commands (starts with '|')"),
1339 /* %start-doc options "5 Paths"
1340 @ftable @code
1341 @item --lib-path <string>
1342 A colon separated list of directories that will be passed to the commands specified
1343 by @option{--element-command} and @option{--element-contents-command}.
1344 @end ftable
1345 %end-doc
1347 SSET (LibraryPath, PCBLIBPATH, "lib-path",
1348 "A colon separated list of directories"),
1350 /* %start-doc options "1 General Options"
1351 @ftable @code
1352 @item --action-script <string>
1353 If set, this file is executed at startup.
1354 @end ftable
1355 %end-doc
1357 SSET (ScriptFilename, 0, "action-script",
1358 "If set, this file is executed at startup"),
1360 /* %start-doc options "1 General Options"
1361 @ftable @code
1362 @item --action-string <string>
1363 If set, this string of actions is executed at startup.
1364 @end ftable
1365 %end-doc
1367 SSET (ActionString, 0, "action-string",
1368 "If set, this is executed at startup"),
1370 /* %start-doc options "1 General Options"
1371 @ftable @code
1372 @item --fab-author <string>
1373 Name of author to be put in the Gerber files.
1374 @end ftable
1375 %end-doc
1377 SSET (FabAuthor, "", "fab-author",
1378 "Name of author to be put in the Gerber files"),
1380 /* %start-doc options "1 General Options"
1381 @ftable @code
1382 @item --layer-stack <string>
1383 Initial layer stackup, for setting up an export. A comma separated list of layer
1384 names, layer numbers and layer groups.
1385 @end ftable
1386 %end-doc
1388 SSET (InitialLayerStack, "", "layer-stack",
1389 "Initial layer stackup, for setting up an export."),
1391 SSET (MakeProgram, NULL, "make-program",
1392 "Sets the name and optionally full path to a make(3) program"),
1393 SSET (GnetlistProgram, NULL, "gnetlist",
1394 "Sets the name and optionally full path to the gnetlist(3) program"),
1396 /* %start-doc options "2 General GUI Options"
1397 @ftable @code
1398 @item --pinout-offset-x <num>
1399 Horizontal offset of the pin number display. Defaults to @code{100mil}.
1400 @end ftable
1401 %end-doc
1403 CSET (PinoutOffsetX, MIL_TO_COORD(1), "pinout-offset-x",
1404 "Horizontal offset of the pin number display in mil"),
1406 /* %start-doc options "2 General GUI Options"
1407 @ftable @code
1408 @item --pinout-offset-y <num>
1409 Vertical offset of the pin number display. Defaults to @code{100mil}.
1410 @end ftable
1411 %end-doc
1413 CSET (PinoutOffsetY, MIL_TO_COORD(1), "pinout-offset-y",
1414 "Vertical offset of the pin number display in mil"),
1416 /* %start-doc options "2 General GUI Options"
1417 @ftable @code
1418 @item --pinout-text-offset-x <num>
1419 Horizontal offset of the pin name display. Defaults to @code{800mil}.
1420 @end ftable
1421 %end-doc
1423 CSET (PinoutTextOffsetX, MIL_TO_COORD(8), "pinout-text-offset-x",
1424 "Horizontal offset of the pin name display in mil"),
1426 /* %start-doc options "2 General GUI Options"
1427 @ftable @code
1428 @item --pinout-text-offset-y <num>
1429 Vertical offset of the pin name display. Defaults to @code{-100mil}.
1430 @end ftable
1431 %end-doc
1433 CSET (PinoutTextOffsetY, MIL_TO_COORD(-1), "pinout-text-offset-y",
1434 "Vertical offset of the pin name display in mil"),
1436 /* %start-doc options "2 General GUI Options"
1437 @ftable @code
1438 @item --draw-grid
1439 If set, draw the grid at start-up.
1440 @end ftable
1441 %end-doc
1443 BSET (DrawGrid, 0, "draw-grid", "If set, draw the grid at start-up"),
1445 /* %start-doc options "2 General GUI Options"
1446 @ftable @code
1447 @item --clear-line
1448 If set, new lines clear polygons.
1449 @end ftable
1450 %end-doc
1452 BSET (ClearLine, 1, "clear-line", "If set, new lines clear polygons"),
1454 /* %start-doc options "2 General GUI Options"
1455 @ftable @code
1456 @item --full-poly
1457 If set, new polygons are full ones.
1458 @end ftable
1459 %end-doc
1461 BSET (FullPoly, 0, "full-poly", 0),
1463 /* %start-doc options "2 General GUI Options"
1464 @ftable @code
1465 @item --unique-names
1466 If set, you will not be permitted to change the name of an component to match that
1467 of another component.
1468 @end ftable
1469 %end-doc
1471 BSET (UniqueNames, 1, "unique-names", "Prevents identical component names"),
1473 /* %start-doc options "2 General GUI Options"
1474 @ftable @code
1475 @item --snap-pin
1476 If set, pin centers and pad end points are treated as additional grid points
1477 that the cursor can snap to.
1478 @end ftable
1479 %end-doc
1481 BSET (SnapPin, 1, "snap-pin",
1482 "If set, the cursor snaps to pads and pin centers"),
1484 /* %start-doc options "1 General Options"
1485 @ftable @code
1486 @item --save-last-command
1487 If set, the last user command is saved.
1488 @end ftable
1489 %end-doc
1491 BSET (SaveLastCommand, 0, "save-last-command", 0),
1493 /* %start-doc options "1 General Options"
1494 @ftable @code
1495 @item --save-in-tmp
1496 If set, all data which would otherwise be lost are saved in a temporary file
1497 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
1498 @end ftable
1499 %end-doc
1501 BSET (SaveInTMP, 0, "save-in-tmp",
1502 "When set, all data which would otherwise be lost are saved in /tmp"),
1504 /* %start-doc options "1 General Options"
1505 @ftable @code
1506 @item --save-metric-only
1507 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
1508 @end ftable
1509 %end-doc
1511 BSET (SaveMetricOnly, 0, "save-metric-only",
1512 "If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm."),
1514 /* %start-doc options "2 General GUI Options"
1515 @ftable @code
1516 @item --all-direction-lines
1517 Allow all directions, when drawing new lines.
1518 @end ftable
1519 %end-doc
1521 BSET (AllDirectionLines, 0, "all-direction-lines",
1522 "Allow all directions, when drawing new lines"),
1524 /* %start-doc options "2 General GUI Options"
1525 @ftable @code
1526 @item --show-number
1527 Pinout shows number.
1528 @end ftable
1529 %end-doc
1531 BSET (ShowNumber, 0, "show-number", "Pinout shows number"),
1533 /* %start-doc options "1 General Options"
1534 @ftable @code
1535 @item --reset-after-element
1536 If set, all found connections are reset before a new component is scanned.
1537 @end ftable
1538 %end-doc
1540 BSET (ResetAfterElement, 1, "reset-after-element",
1541 "If set, all found connections are reset before a new component is scanned"),
1543 /* %start-doc options "1 General Options"
1544 @ftable @code
1545 @item --ring-bell-finished
1546 Execute the bell command when all rats are routed.
1547 @end ftable
1548 %end-doc
1550 BSET (RingBellWhenFinished, 0, "ring-bell-finished",
1551 "Execute the bell command when all rats are routed"),
1554 REGISTER_ATTRIBUTES (main_attribute_list)
1555 /* ----------------------------------------------------------------------
1556 * post-process settings.
1558 static void settings_post_process ()
1560 char *tmps;
1562 if (Settings.LibraryCommand != NULL &&
1563 Settings.LibraryCommand[0] != '\0' &&
1564 Settings.LibraryCommand[0] != PCB_DIR_SEPARATOR_C &&
1565 Settings.LibraryCommand[0] != '.')
1567 Settings.LibraryCommand
1569 Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S,
1570 Settings.LibraryCommand,
1571 NULL);
1573 if (Settings.LibraryContentsCommand != NULL &&
1574 Settings.LibraryContentsCommand[0] != '\0' &&
1575 Settings.LibraryContentsCommand[0] != PCB_DIR_SEPARATOR_C &&
1576 Settings.LibraryContentsCommand[0] != '.')
1578 Settings.LibraryContentsCommand
1580 Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S,
1581 Settings.LibraryContentsCommand, NULL);
1584 if (Settings.LineThickness > MAX_LINESIZE
1585 || Settings.LineThickness < MIN_LINESIZE)
1586 Settings.LineThickness = MIL_TO_COORD(10);
1588 if (Settings.ViaThickness > MAX_PINORVIASIZE
1589 || Settings.ViaThickness < MIN_PINORVIASIZE)
1590 Settings.ViaThickness = MIL_TO_COORD(40);
1592 if (Settings.ViaDrillingHole <= 0)
1593 Settings.ViaDrillingHole =
1594 DEFAULT_DRILLINGHOLE * Settings.ViaThickness / 100;
1596 Settings.MaxWidth = CLAMP (Settings.MaxWidth, MIN_SIZE, MAX_COORD);
1597 Settings.MaxHeight = CLAMP (Settings.MaxHeight, MIN_SIZE, MAX_COORD);
1599 ParseRouteString (Settings.Routes, &Settings.RouteStyle[0], "cmil");
1602 * Make sure we have settings for some various programs we may wish
1603 * to call
1605 if (Settings.MakeProgram == NULL) {
1606 tmps = getenv ("PCB_MAKE_PROGRAM");
1607 if (tmps != NULL)
1608 Settings.MakeProgram = strdup (tmps);
1610 if (Settings.MakeProgram == NULL) {
1611 Settings.MakeProgram = strdup ("make");
1614 if (Settings.GnetlistProgram == NULL) {
1615 tmps = getenv ("PCB_GNETLIST");
1616 if (tmps != NULL)
1617 Settings.GnetlistProgram = strdup (tmps);
1619 if (Settings.GnetlistProgram == NULL) {
1620 Settings.GnetlistProgram = strdup ("gnetlist");
1623 if (grid_units)
1624 Settings.grid_unit = get_unit_struct (grid_units);
1625 if (!grid_units || Settings.grid_unit == NULL)
1626 Settings.grid_unit = get_unit_struct ("mil");
1628 copy_nonzero_increments (get_increments_struct (METRIC), &increment_mm);
1629 copy_nonzero_increments (get_increments_struct (IMPERIAL), &increment_mil);
1631 Settings.increments = get_increments_struct (Settings.grid_unit->family);
1635 * \brief Print help or version messages.
1637 static void
1638 print_version ()
1640 printf ("PCB version %s\n", VERSION);
1641 exit (0);
1644 /* ----------------------------------------------------------------------
1645 * Figure out the canonical name of the executed program
1646 * and fix up the defaults for various paths
1648 char *bindir = NULL;
1649 char *exec_prefix = NULL;
1650 char *pcblibdir = NULL;
1651 char *pcblibpath = NULL;
1652 char *pcbtreedir = NULL;
1653 char *pcbtreepath = NULL;
1654 char *homedir = NULL;
1657 * \brief See if argv0 has enough of a path to let lrealpath give the
1658 * real path.
1660 * This should be the case if you invoke pcb with something like
1661 * /usr/local/bin/pcb or ./pcb or ./foo/pcb but if you just use pcb and
1662 * it exists in your path, you'll just get back pcb again.
1664 static void
1665 InitPaths (char *argv0)
1667 size_t l;
1668 int i;
1669 int haspath;
1670 char *t1, *t2;
1671 int found_bindir = 0;
1673 haspath = 0;
1674 for (i = 0; i < strlen (argv0) ; i++)
1676 if (argv0[i] == PCB_DIR_SEPARATOR_C)
1677 haspath = 1;
1680 #ifdef DEBUG
1681 printf ("InitPaths (%s): haspath = %d\n", argv0, haspath);
1682 #endif
1684 if (haspath)
1686 bindir = strdup (lrealpath (argv0));
1687 found_bindir = 1;
1689 else
1691 char *path, *p, *tmps;
1692 struct stat sb;
1693 int r;
1695 tmps = getenv ("PATH");
1697 if (tmps != NULL)
1699 path = strdup (tmps);
1701 /* search through the font path for a font file */
1702 for (p = strtok (path, PCB_PATH_DELIMETER); p && *p;
1703 p = strtok (NULL, PCB_PATH_DELIMETER))
1705 #ifdef DEBUG
1706 printf ("Looking for %s in %s\n", argv0, p);
1707 #endif
1708 if ( (tmps = (char *)malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
1710 fprintf (stderr, "InitPaths(): malloc failed\n");
1711 exit (1);
1713 sprintf (tmps, "%s%s%s", p, PCB_DIR_SEPARATOR_S, argv0);
1714 r = stat (tmps, &sb);
1715 if (r == 0)
1717 #ifdef DEBUG
1718 printf ("Found it: \"%s\"\n", tmps);
1719 #endif
1720 bindir = lrealpath (tmps);
1721 found_bindir = 1;
1722 free (tmps);
1723 break;
1725 free (tmps);
1727 free (path);
1731 #ifdef DEBUG
1732 printf ("InitPaths(): bindir = \"%s\"\n", bindir);
1733 #endif
1735 if (found_bindir)
1737 /* strip off the executible name leaving only the path */
1738 t2 = NULL;
1739 t1 = strchr (bindir, PCB_DIR_SEPARATOR_C);
1740 while (t1 != NULL && *t1 != '\0')
1742 t2 = t1;
1743 t1 = strchr (t2 + 1, PCB_DIR_SEPARATOR_C);
1745 if (t2 != NULL)
1746 *t2 = '\0';
1748 #ifdef DEBUG
1749 printf ("After stripping off the executible name, we found\n");
1750 printf ("bindir = \"%s\"\n", bindir);
1751 #endif
1753 else
1755 /* we have failed to find out anything from argv[0] so fall back to the original
1756 * install prefix
1758 bindir = strdup (BINDIR);
1761 /* now find the path to exec_prefix */
1762 l = strlen (bindir) + 1 + strlen (BINDIR_TO_EXECPREFIX) + 1;
1763 if ( (exec_prefix = (char *) malloc (l * sizeof (char) )) == NULL )
1765 fprintf (stderr, "InitPaths(): malloc failed\n");
1766 exit (1);
1768 sprintf (exec_prefix, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1769 BINDIR_TO_EXECPREFIX);
1771 /* now find the path to PCBLIBDIR */
1772 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBLIBDIR) + 1;
1773 if ( (pcblibdir = (char *) malloc (l * sizeof (char) )) == NULL )
1775 fprintf (stderr, "InitPaths(): malloc failed\n");
1776 exit (1);
1778 sprintf (pcblibdir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1779 BINDIR_TO_PCBLIBDIR);
1781 /* and the path to PCBTREEDIR */
1782 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBTREEDIR) + 1;
1783 if ( (pcbtreedir = (char *) malloc (l * sizeof (char) )) == NULL )
1785 fprintf (stderr, "InitPaths(): malloc failed\n");
1786 exit (1);
1788 sprintf (pcbtreedir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S,
1789 BINDIR_TO_PCBTREEDIR);
1791 /* and the search path including PCBLIBDIR */
1792 l = strlen (pcblibdir) + 3;
1793 if ( (pcblibpath = (char *) malloc (l * sizeof (char) )) == NULL )
1795 fprintf (stderr, "InitPaths(): malloc failed\n");
1796 exit (1);
1798 sprintf (pcblibpath, ".%s%s", PCB_PATH_DELIMETER, pcblibdir);
1800 /* and the newlib search path */
1801 l = strlen (pcblibdir) + 1 + strlen (pcbtreedir)
1802 + strlen ("pcblib-newlib") + 2;
1803 if ( (pcbtreepath = (char *) malloc (l * sizeof (char) )) == NULL )
1805 fprintf (stderr, "InitPaths(): malloc failed\n");
1806 exit (1);
1808 sprintf (pcbtreepath, "%s%s%s%spcblib-newlib", pcbtreedir,
1809 PCB_PATH_DELIMETER, pcblibdir,
1810 PCB_DIR_SEPARATOR_S);
1812 #ifdef DEBUG
1813 printf ("bindir = %s\n", bindir);
1814 printf ("pcblibdir = %s\n", pcblibdir);
1815 printf ("pcblibpath = %s\n", pcblibpath);
1816 printf ("pcbtreedir = %s\n", pcbtreedir);
1817 printf ("pcbtreepath = %s\n", pcbtreepath);
1818 #endif
1820 l = sizeof (main_attribute_list) / sizeof (main_attribute_list[0]);
1821 for (i = 0; i < l ; i++)
1823 if (NSTRCMP (main_attribute_list[i].name, "lib-command-dir") == 0)
1825 main_attribute_list[i].default_val.str_value = pcblibdir;
1828 if ( (NSTRCMP (main_attribute_list[i].name, "font-path") == 0)
1829 || (NSTRCMP (main_attribute_list[i].name, "element-path") == 0)
1830 || (NSTRCMP (main_attribute_list[i].name, "lib-path") == 0) )
1832 main_attribute_list[i].default_val.str_value = pcblibpath;
1835 if (NSTRCMP (main_attribute_list[i].name, "lib-newlib") == 0)
1837 main_attribute_list[i].default_val.str_value = pcbtreepath;
1843 char *tmps;
1845 tmps = getenv ("HOME");
1847 if (tmps == NULL) {
1848 tmps = getenv ("USERPROFILE");
1851 if (tmps != NULL) {
1852 homedir = strdup (tmps);
1853 } else {
1854 homedir = NULL;
1860 /* ----------------------------------------------------------------------
1861 * main program
1864 char *program_name = 0;
1865 char *program_basename = 0;
1866 char *program_directory = 0;
1868 #include "dolists.h"
1871 * \brief Main program.
1873 * Init application:
1875 * - make program name available for error handlers
1876 * - evaluate special options
1877 * - initialize toplevel shell and resources
1878 * - create an empty PCB with default symbols
1879 * - initialize all other widgets
1880 * - update screen and get size of drawing area
1881 * - evaluate command-line arguments
1882 * - register 'call on exit()' function
1885 main (int argc, char *argv[])
1887 int i;
1889 #include "core_lists.h"
1890 setbuf (stdout, 0);
1891 InitPaths (argv[0]);
1893 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
1894 textdomain (GETTEXT_PACKAGE);
1895 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1897 #ifdef ENABLE_NLS
1898 setlocale (LC_ALL, "");
1899 setlocale (LC_NUMERIC, "C");
1900 #endif
1902 srand ( time(NULL) ); /* Set seed for rand() */
1904 initialize_units();
1905 polygon_init ();
1906 hid_init ();
1908 hid_load_settings ();
1910 program_name = argv[0];
1911 program_basename = strrchr (program_name, PCB_DIR_SEPARATOR_C);
1912 if (program_basename)
1914 program_directory = strdup (program_name);
1915 *strrchr (program_directory, PCB_DIR_SEPARATOR_C) = 0;
1916 program_basename++;
1918 else
1920 program_directory = ".";
1921 program_basename = program_name;
1923 Progname = program_basename;
1925 /* Print usage or version if requested. Then exit. */
1926 if (argc > 1 &&
1927 (strcmp (argv[1], "-h") == 0 ||
1928 strcmp (argv[1], "-?") == 0 ||
1929 strcmp (argv[1], "--help") == 0))
1930 usage ();
1931 if (argc > 1 && strcmp (argv[1], "-V") == 0)
1932 print_version ();
1933 /* Export pcb from command line if requested. */
1934 if (argc > 1 && strcmp (argv[1], "-p") == 0)
1936 exporter = gui = hid_find_printer ();
1937 argc--;
1938 argv++;
1940 else if (argc > 2 && strcmp (argv[1], "-x") == 0)
1942 exporter = gui = hid_find_exporter (argv[2]);
1943 argc -= 2;
1944 argv += 2;
1946 /* Otherwise start GUI. */
1947 else
1948 gui = hid_find_gui ();
1950 /* Exit with error if GUI failed to start. */
1951 if (!gui)
1952 exit (1);
1954 /* Set up layers. */
1955 for (i = 0; i < MAX_LAYER; i++)
1957 char buf[20];
1958 sprintf (buf, "signal%d", i + 1);
1959 Settings.DefaultLayerName[i] = strdup (buf);
1960 Settings.LayerColor[i] = "#c49350";
1961 Settings.LayerSelectedColor[i] = "#00ffff";
1964 gui->parse_arguments (&argc, &argv);
1966 if (show_help || (argc > 1 && argv[1][0] == '-'))
1967 usage ();
1968 if (show_version)
1969 print_version ();
1970 if (show_defaults)
1971 print_defaults ();
1972 if (show_copyright)
1973 copyright ();
1975 settings_post_process ();
1978 if (show_actions)
1980 print_actions ();
1981 exit (0);
1984 if (do_dump_actions)
1986 extern void dump_actions (void);
1987 dump_actions ();
1988 exit (0);
1991 /* Create a new PCB object in memory */
1992 PCB = CreateNewPCB ();
1993 ParseGroupString (Settings.Groups, &PCB->LayerGroups, &PCB->Data->LayerN);
1994 /* Add silk layers to newly created PCB */
1995 CreateNewPCBPost (PCB, 1);
1996 if (argc > 1)
1997 command_line_pcb = argv[1];
1999 ResetStackAndVisibility ();
2001 if (gui->gui)
2002 InitCrosshair ();
2003 InitHandler ();
2004 InitBuffers ();
2005 SetMode (ARROW_MODE);
2007 if (command_line_pcb)
2009 /* keep filename even if initial load command failed;
2010 * file might not exist
2012 if (LoadPCB (command_line_pcb))
2013 PCB->Filename = strdup (command_line_pcb);
2016 if (Settings.InitialLayerStack
2017 && Settings.InitialLayerStack[0])
2019 LayerStringToLayerStack (Settings.InitialLayerStack);
2022 /* This must be called before any other atexit functions
2023 * are registered, as it configures an atexit function to
2024 * clean up and free various items of allocated memory,
2025 * and must be the last last atexit function to run.
2027 leaky_init ();
2029 /* Register a function to be called when the program terminates.
2030 * This makes sure that data is saved even if LEX/YACC routines
2031 * abort the program.
2032 * If the OS doesn't have at least one of them,
2033 * the critical sections will be handled by parse_l.l
2035 atexit (EmergencySave);
2037 /* read the library file and display it if it's not empty
2039 if (!ReadLibraryContents () && Library.MenuN)
2040 hid_action ("LibraryChanged");
2042 #ifdef HAVE_LIBSTROKE
2043 stroke_init ();
2044 #endif
2046 if (Settings.ScriptFilename)
2048 Message (_("Executing startup script file %s\n"),
2049 Settings.ScriptFilename);
2050 hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
2052 if (Settings.ActionString)
2054 Message (_("Executing startup action %s\n"), Settings.ActionString);
2055 hid_parse_actions (Settings.ActionString);
2058 if (gui->printer || gui->exporter)
2060 gui->do_export (0);
2061 exit (0);
2064 #if HAVE_DBUS
2065 pcb_dbus_setup();
2066 #endif
2068 EnableAutosave ();
2070 #ifdef DEBUG
2071 printf ("Settings.LibraryCommandDir = \"%s\"\n",
2072 Settings.LibraryCommandDir);
2073 printf ("Settings.FontPath = \"%s\"\n",
2074 Settings.FontPath);
2075 printf ("Settings.ElementPath = \"%s\"\n",
2076 Settings.ElementPath);
2077 printf ("Settings.LibraryPath = \"%s\"\n",
2078 Settings.LibraryPath);
2079 printf ("Settings.LibraryTree = \"%s\"\n",
2080 Settings.LibraryTree);
2081 printf ("Settings.MakeProgram = \"%s\"\n",
2082 UNKNOWN (Settings.MakeProgram));
2083 printf ("Settings.GnetlistProgram = \"%s\"\n",
2084 UNKNOWN (Settings.GnetlistProgram));
2085 #endif
2087 gui->do_export (0);
2088 #if HAVE_DBUS
2089 pcb_dbus_finish();
2090 #endif
2092 return (0);