static char *exec_macro(char *data, int num) { int p, k; char *d; char cdata[120]; char mdata[16]; d = data; while (*d == ' ' || *d == '\t') d++; if (*d != '(') return(NULL); d++; p = 1; k = 0; while (p != 0) { if (*d == '\0') return (NULL); if (*d == ')') { p--; if (p == 0) { d++; break; } } else if (*d == '(') p++; cdata[k] = *d; k++; d++; } if (k > 0) { cdata[k] = '\0'; k--; while (k > 0) { if (cdata[k] == ' ') { cdata[k] = '\0'; k--; } else break; } sprintf (mdata, ":$glidev%d\n", num); strcat (cdata, mdata); execString(cdata); return (d); } else return (NULL); }
List* cmdReadLog(cmdLog* cLog, List* env, cmdLine* line) { char* prevcmd; if ((strlen(line->arguments[0])>2) || (line->arguments[0][1]<'0' || line->arguments[0][1]>'9')) { perror("illegal arguments after '!'\n"); } else { prevcmd = readLog(cLog,(line->arguments[0][1])-48); if (!prevcmd) { perror("illegal arguments after '!'\n"); } else { return execString(cLog, env, prevcmd); } } return env; }
int main (int argc , char* argv[], char* envp[]) { char my_cwd[PATH_MAX]; char buffer[2048]; cmdLog cLog; List* env= 0; intLog(&cLog); while(1) { getcwd(my_cwd, PATH_MAX); printf("%s$ ", my_cwd); fgets(buffer, 2048, stdin); if ((buffer[0] != '\n') && ((env= execString(&cLog, env, buffer)) == (List*)-1)) { break; } } clearArray(&cLog); return 0; }
void AspFrame::updateMenu() { if(ownScreen()) execString("menu('asp')\n"); else { char str[20]; Wgetgraphicsdisplay(str, 20); if(strstr(str,"dconi") == str) execString("menu('dconi')\n"); else if(strstr(str,"dss") == str) execString("menu('display_1D')\n"); else if(strstr(str,"ds") == str) execString("menu('ds_1')\n"); else if(strstr(str,"dfs") == str) execString("menu('fiddisp_1D')\n"); else if(strstr(str,"df") == str) execString("menu('dfid')\n"); } }
// Insert (another) line of text into the interpreter. OgitorsScriptConsole::State OgitorsScriptConsole::insertLine( std::string& line, bool fInsertInOutput ) { OGRE_LOCK_AUTO_MUTEX; if( fInsertInOutput == true ) { mOutput.push_back(line); } if( mFirstLine && line.substr(0,1) == "=" ) { line = "return " + line.substr(1, line.length()-1 ); } mCurrentStatement += line; mFirstLine = false; mState = LI_READY; if(mCurrentStatement == "list") { listFunctions(); } else { std::string sought = "("; int pos = mCurrentStatement.find(sought); if(pos == std::string::npos) { mCurrentStatement += std::string("()"); } execString(mCurrentStatement); } mCurrentStatement.clear(); mFirstLine = true; mPrompt = LI_PROMPT; return mState; }
int appdir(int argc, char *argv[], int retc, char *retv[]) { static char resetCmd[MAXPATH]; static int sendCmd = 0; static int sendDirs = 1; if (argc > 1) { if ( ! strcmp(argv[1],"file")) { char filepath[MAXPATH]; char operator[MAXPATH]; /* Reset appdirs */ lastOperator[0] = '\0'; appdirRight = -1; getappdirPaths(); filepath[0] = '\0'; if (P_getstring(GLOBAL,"operator",operator,1,MAXPATH-1)) { strcpy(operator,UserName); } if (appdirRight) { sprintf(filepath,"%s/persistence/appdir_%s", userdir, operator); if ( access(filepath,R_OK) ) { filepath[0] = '\0'; } } if ( (filepath[0] == '\0') && strcmp(operator,UserName) ) { P_setstring(GLOBAL,"operator",UserName,1); appdirRight = rightsEval("caneditappdir"); if (appdirRight) { sprintf(filepath,"%s/persistence/appdir_%s", userdir, UserName); if ( access(filepath,R_OK) ) { filepath[0] = '\0'; } } P_setstring(GLOBAL,"operator",operator,1); appdirRight = rightsEval("caneditappdir"); } if (filepath[0] == '\0') { getAppdirTemplate(filepath); } if (retc >= 1) retv[0] = newString(filepath); else Winfoprintf("application directory file is %s",filepath); } else if ( ! strcmp(argv[1],"index")) { if (argc == 3) { int index; int res = 0; for (index=1; index <= appdirNumPaths; index++) { if ( ! strcmp(argv[2], appdirVal(appdirPaths,index) ) ) { res = index; break; } } if (retc >= 1) retv[0] = intString(res); else if (res == 0) Winfoprintf("%s is not an appdir",argv[2]); else Winfoprintf("%s is appdir number %d of %d",argv[2],res,appdirNumPaths); } else { Werrprintf("Usage: %s('index',directory)", argv[0]); ABORT; } } else if ( ! strcmp(argv[1],"info")) { if (argc == 2) { if (retc >= 1) retv[0] = intString(appdirNumPaths); else Winfoprintf("There are %d application directories",appdirNumPaths); } else { int index = atoi(argv[2]); if ( (index <= 0) || (index > appdirNumPaths) ) { Werrprintf("Application directory %s does not exist. Second argument must be between 1 and %d", argv[2],appdirNumPaths); ABORT; } if (retc) { retv[0] = newString( appdirVal(appdirLabels,index) ); if (retc >= 2) { retv[1] = newString( appdirVal(appdirPaths,index) ); } } else { Winfoprintf("Label for application directory %d is %s", index, appdirVal(appdirLabels,index)); } } } #ifdef TODO else if ( ! strcmp(argv[1],"infoall")) { /* Return onOff, path and label */ } #endif else if ( ! strcmp(argv[1],"reset")) { char *saveAppdirPaths; lastOperator[0] = '\0'; saveAppdirPaths = newStringId(appdirPaths,"apptmp"); if (argc > 2) { /* With more than 1 argument, it is called from the login panel */ P_setstring(GLOBAL,"operator",argv[2],1); #ifdef VNMRJ { int num, index; double dval; char msg[MAXSTR]; if (!P_getreal(GLOBAL, "jviewports", &dval, 1)) { num = (int) (dval+0.1); for (index=1; index <= num; index++) { if (index != VnmrJViewId) { sprintf(msg,"VP %d setvalue('operator', '%s', 'global') vnmrjcmd('pnew','operator') appdir('update')\n",index,argv[2]); writelineToVnmrJ("vnmrjcmd",msg); } } } } appendJvarlist("operator"); // writelineToVnmrJ("pnew","1 operator"); #endif appdirRight = -1; /* check rights on next call to appdirFind */ getappdirPaths(); sprintf(resetCmd,"operatorlogin('%s','%s')\n",argv[3],argv[4]); sendCmd = 1; } else { /* With only 1 argument, it is called from the appdir editor */ getappdirPaths(); } #ifdef VNMRJ if (strcmp(saveAppdirPaths, appdirPaths) ) { /* Only update VJ panels if the appdirs has changed * Java will send an appdir('send') when it is ready * for the new appdir directories */ writelineToVnmrJ("vnmrjcmd appdir", "0"); sendDirs = 1; } if (sendCmd && ! sendDirs) { execString(resetCmd); sendCmd = 0; } { /* Update other viewports */ int num, index; double dval; char msg[MAXSTR]; if (!P_getreal(GLOBAL, "jviewports", &dval, 1)) { num = (int) (dval+0.1); for (index=1; index <= num; index++) { if (index != VnmrJViewId) { sprintf(msg,"VP %d appdir('update')\n",index); writelineToVnmrJ("vnmrjcmd",msg); } } } } #endif releaseWithId("apptmp"); } #ifdef VNMRJ else if ( ! strcmp(argv[1],"send")) { /* VJ has requested the new appdirs */ if (sendDirs) { sendAppdirs(); appendJvarlist("operator"); sendDirs = 0; } // writelineToVnmrJ("pnew","1 operator"); if (sendCmd) { execString(resetCmd); sendCmd = 0; } } else if ( ! strcmp(argv[1],"update")) { /* get current appdirs */ lastOperator[0] = '\0'; getappdirPaths(); } #endif } RETURN; }
static void dialog_sync_func(int cmd, int argc, char **argv) { int r, this_expnum, cpid; int gfd; double dval; char *retStr; DLIST *dlist; vInfo info; int ret, tree; char dstr[256]; if (debug > 1) fprintf(stderr, " dialog_sync_func: cmd= %d argc= %d\n", cmd, argc); cpid = atoi(argv[3]); if (debug > 1) fprintf(stderr, " dialog command: %d, pid %d\n", cmd, cpid); dlist = dialog_list; gfd = -1; while (dlist != NULL) { if (dlist->pid == cpid) { gfd = dlist->fout; break; } dlist = dlist->next; } if (dlist == NULL || gfd < 0) { if (debug > 1) fprintf(stderr, " dialog_sync_func: could not find process\n"); return; } if (debug > 1) fprintf(stderr, " execute command: %d, pid %d\n", cmd, cpid); switch (cmd) { case PWD: retStr = get_cwd(); write(gfd, retStr, strlen(retStr)); break; case EXPDIR: write(gfd, curexpdir, strlen(curexpdir)); break; case GEXIT: dlist->used = 0; close_fd(dlist); dlist->pid = -1; break; case GOK: /* verify console is available */ this_expnum = expdir_to_expnum( curexpdir ); r = is_exp_active( this_expnum ); sprintf(data, "%d \n", r); write(gfd, data, strlen(data)); break; case GQUERY: if (argc < 5) { strcpy(data, "0 \n"); write(gfd, data, strlen(data)); return; } retStr = NULL; if (strstr(argv[4], "macro_value") != NULL) { retStr = modify_show_str(argv[4], dstr); } if (retStr == NULL) retStr = argv[4]; queryFlag = 0; sprintf(data, "if (%s) then dialog('SYNCFUNC', %d, %d, '1') else dialog('SYNCFUNC', %d, %d, '0') endif\n", retStr, GTEST,cpid, GTEST, cpid); execString(data); if (queryFlag == 0) { strcpy(data, "0 \n"); write(gfd, data, strlen(data)); } break; case GTEST: if (argc < 5) return; queryFlag = 1; if (debug > 1) fprintf(stderr, " write to dialog: '%s'\n", argv[4]); sprintf(data, "%s \n", argv[4]); write(gfd, data, strlen(data)); break; case VEXEC: if (argc < 5) return; execString(argv[4]); break; case VGET: sprintf(data, " \n"); if (argc < 5) { write(gfd, data, strlen(data)); return; } tree = CURRENT; if ( (ret = P_getVarInfo(tree, argv[4], &info)) ) { tree = GLOBAL; ret = P_getVarInfo(tree, argv[4], &info); } if (ret != 0) { write(gfd, data, strlen(data)); return; } if (info.basicType == T_STRING) { P_getstring(tree,argv[4],data,1,1023); if (strlen(data) < 4) strcat (data, " \n"); } else { dval = 0.0; P_getreal(tree,argv[4],&dval,1); sprintf(data, "%g\n", dval); } write(gfd, data, strlen(data)); break; } }
int vnmr_unlock(int argc, char *argv[], int retc, char *retv[] ) { char host_of_lock[ MAXPATHL ], jexpcmd[ 16 ], lock_file_name[ MAXPATHL ]; int expn, ival, mode_of_lock, pid_of_lock, force; expn = check_unlock_args( argc, argv, &force ); if (expn == expdir_to_expnum(curexpdir)) RETURN; if (expn < 1) ABORT; if (get_secondary_lock( expn, SEC_LOCK_COUNT ) != 0) { Werrprintf( "%s: cannot obtain secondary lock", argv[ 0 ] ); ABORT; } get_primary_lockfile( expn, userdir, &lock_file_name[ 0 ] ); ival = verify_primary_lock( &lock_file_name[ 0 ], &mode_of_lock, &host_of_lock[ 0 ], &pid_of_lock ); remove_secondary_lock( expn ); if (ival != 0) { if (access( &lock_file_name[ 0 ], F_OK ) == 0) unlink( &lock_file_name[ 0 ] ); sprintf( &jexpcmd[ 0 ], "jexp(%d)\n", expn ); execString( &jexpcmd[ 0 ] ); RETURN; } if (!force && (mode_of_lock == ACQUISITION)) { Werrprintf( "%s: cannot remove acquisition lock", argv[ 0 ] ); ABORT; } disp_status( "UNLOCK " ); if (!force && (strcmp( &host_of_lock[ 0 ], &HostName[ 0 ] ) != 0)) { Werrprintf( "%s: experiment locked by remote host %s", argv[ 0 ], &host_of_lock[ 0 ] ); disp_status( " " ); ABORT; } ival = find_pid( pid_of_lock, argv[ 0 ] ); if ( ival < 0) { disp_status( " " ); ABORT; } else if (!force && (ival > 0)) { Werrprintf( "%s: experiment locked by active process", argv[ 0 ] ); disp_status( " " ); ABORT; } ival = unlink( &lock_file_name[ 0 ] ); if (ival != 0) { Werrprintf( "%s: unable to remove lock file", argv[ 0 ] ); disp_status( " " ); ABORT; } Winfoprintf( "experiment %d unlocked", expn ); disp_status( " " ); sprintf( &jexpcmd[ 0 ], "jexp(%d)\n", expn ); execString( &jexpcmd[ 0 ] ); RETURN; }
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(); }
int dpir(int argc, char *argv[], int retc, char *retv[]) /*************/ { int groups; int resets; int i, min, ysize; char name[64]; char tmpstr[MAXSTR]; (void) retc; (void) retv; if (argc > 1 && strcmp(argv[1],"off") == 0) { set_dpir_flag(0,""); redo_dpf_dpir(); RETURN; } else if (argc > 1 && strcmp(argv[1],"turnoff") == 0) { set_dpir_flag(0,""); RETURN; } vertflag=0; if ( ! P_getstring(GLOBAL, "integralOrient", tmpstr, 1, MAXSTR) ) { vertflag = (strcmp(tmpstr,"vert") == 0); } if (argc > 1 && strcmp(argv[1],"vert") == 0) { vertflag=1; } if(argc == 1 || strcmp(argv[1],"noli") != 0) { execString("nli\n"); } if (check_int(&resets)) { Werrprintf("intmod must not be set to 'full'"); ABORT; } if (resets <= 1) { Werrprintf("no integral resets are defined"); ABORT; } plot = (argv[0][0] == 'p'); if (select_init( 0, plot+1, NO_FREQ_DIM, NO_HEADERS, DO_CHECK2D, DO_SPECPARS, NO_BLOCKPARS, NO_PHASEFILE )) { ABORT; } if(strlen(argv[0]) > 4 && argv[0][4] == 'N') { normInt = 1; } else if(strlen(argv[0]) > 3 && argv[0][3] == 'N') { normInt = 1; } if ((groups = getregions(resets)) == 0) { ABORT; } min=mnumxpnts; for (i = 1; i <= groups; i++) { if(gb[i].lowlimit <= 0 || gb[i].highlimit <= 0 || gb[i].lowlimit >= (mnumxpnts-xcharpixels) || gb[i].highlimit >= (mnumxpnts-xcharpixels)) continue; if((gb[i].highlimit-gb[i].lowlimit) < min) min = gb[i].highlimit-gb[i].lowlimit; } if(min != 0 && min < 3*xcharpixels) ysize = 3; else ysize=2; if (!plot) { setwindows(); dispcalib = (float) (mnumypnts-ymin) / (float) wc2max; CharSize = ycharpixels + ycharpixels / 5; getOptName(INTEG_MARK,name); set_line_thickness(name); getOptName(INTEG_NUM,name); set_graphics_font(name); } else { double size = G_getCharSize("IntegralNum"); charsize(size); //charsize((double)0.7); dispcalib = ppmm / ymultiplier; CharSize = ycharpixels; } if (showPlotBox()) dpir_off=0.0; else dpir_off=9.0; if(dispcalib>0) { int size= 12; G_getSize("IntegralNum", &size); i = (int)(vp*dispcalib); if (vertflag && i < 4*size) { char cmd[64]; i = (int)(4*size/dispcalib)+1; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of %d",i); RETURN; } else if (i < 3*size) { char cmd[64]; i = (int)(3*size/dispcalib)+1; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of %d",i); RETURN; } } else { if (vp < 30) { char cmd[64]; i=30; if(vertflag) sprintf(cmd,"vp=%d ds %s('vert')\n",i,argv[0]); else sprintf(cmd,"vp=%d ds %s\n",i,argv[0]); if(!plot) execString(cmd); //Werrprintf("pir requires minimum vp of 30"); RETURN; } } //color(PARAM_COLOR); color(INTEG_MARK_COLOR); if (debug1) { Wscrprintf("dispcalib= %g, dfpnt2= %d, CharSize= %d, bottom= %d\n", dispcalib,dfpnt2,CharSize, dfpnt2 - CharSize + (int) (dispcalib * (vp - dpir_off - 5.0))); Wscrprintf("index highlimit lowlimit below\n"); for (i = 1; i <= groups; i++) Wscrprintf("%d %d %d %s\n",i,gb[i].highlimit,gb[i].lowlimit, (gb[i].below) ? "true" : "false"); } if(vertflag) { for (i = 1; i <= groups; i++) label_pirv(i); } else { for (i = 1; i <= groups; i++) label_pir(i, ysize); } if (!plot) { char cmd[64]; if(argc > 1) { if (isReal(argv[1]) ) sprintf(cmd,"%s(%s",argv[0],argv[1]); else sprintf(cmd,"%s('%s'",argv[0],argv[1]); for(i=2;i<argc;i++) { if (isReal(argv[i]) ) { strcat(cmd,","); strcat(cmd,argv[i]); } else { strcat(cmd,",'"); strcat(cmd,argv[i]); strcat(cmd,"'"); } } strcat(cmd,")\n"); } else sprintf(cmd,"%s\n",argv[0]); Wsetgraphicsdisplay("ds"); set_dpir_flag(1,cmd); } releaseAllWithId("dpir"); endgraphics(); disp_status(" "); set_graphics_font("Default"); RETURN; }
int dpf(int argc, char *argv[], int retc, char *retv[]) /*************/ { int groups; int noisemult_p = 0; int numlines,maxlines; int i; int donll = TRUE; int noneg = FALSE; int top = FALSE; char command[128]; char name[64]; (void) retc; (void) retv; Wturnoff_buttons(); leader_len = 20.0; axish = FALSE; axisp = FALSE; axisp_freq = 1.0; if (argc > 1) { for (i=1; i<argc; i++) { if (strcmp(argv[i],"off") == 0) { set_dpf_flag(0,""); redo_dpf_dpir(); RETURN; } else if (strcmp(argv[i],"turnoff") == 0) { set_dpf_flag(0,""); RETURN; } else if (strcmp(argv[i],"noll") == 0) donll = FALSE; else if (strcmp(argv[i],"pos") == 0) noneg = TRUE; else if (strcmp(argv[i],"top") == 0) top = TRUE; else if (strcmp(argv[i],"axish") == 0) axish = TRUE; else if (strcmp(argv[i],"axisp") == 0) { axisp = TRUE; P_getreal(PROCESSED,"sfrq",&axisp_freq,1); } else if (strcmp(argv[i],"leader") == 0) { if (((i+1) < argc) && isReal(argv[i+1]) ) { i++; leader_len = stringReal(argv[i]); } } else if (isReal(argv[i])) noisemult_p = i; } } if (donll) /* if not donll, dpf uses last previous line listing */ { if (noisemult_p != 0) { if (noneg) strcpy(command,"nll('dpf','pos',"); else strcpy(command,"nll('dpf',"); strcat(command,argv[noisemult_p]); strcat(command,")\n"); } else { if (noneg) strcpy(command,"nll('dpf','pos')\n"); else strcpy(command,"nll('dpf')\n"); } execString(command); } if(P_getreal(CURRENT, "dpf_sc2",&dpf_sc2,1)) dpf_sc2=sc2; if(P_getreal(CURRENT, "dpf_wc2",&dpf_wc2,1)) dpf_wc2=wc2; if(dpf_wc2>wc2) dpf_wc2=wc2; if(dpf_sc2<sc2) dpf_sc2=sc2; /* if (init2d(1,1)) return(ERROR); */ scale = vs; if (normflag) scale *= normalize; /* Wscrprintf("normflag=%d normalize=%g\n",normflag,normalize); */ plot = (argv[0][0] == 'p'); /*select_init(get_rev, dis_setup, fdimname, doheaders, docheck2d, dospecpars, doblockpars, dophasefile)*/ /*if (init2d(0,plot + 1)) return(ERROR); */ if (select_init( 0, plot+1, NO_FREQ_DIM, NO_HEADERS, DO_CHECK2D, DO_SPECPARS, NO_BLOCKPARS, NO_PHASEFILE )) return(ERROR); if ((numlines = getlines(noneg)) == 0) RETURN; if (!plot) { setwindows(); dispcalib = (float) (mnumypnts-ymin) / (float) wc2max; getOptName(PEAK_MARK,name); set_line_thickness(name); getOptName(PEAK_NUM,name); set_graphics_font(name); } else { double size = G_getCharSize("PeakNum"); charsize(size); //charsize((double)0.7); dispcalib = ppmm / ymultiplier; } CharSize = ycharpixels + ycharpixels / 5; maxlines = dnpnt / CharSize; if (maxlines < numlines) remove_lines(maxlines,&numlines); if (numlines > 0) { //color(PARAM_COLOR); color(PEAK_MARK_COLOR); groups = groupcheck(numlines); if (debug1) { Wscrprintf("index high low newhigh newlow highlimit lowlimit\n"); for (i = 1; i <= groups; i++) Wscrprintf("%d %d %d %d %d %d %d\n",i,ga[i].high,ga[i].low, ga[i].newhigh,ga[i].newlow,ga[i].highlimit,ga[i].lowlimit); } label_proc = (top) ? (PFV) label_top : (PFV) label_bot; for (i = 1; i <= groups; i++) label_group(i); if (!plot) { // construct the command, and set the flag and command char cmd[64]; if(argc > 1) { if (isReal(argv[1]) ) sprintf(cmd,"%s(%s",argv[0],argv[1]); else sprintf(cmd,"%s('%s'",argv[0],argv[1]); for(i=2;i<argc;i++) { if (isReal(argv[i]) ) { strcat(cmd,","); strcat(cmd,argv[i]); } else { strcat(cmd,",'"); strcat(cmd,argv[i]); strcat(cmd,"'"); } } strcat(cmd,")\n"); } else sprintf(cmd,"%s\n",argv[0]); Wsetgraphicsdisplay("ds"); set_dpf_flag(1, cmd); } } releaseAllWithId("dpf"); endgraphics(); disp_status(" "); set_graphics_font("Default"); RETURN; }
void autoRedisplay() { char function[20]; char *screenCommand; static int recursive = 0; extern int interuption; extern int textIsOn; extern int grafIsOn; extern int autotextIsOn; extern int autografIsOn; int tmpOn; if (!recursive) { recursive = 1; #ifdef VNMRJ if (Jx_string) /* if there are any changed variables */ { if (!Bnmr) /* if not in background */ { jAutoRedisplayList(); } releaseJvarlist(); } resetjEvalGlo(); #endif if (Dx_string) /* if there are any changed variables */ { if (!Bnmr) /* if not in background */ { screenCommand = Wgettextdisplay(function,20); if (*screenCommand && (strcmp(screenCommand,"") != 0) && isReexecCmd(screenCommand)) { screenCommand = newStringId(screenCommand,"autoRedisplay"); screenCommand = newCatId(screenCommand,"(","autoRedisplay"); screenCommand = newCatId(screenCommand,Dx_string,"autoRedisplay"); screenCommand = newCatId( screenCommand,",'redisplay parameters')\n","autoRedisplay" ); TPRINT1("autoRedisplay: text \"%s\"\n",screenCommand); tmpOn = textIsOn; if (!autotextIsOn) textIsOn = 0; execString(screenCommand); textIsOn = tmpOn; release(screenCommand); } if (Wissun()) /* if text is separate from graphics */ { screenCommand = Wgetgraphicsdisplay(function,20); if (*screenCommand && (strcmp(screenCommand,"") != 0) && isReexecCmd(screenCommand)) { screenCommand = newStringId(screenCommand,"autoRedisplay"); if (Dx_string) { screenCommand = newCatId(screenCommand,"(","autoRedisplay"); screenCommand = newCatId(screenCommand,Dx_string,"autoRedisplay"); screenCommand = newCatId( screenCommand,",'redisplay parameters')\n","autoRedisplay" ); } else screenCommand = newCatId( screenCommand,"('redisplay parameters')\n","autoRedisplay" ); TPRINT1("autoRedisplay: graphics \"%s\"\n",screenCommand); tmpOn = grafIsOn; if (!autografIsOn) grafIsOn = 0; #ifdef VNMRJ setAutoRedisplayMode(1); #endif if(strstr(screenCommand,"asp")) aspFrame("redraw",0,0,0,0,0); else execString(screenCommand); grafIsOn = tmpOn; release(screenCommand); #ifdef VNMRJ setAutoRedisplayMode(0); #endif } } } releasevarlist(); } TPRINT3("menu test: menus %s %s active; buttons %s active\n" ,(menuflag) ? "on" : "off",(menuon) ? "and" : "but not" ,(buttons_active) ? "are" : "not"); if (menuflag && !menuon && !buttons_active && !Bnmr) { interuption = 0; /* turn off effects of cancelCmd button */ execString("menu\n"); } recursive = 0; #ifdef VNMRJ if (!Bnmr) sendTripleEscToMaster( 'p', "" ); #else #ifdef VNMRTCL if (!Bnmr) { if (updateMagicVar()) sendTripleEscToMaster( 'T', "" ); } #endif #endif } }