void SRecordParser::Error( unsigned lineNum, const char *fmt, ... ) { va_list args; va_start( args, fmt ); vError( lineNum, fmt, args ); va_end( args ); }
void ErrorHandler::error (const char *format, ...) { va_list argptr; va_start (argptr, format); vError (format, argptr); va_end (argptr); }
void Cpu::CoreCrash(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vError(fmt, ap); va_end(ap); CoreDump(); this->PowerOn = false; }
Variant Variant::operator-(const Variant &b) const { Variant v(*this); if (v.getType() == Type::Integer && b.getType() == Type::Integer){ v.setInt(static_cast<int>(v) - static_cast<int>(b)); }else { Variant vError("#Calculation Error"); return vError; } return v; }
int main(int argc, // Command line argument count char *argv[]) // Pointers to command line args { // Now parse and apply any output file options Cscalemerge *poScalemerge; Creflnlist *poReflnlistIn; // Pointers to input file Creflnlist oReflnlistOut; Cstring sInFile; Cstring sOutScaledFile = "?"; // dtscale.ref Cstring sOutAverageFile = "?"; // dtunavg.ref Cstring sBatchFixed = ""; Cstring sTemp; Cstring sOut = "dtscalemerge.head"; float fScaleFixed = 1.0; float fBValueFixed = 0.0; float fErrorAdd = 0.0; float fErrorMul = 1.0; float fRejectCrit = (float)10.0E10; float fSigma = 0.0; int nCycles = 30; bool bSigmaOverEstimate = FALSE; int nOutputAnomFlag = 0; int nScaleAnomFlag = 0; int nFixBFlag = 0; int nVerboseLevel= 3; int nTexsan = 0; int nNoHeader = 0; int nNoUnavgHeader = 0; int nCountOverlap= 0; float a2fResolution[2] = {999999.00, 0.00001f}; Cimage_header *poHeader; poHeader = NULL; int j; int nTemp; float fTemp; int nStat = 0; vDtrekSetModuleName("dtscalemerge"); cout << "\ndtscalemerge: Copyright (c) 1996 Molecular Structure" << " Corporation\n"; cout << D_K_DTREKVersion << endl; // Copy command line to output log cout << "Command line:\n " << sGetCommandLine(argc, argv, 71) << endl << flush; // Parse command line arguments, if any (there had better be some!) argc--; argv++; // Skip program name int nArg = 0; nStat = 0; if (nArg < argc) { // Read image header for some information poHeader = new Cimage_header(Cstring((const char*)argv[nArg])); if (!poHeader->bIsAvailable()) { delete poHeader; vError(1, "Header not available!\n"); } } nArg++; // By position ... this must be input reflnlist filename if (nArg < argc) { // Get input reflection file name, but do not read it in yet sInFile = argv[nArg]; } else { vError(1,"Not enough command line arguments!\n"); // This calls exit } nArg++; while ( (nArg < argc) && ('-' == (char) *argv[nArg]) && (0 == nStat) ) { // Remove leading '-'! sTemp = Cstring((argv[nArg]+1)); if ("fix" == sTemp) { // Batch name to fix is found, read next word to see what it is nArg++; if (nArg < argc) { sBatchFixed = (const char*)argv[nArg]; } else { vError(1, "Missing batch name to fix!\n"); // This calls exit } } else if ("add" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fErrorAdd); if (0 != nStat) { vError(1,"Bogus factor for -add!\n"); } } else { vError(1,"Missing factor for -add!\n"); } } else if("out" == sTemp) { nArg++; if(nArg < argc) sOut = (const char *)argv[nArg]; } else if ("sigmaoverestimate" == sTemp) { bSigmaOverEstimate = TRUE; } else if ("mul" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fErrorMul); if (0 != nStat) { vError(1,"Bogus factor for -mul!\n"); } } else { vError(1,"Missing factor for -mul!\n"); } } else if ("reject" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fRejectCrit); if (0 != nStat) { vError(1,"Bogus factor for -reject!\n"); } } else { vError(1,"Missing factor for -reject!\n"); } } else if ("cycles" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%d", &nCycles); if (0 != nStat) { vError(1,"Bogus factor for -cyc!\n"); } } else { vError(1,"Missing factor for -cyc!\n"); } } else if ("sigma" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fSigma); if (0 != nStat) { vError(1,"Bogus factor for -sigma!\n"); } } else { vError(1,"Missing factor for -sigma!\n"); } } else if ("scale" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fScaleFixed); if (0 != nStat) { vError(1,"Bogus scale factor for fixed batch!\n"); } } else { vError(1,"Missing scale factor for fixed batch!\n"); } } else if ("bfac" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%f", &fBValueFixed); if (0 != nStat) { vError(1,"Bogus temperature factor for fixed batch\n"); } } else { vError(1,"Missing temperature factor for fixed batch!\n"); } } else if ("reso" == sTemp) { nArg++; for (j=0; (j < 2) && (nArg < argc); j++, nArg++) { nTemp = sscanf(argv[nArg], "%f", &fTemp); if (1 == nTemp) a2fResolution[j] = fTemp; else vError(6, "Invalid resolution value for -reso option!\n"); } nArg--; if (2 != j) { vError(5, "Missing resolution value for -reso option!\n"); } } else if ( ("ref" == sTemp) || ("unavg" == sTemp) ) { nArg++; if (nArg < argc) { sOutScaledFile = (const char*)argv[nArg]; } else { vError(1,"Missing filename for -ref option!\n"); } } else if ("verbose" == sTemp) { nArg++; if (nArg < argc) { nStat = -1 + sscanf((const char*)argv[nArg], "%d", &nVerboseLevel); if (0 != nStat) { vError(1,"Bogus factor for -verbose!\n"); } } else { vError(1,"Missing factor for -verbose!\n"); } } else if ("anom" == sTemp) { nOutputAnomFlag = 1; } else if ("scaleanom" == sTemp) { nScaleAnomFlag = 1; } else if ("fixB" == sTemp) { nFixBFlag = 1; } else if ("fixb" == sTemp) { nFixBFlag = 1; } else if ("countoverlap" == sTemp) { nCountOverlap = 1; } else if ("texsan" == sTemp) { nTexsan = 1; } else if ("texsan2" == sTemp) { nTexsan = 2; } else if ("noheader" == sTemp) { nNoHeader = 1; } else if ("nounavgheader" == sTemp) { nNoUnavgHeader = 1; } else { sTemp = "Unknown argument: " + sTemp + "\n"; // vError(1, (const char *) sTemp); vError(1, sTemp.string()); } nArg++; } if (nArg < argc) { // By position ... this must be output reflnlist filename sOutAverageFile = argv[nArg]; nArg++; } if (nArg < argc) { vError(1,"Too many command line arguments!\n"); // This calls exit } cout << "Reading " << sInFile << " ..." << endl << flush; poReflnlistIn = new Creflnlist(sInFile); if ( !poReflnlistIn->bIsAvailable() || (1 > poReflnlistIn->nGetNumReflns()) ) { sTemp = "Problem with input reflection list: " + sInFile; delete poHeader; delete poReflnlistIn; vError(2, sTemp); } // Have reflection list, now do something with it. poScalemerge = new Cscalemerge(poReflnlistIn, poHeader); if (!poScalemerge->bIsAvailable()) { delete poHeader; delete poReflnlistIn; delete poScalemerge; vError(3, "Problem with input files!\n"); } poScalemerge->vSetSigmaOverEstimate(bSigmaOverEstimate); poScalemerge->vSetMaxCycles(nCycles); poScalemerge->vSetCountOverlap(nCountOverlap); poScalemerge->vSetScale(fScaleFixed); poScalemerge->vSetTemp(fBValueFixed); poScalemerge->vSetError(fErrorMul, fErrorAdd); poScalemerge->vSetRejCrit(fRejectCrit); poScalemerge->vSetScaleAnomFlag(nScaleAnomFlag); if ( (0 != nScaleAnomFlag) && (1 == nOutputAnomFlag) ) { cout << "\nWARNING! Cannot have both -scaleanom and -anom options," << "\n -anom option ignored!\n" << endl; nOutputAnomFlag = 0; } poScalemerge->vSetOutputAnomFlag(nOutputAnomFlag); poScalemerge->vSetFixBFlag(nFixBFlag); poScalemerge->vSetResolution(a2fResolution[0], a2fResolution[1]); poScalemerge->vSetVerbose(nVerboseLevel); if ("" != sBatchFixed) poScalemerge->vSetBatch(sBatchFixed); cout << "Inp ref file: " << sInFile << '\n' << flush; (void) poScalemerge->nList(); nStat = poScalemerge->nScaleSetup(); if (0 != nStat) { cerr << "ERROR in Cscalemerge::nScaleSetup!\n" << flush; delete poHeader; delete poReflnlistIn; delete poScalemerge; return (nStat); } // Deselect some reflns via a sigma cutoff // The check is before any modification of sigma via fErrorMul and fErrorAdd! // Do this after nScaleSetup because any new Crefln fields // have now all been added. char a255cTemp[255]; sprintf(a255cTemp, "-fIntensity/fSigmaI<%.3f", fSigma); cout << "\nExcluding reflections from the scale factor calculation with" << "\nselection string: " << a255cTemp << endl << flush; // nStat = poReflnlistIn->nSelect((Cstring)a255cTemp); nStat = poScalemerge->m_poReflnlist->nSelect((Cstring)a255cTemp); if (0 > nStat) { cerr << "ERROR in selection mechanism!\n" << flush; delete poHeader; delete poReflnlistIn; delete poScalemerge; return (nStat); } cout << "Number of reflns which match above selection: " << nStat << "\nHowever, all reflections are used in the summary tables below.\n" << endl << flush; nStat = 0; if (0 == nStat) nStat = poScalemerge->nScale1(nCycles, &oReflnlistOut);// This does scaling! if ( (0 == nStat) && ("?" != sOutScaledFile) ) { poScalemerge->vApplyWeights(); if (0 != nTexsan) { // Write out the unaveraged reflection list for texsan purposes: // 1. Do not write out the header. // 2. Do not write out reflns with sigmaI <= 0. // -texsan: // 3. Write out only h, k, l, I, sigmaI fields (the first 5 fields). //+ 2-Mar-1999 // -texsan2: // 4. Write out I/Lp, and, if available, the absorption correction // factors //- 2-Mar-1999 int i; int nFields; char *pcSelect = NULL; nFields = poScalemerge->m_poReflnlist->nGetNumFields(); pcSelect = new char [nFields + 1]; // "Deselect" all fields for (i = 0; i < nFields; i++) pcSelect[i] = poScalemerge->m_poReflnlist->m_pcSelect[i] + 1; // Keep the global selection the same pcSelect[nFields] = poScalemerge->m_poReflnlist->m_pcSelect[nFields]; // Select only the 5 fields we want to keep (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_int_type, poScalemerge->m_poReflnlist->m_nFI_nH, char(0), pcSelect); (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_int_type, poScalemerge->m_poReflnlist->m_nFI_nK, char(0), pcSelect); (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_int_type, poScalemerge->m_poReflnlist->m_nFI_nL, char(0), pcSelect); (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_float_type, poScalemerge->m_poReflnlist->m_nFI_fIntensity, char(0), pcSelect); (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_float_type, poScalemerge->m_poReflnlist->m_nFI_fSigmaI, char(0), pcSelect); //+ 2-Mar-1999 if (2 == nTexsan) { float fInt, fSigma, fTgeos, fScale; float fLorentz, fPolarz, fLP; int nFI_fTgeos = poScalemerge->m_poReflnlist->nGetFieldIndex("fTgeos"); int nFI_fScale = poScalemerge->m_poReflnlist->nGetFieldIndex("fScale"); int nFI_fLorentz = poScalemerge->m_poReflnlist->m_nFI_fLorentz; int nFI_fPolarz = poScalemerge->m_poReflnlist->m_nFI_fPolarz; int nFI_fLP = poScalemerge->m_poReflnlist->nGetFieldIndex("fLPfactor"); if ( (0 > nFI_fTgeos) || (0 > nFI_fScale) ) { cout << "WARNING: transmisson or scale factor not found.\n"; } if ( (0 > nFI_fLP) && ( (0 > nFI_fLorentz) || (0 > nFI_fPolarz) ) ) { cout << "WARNING: Lorentz or Polarz factor not found.\n"; } // Use the 2nd field, whatever it is, to hold the pre-scaled // Intensity, also with no LP correction (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_float_type, 2, char(0), pcSelect); if (0 < nFI_fTgeos) (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_float_type, nFI_fTgeos, char(0), pcSelect); if (0 < nFI_fScale) (void) poScalemerge->m_poReflnlist->nSelectField( eReflnField_float_type, nFI_fScale, char(0), pcSelect); Crefln *poRefln; for (i = 0; i < poScalemerge->m_poReflnlist->nGetNumReflns(); i++) { poRefln = poScalemerge->m_poReflnlist->poGetRefln(i); fTgeos = poRefln->fGetField(nFI_fTgeos); fScale = poRefln->fGetField(nFI_fScale); if (0 < nFI_fLP) { fLP = 1.0f / poRefln->fGetField(nFI_fLP); } else { fLorentz= poRefln->fGetField(nFI_fLorentz); fPolarz = poRefln->fGetField(nFI_fPolarz); fLP = fLorentz * fPolarz; } fInt = poRefln->fGetIntensity(); fSigma = poRefln->fGetSigmaI(); if ( (0.0 < fSigma) && (0.0 < fLP) && (0.0 < fScale) && (0.0 < fTgeos) ) { fInt = fInt / (fScale / fTgeos); fSigma = fSigma / (fScale / fTgeos); poRefln->vSetIntensity(fInt); poRefln->vSetSigmaI(fSigma); fInt = fInt * fLP; poRefln->vSetField(2, fInt); } else if (0.0 < fSigma) { cout << "WARNING -texsan2 problem: "; poRefln->nList(2); } } } //- 2-Mar-1999 poScalemerge->m_poReflnlist->vSetNoWriteHeader(); poScalemerge->m_poReflnlist->nSelect("-fSigmaI<=0.0"); cout << "Writing " << sOutScaledFile << " ..." << endl << flush; nStat = poScalemerge->m_poReflnlist->nWrite(sOutScaledFile, NULL, pcSelect); delete [] pcSelect; } else { if (0 != nNoUnavgHeader) poScalemerge->m_poReflnlist->vSetNoWriteHeader(); cout << "Writing " << sOutScaledFile << " ..." << endl << flush; nStat = poScalemerge->m_poReflnlist->nWrite(sOutScaledFile); } } if ( (0 == nStat) && ("?" != sOutAverageFile) ) { if (0 != nNoHeader) oReflnlistOut.vSetNoWriteHeader(); cout << "Writing " << sOutAverageFile << " ..." << endl << flush; nStat = oReflnlistOut.nWrite(sOutAverageFile); } poHeader->nWrite(sOut); delete poReflnlistIn; delete poScalemerge; delete poHeader; cout << "\ndtscalemerge: Done.\n" << flush; return (nStat); }
/** Main application entry point. */ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(vidalia); QStringList args = char_array_to_stringlist(argv+1, argc-1); /* Construct the application object. Qt strips any command-line arguments * that it recognizes in argv, so we'll pass a stringlist of the original * list of command-line arguments too. */ Vidalia vidalia(args, argc, argv); vNotice("Vidalia %1 using Qt %2").arg(Vidalia::version()) .arg(QT_VERSION_STR); #if defined(USE_BREAKPAD) /* Set up the crash reporting application and exception handlers. */ setup_crash_reporter(); #endif #if defined(USE_MARBLE) && defined(Q_OS_WIN32) vApp->addLibraryPath(vApp->applicationDirPath() + "/plugins/qt"); #endif /* Install a signal handler to clean up properly after a catching a * SIGINT or SIGTERM. */ install_signal_handler(); /* Validate any command-line arguments, or show usage message box, if * necessary. */ QString errmsg; if (vidalia.showUsage()) { Vidalia::showUsageMessageBox(); return 0; } else if (!vidalia.validateArguments(errmsg)) { vError("Unable to apply command-line arguments: %1").arg(errmsg); VMessageBox::critical(0, vApp->translate("Vidalia", QT_TRANSLATE_NOOP("Vidalia", "Invalid Argument")), errmsg, VMessageBox::Ok); return 1; } /* Check if Vidalia is already running. */ QString pidfile = vidalia.pidFile(); if (is_vidalia_running(pidfile)) { vWarn("Detected another process with pid %1. Is Vidalia already running?") .arg(get_pid()); /* Let the user know another Vidalia is running and we are going to exit * now. */ int ret = VMessageBox::critical(0, vApp->translate("Vidalia", QT_TRANSLATE_NOOP("Vidalia", "Vidalia is already running")), vApp->translate("Vidalia", QT_TRANSLATE_NOOP("Vidalia", "Another Vidalia process is possibly already running. " "If there really is not another Vidalia process running, " "you can choose to continue anyway.\n\n" "Would you like to continue starting Vidalia?")), VMessageBox::Continue, VMessageBox::Quit|VMessageBox::Default); if (ret != VMessageBox::Continue) { /* Don't start a second instance of Vidalia */ vError("Exiting duplicate Vidalia process."); return 1; } } write_pidfile(pidfile); /* Since we don't have a visible main window, if we were to display a * QMessageBox (for example, to display an error when starting or stopping * Tor) then the application would exit when that message box was closed. * Setting quitOnLastWindowClosed to false fixes this behavior. */ Vidalia::setQuitOnLastWindowClosed(false); /* Create an instance of the main window */ MainWindow mainWin; /* Run Vidalia */ int ret = vidalia.run(); /* Vidalia exited, so cleanup our pidfile and return */ QFile::remove(pidfile); vNotice("Vidalia is exiting cleanly (return code %1).").arg(ret); #if defined(USE_BREAKPAD) vInfo("Removing Breakpad exception handler."); CrashReporter::remove_exception_handler(); #endif return ret; }