Beispiel #1
0
static int get_params(char *cname, int  argc, char *argv[] )
{
	int	ival;

	if (argc != 2) {
		fprintf( stderr, "%s:  require 2 file names as parameters\n", cname );
		return( -1 );
	}

	ival = access( argv[ 0 ], R_OK );
	if (ival != 0) {
		fprintf( stderr, "%s: cannot access %s\n", cname, argv[ 0 ] );
		perror( "reason" );
		return( -1 );
	} 
	ival = P_read( CURRENT, argv[ 0 ] );
	if (ival != 0) {
		fprintf( stderr, "error reading shims from %s\n", argv[ 0 ] );
		return( -1 );
	}

	ival = access( argv[ 1 ], R_OK );
	if (ival != 0) {
		fprintf( stderr, "%s: cannot access %s\n", cname, argv[ 1 ] );
		perror( "reason" );
		return( -1 );
	} 
	ival = P_read( PROCESSED, argv[ 1 ] );
	if (ival != 0) {
		fprintf( stderr, "error reading shims from %s\n", argv[ 1 ] );
		return( -1 );
	}

	return( 0 );
}
Beispiel #2
0
/*
 * NAME:	get_line()
 * DESCRIPTION:	read a line from the input, return as '\0'-terminated string
 *		without '\n'
 */
