int cmd_impl (int argc,char **argv,struct sub_command* cmd) { if(argc==1 && get_opt("default.lisp",0)) { char* impl=determin_impl(get_opt("default.lisp",0)); printf("%s\n",impl); s(impl); } if(argc==2) { char* impl=determin_impl(argv[1]); printf("%s\n",impl); s(impl); } return 0; }
int cmd_run_star(int argc,char **argv,struct sub_command* cmd) { int ret=1; char* config=configdir(); set_opt(&local_opt,"quicklisp",s_escape_string(cat(config,"impls",SLASH,"ALL",SLASH,"ALL",SLASH,"quicklisp",SLASH,NULL)),0); set_opt(&local_opt,"argv0",argv_orig[0],0); set_opt(&local_opt,"wargv0",which(argv_orig[0]),0); set_opt(&local_opt,"homedir",config,0); if(rc) { char* init=s_cat(configdir(),q("init.lisp"),NULL); #ifdef _WIN32 char* etc=""; #else char* etc="/etc/rosrc"; #endif char* current=get_opt("program",0); char *path,*would; if(file_exist_p(init)) { path=cat("(:load \"",init,"\")",NULL); would=cat(path,current?current:"",NULL); s(current); set_opt(&local_opt,"program",would,0); s(path); } s(init); current=get_opt("program",0); if(file_exist_p(etc)) { path=cat("(:load \"",etc,"\")",NULL); would=cat(path,current?current:"",NULL); set_opt(&local_opt,"program",would,0); } } char*lisp=get_opt("lisp",1); if(!lisp) lisp=get_opt("*lisp",0); set_opt(&local_opt,"impl",determin_impl(lisp),0); char** arg=NULL; int i; char* wrap=get_opt("wrap",1); { struct sub_command cmd; int i; char *_= get_opt("impl",0); i=position_char("/",_); cmd.name=subseq(_,0,i); cmd.short_name=subseq(_,i+1,0); for(i=0;i<sizeof(impls_to_run)/sizeof(struct run_impl_t);++i) if(strcmp(impls_to_run[i].name,cmd.name)==0) { arg=impls_to_run[i].impl(argc,argv,&cmd); break; } s((char*)cmd.name),s((char*)cmd.short_name); } if(wrap) arg[0]=q(wrap); if(arg && file_exist_p(arg[1])) { char* opts=sexp_opts(local_opt); setenv("ROS_OPTS",opts,1); if(verbose&1 ||testing) { fprintf(stderr,"args "); for(i=0;arg[i]!=NULL;++i) fprintf(stderr,"%s ",arg[i]); fprintf(stderr,"\nROS_OPTS %s\n",getenv("ROS_OPTS")); if(testing) s(opts),exit(EXIT_SUCCESS); } s(opts); #ifdef _WIN32 { char* cmd=q(arg[wrap?0:1]); for(i=wrap?1:2;arg[i]!=NULL;++i) { cmd=s_cat(cmd,q(" "),q("\""),escape_string(arg[i]),q("\""),NULL); } SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); exit(System(cmd)); s(cmd); } #else execvp(arg[wrap?0:1],&(arg[wrap?0:1])); #endif }else fprintf(stderr,"%s is not installed.stop.\n",get_opt("impl",0)); s(config); return ret; }