Example #1
0
void do_view(const output_env_t oenv, const char *fn, const char *opts)
{
    char        buf[STRLEN], env[STRLEN];
    const char *cmd;
    int         ftp, n;

    if (output_env_get_view(oenv) && fn)
    {
        if (getenv("DISPLAY") == NULL)
        {
            fprintf(stderr, "Can not view %s, no DISPLAY environment variable.\n", fn);
        }
        else
        {
            ftp = fn2ftp(fn);
            sprintf(env, "GMX_VIEW_%s", ftp2ext(ftp));
            upstring(env);
            switch (ftp)
            {
                case efXVG:
                    if (!(cmd = getenv(env)) )
                    {
                        if (getenv("GMX_USE_XMGR") )
                        {
                            cmd = "xmgr";
                        }
                        else
                        {
                            cmd = "xmgrace";
                        }
                    }
                    break;
                default:
                    if ( (n = can_view(ftp)) )
                    {
                        if (!(cmd = getenv(env)) )
                        {
                            cmd = view_program[n];
                        }
                    }
                    else
                    {
                        fprintf(stderr, "Don't know how to view file %s", fn);
                        return;
                    }
            }
            if (strlen(cmd) )
            {
                sprintf(buf, "%s %s %s &", cmd, opts ? opts : "", fn);
                fprintf(stderr, "Executing '%s'\n", buf);
                if (0 != system(buf) )
                {
                    gmx_fatal(FARGS, "Failed executing command: %s", buf);
                }
            }
        }
    }
}
Example #2
0
void do_view(const output_env_t oenv,const char *fn, const char *opts)
{
  char buf[STRLEN], env[STRLEN];
  const char *cmd;
  int ftp, n;
  
  if (output_env_get_view(oenv) && fn) {
    if (getenv("DISPLAY") == NULL) {
      fprintf(stderr,"Can not view %s, no DISPLAY environment variable.\n",fn);
    } else {
      ftp=fn2ftp(fn);
      sprintf(env, "GMX_VIEW_%s", ftp2ext(ftp));
      upstring(env);
      switch(ftp) {
      case efXVG:
	if ( ! (cmd=getenv(env)) ) {
	  if ( getenv("XMGR") )
	    cmd="xmgr";
	  else
	    cmd="xmgrace";
	}
	break;
      default:
      if ( (n=can_view(ftp)) ) {
	if ( ! (cmd=getenv(env)) )
	  cmd=view_program[n];
      } else {
	fprintf(stderr,"Don't know how to view file %s",fn);
	return;
      }
      }
      if ( strlen(cmd) ) {
	sprintf(buf,"%s %s %s &",cmd,opts ? opts : "",fn);
	fprintf(stderr,"Executing '%s'\n",buf);
#ifdef GMX_NO_SYSTEM
        printf("Warning-- No calls to system(3) supported on this platform.");
        printf("Warning-- Skipping execution of 'system(\"%s\")'.", buf);
#else
	if( 0 != system(buf) )
	{
	  gmx_fatal(FARGS,"Failed executing command: %s",buf);
	}
#endif
      }
    }
  }
}