00001
00030 #ifdef HAVE_CONFIG_H
00031 # include <config.h>
00032 #endif
00033
00034 #include <X11/StringDefs.h>
00035 #include <Xm/Xm.h>
00036 #include <Xm/DialogS.h>
00037 #include <Xm/MwmUtil.h>
00038 #include <X11/Xmu/Editres.h>
00039 #include <sys/types.h>
00040 #include <sys/stat.h>
00041 #include <unistd.h>
00042 #include <string.h>
00043 #include <stdio.h>
00044 #include <getopt.h>
00045 #include <stdlib.h>
00046 #include <stdarg.h>
00047 #include <fcntl.h>
00048 #include <unistd.h>
00049 #include <ctype.h>
00050 #include <strings.h>
00051 #include <time.h>
00052 #include <dirent.h>
00053 #include <errno.h>
00054
00055 #include "../../config.h"
00056 #include "pcb-lfpw.h"
00057 #include "main_window.h"
00058 #include "about_dialog.h"
00059
00060
00061 #define LUI 1
00062
00063 #define GUI 0
00064
00065 #define CLI 0
00066
00069 XtAppContext appcontext;
00070 Widget main_window = NULL;
00072 Widget about_dialog = NULL;
00074 char *fpw_filename = NULL;
00075 char *program_name = NULL;
00076 Boolean debug = 0;
00078 Boolean silent = 0;
00080 Boolean verbose = 0;
00089 int
00090 print_version ()
00091 {
00092 fprintf (stderr, "\npcb-lfpw version %s\n", VERSION);
00093 fprintf (stderr, "(C) 2010 by Bert Timmerman.\n");
00094 fprintf (stderr, "This is free software; see the source for copying conditions.\n");
00095 fprintf (stderr, "There is NO warranty; not even for MERCHANTABILITY\n");
00096 fprintf (stderr, "or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
00097 return (EXIT_SUCCESS);
00098 }
00099
00100
00106 int
00107 print_usage ()
00108 {
00109 fprintf (stderr, "\npcb-lfpw usage and options:\n");
00110 fprintf (stderr, "\t --help \n");
00111 fprintf (stderr, "\t -? \n");
00112 fprintf (stderr, "\t -h : print this help message and exit.\n\n");
00113 fprintf (stderr, "\t --verbose \n");
00114 fprintf (stderr, "\t -v : log messages, be verbose.\n\n");
00115 fprintf (stderr, "\t --silent \n");
00116 fprintf (stderr, "\t --quiet \n");
00117 fprintf (stderr, "\t -q : do not log messages, overrides --verbose.\n\n");
00118 fprintf (stderr, "\t --version \n");
00119 fprintf (stderr, "\t -V : print the version information and exit.\n\n");
00120 fprintf (stderr, "\t --debug \n");
00121 fprintf (stderr, "\t -d : turn on debugging output messages.\n\n");
00122 return (EXIT_SUCCESS);
00123 }
00124
00125
00131 static
00132 int cmdline_options (int argc, char *argv[])
00133 {
00134
00135 program_name = argv[0];
00136 static const struct option opts[] =
00137 {
00138 {"debug", no_argument, NULL, 'd'},
00139 {"help", no_argument, NULL, 'h'},
00140 {"version", no_argument, NULL, 'V'},
00141 {"verbose", no_argument, NULL, 'v'},
00142 {"quiet", no_argument, NULL, 'q'},
00143 {"silent", no_argument, NULL, 'q'},
00144 {"format", required_argument, NULL, 'f'},
00145 {"output", required_argument, NULL, 'o'},
00146 {0, 0, 0, 0}
00147 };
00148 int optc;
00149 while ((optc = getopt_long (argc, argv, "dhVvqq", opts, NULL)) != -1)
00150 {
00151 switch (optc)
00152 {
00153 case 'd':
00154 debug = TRUE;
00155 break;
00156 case 'h':
00157 print_usage ();
00158 exit (EXIT_SUCCESS);
00159 case 'V':
00160 print_version ();
00161 exit (EXIT_SUCCESS);
00162 case 'v':
00163 verbose = TRUE;
00164 break;
00165 case 'q':
00166 silent = TRUE;
00167 verbose = FALSE;
00168 break;
00169 case '?':
00170 print_usage ();
00171 exit (EXIT_FAILURE);
00172 default:
00173 fprintf (stderr, "unknown command line option encountered.\n");
00174 print_usage ();
00175 exit (EXIT_FAILURE);
00176 }
00177 }
00178 if (optind < argc)
00179 {
00180 print_usage ();
00181 exit (EXIT_FAILURE);
00182 }
00183 return (EXIT_SUCCESS);
00184 }
00185
00186
00192 int
00193 main (int argc, char **argv)
00194 {
00195 Arg args[5];
00196 char title[124];
00197 int n;
00198 int status;
00199
00200
00201 status = cmdline_options (argc, argv);
00202 if (status == 0)
00203 {
00204
00205 main_window = XtVaAppInitialize (&appcontext,
00206 "pcb-lfpw",
00207 NULL,
00208 0,
00209 &argc,
00210 argv,
00211 NULL);
00212 create_main_window (main_window);
00213
00214
00215 create_main_window (main_window);
00216 XtRealizeWidget (main_window);
00217 about_dialog = XtVaAppInitialize (&appcontext,
00218 "about dialog",
00219 NULL,
00220 0,
00221 &argc,
00222 argv,
00223 NULL);
00224 create_about_dialog (main_window);
00225 XtRealizeWidget (about_dialog);
00226
00227 XtAppMainLoop (appcontext);
00228 };
00229 return (EXIT_SUCCESS);
00230 }
00231
00232
00233