static char *get_line()
{
    char c, *p, *bp;
    int i;

    if (iostat->ill) {
	/* previous line was incomplete, therefore the last */
	return (char *) NULL;
    }

    p = lbuf;
    bp = bufp;
    i = inbuf;
    do {
	if (i == 0) {	/* buffer empty */
	    i = P_read(ffd, buffer, BUF_SIZE);
	    if (i <= 0) {
		/* eof or error */
		if (i < 0) {
		    error("error while reading file \"/%s\"", filename);
		}
		if (p == lbuf) {
		    return (char *) NULL;
		} else {
		    p++;	/* make room for terminating '\0' */
		    iostat->ill = TRUE;
		    break;
		}
	    }
	    bp = buffer;
	}
	--i;
	c = *bp++;
	if (c == '\0') {
	    iostat->zero++;	/* skip zeroes */
	} else {
	    if (p == lbuflast && c != LF) {
		iostat->split++;
		i++;
		--bp;
		c = LF;
	    }
	    *p++ = c;
	}
    } while (c != LF);	/* eoln */

    iostat->lines++;
    iostat->chars += p - lbuf;	/* including terminating '\0' */
    bufp = bp;
    inbuf = i;
    *--p = '\0';
    return lbuf;
}
Beispiel #3
0
static int get_system_globals(char *cname )
{
	char		*systemdir;
	char		 conpar_path[ MAXPATHL ];
	int		 ival;
	extern char	*getenv();

	systemdir = getenv( "vnmrsystem" );
	if (systemdir == NULL) {
		fprintf( stderr, "error in %s: 'vnmrsystem' not defined\n", cname );
		return( -1 );
	}

	if (strlen( systemdir ) > MAXPATHL-10) {
		fprintf( stderr,
	    "error in %s: 'vnmrsystem' has too many characters\n", cname
		);
		return( -1 );
	}

	strcpy( &conpar_path[ 0 ], systemdir );
#ifdef UNIX
	strcat( &conpar_path[ 0 ], "/conpar" );
#else
	strcat( &conpar_path[ 0 ], "conpar" );
#endif

	ival = access( &conpar_path[ 0 ], R_OK );
	if (ival != 0) {
		fprintf( stderr, "%s: cannot access %s\n", cname, &conpar_path[ 0 ] );
		perror( "reason" );
		return( -1 );
	} 
	ival = P_read( SYSTEMGLOBAL, &conpar_path[ 0 ] );
	return( ival );
}
Beispiel #4
0
int AspFrame::loadSession(char *path) {
   struct stat fstat;
   string dir="";
   char sessionFile[MAXSTR2],file[MAXSTR2];
   if(stat(path, &fstat) != 0) {
        Winfoprintf("Error: cannot find %s.",path);
        return 0;
   } else if(fstat.st_mode & S_IFDIR) { // is a directory
         dir = string(path);
	 sprintf(sessionFile,"%s/aspSession",path);
   } else {
         string tmp = string(path);
	 dir = tmp.substr(0,tmp.find_last_of("/"));
	 sprintf(sessionFile,"%s",path);
   }

   FILE *fp;
   if(!(fp = fopen(sessionFile, "r"))) {
	Winfoprintf("Failed to open session file %s.",sessionFile);
	return 0;
   }

   traceList->clearList();	
   selTraceList->clearList();	
   peakList->clearList();	
   integList->clearList();	
   annoList->clearList();	

   char  buf[MAXSTR2], words[MAXWORDNUM][MAXSTR2], *tokptr;
   int nw, count=0;
   int ntraces = 0;
   char str[MAXSTR2];
   string root="";
   while (fgets(buf,sizeof(buf),fp)) {
      if(strlen(buf) < 1 || buf[0] == '#') continue;
          // break buf into tok of parameter names

      nw=0;
      tokptr = strtok(buf, ", :\n\r");
      while(tokptr != NULL) {
        if(strlen(tokptr) > 0) {
          strcpy(words[nw], tokptr);
          nw++;
        }
        tokptr = strtok(NULL, ", :\n\r");
      }

      if(nw < 2) continue;

      if(strcasecmp(words[0],"disFlags")==0 && nw > 4) {
	//e.g. disFlags: 0 132096 0 256
	disFlag = atoi(words[1]);	
	axisFlag = atoi(words[2]);	
	annoFlag = atoi(words[3]);	
	specFlag = atoi(words[4]);	
	if(nw > 5) peakFlag = atoi(words[5]);	
	if(nw > 6) integFlag = atoi(words[6]);	
      } else if(strcasecmp(words[0],"disParams")==0 && nw > 1) {
	//e.g. disParams: 22.000000 8.000000
	if(nw > 2) {
	   P_setreal(CURRENT, "vp", atof(words[1]), 1);
	   P_setreal(CURRENT, "vo", atof(words[2]), 1);
	}
      } else if(strcasecmp(words[0],"root")==0 && nw > 1) {
        root=string(words[1]);
	if(root.find_last_of("/") == root.length()-1)
	   root=root.substr(0,root.length()-1);
      } else if(strcasecmp(words[0],"procpar")==0 && nw > 1) {
         P_read(CURRENT,words[1]);
      } else if(nw > 11 && strstr(words[0],"load") == words[0]) {
        if(root != "" && words[2][0] != '/') {
	   strcpy(str,words[2]);
	   sprintf(words[2],"%s/%s",root.c_str(),str);
	}
	//e.g. load 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0
	//e.g. load 2 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0
	// each line corresponds to a AspTrace	
        spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw));
	trace->rootPath=string(root);
	sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd);
	string newKey = string(str); 
	traceList->addTrace(newKey, trace);
	selTraceList->maxInd= traceList->getSize();
	ntraces++;	
	count++;

      } else if(nw > 11 && (strstr(words[0],"add") == words[0] || 
		strstr(words[0],"sub") == words[0] || strstr(words[0],"rep") == words[0])) {

        if(root != "" && words[2][0] != '/') {
	   strcpy(str,words[2]);
	   sprintf(words[2],"%s/%s",root.c_str(),str);
	}
	//e.g. add 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0
	//e.g. sub 1 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0
	// each line corresponds to a AspTrace to be add/sub to a specified trace	
        spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw));
	trace->rootPath=string(root);
	int flag = (strstr(words[0],"sub") == words[0]) ? SUB_TRACE:ADD_TRACE;
        if(strstr(words[0],"rep") == words[0]) flag = REP_TRACE;
        spAspTrace_t sumTrace = traceList->getTraceByInd(atoi(words[1])-1);
        if(sumTrace != nullAspTrace) sumTrace->sumTrace(trace,flag);
	else {
	   sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd);
	   string newKey = string(str); 
	   traceList->addTrace(newKey, trace);
	   selTraceList->maxInd= traceList->getSize();
	}
	count++;
      } else if(strcasecmp(words[0],"color")==0 && nw > 4) {
	spAspTrace_t trace = traceList->getTraceByInd(atoi(words[1])-1);
	if(trace != nullAspTrace) {
	   double min = atof(words[3]);
	   double max = atof(words[4]);
	   string str = string("");
           spAspTrace_t sumTrace = spAspTrace_t(new AspTrace(0,str,str,0,0,min,max));
	   sumTrace->colorStr=string(words[2]);
	
	   list<spAspTrace_t> *sumList = trace->getSumTraceList();
	   sumList->push_back(sumTrace);
	}
      } else if(strcasecmp(words[0],"displayed_traces")==0 && nw > 1) {
	//e.g. displayed_traces: 1 2 3 4 5 6 7 8 9 10
	int i;
	for(i=1; i<nw;i++) {
	   spAspTrace_t trace = traceList->getTraceByInd(atoi(words[i])-1);
           if(trace != nullAspTrace) {
	     trace->selected=false;
             selTraceList->addTrace(trace->getKeyInd(), trace);
           }

	}
	selTraceList->maxInd= traceList->getSize();
		
      } else if(strcasecmp(words[0],"roiFile")==0 && nw > 1) {
	sprintf(file,"%s/%s",dir.c_str(),words[1]);
	loadRois(file);
      } else if(strcasecmp(words[0],"annoFile")==0 && nw > 1) {
   	spAspFrame_t frame = AspFrameMgr::get()->getFrame(this);
	sprintf(file,"%s/%s",dir.c_str(),words[1]);
	AspDisAnno::load(frame, file);
      } else if(strcasecmp(words[0],"peakFile")==0 && nw > 1) {
	sprintf(file,"%s/%s",dir.c_str(),words[1]);
   	spAspFrame_t frame = AspFrameMgr::get()->getFrame(this);
	AspDisPeaks::load(frame, file);
      } else if(strcasecmp(words[0],"integFile")==0 && nw > 1) {
	sprintf(file,"%s/%s",dir.c_str(),words[1]);
   	spAspFrame_t frame = AspFrameMgr::get()->getFrame(this);
	AspDisInteg::load(frame, file);
      } 
   }

   // display all traces if displayed_traces: is missing
   if(selTraceList->getSize() < 1) {
     for(int i=0; i<traceList->getSize(); i++) {
        spAspTrace_t trace = traceList->getTraceByInd(i);
        if(trace != nullAspTrace) {
          trace->selected=false;
          selTraceList->addTrace(trace->getKeyInd(), trace);
        }
     }
   }

   fclose(fp);

   if(specFlag) {
      AspMouse::setState(AspMouse::cursor1);
      Wsetgraphicsdisplay("");
   } else {
      AspMouse::setState(AspMouse::noState);
   } 
   getDefaultDataInfo(true);

   draw();
   return count;
}
Beispiel #5
0
rawTime64 pd_thread::getRawCpuTime_sw() {
   int status, fd;
   rawTime64 result = 0;
   int bufsize = 255;
   unsigned long utime, stime;
   char procfn[bufsize], *buf;

   cputime_access++;
   
   unsigned lwpId = dyninst_thread->getLWP();
   
   if( use_task_stat == 0 ) {
      // Check if we should use /proc/*/task/*stat.
      status = snprintf( procfn, 254, "/proc/%d/task/%d/stat", lwpId, lwpId );
      assert(! (status < 0 || status > 254));
      fd = P_open( procfn, O_RDONLY, 0 );
      if( fd < 0 ) {
         use_task_stat = -1;
      } else {
         P_close( fd );
         use_task_stat = 1;
      }
   }
   
   if( use_task_stat == -1 ) {
      // /* DEBUG */ fprintf( stderr, "%s[%d]: using /proc/*/stat\n", __FILE__, __LINE__ );
      status = snprintf( procfn, 254, "/proc/%d/stat", lwpId );
      assert(! (status < 0 || status > 254));
   }
   else if( use_task_stat == 1 ) {
      // /* DEBUG */ fprintf( stderr, "%s[%d]: using /proc/*/task/*/stat\n", __FILE__, __LINE__ );
      status = snprintf( procfn, 254, "/proc/%d/task/%d/stat", lwpId, lwpId );
      assert(! (status < 0 || status > 254));
   }
      
   // The reason for this complicated method of reading and sseekf-ing is
   // to ensure that we read enough of the buffer 'atomically' to make sure
   // the data is consistent.  Is this necessary?  I *think* so. - nash
   do {
      fd = P_open(procfn, O_RDONLY, 0);
      if (fd < 0) {
         perror("getInferiorProcessCPUtime (open)");
         return sw_previous_;
      }
      
      buf = new char[ bufsize ];
      
      if ((int)P_read( fd, buf, bufsize ) < 0) {
         perror("getInferiorProcessCPUtime");
         return sw_previous_;
      }
      
      /* While I'd bet that any of the numbers preceding utime and stime 
         could overflow a signed int on IA-64, the compiler whines if you 
         add length specifiers to elements whose conversion has been 
         surpressed. */
      if(2==sscanf(buf,
            "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu %lu ",
             &utime, &stime ) ) 
      {
         // These numbers are in 'jiffies' or timeslices.
         // Oh, and I'm also assuming that process time includes system time
         result = static_cast<rawTime64>(utime) + static_cast<rawTime64>(stime);
         break;
      }

      delete [] buf;
      bufsize = bufsize * 2;
      
      P_close( fd );
   } while ( true );
   
   delete [] buf;
   P_close(fd);
   
   if (result < sw_previous_) {
      pdlogLine("********* time going backwards in paradynd **********\n");
      result = sw_previous_;
   }
   else 
      sw_previous_ = result;

   return result;
}
Beispiel #6
0
void bootup(char *modeptr, int enumber)
/*****************************/
{
    char	 autodir[MAXPATH];
    char         parampath[MAXPATH];
    char         plotname[STR64];
    char         mstr[MAXPATH];
    char         rtautocmd[2 * MAXPATH + 20];
    char	 estring[5];
    extern char  PlotterName[];
    extern char  PrinterName[];
    int do_rt = 0;
    int lval;
    endian_tester et;

    (void) modeptr;
    et.my_int = 0x0a0b0c0d;
    BigEndian = (et.my_bytes[0] == 0x0a) ? 1:0;
    psg_pid = 0;		/* set pids to zero */

    if ( !Bnmr )
       disp_status("BOOTUP  ");

/*  May 18, 1987.  Addition to read the system global parameters.
    If a problem occurs, the program exits immediately, for this
    should not happen.  The CONPAR file is on the distribution tape.	*/

    strcpy(parampath,systemdir);
#ifdef UNIX
    strcat(parampath,"/conpar");
#else 
    strcat(parampath,"conpar");
#endif 
    if (P_read(SYSTEMGLOBAL,parampath)) 
    {
	fprintf(stderr,"problem loading system global parameters from %s\n",
		parampath);
	exit(1);
    }
    openVnmrInfo(systemdir);

/*  If automation mode, use value of autodir to establish path to experiment  */

    if (mode_of_vnmr == AUTOMATION)
    {
      getAutoDir(autodir, MAXPATH);
      if (strlen(autodir) == 0)
      {
	  fprintf( stderr, "unable to access 'autodir' parameter\n" );
	  exit(1);
      }
    }

    /* setup signal handlers to catch these signals */
    if (Wissun())		/* Only do this if using SUN console */
    {
        set_acqi_signal();
    }
    else if (mode_of_vnmr == FOREGROUND) /* Only creat a Vnmr socket if foreground */
    {

	setupVnmrAsync(AcqSocketIsRead);
    }

#ifndef VNMRJ
    if (Wishds())
	last_line = 19;
    else
#endif
	last_line = 20;

    /* load parameters in global file */
    /* moved 9 lines to read GLOBAL before EXP, this way we can use
       curexpdir to restart Vnmr in the last exp used. May 17, 1997 */

    strcpy(parampath,userdir);
    strcat(parampath,"/global");
    if (P_read(GLOBAL,parampath)) 
	Werrprintf("problem loading global parameters");
#ifdef VNMRJ
   // set curexpdir based on jcurwin of viewport 1
   jcurwin_init(curexpdir);
#endif

     // load unshared globalX for viewport X if foreground
     if (!Bnmr)
     {
        sprintf(parampath,"%s/global%d",userdir,VnmrJViewId);
        /* Don't complain if unshared globals are missing */
        P_read(GLOBAL,parampath);
     }

    // set OperatorName 
    if ( (P_getstring(GLOBAL,"operator",OperatorName,1,MAXSTR) != 0) ||
         ( ! strcmp(OperatorName, "") ) )
	strcpy(OperatorName, UserName);

/*  If lock fails, and program is running in foreground mode, set
    current experiment to be EXP0, which doesn't exist.  The user
    can then join another experiment or use other techniques to
    unlock the desired experiment.

    If running in any other mode, exit immediately with an error
    message.							*/

/* May 19, 1997. Use curexpdir to set the enumber, check if directory
   still exists, if not make it exp1. Only done if FOREGROUND Vnmr.
   Acqproc, autoproc, and other procs determine enumber themselves.
   Note that curexpdir is overwritten below, when we read exp parameters */

#ifdef VNMRJ
   jviewport_init();
   P_setstring(GLOBAL,"curexp",curexpdir,1);
#else 
   P_getstring(GLOBAL,"curexp",curexpdir,1,MAXPATH);
#endif 
   if (mode_of_vnmr == FOREGROUND)
   {
      enumber = expdir_to_expnum(curexpdir);
      if (enumber == 0)
         lval = -1;
      else if ( ! access(curexpdir,F_OK))
        lval = lockExperiment( enumber, FOREGROUND);
      else
        lval = -1;
   }
#ifdef SUN
   else if (mode_of_vnmr == ACQUISITION)
      lval = (enumber == 0) ? -2 :checkAcqLock( enumber );
   else if ( Bnmr && (enumber == 0) )
      lval = -2;
   else
#endif
      lval = lockExperiment( enumber, mode_of_vnmr );

    if (lval != 0)
    {
        if ((mode_of_vnmr != FOREGROUND) && (lval != -2) )
        {
	    fprintf( stderr, "unable to lock experiment %d\n", enumber);
	    exit(1);
	}
        if (enumber == 0)
        {
#ifdef VNMRJ
           if (VnmrJViewId != 1)
           {
	      P_getstring(GLOBAL, "jviewportlabel", mstr, VnmrJViewId, MAXPATH);
	      Werrprintf( "No experiment selected for the %s viewport.",mstr);
           }
           jcurwin_setexp( "0" , -1 );
#else 
           if (lval != -2)
	      Werrprintf( "No experiment selected.");
#endif 
        }
        else
        {
#ifdef VNMRJ
           if (VnmrJViewId == 1)
	      Werrprintf( "Unable to lock experiment %d", enumber );
           else
           {
	      P_getstring(GLOBAL, "jviewportlabel", mstr, VnmrJViewId, MAXPATH);
	      Werrprintf( "Unable to lock experiment %d for the %s viewport.",enumber, mstr);
           }
           jcurwin_setexp( "0", -1 );
#else 
	   Werrprintf( "Unable to lock experiment %d", enumber );
#endif 
        }
        strcpy( curexpdir, userdir );
#ifdef UNIX
        strcat( curexpdir, "/exp0" );
#else 
	vms_fname_cat( curexpdir, "[.exp0]" );
#endif 
#ifdef VNMRJ
        if (mode_of_vnmr != AUTOMATION)
        { 
           sprintf(mstr,"exp0 %s",curexpdir);
           writelineToVnmrJ("expn",mstr);
        }
#endif
    }

/*  Only read in parameters if the target experiment was locked.  */

    else
    {
	if (mode_of_vnmr == AUTOMATION)
	  strcpy( curexpdir, &autodir[ 0 ] );
	else
          strcpy( curexpdir, userdir );

	sprintf(estring, "%d", enumber);
#ifdef UNIX
        strcat(curexpdir, "/exp");
	strcat(curexpdir, estring);
#else 
        vms_fname_cat(curexpdir, "[.exp");
        vms_fname_cat(curexpdir, estring);
        vms_fname_cat(curexpdir, "]");
#endif 

        if (mode_of_vnmr == AUTOMATION)
        {
	    lval = strlen( &datadir[ 0 ] );
	    if (lval > MAXPATH-8)
	    {
	        fprintf(stderr, "data pathname too long in automation mode");
	        exit(1);
	    }
            else if (lval > 1)
            {
                int ex;

                sprintf(rtautocmd, "cp %s.fid/sampleinfo %s/sampleinfo",
                        datadir,curexpdir);
                system(rtautocmd);
                ex = 0;
                /* Wait up to 0.5 secs for fid to appear */
                while ( access(rtautocmd,R_OK) && (ex < 50) )
                {
                   struct timespec timer;

                   timer.tv_sec=0;
                   timer.tv_nsec = 10000000;   /* 10 msec */
#ifdef __INTERIX
				   usleep(timer.tv_nsec/1000);
#else
                   nanosleep( &timer, NULL);
#endif
                   ex++;
                }
	        sprintf( &rtautocmd[ 0 ], "%s('%s','nodg')\n",
                         (acqStartUseRtp) ? "RTP" : "RT", &datadir[ 0 ] );
                do_rt = 1; /* do the rt command after reading global tree */
            }
            else  /* read curpar parameters only from the automation exp */
            {
                D_getparfilepath(CURRENT, parampath, curexpdir);
                if (P_read(CURRENT,parampath))
                {  /* if no parameters in current experiment */
                   strcpy(parampath,systemdir);
#ifdef UNIX
                   strcat(parampath,"/stdpar/H1.par/procpar");
#else 
                   vms_fname_cat(parampath,"[.stdpar.H1_par]procpar");
#endif 
                   if (P_read(CURRENT,parampath))
	              Werrprintf("problem loading current parameters");
                }
                P_copy(CURRENT,PROCESSED);
            }
        }
	else       /* if (mode_of_vnmr != AUTOMATION) */
        {
           /* load parameters in curexp/curpar file */
           D_getparfilepath(CURRENT, parampath, curexpdir);
           if (P_read(CURRENT,parampath))
	       Werrprintf("problem loading current parameters from \"%s\"",
                           parampath);
           /* load parameters in curexp/procpar file */
           D_getparfilepath(PROCESSED, parampath, curexpdir);
           if (P_read(PROCESSED,parampath))
	       Werrprintf("problem loading processed parameters from \"%s\"",
                           parampath);
#ifdef VNMRJ
	   sprintf(mstr,"exp%s %s",estring,curexpdir);
	   writelineToVnmrJ("expn",mstr);
#endif 
        }
    }


    /* May 17, 1997. We read GLOBAL parameters earlier */
    setGlobalPars();
#ifdef VNMRJ
    if (!Bnmr)
       saveViewPortAddr();
#endif 
    bufferscale = getbufscale();	/* obtain the value for bufferscale */
    finddatainfo();
    DEBUGPRINT1("bufferscale set to %d\n", bufferscale);
    D_init();				/* initialize the data file handler;
					   bufferscale must be known before
					   D_init() is called.		    */

    /* setAppdirs needs to happen after operator is set in setGlobalPars but before
     * any macros are called
     */
#ifdef VNMRJ
    if (VnmrJViewId == 1)
#endif 
    {
       setAppdirs();
    }

    specIndex = 1;
    if (mode_of_vnmr == AUTOMATION)
    {
      if (do_rt)
      {
        turnOffFixpar();
        execString( &rtautocmd[ 0 ] );
      }
      else
      {
        Werrprintf( "Spectrometer in automation mode" );
      }
    }
    else if (enumber || (mode_of_vnmr != BACKGROUND) )
    {
       disp_expno();
    }
    init_proc2d();
    strcpy(dconi_runstring,"dcon\n");

    /* Assign some function pointers for the */
    /* graphics module                       */
    set_bootup_gfcn_ptrs();
    if (Bnmr)
       init_colors();  /* set default colors for graphics and plotters */

    set_automount_dir();

    /*  Set up plotting parameters */
    /*  If there is trouble setting plottin parameters (ie plotting device
        doesn't exist or devicetable/devicenames is bad, set to "none" device */
    if (P_getstring(GLOBAL,"plotter" ,plotname, 1,32))
    {  P_setstring(GLOBAL,"plotter","none",0);
       strcpy(PlotterName,"none");
    }
    if (!setPlotterName(plotname))
    {  P_setstring(GLOBAL,"plotter","none",0);
       strcpy(PlotterName,"none");
    }

    /*  Set up printing parameters */
    /*  If there is trouble setting printing parameters (ie printing device
        doesn't exist or devicetable/devicenames is bad, set to "none" device */
    if (P_getstring(GLOBAL,"printer" ,plotname, 1,32))
    {  P_setstring(GLOBAL,"printer","none",0);
       strcpy(PrinterName,"none");
    }
    if (!setPrinterName(plotname))
    {  P_setstring(GLOBAL,"Printer","none",0);
       strcpy(PrinterName,"none");
    }

#ifdef SUN
/*
 *  Set up signal handler to exit VNMR
 *  The function nmr_quit will be called when Vnmr exits
 */
    set_nmr_quit_signal();
#endif 
    check_datastation();

#ifdef VNMRJ
    writelineToVnmrJ("bootup","");
    /* create a frame for graphics display */
    frame_update("init", "");
#endif 

/*  The extra space in the first Wscrprintf is essential for
    the scrollable text subwindow to work correctly.			*/

/* ---  print revision ID and Date, Compiled within revdate.c --- */
    P_setstring( SYSTEMGLOBAL, "rev", &RevID[ 0 ], 1);
    P_setstring( SYSTEMGLOBAL, "revdate", &RevDate[ 0 ], 1);
    if (!Bnmr) /* only execute the bootup macro if we are in forground */
    {
	Wscrprintf("\n              %s\n",RevID);
        Wscrprintf("              %s\n",RevDate);

        Wscrprintf("              %s\n\n",Copyright);
        if (strlen(PlotterName) > 0)
           Wscrprintf( "              Plotting Device is set to %s\n",PlotterName);
        else
           Wscrprintf( "              Plotting Device is set to ''\n");
        if (strlen(PrinterName) > 0)
           Wscrprintf( "              Printing Device is set to %s\n\n",PrinterName);
        else
           Wscrprintf( "              Printing Device is set to ''\n\n");

        disp_current_seq();
        if (Wissun())
           sendTripleEscToMaster( 'C',"bootup(0)");
        else
	   execString("bootup(0)\n");
        disp_status("        ");
    }
    else if (enumber)
    {
	execString("bootup(1)\n");
    }

    p11_init();
}