pcb 4.1.1
An interactive printed circuit board layout editor.

main.c

Go to the documentation of this file.
00001 
00034 #ifdef HAVE_CONFIG_H
00035 #include "config.h"
00036 #endif
00037 
00038 #include <stdlib.h>
00039 #ifdef HAVE_STRING_H
00040 #include <string.h>
00041 #endif
00042 
00043 #if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
00044 #include <locale.h>
00045 #endif
00046 
00047 #include <signal.h>
00048 #include <unistd.h>
00049 #include <sys/stat.h>
00050 #include <time.h> /* Seed for srand() */
00051 
00052 #include "global.h"
00053 #include "data.h"
00054 #include "buffer.h"
00055 #include "create.h"
00056 #include "crosshair.h"
00057 #include "draw.h"
00058 #include "error.h"
00059 #include "file.h"
00060 #include "set.h"
00061 #include "action.h"
00062 #include "misc.h"
00063 #include "lrealpath.h"
00064 #include "free_atexit.h"
00065 #include "polygon.h"
00066 #include "gettext.h"
00067 #include "pcb-printf.h"
00068 #include "strflags.h"
00069 
00070 #include "hid/common/actions.h"
00071 
00072 /* This next one is so we can print the help messages. */
00073 #include "hid/hidint.h"
00074 
00075 #ifdef HAVE_DBUS
00076 #include "dbus.h"
00077 #endif
00078 
00079 #ifdef HAVE_LIBDMALLOC
00080 #include <dmalloc.h>
00081 #endif
00082 
00083 #define PCBLIBPATH ".:" PCBLIBDIR
00084 
00085 
00086 #ifdef HAVE_LIBSTROKE
00087 extern void stroke_init (void);
00088 #endif
00089 
00090 
00094 static void
00095 InitHandler (void)
00096 {
00097 /*
00098         signal(SIGHUP, CatchSignal);
00099         signal(SIGQUIT, CatchSignal);
00100         signal(SIGABRT, CatchSignal);
00101         signal(SIGSEGV, CatchSignal);
00102         signal(SIGTERM, CatchSignal);
00103         signal(SIGINT, CatchSignal);
00104 */
00105 
00106   /* calling external program by popen() may cause a PIPE signal,
00107    * so we ignore it
00108    */
00109 #ifdef SIGPIPE
00110   signal (SIGPIPE, SIG_IGN);
00111 #endif
00112 }
00113 
00114 
00115   /* ----------------------------------------------------------------------
00116      |  command line and rc file processing.
00117    */
00118 static char *command_line_pcb;
00119 
00123 void
00124 copyright (void)
00125 {
00126   printf ("\n"
00127           "                COPYRIGHT for %s version %s\n\n"
00128           "    PCB, interactive printed circuit board design\n"
00129           "    Copyright (C) 1994,1995,1996,1997 Thomas Nau\n"
00130           "    Copyright (C) 1998, 1999, 2000 Harry Eaton\n\n"
00131           "    This program is free software; you can redistribute it and/or modify\n"
00132           "    it under the terms of the GNU General Public License as published by\n"
00133           "    the Free Software Foundation; either version 2 of the License, or\n"
00134           "    (at your option) any later version.\n\n"
00135           "    This program is distributed in the hope that it will be useful,\n"
00136           "    but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
00137           "    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
00138           "    GNU General Public License for more details.\n\n"
00139           "    You should have received a copy of the GNU General Public License along\n"
00140           "    with this program; if not, write to the Free Software Foundation, Inc.,\n"
00141           "    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\n",
00142           Progname, VERSION);
00143   exit (0);
00144 }
00145 
00146 static inline void
00147 u (const char *fmt, ...)
00148 {
00149   va_list ap;
00150   va_start (ap, fmt);
00151   vfprintf (stderr, fmt, ap);
00152   fputc ('\n', stderr);
00153   va_end (ap);
00154 }
00155 
00156 typedef struct UsageNotes {
00157   struct UsageNotes *next;
00158   HID_Attribute *seen;
00159 } UsageNotes;
00160 
00161 static UsageNotes *usage_notes = NULL;
00162 
00163 static void
00164 usage_attr (HID_Attribute * a)
00165 {
00166   int i, n;
00167   const Unit *unit_list;
00168   static char buf[200];
00169 
00170   if (a->help_text == ATTR_UNDOCUMENTED)
00171     return;
00172 
00173   switch (a->type)
00174     {
00175     case HID_Label:
00176       return;
00177     case HID_Integer:
00178     case HID_Real:
00179       sprintf (buf, "--%s <num>", a->name);
00180       break;
00181     case HID_Coord:
00182       sprintf (buf, "--%s <measure>", a->name);
00183       break;
00184     case HID_String:
00185       sprintf (buf, "--%s <string>", a->name);
00186       break;
00187     case HID_Boolean:
00188       sprintf (buf, "--%s", a->name);
00189       break;
00190     case HID_Mixed:
00191     case HID_Enum:
00192       sprintf (buf, "--%s ", a->name);
00193       if (a->type == HID_Mixed)
00194         strcat (buf, " <val>");
00195       for (i = 0; a->enumerations[i]; i++)
00196         {
00197           strcat (buf, i ? "|" : "<");
00198           strcat (buf, a->enumerations[i]);
00199         }
00200       strcat (buf, ">");
00201       break;
00202     case HID_Path:
00203       sprintf (buf, "--%s <path>", a->name);
00204       break;
00205     case HID_Unit:
00206       unit_list = get_unit_list ();
00207       n = get_n_units ();
00208       sprintf (buf, "--%s ", a->name);
00209       for (i = 0; i < n; i++)
00210         {
00211           strcat (buf, i ? "|" : "<");
00212           strcat (buf, unit_list[i].suffix);
00213         }
00214       strcat (buf, ">");
00215       break;
00216     }
00217 
00218   if (strlen (buf) <= 30)
00219     {
00220       if (a->help_text)
00221         fprintf (stderr, " %-30s\t%s\n", buf, a->help_text);
00222       else
00223         fprintf (stderr, " %-30s\n", buf);
00224     }
00225   else if (a->help_text && strlen (a->help_text) + strlen (buf) < 72)
00226     fprintf (stderr, " %s\t%s\n", buf, a->help_text);
00227   else if (a->help_text)
00228     fprintf (stderr, " %s\n\t\t\t%s\n", buf, a->help_text);
00229   else
00230     fprintf (stderr, " %s\n", buf);
00231 }
00232 
00233 static void
00234 usage_hid (HID * h)
00235 {
00236   HID_Attribute *attributes;
00237   int i, n_attributes = 0;
00238   UsageNotes *note;
00239 
00240   if (h->gui)
00241     {
00242       fprintf (stderr, "\n%s gui options:\n", h->name);
00243       attributes = h->get_export_options (&n_attributes);
00244     }
00245   else
00246     {
00247       fprintf (stderr, "\n%s options:\n", h->name);
00248       exporter = h;
00249       attributes = exporter->get_export_options (&n_attributes);
00250       exporter = NULL;
00251     }
00252 
00253   note = (UsageNotes *)malloc (sizeof (UsageNotes));
00254   note->next = usage_notes;
00255   note->seen = attributes;
00256   usage_notes = note;
00257   
00258   for (i = 0; i < n_attributes; i++)
00259     usage_attr (attributes + i);
00260 }
00261 
00262 static void
00263 usage (void)
00264 {
00265   HID **hl = hid_enumerate ();
00266   HID_AttrNode *ha;
00267   UsageNotes *note;
00268   int i;
00269   int n_printer = 0, n_gui = 0, n_exporter = 0;
00270 
00271   for (i = 0; hl[i]; i++)
00272     {
00273       if (hl[i]->gui)
00274         n_gui++;
00275       if (hl[i]->printer)
00276         n_printer++;
00277       if (hl[i]->exporter)
00278         n_exporter++;
00279     }
00280 
00281   u ("PCB Printed Circuit Board editing program, http://pcb.geda-project.org");
00282   u ("%s [-h|-V|--copyright]\t\t\tHelp, version, copyright", Progname);
00283   u ("%s [gui options] <pcb file>\t\tto edit", Progname);
00284   u ("Available GUI hid%s:", n_gui == 1 ? "" : "s");
00285   for (i = 0; hl[i]; i++)
00286     if (hl[i]->gui)
00287       fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
00288   u ("%s -p [printing options] <pcb file>\tto print", Progname);
00289   u ("Available printing hid%s:", n_printer == 1 ? "" : "s");
00290   for (i = 0; hl[i]; i++)
00291     if (hl[i]->printer)
00292       fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
00293   u ("%s -x hid [export options] <pcb file>\tto export", Progname);
00294   u ("Available export hid%s:", n_exporter == 1 ? "" : "s");
00295   for (i = 0; hl[i]; i++)
00296     if (hl[i]->exporter)
00297       fprintf (stderr, "\t%-8s %s\n", hl[i]->name, hl[i]->description);
00298 
00299   for (i = 0; hl[i]; i++)
00300     if (hl[i]->gui)
00301       usage_hid (hl[i]);
00302   for (i = 0; hl[i]; i++)
00303     if (hl[i]->printer)
00304       usage_hid (hl[i]);
00305   for (i = 0; hl[i]; i++)
00306     if (hl[i]->exporter)
00307       usage_hid (hl[i]);
00308 
00309   u ("\nCommon options:");
00310   for (ha = hid_attr_nodes; ha; ha = ha->next)
00311     {
00312       for (note = usage_notes; note && note->seen != ha->attributes; note = note->next)
00313         ;
00314       if (note)
00315         continue;
00316       for (i = 0; i < ha->n; i++)
00317         {
00318           usage_attr (ha->attributes + i);
00319         }
00320     }  
00321 
00322   exit (1);
00323 }
00324 
00325 static void
00326 print_defaults_1 (HID_Attribute * a, void *value)
00327 {
00328   int i;
00329   Coord c;
00330   double d;
00331   const char *s;
00332 
00333   /* Remember, at this point we've parsed the command line, so they
00334      may be in the global variable instead of the default_val.  */
00335   switch (a->type)
00336     {
00337     case HID_Integer:
00338       i = value ? *(int *) value : a->default_val.int_value;
00339       fprintf (stderr, "%s %d\n", a->name, i);
00340       break;
00341     case HID_Boolean:
00342       i = value ? *(char *) value : a->default_val.int_value;
00343       fprintf (stderr, "%s %s\n", a->name, i ? "yes" : "no");
00344       break;
00345     case HID_Real:
00346       d = value ? *(double *) value : a->default_val.real_value;
00347       fprintf (stderr, "%s %g\n", a->name, d);
00348       break;
00349     case HID_Coord:
00350       c = value ? *(Coord *) value : a->default_val.coord_value;
00351       pcb_fprintf (stderr, "%s %$mS\n", a->name, c);
00352       break;
00353     case HID_String:
00354     case HID_Path:
00355       s = value ? *(char **) value : a->default_val.str_value;
00356       fprintf (stderr, "%s \"%s\"\n", a->name, s);
00357       break;
00358     case HID_Enum:
00359       i = value ? *(int *) value : a->default_val.int_value;
00360       fprintf (stderr, "%s %s\n", a->name, a->enumerations[i]);
00361       break;
00362     case HID_Mixed:
00363       i = value ?
00364         ((HID_Attr_Val*)value)->int_value  : a->default_val.int_value;
00365       d = value ?
00366         ((HID_Attr_Val*)value)->real_value : a->default_val.real_value;
00367       fprintf (stderr, "%s %g%s\n", a->name, d, a->enumerations[i]);
00368       break;
00369     case HID_Label:
00370       break;
00371     case HID_Unit:
00372       i = value ? *(int *) value : a->default_val.int_value;
00373       fprintf (stderr, "%s %s\n", a->name, get_unit_list()[i].suffix);
00374     }
00375 }
00376 
00377 static void
00378 print_defaults ()
00379 {
00380   HID **hl = hid_enumerate ();
00381   HID_Attribute *e;
00382   int i, n, hi;
00383 
00384   for (hi = 0; hl[hi]; hi++)
00385     {
00386       HID *h = hl[hi];
00387       if (h->gui)
00388         {
00389           HID_AttrNode *ha;
00390           fprintf (stderr, "\ngui defaults:\n");
00391           for (ha = hid_attr_nodes; ha; ha = ha->next)
00392             for (i = 0; i < ha->n; i++)
00393               print_defaults_1 (ha->attributes + i, ha->attributes[i].value);
00394         }
00395       else
00396         {
00397           fprintf (stderr, "\n%s defaults:\n", h->name);
00398           exporter = h;
00399           e = exporter->get_export_options (&n);
00400           exporter = NULL;
00401           if (e)
00402             for (i = 0; i < n; i++)
00403               print_defaults_1 (e + i, 0);
00404         }
00405     }
00406   exit (1);
00407 }
00408 
00409 #define SSET(F,D,N,H) { N, H, \
00410         HID_String,  0, 0, { 0, D, 0 }, 0, &Settings.F }
00411 #define ISET(F,D,N,H) { N, H, \
00412         HID_Integer, 0, 0, { D, 0, 0 }, 0, &Settings.F }
00413 #define BSET(F,D,N,H) { N, H, \
00414         HID_Boolean, 0, 0, { D, 0, 0 }, 0, &Settings.F }
00415 #define RSET(F,D,N,H) { N, H, \
00416         HID_Real,    0, 0, { 0, 0, D }, 0, &Settings.F }
00417 #define CSET(F,D,N,H) { N, H, \
00418         HID_Coord,    0, 0, { 0, 0, 0, D }, 0, &Settings.F }
00419 
00420 #define COLOR(F,D,N,H) { N, H, \
00421         HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.F }
00422 #define LAYERCOLOR(N,D) { "layer-color-" #N, "Color for layer " #N, \
00423         HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.LayerColor[N-1] }
00424 #define LAYERNAME(N,D) { "layer-name-" #N, "Name for layer " #N, \
00425         HID_String, 0, 0, { 0, D, 0 }, 0, &Settings.DefaultLayerName[N-1] }
00426 #define LAYERSELCOLOR(N) { "layer-selected-color-" #N, "Color for layer " #N " when selected", \
00427         HID_String, 0, 0, { 0, "#00ffff", 0 }, 0, &Settings.LayerSelectedColor[N-1] }
00428 
00429 static int show_help = 0;
00430 static int show_version = 0;
00431 static int show_copyright = 0;
00432 static int show_defaults = 0;
00433 static int show_actions = 0;
00434 static int do_dump_actions = 0;
00435 static char *grid_units;
00436 static Increments increment_mm  = { 0 };
00437 static Increments increment_mil = { 0 };
00438 
00439 void save_increments (const Increments *mm, const Increments *mil)
00440 {
00441   memcpy (&increment_mm,  mm,  sizeof (*mm));
00442   memcpy (&increment_mil, mil, sizeof (*mil));
00443 }
00444 
00445 HID_Attribute main_attribute_list[] = {
00446 
00447 /* %start-doc options "1 General Options"
00448 @ftable @code
00449 @item --help
00450 Show help on command line options.
00451 @end ftable
00452 %end-doc
00453 */
00454   {"help", "Show help on command line options", HID_Boolean, 0, 0, {0, 0, 0}, 0,
00455   &show_help},
00456 
00457 /* %start-doc options "1 General Options"
00458 @ftable @code
00459 @item --version
00460 Show version.
00461 @end ftable
00462 %end-doc
00463 */
00464   {"version", "Show version", HID_Boolean, 0, 0, {0, 0, 0}, 0, &show_version},
00465 
00466 /* %start-doc options "1 General Options"
00467 @ftable @code
00468 @item --verbose
00469 Be verbose on stdout.
00470 @end ftable
00471 %end-doc
00472 */
00473   {"verbose", "Be verbose on stdout", HID_Boolean, 0, 0, {0, 0, 0}, 0,
00474    &Settings.verbose},
00475 
00476 /* %start-doc options "1 General Options"
00477 @ftable @code
00478 @item --copyright
00479 Show copyright.
00480 @end ftable
00481 %end-doc
00482 */
00483   {"copyright", "Show Copyright", HID_Boolean, 0, 0, {0, 0, 0}, 0,
00484    &show_copyright},
00485 
00486 /* %start-doc options "1 General Options"
00487 @ftable @code
00488 @item --show-defaults
00489 Show option defaults.
00490 @end ftable
00491 %end-doc
00492 */
00493   {"show-defaults", "Show option defaults", HID_Boolean, 0, 0, {0, 0, 0}, 0,
00494    &show_defaults},
00495 
00496 /* %start-doc options "1 General Options"
00497 @ftable @code
00498 @item --show-actions
00499 Show available actions and exit.
00500 @end ftable
00501 %end-doc
00502 */
00503   {"show-actions", "Show available actions", HID_Boolean, 0, 0, {0, 0, 0}, 0,
00504    &show_actions},
00505 
00506 /* %start-doc options "1 General Options"
00507 @ftable @code
00508 @item --dump-actions
00509 Dump actions (for documentation).
00510 @end ftable
00511 %end-doc
00512 */
00513   {"dump-actions", "Dump actions (for documentation)", HID_Boolean, 0, 0,
00514    {0, 0, 0}, 0, &do_dump_actions},
00515 
00516 /* %start-doc options "1 General Options"
00517 @ftable @code
00518 @item --grid-units-mm <string>
00519 Set default grid units. Can be mm or mil. Defaults to mil.
00520 @end ftable
00521 %end-doc
00522 */
00523   {"grid-units", "Default grid units (mm|mil)", HID_String, 0, 0, {0, "mil", 0},
00524   0, &grid_units},
00525 
00526 /* %start-doc options "1 General Options"
00527 @ftable @code
00528 @item --clear-increment-mm <string>
00529 Set default clear increment (amount to change when user presses k or K)
00530 when user is using a metric grid unit.
00531 @end ftable
00532 %end-doc
00533 */
00534   {"clear-increment-mm", "Default clear increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
00535   0, &increment_mm.clear},
00536 
00537 /* %start-doc options "1 General Options"
00538 @ftable @code
00539 @item --grid-increment-mm <string>
00540 Set default grid increment (amount to change when user presses g or G)
00541 when user is using a metric grid unit.
00542 @end ftable
00543 %end-doc
00544 */
00545   {"grid-increment-mm", "Default grid increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
00546   0, &increment_mm.grid},
00547 
00548 /* %start-doc options "1 General Options"
00549 @ftable @code
00550 @item --line-increment-mm <string>
00551 Set default line increment (amount to change when user presses l or L)
00552 when user is using a metric grid unit.
00553 @end ftable
00554 %end-doc
00555 */
00556   {"line-increment-mm", "Default line increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
00557   0, &increment_mm.line},
00558 
00559 /* %start-doc options "1 General Options"
00560 @ftable @code
00561 @item --size-increment-mm <string>
00562 Set default size increment (amount to change when user presses s or S)
00563 when user is using a metric grid unit.
00564 @end ftable
00565 %end-doc
00566 */
00567   {"size-increment-mm", "Default size increment amount (metric)", HID_Coord, 0, 0, {0, 0, 0},
00568   0, &increment_mm.size},
00569 
00570 /* %start-doc options "1 General Options"
00571 @ftable @code
00572 @item --clear-increment-mil <string>
00573 Set default clear increment (amount to change when user presses k or K)
00574 when user is using an imperial grid unit.
00575 @end ftable
00576 %end-doc
00577 */
00578   {"clear-increment-mil", "Default clear increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
00579   0, &increment_mil.clear},
00580 
00581 /* %start-doc options "1 General Options"
00582 @ftable @code
00583 @item --grid-increment-mil <string>
00584 Set default grid increment (amount to change when user presses g or G)
00585 when user is using a imperial grid unit.
00586 @end ftable
00587 %end-doc
00588 */
00589   {"grid-increment-mil", "Default grid increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
00590   0, &increment_mil.grid},
00591 
00592 /* %start-doc options "1 General Options"
00593 @ftable @code
00594 @item --line-increment-mil <string>
00595 Set default line increment (amount to change when user presses l or L)
00596 when user is using a imperial grid unit.
00597 @end ftable
00598 %end-doc
00599 */
00600   {"line-increment-mil", "Default line increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
00601   0, &increment_mil.line},
00602 
00603 /* %start-doc options "1 General Options"
00604 @ftable @code
00605 @item --size-increment-mil <string>
00606 Set default size increment (amount to change when user presses s or S)
00607 when user is using a imperial grid unit.
00608 @end ftable
00609 %end-doc
00610 */
00611   {"size-increment-mil", "Default size increment amount (imperial)", HID_Coord, 0, 0, {0, 0, 0},
00612   0, &increment_mil.size},
00613 
00614 /* %start-doc options "3 Colors"
00615 @ftable @code
00616 @item --black-color <string>
00617 Color value for black. Default: @samp{#000000}
00618 @end ftable
00619 %end-doc
00620 */
00621   COLOR (BlackColor, "#000000", "black-color", "color value of 'black'"),
00622 
00623 /* %start-doc options "3 Colors"
00624 @ftable @code
00625 @item --black-color <string>
00626 Color value for white. Default: @samp{#ffffff}
00627 @end ftable
00628 %end-doc
00629 */
00630   COLOR (WhiteColor, "#ffffff", "white-color", "color value of 'white'"),
00631 
00632 /* %start-doc options "3 Colors"
00633 @ftable @code
00634 @item --background-color <string>
00635 Background color of the canvas. Default: @samp{#e5e5e5}
00636 @end ftable
00637 %end-doc
00638 */
00639   COLOR (BackgroundColor, "#e5e5e5", "background-color",
00640          "color for background"),
00641 
00642 /* %start-doc options "3 Colors"
00643 @ftable @code
00644 @item --crosshair-color <string>
00645 Color of the crosshair. Default: @samp{#ff0000}
00646 @end ftable
00647 %end-doc
00648 */
00649   COLOR (CrosshairColor, "#ff0000", "crosshair-color",
00650          "color for the crosshair"),
00651 
00652 /* %start-doc options "3 Colors"
00653 @ftable @code
00654 @item --cross-color <string>
00655 Color of the cross. Default: @samp{#cdcd00}
00656 @end ftable
00657 %end-doc
00658 */
00659   COLOR (CrossColor, "#cdcd00", "cross-color", "color of the cross"),
00660 
00661 /* %start-doc options "3 Colors"
00662 @ftable @code
00663 @item --via-color <string>
00664 Color of vias. Default: @samp{#7f7f7f}
00665 @end ftable
00666 %end-doc
00667 */
00668   COLOR (ViaColor, "#7f7f7f", "via-color", "color of vias"),
00669 
00670 /* %start-doc options "3 Colors"
00671 @ftable @code
00672 @item --via-selected-color <string>
00673 Color of selected vias. Default: @samp{#00ffff}
00674 @end ftable
00675 %end-doc
00676 */
00677   COLOR (ViaSelectedColor, "#00ffff", "via-selected-color",
00678          "color for selected vias"),
00679 
00680 /* %start-doc options "3 Colors"
00681 @ftable @code
00682 @item --pin-color <string>
00683 Color of pins. Default: @samp{#4d4d4d}
00684 @end ftable
00685 %end-doc
00686 */
00687   COLOR (PinColor, "#4d4d4d", "pin-color", "color of pins"),
00688 
00689 /* %start-doc options "3 Colors"
00690 @ftable @code
00691 @item --pin-selected-color <string>
00692 Color of selected pins. Default: @samp{#00ffff}
00693 @end ftable
00694 %end-doc
00695 */
00696   COLOR (PinSelectedColor, "#00ffff", "pin-selected-color",
00697          "color of selected pins"),
00698 
00699 /* %start-doc options "3 Colors"
00700 @ftable @code
00701 @item --pin-name-color <string>
00702 Color of pin names and pin numbers. Default: @samp{#ff0000}
00703 @end ftable
00704 %end-doc
00705 */
00706   COLOR (PinNameColor, "#ff0000", "pin-name-color",
00707          "color for pin names and pin numbers"),
00708 
00709 /* %start-doc options "3 Colors"
00710 @ftable @code
00711 @item --element-color <string>
00712 Color of components. Default: @samp{#000000}
00713 @end ftable
00714 %end-doc
00715 */
00716   COLOR (ElementColor, "#000000", "element-color", "color of components"),
00717 
00718 /* %start-doc options "3 Colors"
00719 @ftable @code
00720 @item --rat-color <string>
00721 Color of ratlines. Default: @samp{#b8860b}
00722 @end ftable
00723 %end-doc
00724 */
00725   COLOR (RatColor, "#b8860b", "rat-color", "color of ratlines"),
00726 
00727 /* %start-doc options "3 Colors"
00728 @ftable @code
00729 @item --invisible-objects-color <string>
00730 Color of invisible objects. Default: @samp{#cccccc}
00731 @end ftable
00732 %end-doc
00733 */
00734   COLOR (InvisibleObjectsColor, "#cccccc", "invisible-objects-color",
00735          "color of invisible objects"),
00736 
00737 /* %start-doc options "3 Colors"
00738 @ftable @code
00739 @item --invisible-mark-color <string>
00740 Color of invisible marks. Default: @samp{#cccccc}
00741 @end ftable
00742 %end-doc
00743 */
00744   COLOR (InvisibleMarkColor, "#cccccc", "invisible-mark-color",
00745          "color of invisible marks"),
00746 
00747 /* %start-doc options "3 Colors"
00748 @ftable @code
00749 @item --element-selected-color <string>
00750 Color of selected components. Default: @samp{#00ffff}
00751 @end ftable
00752 %end-doc
00753 */
00754   COLOR (ElementSelectedColor, "#00ffff", "element-selected-color",
00755          "color of selected components"),
00756 
00757 /* %start-doc options "3 Colors"
00758 @ftable @code
00759 @item --rat-selected-color <string>
00760 Color of selected rats. Default: @samp{#00ffff}
00761 @end ftable
00762 %end-doc
00763 */
00764   COLOR (RatSelectedColor, "#00ffff", "rat-selected-color",
00765          "color of selected rats"),
00766 
00767 /* %start-doc options "3 Colors"
00768 @ftable @code
00769 @item --connected-color <string>
00770 Color to indicate physical connections. Default: @samp{#00ff00}
00771 @end ftable
00772 %end-doc
00773 */
00774   COLOR (ConnectedColor, "#00ff00", "connected-color",
00775          "color to indicate physically connected objects"),
00776 
00777 /* %start-doc options "3 Colors"
00778 @ftable @code
00779 @item --found-color <string>
00780 Color to indicate logical connections. Default: @samp{#ff00ff}
00781 @end ftable
00782 %end-doc
00783 */
00784   COLOR (FoundColor, "#ff00ff", "found-color",
00785          "color to indicate logically connected objects"),
00786 
00787 /* %start-doc options "3 Colors"
00788 @ftable @code
00789 @item --off-limit-color <string>
00790 Color of off-canvas area. Default: @samp{#cccccc}
00791 @end ftable
00792 %end-doc
00793 */
00794   COLOR (OffLimitColor, "#cccccc", "off-limit-color",
00795          "color of off-canvas area"),
00796 
00797 /* %start-doc options "3 Colors"
00798 @ftable @code
00799 @item --grid-color <string>
00800 Color of the grid. Default: @samp{#ff0000}
00801 @end ftable
00802 %end-doc
00803 */
00804   COLOR (GridColor, "#ff0000", "grid-color", "color of the grid"),
00805 
00806 /* %start-doc options "3 Colors"
00807 @ftable @code
00808 @item --layer-color-<n> <string>
00809 Color of layer @code{<n>}, where @code{<n>} is an integer from 1 to 16.
00810 @end ftable
00811 %end-doc
00812 */
00813   LAYERCOLOR (1, "#8b2323"),
00814   LAYERCOLOR (2, "#3a5fcd"),
00815   LAYERCOLOR (3, "#104e8b"),
00816   LAYERCOLOR (4, "#cd3700"),
00817   LAYERCOLOR (5, "#548b54"),
00818   LAYERCOLOR (6, "#8b7355"),
00819   LAYERCOLOR (7, "#00868b"),
00820   LAYERCOLOR (8, "#228b22"),
00821   LAYERCOLOR (9, "#8b2323"),
00822   LAYERCOLOR (10, "#3a5fcd"),
00823   LAYERCOLOR (11, "#104e8b"),
00824   LAYERCOLOR (12, "#cd3700"),
00825   LAYERCOLOR (13, "#548b54"),
00826   LAYERCOLOR (14, "#8b7355"),
00827   LAYERCOLOR (15, "#00868b"),
00828   LAYERCOLOR (16, "#228b22"),
00829 /* %start-doc options "3 Colors"
00830 @ftable @code
00831 @item --layer-selected-color-<n> <string>
00832 Color of layer @code{<n>}, when selected. @code{<n>} is an integer from 1 to 16.
00833 @end ftable
00834 %end-doc
00835 */
00836   LAYERSELCOLOR (1),
00837   LAYERSELCOLOR (2),
00838   LAYERSELCOLOR (3),
00839   LAYERSELCOLOR (4),
00840   LAYERSELCOLOR (5),
00841   LAYERSELCOLOR (6),
00842   LAYERSELCOLOR (7),
00843   LAYERSELCOLOR (8),
00844   LAYERSELCOLOR (9),
00845   LAYERSELCOLOR (10),
00846   LAYERSELCOLOR (11),
00847   LAYERSELCOLOR (12),
00848   LAYERSELCOLOR (13),
00849   LAYERSELCOLOR (14),
00850   LAYERSELCOLOR (15),
00851   LAYERSELCOLOR (16),
00852 
00853 /* %start-doc options "3 Colors"
00854 @ftable @code
00855 @item --warn-color <string>
00856 Color of offending objects during DRC. Default value is @code{"#ff8000"}
00857 @end ftable
00858 %end-doc
00859 */
00860   COLOR (WarnColor, "#ff8000", "warn-color", "color of offending objects during DRC"),
00861 
00862 /* %start-doc options "3 Colors"
00863 @ftable @code
00864 @item --mask-color <string>
00865 Color of the mask layer. Default value is @code{"#ff0000"}
00866 @end ftable
00867 %end-doc
00868 */
00869   COLOR (MaskColor, "#ff0000", "mask-color", "color for solder mask"),
00870 
00871 
00872 /* %start-doc options "5 Sizes"
00873 All parameters should be given with an unit. If no unit is given, 1/100 mil
00874 (cmil) will be used. Write units without space to the
00875 number like @code{3mm}, not @code{3 mm}.
00876 Valid Units are:
00877  @table @samp
00878    @item km
00879     Kilometer
00880    @item m
00881     Meter
00882    @item cm
00883     Centimeter
00884    @item mm
00885     Millimeter
00886    @item um
00887     Micrometer
00888    @item nm
00889     Nanometer
00890    @item in
00891     Inch (1in = 0.0254m)
00892    @item mil
00893     Mil (1000mil = 1in)
00894    @item cmil
00895     Centimil (1/100 mil)
00896 @end table
00897 
00898 @ftable @code
00899 @item --via-thickness <num>
00900 Default diameter of vias. Default value is @code{60mil}.
00901 @end ftable
00902 %end-doc
00903 */
00904   CSET (ViaThickness, MIL_TO_COORD(60), "via-thickness",
00905   "default diameter of vias in 1/100 mil"),
00906 
00907 /* %start-doc options "5 Sizes"
00908 @ftable @code
00909 @item --via-drilling-hole <num>
00910 Default diameter of holes. Default value is @code{28mil}.
00911 @end ftable
00912 %end-doc
00913 */
00914   CSET (ViaDrillingHole, MIL_TO_COORD(28), "via-drilling-hole",
00915   "default diameter of holes"),
00916 
00917 /* %start-doc options "5 Sizes"
00918 @ftable @code
00919 @item --line-thickness <num>
00920 Default thickness of new lines. Default value is @code{10mil}.
00921 @end ftable
00922 %end-doc
00923 */
00924   CSET (LineThickness, MIL_TO_COORD(10), "line-thickness",
00925         "initial thickness of new lines"),
00926 
00927 /* %start-doc options "5 Sizes"
00928 @ftable @code
00929 @item --rat-thickness <num><unit>
00930 Thickness of rats. If no unit is given, PCB units are assumed (i.e. 100 
00931 means "1 nm"). This option allows for a special unit @code{px} which 
00932 sets the rat thickness to a fixed value in terms of screen pixels.
00933 Maximum fixed thickness is 100px. Minimum saling rat thickness is 101nm.  
00934 Default value is @code{10mil}.
00935 @end ftable
00936 %end-doc
00937 */
00938   CSET (RatThickness, MIL_TO_COORD(10), "rat-thickness", "thickness of rat lines"),
00939 
00940 /* %start-doc options "5 Sizes"
00941 @ftable @code
00942 @item --keepaway <num>
00943 Default minimum distance between a track and adjacent copper.
00944 Default value is @code{10mil}.
00945 @end ftable
00946 %end-doc
00947 */
00948   CSET (Keepaway, MIL_TO_COORD(10), "keepaway", "minimum distance between adjacent copper"),
00949 
00950 /* %start-doc options "5 Sizes"
00951 @ftable @code
00952 @item --default-PCB-width <num>
00953 Default width of the canvas. Default value is @code{6000mil}.
00954 @end ftable
00955 %end-doc
00956 */
00957   CSET (MaxWidth, MIL_TO_COORD(6000), "default-PCB-width",
00958   "default width of the canvas"),
00959 
00960 /* %start-doc options "5 Sizes"
00961 @ftable @code
00962 @item --default-PCB-height <num>
00963 Default height of the canvas. Default value is @code{5000mil}.
00964 @end ftable
00965 %end-doc
00966 */
00967   CSET (MaxHeight, MIL_TO_COORD(5000), "default-PCB-height",
00968   "default height of the canvas"),
00969 
00970 /* %start-doc options "5 Sizes"
00971 @ftable @code
00972 @item --text-scale <num>
00973 Default text scale. This value is in percent. Default value is @code{100}.
00974 @end ftable
00975 %end-doc
00976 */
00977   ISET (TextScale, 100, "text-scale", "default text scale in percent"),
00978 
00979 /* %start-doc options "5 Sizes"
00980 @ftable @code
00981 @item --alignment-distance <num>
00982 Specifies the distance between the board outline and alignment targets.
00983 Default value is @code{2mil}.
00984 @end ftable
00985 %end-doc
00986 */
00987   CSET (AlignmentDistance, MIL_TO_COORD(2), "alignment-distance",
00988   "distance between the boards outline and alignment targets"),
00989 
00990 /* %start-doc options "7 DRC Options"
00991 All parameters should be given with an unit. If no unit is given, 1/100 mil
00992 (cmil) will be used for backward compability. Valid units are given in section
00993 @ref{Sizes}.
00994 %end-doc
00995 */
00996 
00997 
00998 /* %start-doc options "7 DRC Options"
00999 @ftable @code
01000 @item --bloat <num>
01001 Minimum spacing. Default value is @code{10mil}.
01002 @end ftable
01003 %end-doc
01004 */
01005   CSET (Bloat, MIL_TO_COORD(10), "bloat", "DRC minimum spacing in 1/100 mil"),
01006 
01007 /* %start-doc options "7 DRC Options"
01008 @ftable @code
01009 @item --shrink <num>
01010 Minimum touching overlap. Default value is @code{10mil}.
01011 @end ftable
01012 %end-doc
01013 */
01014   CSET (Shrink, MIL_TO_COORD(10), "shrink", "DRC minimum overlap in 1/100 mils"),
01015 
01016 /* %start-doc options "7 DRC Options"
01017 @ftable @code
01018 @item --min-width <num>
01019 Minimum width of copper. Default value is @code{10mil}.
01020 @end ftable
01021 %end-doc
01022 */
01023   CSET (minWid, MIL_TO_COORD(10), "min-width", "DRC minimum copper spacing"),
01024 
01025 /* %start-doc options "7 DRC Options"
01026 @ftable @code
01027 @item --min-silk <num>
01028 Minimum width of lines in silk. Default value is @code{10mil}.
01029 @end ftable
01030 %end-doc
01031 */
01032   CSET (minSlk, MIL_TO_COORD(10), "min-silk", "DRC minimum silk width"),
01033 
01034 /* %start-doc options "7 DRC Options"
01035 @ftable @code
01036 @item --min-drill <num>
01037 Minimum diameter of holes. Default value is @code{15mil}.
01038 @end ftable
01039 %end-doc
01040 */
01041   CSET (minDrill, MIL_TO_COORD(15), "min-drill", "DRC minimum drill diameter"),
01042 
01043 /* %start-doc options "7 DRC Options"
01044 @ftable @code
01045 @item --min-ring <num>
01046 Minimum width of annular ring. Default value is @code{10mil}.
01047 @end ftable
01048 %end-doc
01049 */
01050   CSET (minRing, MIL_TO_COORD(10), "min-ring", "DRC minimum annular ring"),
01051 
01052 
01053 /* %start-doc options "5 Sizes"
01054 @ftable @code
01055 @item --grid <num>
01056 Initial grid size. Default value is @code{10mil}.
01057 @end ftable
01058 %end-doc
01059 */
01060   CSET (Grid, MIL_TO_COORD(10), "grid", "Initial grid size in 1/100 mil"),
01061 
01062 /* %start-doc options "5 Sizes"
01063 @ftable @code
01064 @item --minimum polygon area <num>
01065 Minimum polygon area.
01066 @end ftable
01067 %end-doc
01068 */
01069   RSET (IsleArea, MIL_TO_COORD(100) * MIL_TO_COORD(100), "minimum polygon area", 0),
01070 
01071 
01072 /* %start-doc options "5 Sizes"
01073 @ftable @code
01074 @item --paste-adjust <num>
01075 Adjust pad thickness in paste layer. Default value is @code{0}.
01076 Shrinking the pads is done with a negative amount.
01077 
01078 Example:
01079 @example
01080 pcb -x gerber --paste-adjust -0.07mm filename.pcb
01081 @end example
01082 @end ftable
01083 %end-doc
01084 */
01085   CSET (PasteAdjust, MIL_TO_COORD(0), "paste-adjust", "Adjustment to pad thickness in paste layer in 1/100 mil"),
01086 
01087 
01088 /* %start-doc options "1 General Options"
01089 @ftable @code
01090 @item --backup-interval
01091 Time between automatic backups in seconds. Set to @code{0} to disable.
01092 The default value is @code{60}.
01093 @end ftable
01094 %end-doc
01095 */
01096   ISET (BackupInterval, 60, "backup-interval",
01097   "Time between automatic backups in seconds. Set to 0 to disable"),
01098 
01099 /* %start-doc options "4 Layer Names"
01100 @ftable @code
01101 @item --layer-name-1 <string>
01102 Name of the 1st Layer. Default is @code{"top"}.
01103 @end ftable
01104 %end-doc
01105 */
01106   LAYERNAME (1, "top"),
01107 
01108 /* %start-doc options "4 Layer Names"
01109 @ftable @code
01110 @item --layer-name-2 <string>
01111 Name of the 2nd Layer. Default is @code{"ground"}.
01112 @end ftable
01113 %end-doc
01114 */
01115   LAYERNAME (2, "ground"),
01116 
01117 /* %start-doc options "4 Layer Names"
01118 @ftable @code
01119 @item --layer-name-3 <string>
01120 Name of the 3nd Layer. Default is @code{"signal2"}.
01121 @end ftable
01122 %end-doc
01123 */
01124   LAYERNAME (3, "signal2"),
01125 
01126 /* %start-doc options "4 Layer Names"
01127 @ftable @code
01128 @item --layer-name-4 <string>
01129 Name of the 4rd Layer. Default is @code{"signal3"}.
01130 @end ftable
01131 %end-doc
01132 */
01133   LAYERNAME (4, "signal3"),
01134 
01135 /* %start-doc options "4 Layer Names"
01136 @ftable @code
01137 @item --layer-name-5 <string>
01138 Name of the 5rd Layer. Default is @code{"power"}.
01139 @end ftable
01140 %end-doc
01141 */
01142   LAYERNAME (5, "power"),
01143 
01144 /* %start-doc options "4 Layer Names"
01145 @ftable @code
01146 @item --layer-name-6 <string>
01147 Name of the 6rd Layer. Default is @code{"bottom"}.
01148 @end ftable
01149 %end-doc
01150 */
01151   LAYERNAME (6, "bottom"),
01152 
01153 /* %start-doc options "4 Layer Names"
01154 @ftable @code
01155 @item --layer-name-7 <string>
01156 Name of the 7rd Layer. Default is @code{"outline"}.
01157 @end ftable
01158 %end-doc
01159 */
01160   LAYERNAME (7, "outline"),
01161 
01162 /* %start-doc options "4 Layer Names"
01163 @ftable @code
01164 @item --layer-name-8 <string>
01165 Name of the 8rd Layer. Default is @code{"spare"}.
01166 @end ftable
01167 %end-doc
01168 */
01169   LAYERNAME (8, "spare"),
01170 
01171 /* %start-doc options "1 General Options"
01172 @ftable @code
01173 @item --groups <string>
01174 Layer group string. Defaults to @code{"1,c:2:3:4:5:6,s:7:8"}.
01175 @end ftable
01176 %end-doc
01177 */
01178   SSET (Groups, "1,c:2:3:4:5:6,s:7:8", "groups", "Layer group string"),
01179 
01180 
01181 /* %start-doc options "6 Commands"
01182 pcb uses external commands for input output operations. These commands can be
01183 configured at start-up to meet local requirements. The command string may include
01184 special sequences @code{%f}, @code{%p} or @code{%a}. These are replaced when the
01185 command is called. The sequence @code{%f} is replaced by the file name,
01186 @code{%p} gets the path and @code{%a} indicates a package name.
01187 %end-doc
01188 */
01189 
01190 /* %start-doc options "6 Commands"
01191 @ftable @code
01192 @item --font-command <string>
01193 Command to load a font.
01194 @end ftable
01195 %end-doc
01196 */
01197   SSET (FontCommand, "", "font-command", "Command to load a font"),
01198 
01199 /* %start-doc options "6 Commands"
01200 @ftable @code
01201 @item --file-command <string>
01202 Command to read a file.
01203 @end ftable
01204 %end-doc
01205 */
01206   SSET (FileCommand, "", "file-command", "Command to read a file"),
01207 
01208 /* %start-doc options "6 Commands"
01209 @ftable @code
01210 @item --element-command <string>
01211 Command to read a footprint. @*
01212 Defaults to @code{"M4PATH='%p';export M4PATH;echo 'include(%f)' | m4"}
01213 @end ftable
01214 %end-doc
01215 */
01216   SSET (ElementCommand,
01217         "M4PATH='%p';export M4PATH;echo 'include(%f)' | " GNUM4,
01218         "element-command", "Command to read a footprint"),
01219 
01220 /* %start-doc options "6 Commands"
01221 @ftable @code
01222 @item --print-file <string>
01223 Command to print to a file.
01224 @end ftable
01225 %end-doc
01226 */
01227   SSET (PrintFile, "%f.output", "print-file", "Command to print to a file"),
01228 
01229 /* %start-doc options "6 Commands"
01230 @ftable @code
01231 @item --lib-command-dir <string>
01232 Path to the command that queries the library.
01233 @end ftable
01234 %end-doc
01235 */
01236   SSET (LibraryCommandDir, PCBLIBDIR, "lib-command-dir",
01237        "Path to the command that queries the library"),
01238 
01239 /* %start-doc options "6 Commands"
01240 @ftable @code
01241 @item --lib-command <string>
01242 Command to query the library. @*
01243 Defaults to @code{"QueryLibrary.sh '%p' '%f' %a"}
01244 @end ftable
01245 %end-doc
01246 */
01247   SSET (LibraryCommand, "QueryLibrary.sh '%p' '%f' %a",
01248        "lib-command", "Command to query the library"),
01249 
01250 /* %start-doc options "6 Commands"
01251 @ftable @code
01252 @item --lib-contents-command <string>
01253 Command to query the contents of the library. @*
01254 Defaults to @code{"ListLibraryContents.sh %p %f"} or,
01255 on Windows builds, an empty string (to disable this feature).
01256 @end ftable
01257 %end-doc
01258 */
01259   SSET (LibraryContentsCommand,
01260 #ifdef __WIN32__
01261         "",
01262 #else
01263         "ListLibraryContents.sh '%p' '%f'",
01264 #endif
01265         "lib-contents-command", "Command to query the contents of the library"),
01266 
01267 /* %start-doc options "5 Paths"
01268 @ftable @code
01269 @item --lib-newlib <string>
01270 Top level directory for the newlib style library.
01271 @end ftable
01272 %end-doc
01273 */
01274   SSET (LibraryTree, PCBTREEPATH, "lib-newlib",
01275         "Top level directory for the newlib style library"),
01276 
01277 /* %start-doc options "6 Commands"
01278 @ftable @code
01279 @item --save-command <string>
01280 Command to save to a file.
01281 @end ftable
01282 %end-doc
01283 */
01284   SSET (SaveCommand, "", "save-command", "Command to save to a file"),
01285 
01286 /* %start-doc options "5 Paths"
01287 @ftable @code
01288 @item --lib-name <string>
01289 The default filename for the library.
01290 @end ftable
01291 %end-doc
01292 */
01293   SSET (LibraryFilename, LIBRARYFILENAME, "lib-name",
01294                                 "The default filename for the library"),
01295 
01296 /* %start-doc options "5 Paths"
01297 @ftable @code
01298 @item --default-font <string>
01299 The name of the default font.
01300 @end ftable
01301 %end-doc
01302 */
01303   SSET (FontFile, "default_font", "default-font",
01304         "File name of default font"),
01305 
01306 /* %start-doc options "1 General Options"
01307 @ftable @code
01308 @item --route-styles <string>
01309 A string that defines the route styles. Defaults to @*
01310 @code{"Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000
01311         :Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600"}
01312 @end ftable
01313 %end-doc
01314 */
01315   SSET (Routes, "Signal,1000,3600,2000,1000:Power,2500,6000,3500,1000"
01316         ":Fat,4000,6000,3500,1000:Skinny,600,2402,1181,600", "route-styles",
01317         "A string that defines the route styles"),
01318 
01319 /* %start-doc options "5 Paths"
01320 @ftable @code
01321 @item --file-path <string>
01322 A colon separated list of directories or commands (starts with '|'). The path
01323 is passed to the program specified in @option{--file-command} together with the selected
01324 filename.
01325 @end ftable
01326 %end-doc
01327 */
01328   SSET (FilePath, "", "file-path", 0),
01329 
01330 /* %start-doc options "6 Commands"
01331 @ftable @code
01332 @item --rat-command <string>
01333 Command for reading a netlist. Sequence @code{%f} is replaced by the netlist filename.
01334 @end ftable
01335 %end-doc
01336 */
01337   SSET (RatCommand, "", "rat-command", "Command for reading a netlist"),
01338 
01339 /* %start-doc options "5 Paths"
01340 @ftable @code
01341 @item --font-path <string>
01342 A colon separated list of directories to search the default font. Defaults to
01343 the default library path.
01344 @end ftable
01345 %end-doc
01346 */
01347   SSET (FontPath, PCBLIBPATH, "font-path",
01348        "Colon separated list of directories to search the default font"),
01349 
01350 /* %start-doc options "1 General Options"
01351 @ftable @code
01352 @item --element-path <string>
01353 A colon separated list of directories or commands (starts with '|').
01354 The path is passed to the program specified in @option{--element-command}.
01355 @end ftable
01356 %end-doc
01357 */
01358   SSET(ElementPath, PCBLIBPATH, "element-path",
01359       "A colon separated list of directories or commands (starts with '|')"),
01360 
01361 /* %start-doc options "5 Paths"
01362 @ftable @code
01363 @item --lib-path <string>
01364 A colon separated list of directories that will be passed to the commands specified
01365 by @option{--element-command} and @option{--element-contents-command}.
01366 @end ftable
01367 %end-doc
01368 */
01369   SSET (LibraryPath, PCBLIBPATH, "lib-path",
01370        "A colon separated list of directories"),
01371 
01372 /* %start-doc options "1 General Options"
01373 @ftable @code
01374 @item --action-script <string>
01375 If set, this file is executed at startup.
01376 @end ftable
01377 %end-doc
01378 */
01379   SSET (ScriptFilename, 0, "action-script",
01380              "If set, this file is executed at startup"),
01381 
01382 /* %start-doc options "1 General Options"
01383 @ftable @code
01384 @item --action-string <string>
01385 If set, this string of actions is executed at startup.
01386 @end ftable
01387 %end-doc
01388 */
01389   SSET (ActionString, 0, "action-string",
01390        "If set, this is executed at startup"),
01391 
01392 /* %start-doc options "1 General Options"
01393 @ftable @code
01394 @item --fab-author <string>
01395 Name of author to be put in the Gerber files.
01396 @end ftable
01397 %end-doc
01398 */
01399   SSET (FabAuthor, "", "fab-author",
01400        "Name of author to be put in the Gerber files"),
01401 
01402 /* %start-doc options "1 General Options"
01403 @ftable @code
01404 @item --layer-stack <string>
01405 Initial layer stackup, for setting up an export. A comma separated list of layer
01406 names, layer numbers and layer groups.
01407 @end ftable
01408 %end-doc
01409 */
01410   SSET (InitialLayerStack, "", "layer-stack",
01411         "Initial layer stackup, for setting up an export."),
01412 
01413   SSET (MakeProgram, NULL, "make-program",
01414         "Sets the name and optionally full path to a make(3) program"),
01415   SSET (GnetlistProgram, NULL, "gnetlist",
01416         "Sets the name and optionally full path to the gnetlist(3) program"),
01417 
01418 /* %start-doc options "2 General GUI Options"
01419 @ftable @code
01420 @item --pinout-offset-x <num>
01421 Horizontal offset of the pin number display. Defaults to @code{100mil}.
01422 @end ftable
01423 %end-doc
01424 */
01425   CSET (PinoutOffsetX, MIL_TO_COORD(1), "pinout-offset-x",
01426        "Horizontal offset of the pin number display in mil"),
01427 
01428 /* %start-doc options "2 General GUI Options"
01429 @ftable @code
01430 @item --pinout-offset-y <num>
01431 Vertical offset of the pin number display. Defaults to @code{100mil}.
01432 @end ftable
01433 %end-doc
01434 */
01435   CSET (PinoutOffsetY, MIL_TO_COORD(1), "pinout-offset-y",
01436        "Vertical offset of the pin number display in mil"),
01437 
01438 /* %start-doc options "2 General GUI Options"
01439 @ftable @code
01440 @item --pinout-text-offset-x <num>
01441 Horizontal offset of the pin name display. Defaults to @code{800mil}.
01442 @end ftable
01443 %end-doc
01444 */
01445   CSET (PinoutTextOffsetX, MIL_TO_COORD(8), "pinout-text-offset-x",
01446        "Horizontal offset of the pin name display in mil"),
01447 
01448 /* %start-doc options "2 General GUI Options"
01449 @ftable @code
01450 @item --pinout-text-offset-y <num>
01451 Vertical offset of the pin name display. Defaults to @code{-100mil}.
01452 @end ftable
01453 %end-doc
01454 */
01455   CSET (PinoutTextOffsetY, MIL_TO_COORD(-1), "pinout-text-offset-y",
01456        "Vertical offset of the pin name display in mil"),
01457 
01458 /* %start-doc options "2 General GUI Options"
01459 @ftable @code
01460 @item --draw-grid
01461 If set, draw the grid at start-up.
01462 @end ftable
01463 %end-doc
01464 */
01465   BSET (DrawGrid, 0, "draw-grid", "If set, draw the grid at start-up"),
01466 
01467 /* %start-doc options "2 General GUI Options"
01468 @ftable @code
01469 @item --clear-line
01470 If set, new lines clear polygons.
01471 @end ftable
01472 %end-doc
01473 */
01474   BSET (ClearLine, 1, "clear-line", "If set, new lines clear polygons"),
01475 
01476 /* %start-doc options "2 General GUI Options"
01477 @ftable @code
01478 @item --full-poly
01479 If set, new polygons are full ones.
01480 @end ftable
01481 %end-doc
01482 */
01483   BSET (FullPoly, 0, "full-poly", 0),
01484 
01485 /* %start-doc options "2 General GUI Options"
01486 @ftable @code
01487 @item --unique-names
01488 If set, you will not be permitted to change the name of an component to match that
01489 of another component.
01490 @end ftable
01491 %end-doc
01492 */
01493   BSET (UniqueNames, 1, "unique-names", "Prevents identical component names"),
01494 
01495 /* %start-doc options "2 General GUI Options"
01496 @ftable @code
01497 @item --snap-pin
01498 If set, pin centers and pad end points are treated as additional grid points
01499 that the cursor can snap to.
01500 @end ftable
01501 %end-doc
01502 */
01503   BSET (SnapPin, 1, "snap-pin",
01504        "If set, the cursor snaps to pads and pin centers"),
01505 
01506 /* %start-doc options "1 General Options"
01507 @ftable @code
01508 @item --save-last-command
01509 If set, the last user command is saved.
01510 @end ftable
01511 %end-doc
01512 */
01513   BSET (SaveLastCommand, 0, "save-last-command", 0),
01514 
01515 /* %start-doc options "1 General Options"
01516 @ftable @code
01517 @item --save-in-tmp
01518 If set, all data which would otherwise be lost are saved in a temporary file
01519 @file{/tmp/PCB.%i.save} . Sequence @samp{%i} is replaced by the process ID.
01520 @end ftable
01521 %end-doc
01522 */
01523   BSET (SaveInTMP, 0, "save-in-tmp",
01524        "When set, all data which would otherwise be lost are saved in /tmp"),
01525 
01526 /* %start-doc options "1 General Options"
01527 @ftable @code
01528 @item --save-metric-only
01529 If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm.
01530 @end ftable
01531 %end-doc
01532 */
01533   BSET (SaveMetricOnly, 0, "save-metric-only",
01534         "If set, save pcb files using only mm unit suffix rather than 'smart' mil/mm."),
01535 
01536 /* %start-doc options "2 General GUI Options"
01537 @ftable @code
01538 @item --all-direction-lines
01539 Allow all directions, when drawing new lines.
01540 @end ftable
01541 %end-doc
01542 */
01543   BSET (AllDirectionLines, 0, "all-direction-lines",
01544        "Allow all directions, when drawing new lines"),
01545 
01546 /* %start-doc options "2 General GUI Options"
01547 @ftable @code
01548 @item --show-number
01549 Pinout shows number.
01550 @end ftable
01551 %end-doc
01552 */
01553   BSET (ShowNumber, 0, "show-number", "Pinout shows number"),
01554 
01555 /* %start-doc options "1 General Options"
01556 @ftable @code
01557 @item --reset-after-element
01558 If set, all found connections are reset before a new component is scanned.
01559 @end ftable
01560 %end-doc
01561 */
01562   BSET (ResetAfterElement, 1, "reset-after-element",
01563        "If set, all found connections are reset before a new component is scanned"),
01564 
01565 /* %start-doc options "1 General Options"
01566 @ftable @code
01567 @item --auto-buried-vias
01568 Enables automatically created vias (during line moves and layer switch) to be buriad/blind vias
01569 @end ftable
01570 %end-doc
01571 */
01572   BSET (AutoBuriedVias, 0, "auto-buried-vias",
01573        "Enables automatically created vias to be buriad/blind vias"),
01574 
01575 /* %start-doc options "1 General Options"
01576 @ftable @code
01577 @item --ring-bell-finished
01578 Execute the bell command when all rats are routed.
01579 @end ftable
01580 %end-doc
01581 */
01582   BSET (RingBellWhenFinished, 0, "ring-bell-finished",
01583        "Execute the bell command when all rats are routed"),
01584 };
01585 
01586 REGISTER_ATTRIBUTES (main_attribute_list)
01587 /* ---------------------------------------------------------------------- 
01588  * post-process settings.
01589  */
01590      static void settings_post_process ()
01591 {
01592   char *tmps;
01593 
01594   if (Settings.LibraryCommand != NULL &&
01595       Settings.LibraryCommand[0] != '\0' &&
01596       Settings.LibraryCommand[0] != PCB_DIR_SEPARATOR_C &&
01597       Settings.LibraryCommand[0] != '.')
01598     {
01599       Settings.LibraryCommand
01600         =
01601         Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S, 
01602                 Settings.LibraryCommand,
01603                 NULL);
01604     }
01605   if (Settings.LibraryContentsCommand != NULL &&
01606       Settings.LibraryContentsCommand[0] != '\0' &&
01607       Settings.LibraryContentsCommand[0] != PCB_DIR_SEPARATOR_C &&
01608       Settings.LibraryContentsCommand[0] != '.')
01609     {
01610       Settings.LibraryContentsCommand
01611         =
01612         Concat (Settings.LibraryCommandDir, PCB_DIR_SEPARATOR_S,
01613                 Settings.LibraryContentsCommand, NULL);
01614     }
01615 
01616   if (Settings.LineThickness > MAX_LINESIZE
01617       || Settings.LineThickness < MIN_LINESIZE)
01618     Settings.LineThickness = MIL_TO_COORD(10);
01619 
01620   if (Settings.ViaThickness > MAX_PINORVIASIZE
01621       || Settings.ViaThickness < MIN_PINORVIASIZE)
01622     Settings.ViaThickness = MIL_TO_COORD(40);
01623 
01624   if (Settings.ViaDrillingHole <= 0)
01625     Settings.ViaDrillingHole =
01626       DEFAULT_DRILLINGHOLE * Settings.ViaThickness / 100;
01627 
01628   Settings.MaxWidth  = CLAMP (Settings.MaxWidth, MIN_SIZE, MAX_COORD);
01629   Settings.MaxHeight = CLAMP (Settings.MaxHeight, MIN_SIZE, MAX_COORD);
01630 
01631   ParseRouteString (Settings.Routes, &Settings.RouteStyle[0], "cmil");
01632 
01633   /*
01634    * Make sure we have settings for some various programs we may wish
01635    * to call
01636    */
01637   if (Settings.MakeProgram == NULL) {
01638     tmps = getenv ("PCB_MAKE_PROGRAM");
01639     if (tmps != NULL)
01640       Settings.MakeProgram = strdup (tmps);
01641   }
01642   if (Settings.MakeProgram == NULL) {
01643     Settings.MakeProgram = strdup ("make");
01644   }
01645 
01646   if (Settings.GnetlistProgram == NULL) {
01647     tmps = getenv ("PCB_GNETLIST");
01648     if (tmps != NULL)
01649       Settings.GnetlistProgram = strdup (tmps);
01650   }
01651   if (Settings.GnetlistProgram == NULL) {
01652     Settings.GnetlistProgram = strdup ("gnetlist");
01653   }
01654 
01655   if (grid_units)
01656     Settings.grid_unit = get_unit_struct (grid_units);
01657   if (!grid_units || Settings.grid_unit == NULL)
01658     Settings.grid_unit = get_unit_struct ("mil");
01659 
01660   copy_nonzero_increments (get_increments_struct (METRIC), &increment_mm);
01661   copy_nonzero_increments (get_increments_struct (IMPERIAL), &increment_mil);
01662 
01663   Settings.increments = get_increments_struct (Settings.grid_unit->family);
01664 }
01665 
01669 static void
01670 print_version ()
01671 {
01672   printf ("PCB version %s\n", VERSION);
01673   exit (0);
01674 }
01675 
01676 /* ----------------------------------------------------------------------
01677  * Figure out the canonical name of the executed program
01678  * and fix up the defaults for various paths
01679  */
01680 char *bindir = NULL;
01681 char *exec_prefix = NULL;
01682 char *pcblibdir = NULL;
01683 char *pcblibpath = NULL;
01684 char *pcbtreedir = NULL;
01685 char *pcbtreepath = NULL;
01686 char *homedir = NULL;
01687 
01696 static void
01697 InitPaths (char *argv0)
01698 {
01699   size_t l;
01700   int i;
01701   int haspath;
01702   char *t1, *t2;
01703   int found_bindir = 0;
01704 
01705   haspath = 0;
01706   for (i = 0; i < strlen (argv0) ; i++)
01707     {
01708       if (argv0[i] == PCB_DIR_SEPARATOR_C) 
01709         haspath = 1;
01710     }
01711 
01712 #ifdef DEBUG
01713   printf ("InitPaths (%s): haspath = %d\n", argv0, haspath);
01714 #endif
01715 
01716   if (haspath)
01717     {
01718       bindir = strdup (lrealpath (argv0));
01719       found_bindir = 1;
01720     }
01721   else
01722     {
01723       char *path, *p, *tmps;
01724       struct stat sb;
01725       int r;
01726 
01727       tmps = getenv ("PATH");
01728 
01729       if (tmps != NULL) 
01730         {
01731           path = strdup (tmps);
01732 
01733           /* search through the font path for a font file */
01734           for (p = strtok (path, PCB_PATH_DELIMETER); p && *p;
01735                p = strtok (NULL, PCB_PATH_DELIMETER))
01736             {
01737 #ifdef DEBUG
01738               printf ("Looking for %s in %s\n", argv0, p);
01739 #endif
01740               if ( (tmps = (char *)malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
01741                 {
01742                   fprintf (stderr, "InitPaths():  malloc failed\n");
01743                   exit (1);
01744                 }
01745               sprintf (tmps, "%s%s%s", p, PCB_DIR_SEPARATOR_S, argv0);
01746               r = stat (tmps, &sb);
01747               if (r == 0)
01748                 {
01749 #ifdef DEBUG
01750                   printf ("Found it:  \"%s\"\n", tmps);
01751 #endif
01752                   bindir = lrealpath (tmps);
01753                   found_bindir = 1;
01754                   free (tmps);
01755                   break;
01756                 }  
01757               free (tmps);
01758             }
01759           free (path);
01760         }
01761     }
01762 
01763 #ifdef DEBUG
01764   printf ("InitPaths():  bindir = \"%s\"\n", bindir);
01765 #endif
01766 
01767   if (found_bindir)
01768     {
01769       /* strip off the executible name leaving only the path */
01770       t2 = NULL;
01771       t1 = strchr (bindir, PCB_DIR_SEPARATOR_C);
01772       while (t1 != NULL && *t1 != '\0')
01773         {
01774           t2 = t1;
01775           t1 = strchr (t2 + 1, PCB_DIR_SEPARATOR_C);
01776         }
01777       if (t2 != NULL)
01778         *t2 = '\0';
01779 
01780 #ifdef DEBUG
01781       printf ("After stripping off the executible name, we found\n");
01782       printf ("bindir = \"%s\"\n", bindir);
01783 #endif
01784     }
01785   else
01786     {
01787       /* we have failed to find out anything from argv[0] so fall back to the original
01788        * install prefix
01789        */
01790        bindir = strdup (BINDIR);
01791     }
01792 
01793   /* now find the path to exec_prefix */
01794   l = strlen (bindir) + 1 + strlen (BINDIR_TO_EXECPREFIX) + 1;
01795   if ( (exec_prefix = (char *) malloc (l * sizeof (char) )) == NULL )
01796     {
01797       fprintf (stderr, "InitPaths():  malloc failed\n");
01798       exit (1);
01799     }
01800   sprintf (exec_prefix, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S, 
01801            BINDIR_TO_EXECPREFIX);
01802 
01803   /* now find the path to PCBLIBDIR */
01804   l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBLIBDIR) + 1;
01805   if ( (pcblibdir = (char *) malloc (l * sizeof (char) )) == NULL )
01806     {
01807       fprintf (stderr, "InitPaths():  malloc failed\n");
01808       exit (1);
01809     }
01810   sprintf (pcblibdir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S, 
01811            BINDIR_TO_PCBLIBDIR);
01812 
01813   /* and the path to PCBTREEDIR */
01814   l = strlen (bindir) + 1 + strlen (BINDIR_TO_PCBTREEDIR) + 1;
01815   if ( (pcbtreedir = (char *) malloc (l * sizeof (char) )) == NULL )
01816     {
01817       fprintf (stderr, "InitPaths():  malloc failed\n");
01818       exit (1);
01819     }
01820   sprintf (pcbtreedir, "%s%s%s", bindir, PCB_DIR_SEPARATOR_S, 
01821            BINDIR_TO_PCBTREEDIR);
01822 
01823   /* and the search path including PCBLIBDIR */
01824   l = strlen (pcblibdir) + 3;
01825   if ( (pcblibpath = (char *) malloc (l * sizeof (char) )) == NULL )
01826     {
01827       fprintf (stderr, "InitPaths():  malloc failed\n");
01828       exit (1);
01829     }
01830   sprintf (pcblibpath, ".%s%s", PCB_PATH_DELIMETER, pcblibdir);
01831 
01832   /* and the newlib search path */
01833   l = strlen (pcblibdir) + 1 + strlen (pcbtreedir) 
01834     + strlen ("pcblib-newlib") + 2;
01835   if ( (pcbtreepath = (char *) malloc (l * sizeof (char) )) == NULL )
01836     {
01837       fprintf (stderr, "InitPaths():  malloc failed\n");
01838       exit (1);
01839     }
01840   sprintf (pcbtreepath, "%s%s%s%spcblib-newlib", pcbtreedir, 
01841         PCB_PATH_DELIMETER, pcblibdir,
01842         PCB_DIR_SEPARATOR_S);
01843   
01844 #ifdef DEBUG
01845   printf ("bindir      = %s\n", bindir);
01846   printf ("pcblibdir   = %s\n", pcblibdir);
01847   printf ("pcblibpath  = %s\n", pcblibpath);
01848   printf ("pcbtreedir  = %s\n", pcbtreedir);
01849   printf ("pcbtreepath = %s\n", pcbtreepath);
01850 #endif
01851 
01852   l = sizeof (main_attribute_list) / sizeof (main_attribute_list[0]);
01853   for (i = 0; i < l ; i++) 
01854     {
01855       if (NSTRCMP (main_attribute_list[i].name, "lib-command-dir") == 0)
01856         {
01857           main_attribute_list[i].default_val.str_value = pcblibdir;
01858         }
01859 
01860       if ( (NSTRCMP (main_attribute_list[i].name, "font-path") == 0) 
01861            || (NSTRCMP (main_attribute_list[i].name, "element-path") == 0)
01862            || (NSTRCMP (main_attribute_list[i].name, "lib-path") == 0) )
01863         {
01864           main_attribute_list[i].default_val.str_value = pcblibpath;
01865         }
01866 
01867       if (NSTRCMP (main_attribute_list[i].name, "lib-newlib") == 0)
01868         {
01869           main_attribute_list[i].default_val.str_value = pcbtreepath;
01870         }
01871 
01872     }
01873 
01874     {
01875       char *tmps;
01876 
01877       tmps = getenv ("HOME");
01878 
01879       if (tmps == NULL) {
01880           tmps = getenv ("USERPROFILE");
01881       }
01882 
01883       if (tmps != NULL) {
01884           homedir = strdup (tmps);
01885       } else {
01886           homedir = NULL;
01887       }
01888 
01889     }
01890 }
01891 
01892 /* ---------------------------------------------------------------------- 
01893  * main program
01894  */
01895 
01896 char *program_name = 0;
01897 char *program_basename = 0;
01898 char *program_directory = 0;
01899 
01900 #include "dolists.h"
01901 
01909 void
01910 pcb_main_uninit (void)
01911 {
01912   if (gui->uninit != NULL)
01913     gui->uninit (gui);
01914 
01915   hid_uninit ();
01916 
01917   UninitBuffers ();
01918 
01919   FreePCBMemory (PCB);
01920   free (PCB);
01921   PCB = NULL;
01922 
01939   uninit_strflags_buf ();
01940   uninit_strflags_layerlist ();
01941 
01942 #define free0(ptr) \
01943   do \
01944     { \
01945       if (ptr != NULL) \
01946         { \
01947           free (ptr); \
01948           ptr = 0; \
01949         } \
01950     } while (0)
01951 
01952   free0 (pcblibdir);
01953   free0 (homedir);
01954   free0 (bindir);
01955   free0 (exec_prefix);
01956   free0 (program_directory);
01957   free0 (Settings.MakeProgram);
01958   free0 (Settings.GnetlistProgram);
01959 
01960 #undef free0
01961 }
01962 
01977 int
01978 main (int argc, char *argv[])
01979 {
01980   int i;
01981 
01982 #include "core_lists.h"
01983   setbuf (stdout, 0);
01984   InitPaths (argv[0]);
01985 
01986   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
01987   textdomain (GETTEXT_PACKAGE);
01988   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
01989 
01990 #ifdef ENABLE_NLS
01991   setlocale (LC_ALL, "");
01992   setlocale (LC_NUMERIC, "C");
01993 #endif
01994 
01995   srand ( time(NULL) ); /* Set seed for rand() */
01996 
01997   initialize_units();
01998   polygon_init ();
01999   hid_init ();
02000 
02001   hid_load_settings ();
02002 
02003   program_name = argv[0];
02004   program_basename = strrchr (program_name, PCB_DIR_SEPARATOR_C);
02005   if (program_basename)
02006     {
02007       program_directory = strdup (program_name);
02008       *strrchr (program_directory, PCB_DIR_SEPARATOR_C) = 0;
02009       program_basename++;
02010     }
02011   else
02012     {
02013       program_directory = strdup (".");
02014       program_basename = program_name;
02015     }
02016   Progname = program_basename;
02017 
02018   /* Print usage or version if requested.  Then exit.  */  
02019   if (argc > 1 &&
02020       (strcmp (argv[1], "-h") == 0 ||
02021        strcmp (argv[1], "-?") == 0 ||
02022        strcmp (argv[1], "--help") == 0))
02023     usage ();
02024   if (argc > 1 && strcmp (argv[1], "-V") == 0)
02025     print_version ();
02026   /* Export pcb from command line if requested.  */
02027   if (argc > 1 && strcmp (argv[1], "-p") == 0)
02028     {
02029       exporter = gui = hid_find_printer ();
02030       argc--;
02031       argv++;
02032     }
02033   else if (argc > 2 && strcmp (argv[1], "-x") == 0)
02034     {
02035       exporter = gui = hid_find_exporter (argv[2]);
02036       argc -= 2;
02037       argv += 2;
02038     }
02039     /* Otherwise start GUI. */
02040   else
02041     gui = hid_find_gui ();
02042 
02043   /* Exit with error if GUI failed to start. */
02044   if (!gui)
02045     exit (1);
02046 
02047   /* Set up layers. */
02048   for (i = 0; i < MAX_LAYER; i++)
02049     {
02050       char buf[20];
02051       sprintf (buf, "signal%d", i + 1);
02052       Settings.DefaultLayerName[i] = strdup (buf);
02053       Settings.LayerColor[i] = "#c49350";
02054       Settings.LayerSelectedColor[i] = "#00ffff";
02055     }
02056 
02057   gui->parse_arguments (&argc, &argv);
02058 
02059   if (show_help || (argc > 1 && argv[1][0] == '-'))
02060     usage ();
02061   if (show_version)
02062     print_version ();
02063   if (show_defaults)
02064     print_defaults ();
02065   if (show_copyright)
02066     copyright ();
02067 
02068   settings_post_process ();
02069 
02070 
02071   if (show_actions)
02072     {
02073       print_actions ();
02074       exit (0);
02075     }
02076 
02077   if (do_dump_actions)
02078     {
02079       extern void dump_actions (void);
02080       dump_actions ();
02081       exit (0);
02082     }
02083 
02084   /* Create a new PCB object in memory */
02085   PCB = CreateNewPCB ();
02086   ParseGroupString (Settings.Groups, &PCB->LayerGroups, &PCB->Data->LayerN);
02087   /* Add silk layers to newly created PCB */
02088   CreateNewPCBPost (PCB, 1);
02089   if (argc > 1)
02090     command_line_pcb = argv[1];
02091 
02092   ResetStackAndVisibility ();
02093 
02094   InitCrosshair ();
02095   InitHandler ();
02096   InitBuffers ();
02097   SetMode (ARROW_MODE);
02098 
02099   if (command_line_pcb)
02100     {
02101       if (access(command_line_pcb, F_OK))
02102         {
02103            /* File does not exist, save the filename and continue with empty board */
02104            PCB->Filename = strdup (command_line_pcb);
02105         } else {
02106            /* Hard fail if file exists and fails to load */
02107            if (LoadPCB (command_line_pcb))
02108              {
02109                fprintf(stderr, "LoadPCB: Failed to load existing file \"%s\". Is it supported PCB file?\n", command_line_pcb);
02110                exit(1);
02111              }
02112         }
02113     }
02114 
02115   if (Settings.InitialLayerStack
02116       && Settings.InitialLayerStack[0])
02117     {
02118       LayerStringToLayerStack (Settings.InitialLayerStack);
02119     }
02120 
02121   /* This must be called before any other atexit functions
02122    * are registered, as it configures an atexit function to
02123    * clean up and free various items of allocated memory,
02124    * and must be the last last atexit function to run.
02125    */
02126   leaky_init ();
02127 
02128   /* Register a function to be called when the program terminates.
02129    * This makes sure that data is saved even if LEX/YACC routines
02130    * abort the program.
02131    * If the OS doesn't have at least one of them,
02132    * the critical sections will be handled by parse_l.l
02133    */
02134   atexit (EmergencySave);
02135 
02136   /* read the library file and display it if it's not empty
02137    */
02138   if (!ReadLibraryContents () && Library.MenuN)
02139     hid_action ("LibraryChanged");
02140 
02141 #ifdef HAVE_LIBSTROKE
02142   stroke_init ();
02143 #endif
02144 
02145   if (Settings.ScriptFilename)
02146     {
02147       Message (_("Executing startup script file %s\n"),
02148                Settings.ScriptFilename);
02149       hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
02150     }
02151   if (Settings.ActionString)
02152     {
02153       Message (_("Executing startup action %s\n"), Settings.ActionString);
02154       hid_parse_actions (Settings.ActionString);
02155     }
02156 
02157   if (gui->printer || gui->exporter)
02158     {
02159       gui->do_export (0);
02160       exit (0);
02161     }
02162 
02163 #if HAVE_DBUS
02164   pcb_dbus_setup();
02165 #endif
02166 
02167   EnableAutosave ();
02168 
02169 #ifdef DEBUG
02170   printf ("Settings.LibraryCommandDir = \"%s\"\n",
02171           Settings.LibraryCommandDir);
02172   printf ("Settings.FontPath          = \"%s\"\n", 
02173           Settings.FontPath);
02174   printf ("Settings.ElementPath       = \"%s\"\n", 
02175           Settings.ElementPath);
02176   printf ("Settings.LibraryPath       = \"%s\"\n", 
02177           Settings.LibraryPath);
02178   printf ("Settings.LibraryTree       = \"%s\"\n", 
02179           Settings.LibraryTree);
02180   printf ("Settings.MakeProgram = \"%s\"\n",
02181           UNKNOWN (Settings.MakeProgram));
02182   printf ("Settings.GnetlistProgram = \"%s\"\n",
02183           UNKNOWN (Settings.GnetlistProgram));
02184 #endif
02185 
02186   gui->do_export (0);
02187 #if HAVE_DBUS
02188   pcb_dbus_finish();
02189 #endif
02190 
02191   pcb_main_uninit ();
02192 
02193   return (0);
02194 }
02195