Exemplo n.º 1
0
char* extract_command_str(int flags,const char *filename,int do_extract,const char* outputpath,char* type) {
  char* str;
  char* _uname_m=uname_m();
  char* _uname=uname();
  char* _homedir=configdir();
  char* exe=s_escape_string(cat(_homedir,"impls",SLASH,_uname_m,SLASH,_uname,SLASH,"7za",SLASH,"9.20",SLASH,"7za.exe",NULL));
  char *outputpath2=q(outputpath);
  char *filename2=q(filename);
  substitute_char('\\','/',outputpath2);
  outputpath2=s_escape_string(outputpath2);
  filename2=s_escape_string(filename2);
  ensure_directories_exist(outputpath2);
  if(strcmp(type,"gzip")==0 || strcmp(type,"bzip2")==0 || strcmp(type,"xz")==0) {
    str=cat("cmd /c \"",exe," ",do_extract?"x ":"l ",filename2," -so |",exe," x -ttar -si -y -o",outputpath2,"\"",NULL);
  }else if(strcmp(type,"7za")==0) {
    ensure_directories_exist(outputpath2);
    str=cat(exe," ",do_extract?"x":"t"," -y -o",outputpath2," ",filename2,NULL);
  }
  s(outputpath2),s(filename2),s(_homedir),s(_uname),s(_uname_m);
  return str;
}
Exemplo n.º 2
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;
}