/** * This routine gets which mouse buttons are down. Similar functionality * is in gin(), but that routine does a lot of initialization, and beeps * if there is no transformed data. * * Returns: Bit mapped integer--a set bit means the corresponding mouse * button is down. E.g., return=5 means first and third buttons are * down, return=1 means first button is down. Return 0 if no buttons * are down. */ int getMouseButtons(int argc, char *argv[], int retc, char *retv[]) { if (retc > 0) { retv[0] = intString(buttonsDown); } else { Winfoprintf("mouseButtons = %d", buttonsDown); } RETURN; }
int bigendian( int argc, char *argv[], int retc, char *retv[] ) { (void) argc; (void) argv; if (retc > 0) retv[0] = intString( BigEndian ); else Winfoprintf("System architecture is %s Endian\n",(BigEndian) ? "Big" : "Little"); RETURN; }
Song::Song(int id) { MYSQL_RES* res = query("SELECT id, title, path, type FROM song WHERE id = '" + esc(intString(id)) + "'"); if (num_rows(res)) { MYSQL_ROW row = next_res(res); this->id = stringInt(row[0]); this->title = row[1]; this->path = row[2]; this->type = row[3]; } free_res(res); }
int getMaxIndex(int argc, char *argv[], int retc, char *retv[]) /*************/ { (void) argc; (void) argv; if (retc > 0) { int numtraces=nblocks * specperblock; if(!d2flag){ int numarrays=dim1count(); numtraces=numtraces>numarrays?numtraces:numarrays; } retv[0] = intString(numtraces); } RETURN; }
int autoq(int argc, char *argv[], int retc, char *retv[]) { char autodir[MAXPATH]; char lockPath[MAXPATH]; char idPath[MAXPATH]; char lockLogPath[MAXPATH]; char idLogPath[MAXPATH]; char logBasePath[MAXPATH]; char *blockname = "autoqBlock"; char *lockname = "lockEnterQ"; time_t lockSecs = 5; /* default lock timeout */ int res = 1; if (argc < 2) { Werrprintf("usage: %s requires add, get, lock, unlock, sendmsg, or recvmsg argument", argv[0]); ABORT; } if ( !strcmp(argv[1],"sendmsg") || !strcmp(argv[1],"recvmsg") ) { res = 4; } else { #ifdef VNMRJ if ( ! strcmp(argv[1],"add") ) P_getstring(GLOBAL,"autodir",autodir,1,MAXPATH); else #endif getAutoDir(autodir, MAXPATH); sprintf(lockPath,"%s/%s",autodir,lockname); sprintf(idPath,"%s/eq_%s_%s_%d",autodir,HostName,UserName,HostPid); } if ( ! strcmp(argv[1],"add") ) { char queuename[MAXPATH]; if (argc < 3) { Werrprintf("usage: %s('add',filename) requires a filename.",argv[0]); ABORT; } if (argc == 4) strcpy(queuename,argv[3]); else strcpy(queuename,"std"); /* Wait for get operations to complete first */ blockedByGet(autodir, blockname); if ( lockit(lockPath,idPath,lockSecs) ) { res = addQueueFile(autodir, argv[2], queuename); unlockit(lockPath,idPath); } else { res = -4; } } else if ( ! strcmp(argv[1],"get") ) { FILE *fd; char blockfile[MAXPATH]; if (argc < 3) { Werrprintf("usage: %s('get',filename) requires a filename.",argv[0]); ABORT; } /* The get operation will block add and lock from other processes */ sprintf(blockfile,"%s/%s",autodir,blockname); fd = fopen(blockfile,"w"); fclose(fd); if ( lockit(lockPath,idPath,lockSecs) ) { res = getQueueFile(autodir, argv[2]); unlockit(lockPath,idPath); } else { res = -4; } #ifdef TESTING if (argc == 4) sleepnano(atoi(argv[3])); #endif /* Allow access by add and lock from other processes */ unlink(blockfile); } else if ( ! strcmp(argv[1],"lock") ) { if (argc == 3) { lockSecs = atoi(argv[2]); if (lockSecs < 1) lockSecs = 1; else if (lockSecs > 15) lockSecs = 15; } /* Wait for get operations to complete first */ blockedByGet(autodir, blockname); DPRINT1("lock called with %ld timeout\n",lockSecs); res = lockit(lockPath,idPath,lockSecs); } else if ( ! strcmp(argv[1],"unlock") ) { unlockit(lockPath,idPath); res = 1; } else if ( ! strcmp(argv[1],"addAcct") ) { char accFile[MAXPATH]; char idFile[MAXPATH]; if (argc != 3) { Werrprintf("autoq('addAcct',filename) requires filename as the second argument"); ABORT; } if ( access(argv[2], R_OK|W_OK) ) { Werrprintf("autoq('addAcct',filename) filename does not exist or has wrong permissions"); ABORT; } res = 0; strcpy(lockPath, getenv("vnmrsystem") ); strcat(lockPath,"/adm/accounting/"); strcpy(accFile, lockPath); strcat(accFile,"acctLog.xml"); if ( !access(accFile,F_OK) ) { FILE *inputFd; int bufSize=4095; char buf[bufSize+1]; int size = 0; inputFd = fopen(argv[2],"r"); if (inputFd) { size = fread(buf, 1, bufSize, inputFd); /* Terminate the buffer */ buf[size] = 0; fclose(inputFd); } unlink(argv[2]); if (size) { lockSecs = 2; // Create filepaths for the lock files to lock acctLog strcpy(idPath, lockPath); strcat(lockPath, "acctLogLock"); sprintf(idFile, "acctLogLockId_%s_%d", HostName, HostPid); strcat(idPath, idFile); DPRINT1("lock called with %ld timeout\n",lockSecs); if ( lockit(lockPath,idPath,lockSecs) ) { const char root_end[]="</accounting>\n"; FILE *xmlFd; xmlFd = fopen(accFile,"r+"); if (xmlFd) { /* find the closing /> at the end and put log info above that */ fseek(xmlFd,-strlen(root_end),SEEK_END); /* Write to the log file */ fprintf(xmlFd,"%s",buf); fprintf(xmlFd,"%s",root_end); fflush(xmlFd); fclose(xmlFd); } unlockit(lockPath,idPath); res = 1; } } } } else if ( ! strcmp(argv[1],"locklog") ) { lockSecs = 15; // Create filepaths for the lock files to lock acctLog strcpy(logBasePath, (char *)getenv("vnmrsystem") ); strcat(logBasePath,"/adm/accounting/"); sprintf(lockLogPath, "%s%s", logBasePath, "acctLogLock"); sprintf(idLogPath, "%sacctLogLockId_%s_%d", logBasePath, HostName, HostPid); /* Wait for get operations to complete first */ blockedByGet(autodir, blockname); DPRINT1("lock called with %ld timeout\n",lockSecs); res = lockit(lockLogPath,idLogPath,lockSecs); } else if ( ! strcmp(argv[1],"unlocklog") ) { // Create filepaths for the lock files to lock acctLog strcpy(logBasePath, (char *)getenv("vnmrsystem") ); strcat(logBasePath,"/adm/accounting/"); sprintf(lockLogPath, "%s%s", logBasePath, "acctLogLock"); sprintf(idLogPath, "%sacctLogLockId_%s_%d", logBasePath, HostName, HostPid); unlockit(lockLogPath,idLogPath); res = 1; } else if (res == 4) /* ( !strcmp(argv[1],"sendmsg") || !strcmp(argv[1],"recvmsg") ) */ { if ( ! strcmp(argv[1],"recvmsg") ) { if ( (argc != 3) || ( strcmp(argv[2],"on") && strcmp(argv[2],"off")) ) { Werrprintf("autoq %s requires 'on' or 'off' as the second argument",argv[1]); ABORT; } } if (argc != 3) { Werrprintf("autoq %s requires another argument",argv[1]); ABORT; } res = 1; if (is_acqproc_active()) { char msg[MAXSTR]; sprintf(msg,"%s %s",argv[1],argv[2]); if (send2Acq(AUTOQMSG, msg) < 0) res = 0; if (res) receivingMsg = ( ! strcmp(argv[2],"on")); } } DPRINT1("operation returns %d\n",res); if (retc) { retv[0] = intString(res); } RETURN; }
/*-------------------------------------------------------------------------- | | macroLd | | This command loads a macro into cache memory. If the macro | of the same name already exists in the cache memory, it is first | deleted before the new macro is loaded. | /+--------------------------------------------------------------------------*/ int macroLd(int argc, char *argv[], int retc, char *retv[]) { int i; node *codeTree; int res; int ret = 0; if (argc == 1) { Werrprintf("Usage -- %s('macro1'[,'macro2',...])",argv[0]); ABORT; } else { if (retc > 1) WstoreMessageOn(); for (i=1;i<argc;i++) { TPRINT1("macroLd: removing macro \"%s\"\n",argv[i]); rmMacro(argv[i]); renameAllocation("newMacro","tmpSavenewMacro"); if (argv[i][0] == '/') { char *s; s = strrchr(argv[i],'/'); rmMacro(s+1); if ( (codeTree = loadMacro(argv[i],NOSEARCH, &res)) ) { TPRINT1("macroLd: saving macro \"%s\"\n",s+1); saveMacro(s+1,codeTree,PERMANENT); ret = 1; if (!retc) Winfoprintf("Loaded macro '%s'",s+1); else if (retc > 1) sprintf(storeMessage,"Loaded macro '%s'",s+1); } } else if ( (codeTree = loadMacro(argv[i],SEARCH, &res)) ) { TPRINT1("macroLd: saving macro \"%s\"\n",argv[i]); saveMacro(argv[i],codeTree,PERMANENT); ret = 1; if (!retc) Winfoprintf("Loaded macro '%s'",argv[i]); else if (retc > 1) sprintf(storeMessage,"Loaded macro '%s'",argv[i]); } releaseAllWithId("newMacro"); renameAllocation("tmpSavenewMacro","newMacro"); } if (retc) { retv[0] = intString( ret ); if (retc > 1) { retv[1] = newString(storeMessage); WstoreMessageOff(); } } } RETURN; }
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; }
types::Function::ReturnValue sci_string(types::typed_list &in, int _iRetCount, types::typed_list &out) { if (in.size() != 1) { Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "string", 1); return types::Function::Error; } switch (in[0]->getType()) { case types::GenericType::ScilabSparse: { //C=sparse([0 0 4 0 9;0 0 5 0 0;1 3 0 7 0;0 0 6 0 10;2 0 0 8 0]);string(C) types::Sparse* pS = in[0]->getAs<types::Sparse>(); int iRows = pS->getRows(); int iCols = pS->getCols(); bool isComplex = pS->isComplex(); std::wostringstream ostr; std::vector<std::wstring> vect; ostr << "(" << iRows << "," << iCols << ") sparse matrix"; vect.push_back(ostr.str()); ostr.str(L""); ostr.clear(); for (int i = 0 ; i < iRows ; i++) { for (int j = 0 ; j < iCols ; j++) { std::wostringstream temp; double real = pS->getReal(i, j); double cplx = 0; if (isComplex) { cplx = pS->getImg(i, j).imag(); } if (real || cplx ) { temp << L"(" << i + 1 << L"," << j + 1 << L") "; if (real) { temp << pS->getReal(i, j); } if (cplx) { if (real && cplx > 0) { temp << L"+"; } else if (cplx < 0) { temp << L"-"; } temp << L"%i*" << std::abs(cplx); } ostr << temp.str(); vect.push_back(ostr.str()); ostr.str(L""); ostr.clear(); } } } types::String* pSt = new types::String((int)vect.size(), 1); for (int i = 0 ; i < vect.size(); i++) { pSt->set(i, vect[i].c_str()); } out.push_back(pSt); break; } case types::InternalType::ScilabInt8 : { return intString(in[0]->getAs<types::Int8>(), out); } case types::InternalType::ScilabUInt8 : { return intString(in[0]->getAs<types::UInt8>(), out); } case types::InternalType::ScilabInt16 : { return intString(in[0]->getAs<types::Int16>(), out); } case types::InternalType::ScilabUInt16 : { return intString(in[0]->getAs<types::UInt16>(), out); } case types::InternalType::ScilabInt32 : { return intString(in[0]->getAs<types::Int32>(), out); } case types::InternalType::ScilabUInt32 : { return intString(in[0]->getAs<types::UInt32>(), out); } case types::InternalType::ScilabInt64 : { return intString(in[0]->getAs<types::Int64>(), out); } case types::InternalType::ScilabUInt64 : { return intString(in[0]->getAs<types::UInt64>(), out); } case types::InternalType::ScilabDouble : { return doubleString(in[0]->getAs<types::Double>(), out); } case types::InternalType::ScilabString : { out.push_back(in[0]); break; } case types::InternalType::ScilabFunction: { Scierror(999, _("%s: Wrong type for input argument #%d.\n"), "string", 1); return types::Function::Error; } case types::InternalType::ScilabMacroFile : { if (_iRetCount != 3) { Scierror(77, _("%s: Wrong number of output argument(s): %d expected.\n"), "string", 3); return types::Function::Error; } types::MacroFile* pMF = in[0]->getAs<types::MacroFile>(); types::InternalType* pOut = NULL; types::InternalType* pIn = NULL; types::InternalType* pBody = NULL; getMacroString(pMF->getMacro(), &pOut, &pIn, &pBody); out.push_back(pOut); out.push_back(pIn); out.push_back(pBody); break; } case types::InternalType::ScilabMacro : { if (_iRetCount != 3) { Scierror(77, _("%s: Wrong number of output argument(s): %d expected.\n"), "string", 3); return types::Function::Error; } types::Macro* pM = in[0]->getAs<types::Macro>(); types::InternalType* pOut = NULL; types::InternalType* pIn = NULL; types::InternalType* pBody = NULL; getMacroString(pM, &pOut, &pIn, &pBody); out.push_back(pOut); out.push_back(pIn); out.push_back(pBody); break; } case types::InternalType::ScilabTList : case types::InternalType::ScilabMList : case types::InternalType::ScilabPolynom : { std::wstring wstFuncName = L"%" + in[0]->getShortTypeStr() + L"_string"; return Overload::call(wstFuncName, in, _iRetCount, out); } case types::InternalType::ScilabBool: { return booleanString(in[0]->getAs<types::Bool>(), out); } case types::InternalType::ScilabLibrary: { types::Library* pL = in[0]->getAs<types::Library>(); std::wstring path = pL->getPath(); std::list<std::wstring> macros; int size = pL->getMacrosName(macros); types::String* pS = new types::String(size + 1, 1); pS->set(0, path.c_str()); int i = 1; for (auto it : macros) { pS->set(i++, it.c_str()); } out.push_back(pS); break; } case types::InternalType::ScilabImplicitList: { return implicitListString(in[0]->getAs<types::ImplicitList>(), out); } case types::InternalType::ScilabColon: { out.push_back(new types::String(L"")); break; } default: { std::wostringstream ostr; in[0]->toString(ostr); out.push_back(new types::String(ostr.str().c_str())); break; } } return types::Function::OK; }
int wrspec(int argc, char *argv[], int retc, char *retv[] ) { char *cmd_name, *outfile_name; char ow_prompt[ MAXPATHL + 20 ], ow_ans[ 4 ]; int elem1_num, elem2_num, elem3_num, elem4_num, i, ival, np_out; int proctype; /* proctype for processing function type */ float *vdata, /* output data */ epscale = 0.0, rms = 0.0; double swmagic, tmp; FILE *tfile=NULL; /* retv[0]=0 ok; retv[0]=1 failed */ cmd_name = argv[ 0 ]; if (argc < MINNEW_ARGS) /* compare MAXNEW_ARGS in wrspec_args */ { Werrprintf( "Usage: %s( 'file_name' <, trace number > )", cmd_name); if (retc>0) retv[0] = intString(1); return( 0 ); } outfile_name = argv[ WRFILE_ARG ]; /* address of (output) file name: argv[1] */ /* do avg_scale if asked for it */ if (strcmp(outfile_name, "expl_avg_scale")==0) { if (argc < 3) { if (retc>0) retv[0] = intString(1); return( 0 ); } if (calc_avg_scale( cmd_name, argv[2] ) != 0) { /* errors reported in function */ if (retc>0) retv[0] = intString(1); return( 0 ); } if (retc>0) retv[0] = intString(0); return( 0 ); } init2d(1,1); /* get data headers */ if ((datahead.status & S_SPEC) == 0) { Werrprintf("%s: data must be ft'd first", cmd_name); if (retc>0) retv[0] = intString(1); return( 0 ); } if (wrspec_args( argc, argv, &proctype, &elem1_num, &elem2_num, &elem3_num, &elem4_num ) != 0) { if (retc>0) retv[0] = intString(1); return( 0 ); /* `writefid_args' reports error */ /* depends on argc */ } EPRINT0(1,"calling wrspec...\n"); EPRINT1(1," wrspec: proctype %d, ", proctype); EPRINT2(1,"trace numbers %d %d ",elem1_num,elem2_num); EPRINT2(1,"%d %d\n",elem3_num,elem4_num); /* if (proctype == 8) { outfile_name="ds"; for dmg; use outfile_name="dmg" and proctype=2? } else { below; } */ vdata=(float *)malloc((fn/2) * sizeof(float)); if (!vdata) { Werrprintf( "ddph: memory allocation failure" ); if (retc>0) retv[0] = intString(1); return( 0 ); } if ( strcmp( outfile_name, "ds") != 0) { /* Handle situation where the output file is already present. */ if (access( outfile_name, F_OK ) == 0) { if (!Bnmr) { sprintf( &ow_prompt[ 0 ], "OK to overwrite %s? ", outfile_name); W_getInputCR( &ow_prompt[ 0 ], &ow_ans[ 0 ], sizeof( ow_ans ) - 1); if (ow_ans[ 0 ] != 'Y' && ow_ans[ 0 ] != 'y') { free((char*) vdata); Winfoprintf( "%s: operation aborted", cmd_name ); if (retc>0) retv[0] = intString(1); return( 0 ); } } ival = unlink( outfile_name ); if (ival != 0) { free((char*) vdata); Werrprintf( "%s: cannot remove %s", cmd_name, outfile_name ); if (retc>0) retv[0] = intString(1); return( 0 ); } } tfile = fopen( outfile_name, "w" ); /* open file */ if (tfile == NULL) { free((char*) vdata); Werrprintf( "%s: problem opening %s", cmd_name, outfile_name ); if (retc>0) retv[0] = intString(1); return( 0 ); } } /* end "not ds" mode */ if (proctype==2 || proctype==4 || proctype==5 || proctype==7) { if (wrspec_find_epscale( &epscale, proctype, elem1_num, elem2_num) != 0) { Werrprintf( "%s: find epscale failed", cmd_name); free((char*) vdata); if (retc>0) retv[0] = intString(1); return( 0 ); } } if (proctype != 5) { if (wrspec_calcdata(cmd_name, proctype, elem1_num, elem2_num, elem3_num, elem4_num, vdata) != 0) { free((char*) vdata); if (retc>0) retv[0] = intString(1); return( 0 ); /* calcdata reports error */ } if (wrspec_output( cmd_name, outfile_name, tfile, vdata, proctype, epscale, &rms) != 0) { if (retc>0) retv[0] = intString(1); return( 0 ); /* write output to file or 'ds' */ } } else { /* proctype == 5 */ if ( (ival=P_getreal(CURRENT, "gzwin", &swmagic, 1)) ) { swmagic = 100.0; } else { if (swmagic < 0.0) swmagic = -swmagic; tmp = 100.0 * 1.0/((float) (fn/2-1)); if (swmagic < tmp) swmagic = tmp; if (swmagic > 100.0) swmagic = 100.0; } swmagic /= 100.0; np_out = fn/2 - 2 * (int) ((1.0 - ((float) swmagic)) * ((float) (fn/4)) ); ival = ((datahead.nblocks + 1) / 2) - 2; /* ival is gzsize, number of z shims */ if ( epscale < NEW_AMP_TOL ) { fprintf( tfile, "exp 4\n %d %d\nFrequency (hz) vs Phase\n", ival, np_out ); } else { fprintf( tfile, "exp 4\n %d %d\nFrequency (hz) vs Field (hz)\n", ival, np_out ); } for (i=0; i<ival; i++) { fprintf( tfile, "\n%d 0 0 0\n", i+1 ); elem3_num = 2 * i + 3; elem4_num = 2 * i + 4; if (wrspec_calcdata(cmd_name, 4, elem1_num, elem2_num, elem3_num, elem4_num, vdata) != 0) { if (retc>0) retv[0] = intString(1); return( 0 ); /* calcdata reports error; use proctype=4 */ } rms = (float) elem3_num; if (wrspec_output( cmd_name, outfile_name, tfile, vdata, proctype, epscale, &rms) != 0) { if (retc>0) retv[0] = intString(1); return( 0 ); /* write output to file or 'ds' */ } } } if (strcmp( outfile_name, "ds") != 0) fclose( tfile ); free((char*) vdata); if (retc>0) retv[0] = intString(0); if (retc>1) retv[1] = realString( ((double)rms) ); EPRINT0(1,"wrspec done!\n"); return( 0 ); }
int flushpars( int argc, char *argv[], int retc, char *retv[] ) { char parampath[MAXPATH]; int diskIsFull; int ival; sprintf(parampath,"%s/flushparsFailed",curexpdir); unlink(parampath); D_getparfilepath(CURRENT, parampath, curexpdir); if (P_save(CURRENT,parampath)) { if (argc == 2) { FILE *fd; sprintf(parampath,"%s/flushparsFailed",curexpdir); fd = fopen(parampath,"w"); if (fd) fclose(fd); sprintf(parampath,"%s/%s",curexpdir,argv[1]); unlink(parampath); RETURN; } else if (retc) { retv[0] = intString( 0 ); RETURN; } else { ival = isDiskFullFile( curexpdir, parampath, &diskIsFull ); if (ival == 0 && diskIsFull) { Werrprintf("problem saving current parameters: disk is full"); } else Werrprintf("problem saving current parameters"); ABORT; } } D_getparfilepath(PROCESSED, parampath, curexpdir); if (P_save(PROCESSED,parampath)) { if (argc == 2) { FILE *fd; sprintf(parampath,"%s/flushparsFailed",curexpdir); fd = fopen(parampath,"w"); if (fd) fclose(fd); sprintf(parampath,"%s/%s",curexpdir,argv[1]); unlink(parampath); RETURN; } else if (retc) { retv[0] = intString( 0 ); RETURN; } else { ival = isDiskFullFile( curexpdir, parampath, &diskIsFull ); if (ival == 0 && diskIsFull) { Werrprintf("problem saving processed parameters: disk is full"); } else { Werrprintf("problem saving processed parameters"); } ABORT; } } if (argc == 2) { sprintf(parampath,"%s/%s",curexpdir,argv[1]); unlink(parampath); } if (retc) { retv[0] = intString( 1 ); } RETURN; }
const char* GmpInt::getAsString(int base) const { intString().resize(mpz_sizeinbase(mData->mInteger, base) + 2); return mpz_get_str(&intString()[0], base, mData->mInteger); }