refactored some global var names, used only in command option processing
This commit is contained in:
parent
abce61655f
commit
c44673b2ac
|
|
@ -161,28 +161,18 @@ int debug_var=-10; /* will be set to 0 in xinit.c */
|
|||
int help=0; /* help option set to global scope, printing help is deferred */
|
||||
/* when configuration xschemrc has been read 20140406 */
|
||||
FILE *errfp = NULL;
|
||||
int no_readline=0;
|
||||
char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */
|
||||
char user_conf_dir[PATH_MAX];
|
||||
char pwd_dir[PATH_MAX]; /* obtained via getcwd() */
|
||||
int load_initfile=1;
|
||||
char rcfile[PATH_MAX] = {'\0'};
|
||||
char *tcl_command = NULL; /* tcl command given on command line with --tcl <script> */
|
||||
char tcl_script[PATH_MAX] = {'\0'};
|
||||
int tcp_port = 0;
|
||||
int text_svg=1; /* use <text> svg element for text instead of xschem's internal vector font */
|
||||
int text_ps=1; /* use ps font for text instead of xschem's internal vector font */
|
||||
double cadhalfdotsize = CADHALFDOTSIZE;
|
||||
char initial_netlist_name[PATH_MAX]={0};
|
||||
char bus_char[3] = {0, 0, 0};
|
||||
int yyparse_error = 0;
|
||||
char *xschem_executable=NULL;
|
||||
Tcl_Interp *interp = NULL;
|
||||
double *character[256]; /* array or per-char coordinates of xschem internal vector font */
|
||||
int do_netlist=0; /* set by process_options if user wants netllist from cmdline */
|
||||
int do_simulation=0;
|
||||
int do_waves=0;
|
||||
int do_print=0;
|
||||
int quit=0; /* set from process_options (ex netlist from cmdline and quit) */
|
||||
int detach = 0; /* no tcl console if set; batch mode */
|
||||
#ifndef __unix__
|
||||
|
|
@ -202,7 +192,16 @@ int cli_opt_flat_netlist = 0;
|
|||
char cli_opt_plotfile[PATH_MAX] = "";
|
||||
char cli_opt_netlist_dir[PATH_MAX] = "";
|
||||
char cli_opt_filename[PATH_MAX] = ""; /* filename given on cmdline */
|
||||
|
||||
int cli_opt_no_readline=0;
|
||||
char *cli_opt_tcl_command = NULL; /* tcl command given on command line with --tcl <script> */
|
||||
int cli_opt_do_print=0;
|
||||
int cli_opt_do_netlist=0; /* set by process_options if user wants netllist from cmdline */
|
||||
int cli_opt_do_simulation=0;
|
||||
int cli_opt_do_waves=0;
|
||||
char cli_opt_tcl_script[PATH_MAX] = {'\0'};
|
||||
char cli_opt_initial_netlist_name[PATH_MAX]={0};
|
||||
char cli_opt_rcfile[PATH_MAX] = {'\0'};
|
||||
int cli_opt_load_initfile=1;
|
||||
|
||||
/* --------------------------------------------------- */
|
||||
/* Following data is relative to the current schematic */
|
||||
|
|
|
|||
|
|
@ -32,50 +32,50 @@ void check_opt(char *opt, char *optval, int type)
|
|||
|
||||
} else if( (type == SHORT && *opt == 'S') || (type == LONG && !strcmp("simulate", opt)) ) {
|
||||
dbg(1, "process_options(): will do simulation\n");
|
||||
do_simulation=1;
|
||||
cli_opt_do_simulation=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'W') || (type == LONG && !strcmp("waves", opt)) ) {
|
||||
dbg(1, "process_options(): will show waves\n");
|
||||
do_waves=1;
|
||||
cli_opt_do_waves=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'n') || (type == LONG && !strcmp("netlist", opt)) ) {
|
||||
dbg(1, "process_options(): will do netlist\n");
|
||||
do_netlist=1;
|
||||
cli_opt_do_netlist=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'f') || (type == LONG && !strcmp("flat_netlist", opt)) ) {
|
||||
dbg(1, "process_options(): set flat netlist\n");
|
||||
cli_opt_flat_netlist=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'r') || (type == LONG && !strcmp("no_readline", opt)) ) {
|
||||
no_readline=1;
|
||||
} else if( (type == SHORT && *opt == 'r') || (type == LONG && !strcmp("cli_opt_no_readline", opt)) ) {
|
||||
cli_opt_no_readline=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'p') || (type == LONG && !strcmp("postscript", opt)) ) {
|
||||
dbg(1, "process_options(): will print postscript/pdf\n");
|
||||
do_print=1;
|
||||
cli_opt_do_print=1;
|
||||
|
||||
} else if( (type == LONG && !strcmp("pdf", opt)) ) {
|
||||
dbg(1, "process_options(): will print postscript/pdf\n");
|
||||
do_print=1;
|
||||
cli_opt_do_print=1;
|
||||
|
||||
} else if( (type == LONG && !strcmp("plotfile", opt)) ) {
|
||||
dbg(1, "process_options(): user plotfile specified: %s\n", optval ? optval : "NULL");
|
||||
if(optval) my_strncpy(cli_opt_plotfile, optval, S(cli_opt_plotfile));
|
||||
|
||||
} else if( (type == LONG && !strcmp("rcfile", opt)) ) {
|
||||
dbg(1, "process_options(): user rcfile specified: %s\n", optval ? optval : "NULL");
|
||||
if(optval) my_strncpy(rcfile, optval, S(rcfile));
|
||||
} else if( (type == LONG && !strcmp("cli_opt_rcfile", opt)) ) {
|
||||
dbg(1, "process_options(): user cli_opt_rcfile specified: %s\n", optval ? optval : "NULL");
|
||||
if(optval) my_strncpy(cli_opt_rcfile, optval, S(cli_opt_rcfile));
|
||||
|
||||
} else if( (type == LONG && !strcmp("png", opt)) ) {
|
||||
dbg(1, "process_options(): will print png\n");
|
||||
do_print=2;
|
||||
cli_opt_do_print=2;
|
||||
|
||||
} else if( (type == LONG && !strcmp("tcl", opt)) ) {
|
||||
dbg(1, "process_options(): passing tcl command to interpreter: %s\n", optval);
|
||||
if(optval) my_strdup(110, &tcl_command, optval);
|
||||
if(optval) my_strdup(110, &cli_opt_tcl_command, optval);
|
||||
|
||||
} else if( (type == LONG && !strcmp("script", opt)) ) {
|
||||
dbg(1, "process_options(): passing tcl script file to interpreter: %s\n", optval);
|
||||
if(optval) my_strncpy(tcl_script, optval, S(tcl_script));
|
||||
if(optval) my_strncpy(cli_opt_tcl_script, optval, S(cli_opt_tcl_script));
|
||||
|
||||
} else if( (type == LONG && !strcmp("tcp_port", opt)) ) {
|
||||
dbg(1, "process_options(): setting tcp port: %s\n", optval);
|
||||
|
|
@ -84,14 +84,14 @@ void check_opt(char *opt, char *optval, int type)
|
|||
|
||||
} else if( (type == LONG && !strcmp("svg", opt)) ) {
|
||||
dbg(1, "process_options(): will print png\n");
|
||||
do_print=3;
|
||||
cli_opt_do_print=3;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'c') || (type == LONG && !strcmp("color_ps", opt)) ) {
|
||||
dbg(1, "process_options(): set color postscript\n");
|
||||
color_ps=1;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'i') || (type == LONG && !strcmp("no_rcload", opt)) ) {
|
||||
load_initfile=0;
|
||||
cli_opt_load_initfile=0;
|
||||
|
||||
} else if( (type == SHORT && *opt == 'l') || (type == LONG && !strcmp("log", opt)) ) {
|
||||
if(optval) {
|
||||
|
|
@ -106,7 +106,7 @@ void check_opt(char *opt, char *optval, int type)
|
|||
|
||||
} else if( (type == SHORT && *opt == 'N') || (type == LONG && !strcmp("netlist_filename", opt)) ) {
|
||||
dbg(1, "process_options(): set netlist name to %s\n", optval);
|
||||
if(optval) my_strncpy(initial_netlist_name, optval, S(initial_netlist_name));
|
||||
if(optval) my_strncpy(cli_opt_initial_netlist_name, optval, S(cli_opt_initial_netlist_name));
|
||||
|
||||
} else if( (type == SHORT && *opt == 's') || (type == LONG && !strcmp("spice", opt)) ) {
|
||||
dbg(1, "process_options(): set netlist type to spice\n");
|
||||
|
|
@ -191,7 +191,7 @@ int process_options(int argc, char *argv[])
|
|||
else if(!strcmp("netlist_path", opt)) {
|
||||
optval = argv[++i];
|
||||
}
|
||||
else if(!strcmp("rcfile", opt)) {
|
||||
else if(!strcmp("cli_opt_rcfile", opt)) {
|
||||
optval = argv[++i];
|
||||
}
|
||||
else if(!strcmp("plotfile", opt)) {
|
||||
|
|
|
|||
44
src/xinit.c
44
src/xinit.c
|
|
@ -676,7 +676,7 @@ void xwin_exit(void)
|
|||
my_free(1102, &pixdata[i]);
|
||||
}
|
||||
my_free(1122, &pixdata);
|
||||
my_free(1138, &tcl_command);
|
||||
my_free(1138, &cli_opt_tcl_command);
|
||||
clear_expandlabel_data();
|
||||
get_sym_template(NULL, NULL); /* clear static data in function */
|
||||
list_tokens(NULL, 0); /* clear static data in function */
|
||||
|
|
@ -1832,12 +1832,12 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
/* */
|
||||
/* SOURCE xschemrc file */
|
||||
/* */
|
||||
if(load_initfile) {
|
||||
if(cli_opt_load_initfile) {
|
||||
/* get xschemrc given om cmdline, in this case do *not* source any other xschemrc*/
|
||||
if(rcfile[0]) {
|
||||
my_snprintf(name, S(name), rcfile);
|
||||
if(cli_opt_rcfile[0]) {
|
||||
my_snprintf(name, S(name), cli_opt_rcfile);
|
||||
if(stat(name, &buf) ) {
|
||||
/* rcfile given on cmdline is not existing */
|
||||
/* cli_opt_rcfile given on cmdline is not existing */
|
||||
fprintf(errfp, "Tcl_AppInit() err 2: cannot find %s\n", name);
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_Exit(EXIT_FAILURE);
|
||||
|
|
@ -1929,8 +1929,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
|
||||
|
||||
/* Execute tcl script given on command line with --tcl */
|
||||
if(tcl_command) {
|
||||
tcleval(tcl_command);
|
||||
if(cli_opt_tcl_command) {
|
||||
tcleval(cli_opt_tcl_command);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2209,7 +2209,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
n = tclgetvar("netlist_dir");
|
||||
fprintf(errfp, "problems creating netlist directory %s\n", n ? n : "<NULL>");
|
||||
}
|
||||
if(initial_netlist_name[0]) my_strncpy(xctx->netlist_name, initial_netlist_name, S(initial_netlist_name));
|
||||
if(cli_opt_initial_netlist_name[0]) my_strncpy(xctx->netlist_name, cli_opt_initial_netlist_name, S(cli_opt_initial_netlist_name));
|
||||
|
||||
enable_layers();
|
||||
|
||||
|
|
@ -2236,11 +2236,11 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
#endif
|
||||
dbg(1, "Tcl_AppInit(): cli_opt_filename %s given, removing symbols\n", cli_opt_filename);
|
||||
remove_symbols();
|
||||
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
|
||||
/* if cli_opt_do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
|
||||
to tcl is_xschem_file that could change xctx->netlist_type to symbol */
|
||||
load_schematic(1, f, !do_netlist);
|
||||
load_schematic(1, f, !cli_opt_do_netlist);
|
||||
tclvareval("update_recent_file {", f, "}", NULL);
|
||||
} else if(!tcl_script[0]) {
|
||||
} else if(!cli_opt_tcl_script[0]) {
|
||||
char * tmp;
|
||||
char fname[PATH_MAX];
|
||||
tmp = (char *) tclgetvar("XSCHEM_START_WINDOW");
|
||||
|
|
@ -2249,15 +2249,15 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
#endif
|
||||
dbg(1, "Tcl_AppInit(): tmp=%s\n", tmp? tmp: "NULL");
|
||||
my_strncpy(fname, abs_sym_path(tmp, ""), S(fname));
|
||||
/* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
|
||||
/* if cli_opt_do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call
|
||||
to tcl is_xschem_file that could change xctx->netlist_type to symbol */
|
||||
load_schematic(1, fname, !do_netlist);
|
||||
load_schematic(1, fname, !cli_opt_do_netlist);
|
||||
}
|
||||
|
||||
|
||||
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the initial area to display */
|
||||
xctx->pending_fullzoom=1;
|
||||
if(do_netlist) {
|
||||
if(cli_opt_do_netlist) {
|
||||
if(debug_var>=1) {
|
||||
if(xctx->flat_netlist)
|
||||
fprintf(errfp, "xschem: flat netlist requested\n");
|
||||
|
|
@ -2279,12 +2279,12 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
fprintf(errfp, "xschem: please set netlist_dir in xschemrc\n");
|
||||
}
|
||||
}
|
||||
if(do_print) {
|
||||
if(cli_opt_do_print) {
|
||||
if(!cli_opt_filename[0]) {
|
||||
dbg(0, "xschem: can't do a print without a filename\n");
|
||||
tcleval("exit");
|
||||
}
|
||||
if(do_print==1) {
|
||||
if(cli_opt_do_print==1) {
|
||||
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
|
|
@ -2298,7 +2298,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
xctx->areah = xctx->areay2-xctx->areay1;
|
||||
zoom_full(0, 0, 2, 0.97);
|
||||
ps_draw(7);
|
||||
} else if(do_print == 2) {
|
||||
} else if(cli_opt_do_print == 2) {
|
||||
if(!has_x) {
|
||||
dbg(0, "xschem: can not do a png export if no X11 present / Xserver running (check if DISPLAY set).\n");
|
||||
} else {
|
||||
|
|
@ -2309,7 +2309,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
else svg_draw();
|
||||
}
|
||||
|
||||
if(do_simulation) {
|
||||
if(cli_opt_do_simulation) {
|
||||
if(!cli_opt_filename[0]) {
|
||||
fprintf(errfp, "xschem: can't do a simulation without a filename\n");
|
||||
tcleval("exit");
|
||||
|
|
@ -2317,7 +2317,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
tcleval( "simulate");
|
||||
}
|
||||
|
||||
if(do_waves) {
|
||||
if(cli_opt_do_waves) {
|
||||
if(!cli_opt_filename[0]) {
|
||||
fprintf(errfp, "xschem: can't show simulation waves without a filename\n");
|
||||
tcleval("exit");
|
||||
|
|
@ -2331,13 +2331,13 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
tcleval("update; source_user_tcl_files");
|
||||
|
||||
/* source tcl file given on command line with --script */
|
||||
if(tcl_script[0]) {
|
||||
if(cli_opt_tcl_script[0]) {
|
||||
char str[PATH_MAX + 40];
|
||||
/* can not use tclvareval() here because if script contains 'exit'
|
||||
* program terminates before tclvareval() has a chance to cleanup
|
||||
* its dynamically allocated string
|
||||
*/
|
||||
my_snprintf(str, S(str), "update; source {%s}", tcl_script);
|
||||
my_snprintf(str, S(str), "update; source {%s}", cli_opt_tcl_script);
|
||||
tcleval(str);
|
||||
}
|
||||
|
||||
|
|
@ -2357,7 +2357,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
/* */
|
||||
|
||||
|
||||
if(!detach && !no_readline) {
|
||||
if(!detach && !cli_opt_no_readline) {
|
||||
tcleval( "if {![catch {package require tclreadline}]} "
|
||||
"{::tclreadline::readline builtincompleter 0;"
|
||||
/* "::tclreadline::readline customcompleter completer;" */
|
||||
|
|
|
|||
20
src/xschem.h
20
src/xschem.h
|
|
@ -969,29 +969,19 @@ extern int debug_var;
|
|||
/*********** These variables are NOT mirrored in tcl code ***********/
|
||||
extern int help;
|
||||
extern char *cad_icon[];
|
||||
extern int do_print;
|
||||
extern FILE *errfp;
|
||||
extern int no_readline;
|
||||
extern char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */
|
||||
extern char user_conf_dir[PATH_MAX]; /* usually ~/.xschem */
|
||||
extern char pwd_dir[PATH_MAX]; /* obtained via getcwd() */
|
||||
extern int load_initfile;
|
||||
extern char rcfile[PATH_MAX];
|
||||
extern char *tcl_command;
|
||||
extern char tcl_script[PATH_MAX];
|
||||
extern int tcp_port;
|
||||
extern int text_svg;
|
||||
extern int text_ps;
|
||||
extern double cadhalfdotsize;
|
||||
extern char initial_netlist_name[PATH_MAX];
|
||||
extern char bus_char[];
|
||||
extern int yyparse_error;
|
||||
extern char *xschem_executable;
|
||||
extern Tcl_Interp *interp;
|
||||
extern double *character[256];
|
||||
extern int do_netlist;
|
||||
extern int do_simulation;
|
||||
extern int do_waves;
|
||||
extern int quit;
|
||||
extern int detach; /* no TCL console */
|
||||
extern const char fopen_read_mode[]; /* "r" on unix, "rb" on windows */
|
||||
|
|
@ -1004,6 +994,16 @@ extern int cli_opt_flat_netlist;
|
|||
extern char cli_opt_plotfile[PATH_MAX];
|
||||
extern char cli_opt_netlist_dir[PATH_MAX];
|
||||
extern char cli_opt_filename[PATH_MAX];
|
||||
extern int cli_opt_no_readline;
|
||||
extern char *cli_opt_tcl_command;
|
||||
extern int cli_opt_do_print;
|
||||
extern int cli_opt_do_netlist;
|
||||
extern int cli_opt_do_simulation;
|
||||
extern int cli_opt_do_waves;
|
||||
extern char cli_opt_tcl_script[PATH_MAX];
|
||||
extern char cli_opt_initial_netlist_name[PATH_MAX];
|
||||
extern char cli_opt_rcfile[PATH_MAX];
|
||||
extern int cli_opt_load_initfile;
|
||||
|
||||
/*********** Following data is relative to the current schematic ***********/
|
||||
extern Xschem_ctx *xctx;
|
||||
|
|
|
|||
Loading…
Reference in New Issue