示例#1
0
void SimpleStream::Dump(Signal &sig, const void *buff, size_t bytes, bool upperFlag)
{
	int iCol = 0;
	String strHex, strASCII;
	const UChar *p = reinterpret_cast<const UChar *>(buff);
	for (size_t i = 0; i < bytes; i++, p++) {
		UChar ch = *p;
		char buff[8];
		if (upperFlag) {
			::sprintf(buff, (iCol > 0)? " %02X" : "%02X", ch);
		} else {
			::sprintf(buff, (iCol > 0)? " %02x" : "%02x", ch);
		}
		strHex += buff;
		strASCII += (0x20 <= ch && ch < 0x7f)? ch : '.';
		iCol++;
		if (iCol == 16) {
			String strLine = strHex;
			strLine += "  ";
			strLine += strASCII;
			Println(sig, strLine.c_str());
			if (sig.IsSignalled()) return;
			strHex.clear();
			strASCII.clear();
			iCol = 0;
		}
	}
	if (iCol > 0) {
		String strLine = strHex;
		for ( ; iCol < 16; iCol++) strLine += "   ";
		strLine += "  ";
		strLine += strASCII;
		Println(sig, strLine.c_str());
	}
}
示例#2
0
文件: eval.cpp 项目: hyln9/nV
bool SearchCProcs(var &result, var head, var body)
{
	stdext::hash_map<Var,CProc>::const_iterator
		iter = CProcs.find(head);
	if(iter != CProcs.end())
	{
		PushCProcSymbol pcs(head);
		if (Verbose >= 3) {
			wcerr << _W("Enter cproc for ");
			Println(Ex(head, body), wcerr);
		}
		try {
			result = iter->second(body);
		}
		catch (UserException&) {
			throw;
		}
// 		catch (std::exception& e) {
// 			wcerr << L"std::exception thrown: " << mbs2wcs(e.what()) << std::endl;
// 			wcerr << "CProc error while eval ";
// 			Println(Ex(head, body), wcerr);
// 			return false;
// 		}
		catch (...) {
			wcerr << "CProc error while eval ";
			Println(Ex(head, body), wcerr);
			throw;
		}
		if (result)
		{
			if (TraceRuleSymbols.count(head) != 0)
			{
				// FIXME: rewrite this after we implement the kernel message infrastructure
				Print(head);
				wcout << _W("::tracer : ");
				Print(Ex(head, body));
				wcout << _W(" :> ");
				Println(result);
			}
			if (Verbose >= 3) {
				wcerr << _W("Result is ");
				Println(result, wcerr);
			}
			return true;
		}
	}
	return false;
}
示例#3
0
void GForce::ManageFieldChanges() {
	long i;

	// If we have have a delta field in mid-calculation, chip away at it...
	if ( ! mNextField -> IsCalculated() )
		mNextField -> CalcSome();

	if ( mT > mNextFieldChange && mNextField -> IsCalculated() && mFieldSlideShow ) {

		// Load the next field in the (randomized) field list...
		i = mFieldPlayList.FindIndexOf( mCurFieldNum );

		// Make a new play list if we've reached the end of the list...
		if ( i >= mFieldPlayList.Count() ) {
			mFieldPlayList.Randomize();
			i = 0;
		}

		// loadGradField() will initiate computation on mField with a new grad field...
		loadDeltaField( mFieldPlayList.Fetch( i + 1 ) );
		DeltaField* temp = mField;
		mField = mNextField;
		mNextField = temp;

		// If the pref says so, display that we're loading a new config
		if ( mNewConfigNotify ) {
			Print( "Loaded DeltaField: " );
			Println( mField -> GetName() );
		}
	}
}
示例#4
0
    CbcAction event(CbcEvent whichEvent) {
        if (whichEvent == CbcEvent::solution && !recoveryPath.empty()) {
            ofstream out(recoveryPath, std::ios::app);
            auto solution = model_->bestSolution();
            if (solution == nullptr) {
                Println(out, "NULL");

                return CbcEventHandler::event(whichEvent);
            }
            auto numCols = model_->solver()->getNumCols();
            auto colorCount = 1 + *max_element(solution, solution+numCols);

            Println(out, colorCount);
            PrintlnSequence(out, solution, solution+numCols);
        }

        return CbcEventHandler::event(whichEvent);
    }
示例#5
0
    // nothing to inherit from GC really
    ColoredGraph solve(const Graph& gr) override {

        CoinModel coinModel;
        for (auto i = 0; i < gr.nodeCount(); ++i) {
            coinModel.addCol(0, nullptr, nullptr, 0, gr.nodeCount()-1, 1, nullptr, true);
        }
        OsiClpSolverInterface solver;
        solver.loadFromCoinModel(coinModel);

        CbcModel model(solver);
        model.setLogLevel(0);
        model.passInEventHandler(make_unique<GC_LP_EventHandler>(recoveryPath).get());

        if (use_heuristic) {
            GC_LP_Heuristic heuristic;
            model.addHeuristic(&heuristic);
        }

        AddRules(model, gr);

        if (use_parallel) {
            model.setNumberThreads(std::thread::hardware_concurrency());
        }

        if (max_seconds != 0) model.setMaximumSeconds(max_seconds);

        model.initialSolve();
        model.branchAndBound();

        if (model.maximumSecondsReached()) Println(cout, "max seconds reached");
        if (model.isSecondsLimitReached()) Println(cout, "seconds limit reached");

        seconds_passed_ = model.getCurrentSeconds();
        iterations_passed_ = model.getIterationCount();

        const double *solution = model.bestSolution();

        if (solution == nullptr) {
            vector<Color> colors(gr.nodeCount());
            iota(colors.begin(), colors.end(), 0);
            return {gr, colors};
        }
        return ColoredGraph(gr, {solution, solution+gr.nodeCount()});
    }
示例#6
0
void GForce::StoreConfigState( long inParamName ) {
	UtilStr str;

	str.Assign( mWaveShapeName );		str.Append( ',' );
	str.Append( mColorMapName );		str.Append( ',' );
	str.Append( mField -> GetName() );	str.Append( ',' );

	mPrefs.SetPref( inParamName, str );
	Println(_("State stored."));
}
示例#7
0
文件: main.cpp 项目: xeviar/LrcParser
int wmain()
{
    init();

    lrc::Parser par;
    if (!par.LoadFile(std::wstring(L"D:\\小小约会.lrc")))
    {
        Println(L"载入文件失败");
        return 0;
    }

    lrc::Lyric l;
    if (!par.MakeLyric(&l))
    {
        Println(L"生成歌词数据结构失败");
        return 0;
    }

    PrintLrc(l);

    return 0;
}
示例#8
0
文件: eval.cpp 项目: hyln9/nV
bool SearchFactValues(var &result, var head, var body)
{
	std::map<Var,dict_t>::const_iterator
		iter = FactValues.find(head);
	if(iter != FactValues.end())
	{
		dict_t::const_iterator
			iter2 = iter->second.find(body);
		if (Verbose >= 2) {
			wcerr << _W("Search factvalue for ");
			Println(Ex(head, body), wcerr);
		}
		if(iter2 != iter->second.end())
		{
			if (TraceRuleSymbols.count(head) != 0)
			{
				// FIXME: rewrite this after we implement the kernel message infrastructure
				Print(head);
				wcout << "::tracer : ";
				Print(Ex(head, body));
				wcout << " :> ";
				Print(iter2->second);
				wcout << "\n";
			}
			if (Verbose >= 2) {
				wcerr << _W("# Try ");
				Println(iter2->second, wcerr);
			}
			result = Eval(iter2->second);
			if (Verbose >= 2) {
				wcerr << _W("Result is ");
				Println(result, wcerr);
			}
			return true;
		}
	}
	return false;
}
示例#9
0
文件: print.cpp 项目: hyln9/nV
void Write(wostream &f, Var x)
{
	if(StrQ(x))
	{
		const wchar *s = CStr(x).c_str();
		size_t n = wcslen(s);
		for(size_t i = 0; i < n; ++i)
			FullPrint(s[i],f);
		f << std::endl;
	}
	else if(VecQ(x))
	{
		size_t n = Size(x);
		for(size_t i = 0; i < n; ++i)
			Print(Pretty(At(x,i)),f);
		f << std::endl;
	}
	else
		Println(x,f);
}
示例#10
0
文件: eval.cpp 项目: hyln9/nV
bool SearchCOpers(var &result, var head, var body)
{
	stdext::hash_map<Var,COper>::const_iterator
		iter = COpers.find(Head(head));
	if(iter != COpers.end())
	{
		try {
			result = iter->second(Body(head),body);
		}
		catch (UserException&) {
			throw;
		}
		catch (...) {
			wcerr << "COper error while eval ";
			Println(Ex(head, body), wcerr);
			throw;
		}
		if (result)
		{
			return true;
		}
	}
	return false;
}
示例#11
0
void GForce::ShowHelp() {
	UtilStr s;

	s.Assign( "X     - Display track title" );			__setChar( 1, cDispTrackTitle );	Println( &s );
	s.Assign( "X     - List configs" );					__setChar( 1, cGetConfigInfo );		Println( &s );
	s.Assign( "X     - Frame Rate" );					__setChar( 1, cFrameRate );			Println( &s );
	s.Assign( "X     - Particles on/off" );				__setChar( 1, cToggleParticles );	Println( &s );
	s.Assign( "X     - Spawn new particle" );			__setChar( 1, cSpawnNewParticle );	Println( &s );
	s.Assign( "X     - Fullscreen on/off" );			__setChar( 1, cToggleFullsceen );	Println( &s );
	s.Assign( "X     - Show config titles on/off" );	__setChar( 1, cToggleConfigName );	Println( &s );
	s.Assign( "X     - Normalize input on/off" );		__setChar( 1, cToggleNormalize );	Println( &s );

	s.Assign( "X X   - Freeze/Continue slideshow" );		__setChar( 1, cStopSlideshowAll );	__setChar( 3, cStartSlideshowAll );		Println( &s );
	s.Assign( "X X   - +/- sound amplitude (See Extras docs)" );		__setChar( 1, cDecMagScale );		__setChar( 3, cIncMagScale );		Println( &s );
	s.Assign( "X X   - +/- num of bins (Stps) (See Extras docs)" );		__setChar( 1, cDecNumSSteps );		__setChar( 3, cIncNumSSteps );		Println( &s );
	s.Assign( "X X X - Prev/Next/Hold DeltaField" );		__setChar( 1, cPrevDeltaField );	__setChar( 3, cNextDeltaField );		__setChar( 5, cToggleFieldShow );		Println( &s );
	s.Assign( "X X X - Prev/Next/Hold ColorMap" );			__setChar( 1, cPrevColorMap );		__setChar( 3, cNextColorMap );			__setChar( 5, cToggleColorShow );		Println( &s );
	s.Assign( "X X X - Prev/Next/Hold WaveShape" );			__setChar( 1, cPrevWaveShape );		__setChar( 3, cNextWaveShape );			__setChar( 5, cToggleShapeShow );		Println( &s );

	Println( "" );
	Println( "Press SHIFT and a number to store the current ColorMap, Waveshape, and" );
	Println( "   DeltaField, and press just the number to recall them." );

	// Give the user more time than usual since this is help info
	mConsoleExpireTime += 8000;
}
示例#12
0
GForce::GForce( void* inRefCon ) :
#if defined(UNIX_X)
	mPrefs( ".G-Force", true ),
#endif
	mConsoleLines( cDuplicatesAllowed, cOrderImportant ),
	mLineExpireTimes( cOrderImportant ),
	mPal1( mT, mIntensityParam ),
	mPal2( mT, mIntensityParam ),
	mDeltaFields	( cNoDuplicates_CaseInsensitive, cSortLowToHigh ),
	mColorMaps		( cNoDuplicates_CaseInsensitive, cSortLowToHigh ),
	mWaveShapes		( cNoDuplicates_CaseInsensitive, cSortLowToHigh ),
	mParticles		( cNoDuplicates_CaseInsensitive, cSortLowToHigh ),
	mWave1( mT ),
	mWave2( mT )
{
	// Do initting...
	mWind				= 0;
	mOutPort			= 0;
	mRefCon				= inRefCon;
	mFrameCount			= 0;
	mT_MS_Base			= EgOSUtils::CurTimeMS();
	mConsoleExpireTime	=
	mLastCursorUpdate	=
	mLastGetKeys		=
	mT_MS				= 0;
	mFrameCountStart	=
	mNextPaletteUpdate	=
	mT					= 0;
	mNextShapeChange	= mT + 10;
	mNextFieldChange	= mT + 10;
	mNextColorChange	= mT + 10;
	mLastSongStart		= mT - 10000;
	mLastKeyPollTime	= mT;
	mLastActiveTime		= mT;
	mDoingSetPortWin	= false;
	mNeedsPaneErased	= true;
	mShapeSlideShow		=
	mColorSlideShow		=
	mFieldSlideShow		= true;
	mAtFullScreen		= false;
	mMouseWillAwaken	= false;
	mTrackTextDur		= 0;

	mPrefs.Load();
	if ( mPrefs.GetPref( VAL('V','e','r','s') ) != GFORCE_COMPAT_VERSION ) {
		mConsoleDelay		= 8;
		mConsoleLineDur		= 14;
		mMagScale 			= 1;
		mTransitionLo		= 4;
		mTransitionHi		= 18;
		mScrnSaverDelay		= -1 * 60;			// Factory: screen saver mode disabled
		mPrefs.SetPref( VAL('V','e','r','s'), GFORCE_COMPAT_VERSION );
		mBorderlessWind		= 0;
		mHandleKeys			= 1;
		mNum_S_Steps 		= 200;
		mFullscreenSize.h	= 640;
		mFullscreenSize.v	= 480;
		mFullscreenDepth	= 8;
		mFullscreenDevice	= 0;
		mMaxSize.h			= 30000;
		mMaxSize.v			= 360;
		mTrackTextPosMode	= 5;
		mTrackTextSize		= 18;
		mNormalizeInput		= false;
		mNewConfigNotify	= false;
		mParticlesOn		= true;
		mKeyMap					.Assign( "TLRY`SNGFZXCQWE,.M[]{}P******!@#$%^&*()1234567890" );
		mFieldIntervalStr		.Assign( "18 + rnd( 15 )" );
		mColorIntervalStr		.Assign( "10 + rnd( 15 )" );
		mShapeIntervalStr		.Assign( "10 + rnd( 15 )" );
		mTrackFont				.Assign( __defaultFont );
		mTrackTextStartStr		.Assign( "4 + LAST_SONG_START - t" );
		mTrackTextDurationStr	.Assign( "5" );
		mTrackMetaText			.Assign( __defaultTTFormat );
		mParticleDuration		.Assign( "8 + rnd( 15 )" );
		mParticleProbability	.Assign( ".09/((NUM_PARTICLES+1)^1.66)" );


		// Show the welcome msg for a pref rewrite...
		Println( GFORCE_VERS_STR );
		Println( "Press '?' for help" );
	}
	else {
		mConsoleDelay       = mPrefs.GetPref( VAL('C','D','u','r') );
		mConsoleLineDur     = mPrefs.GetPref( VAL('C','L','i','n') );
		mMagScale           = mPrefs.GetPref( VAL('M','S','c','l') ) / 1000.0;
		mTransitionLo       = mPrefs.GetPref( VAL('T','r','L','o') );
		mTransitionHi       = mPrefs.GetPref( VAL('T','r','H','i') );
		mScrnSaverDelay     = mPrefs.GetPref( VAL('S','S','v','r') ) * 60.0;
		mBorderlessWind     = mPrefs.GetPref( VAL('N','o','B','o') );
		mHandleKeys         = mPrefs.GetPref( VAL('K','y','b','d') );
		mNum_S_Steps        = mPrefs.GetPref( VAL('S','t','p','s') );
		mFullscreenSize.h   = mPrefs.GetPref( VAL('F','S','_','X') );
		mFullscreenSize.v   = mPrefs.GetPref( VAL('F','S','_','Y') );
		mFullscreenDepth    = mPrefs.GetPref( VAL('F','S','_','D') );
		mFullscreenDevice   = mPrefs.GetPref( VAL('F','S','_','#') );
		mParticlesOn        = mPrefs.GetPref( VAL('P','_','O','n') );
		mNormalizeInput     = mPrefs.GetPref( VAL('N','o','r','m') );
		mMaxSize.v          = mPrefs.GetPref( VAL('M','a','x','Y') );
		mMaxSize.h          = mPrefs.GetPref( VAL('M','a','x','X') );
		mNewConfigNotify    = mPrefs.GetPref( VAL('S','h','w','T') );
		mTrackTextPosMode   = mPrefs.GetPref( VAL('T','P','o','s') );
		mTrackTextSize      = mPrefs.GetPref( VAL('T','S','z','e') );
		mPrefs.GetPref( VAL('W','I','n','t'), mShapeIntervalStr );
		mPrefs.GetPref( VAL('D','I','n','t'), mFieldIntervalStr );
		mPrefs.GetPref( VAL('C','I','n','t'), mColorIntervalStr );
		mPrefs.GetPref( VAL2('T','?'), mTrackTextStartStr );
		mPrefs.GetPref( VAL('T','D','u','r'), mTrackTextDurationStr );
		mPrefs.GetPref( VAL('T','F','n','t'), mTrackFont );
		mPrefs.GetPref( VAL('T','S','t','r'), mTrackMetaText );
		mPrefs.GetPref( VAL('P','D','u','r'), mParticleDuration );
		mPrefs.GetPref( VAL('P','P','r','b'), mParticleProbability );
		mPrefs.GetPref( VAL('K','M','a','p'), mKeyMap );
	}

	mPortA.SetTrackTextFont( mTrackFont, mTrackTextSize );
	mPortB.SetTrackTextFont( mTrackFont, mTrackTextSize );

	// Catch any bad values for mNumSampleBins
	if ( mNum_S_Steps < 1 || mNum_S_Steps > 10000 )
		mNum_S_Steps = 320;


	mNum_FFT_Steps = 256;

	// Alloc/setup the data we'll have our virtual machines accessing...
	SetNumSampleBins( mNum_S_Steps );
	SetNumFFTBins( mNum_FFT_Steps );

	// Setup waveshape members
	mWave1.SetMagFcn( (ExprUserFcn**) &mSampleFcn );
	mWave2.SetMagFcn( (ExprUserFcn**) &mSampleFcn );

	// FIXME, use FFT data here
	mWave1.SetFFTFcn( (ExprUserFcn**) &mFFTFcn );
	mWave2.SetFFTFcn( (ExprUserFcn**) &mFFTFcn );

	// Init particle stuff
	mDict.AddVar( "T", &mT );
	mDict.AddVar( "LAST_PARTICLE_START", &mLastParticleStart );
	mDict.AddVar( "NUM_PARTICLES", &mNumRunningParticles );
	mNumRunningParticles = 0;
	mNextParticleCheck = mT + 1;
	mParticleProbabilityFcn.Compile( mParticleProbability, mDict );
	mParticleDurationFcn.Compile( mParticleDuration, mDict );
	mShapeInterval.Compile( mShapeIntervalStr, mDict );
	mColorInterval.Compile( mColorIntervalStr, mDict );
	mFieldInterval.Compile( mFieldIntervalStr, mDict );

	// Track Text stuff
	mDict.AddVar( "LAST_SONG_START", &mLastSongStart );
	mTrackTextStartFcn.Compile( mTrackTextStartStr, mDict );
	mTrackTextDurFcn.Compile( mTrackTextDurationStr, mDict );

	// Transition bookkeeping
	mColorTransTime		= -1;
	mShapeTransTime		= -1;
	mGF_Palette			= 0;
	mWave				= 0;


	// Look in G-Force's support folders and see what we have to select from...
	BuildConfigLists();

	mField		= &mField1;
	mNextField	= &mField2;

	for ( int i = 0; i < 4; i++ )
		mCurKeys[ i ] = 0;
}
示例#13
0
void TPanel::Println(char* str){ Println((String) str);}
示例#14
0
 void ByteSink::Println(ByteSerializable & byteSerializable, s32 argument) {
   Print(byteSerializable, argument);
   Println();
 }
示例#15
0
  void ByteSink::Vprintf(const char * format, va_list & ap)
  {
    MFM_API_ASSERT_NONNULL(format);

    u8 p;
    Format::Type type;
    bool alt;
    s32 fieldWidth;
    u8 padChar;
    while ((p = *format++)) {
      if (p != '%') {
        if (p == '\n')          // '\n's _in_the_format_string_ are
          Println();            // treated as packet delimiters!
        else
          Print(p,Format::BYTE);
        continue;
      }

    alt = false;
    fieldWidth = -1;
    padChar = ' ';
  again:
    switch (p = *format++) {
    case '#': alt = true; goto again;

    case '0':
      if (fieldWidth < 0) {
        padChar = '0';
        fieldWidth = 0;
      } else fieldWidth *= 10;
      goto again;

    case '1': case '2': case '3': case '4': case '5':
    case '6': case '7': case '8': case '9':
      if (fieldWidth < 0) fieldWidth = 0;
      fieldWidth = fieldWidth * 10 + (p - '0');
      goto again;

    case 'c':
      {
        u32 ch = va_arg(ap,int);
        if (!alt || IsPrint(ch)) Print(ch,Format::BYTE);
        else {
          Print('[',Format::BYTE);
          if (ch < 0x10)
            Print('0', Format::BYTE);
          Print(ch, Format::HEX);
          Print(']', Format::BYTE);
        }
      }
      break;

    case '<':  // Print the rest of a given &ByteSource
      {
        ByteSource * bs = va_arg(ap,ByteSource*);
        if (!bs) Print("(null)");
        else Copy(*bs);
      }
      break;

    case '@':
      {
        s32 argument = 0;
        if (alt) argument = va_arg(ap,s32);
        ByteSerializable * bs = va_arg(ap,ByteSerializable*);
        if (!bs) Print("(null)");
        else Print(*bs, argument);
      }
      break;

    case 'q':
      Print(va_arg(ap,u64), Format::BEU64);
      break;
    case 'H': type = Format::LEXHD; goto print;
    case 'h': type = Format::BEU16; goto print;
    case 'l': type = Format::BEU32; goto print;

    case 'b': type = Format::BIN; goto printbase;
    case 'o': type = Format::OCT; goto printbase;
    case 'u': type = Format::DEC; goto printbase;
    case 'd':
      if (alt) {
        type = Format::DEC;
        goto printbase;
      } else {
        Print(va_arg(ap,s32), fieldWidth, padChar);
        break;
      }
    case 'x': type = Format::HEX; goto printbase;
    case 't': type = Format::B36; goto printbase;

    case 'D': type = Format::LEX32; goto print;
    case 'X': type = Format::LXX32; goto print;

    printbase:
      PrintInBase(va_arg(ap,u32), type, fieldWidth, padChar);
      break;
    print:
      Print(va_arg(ap,u32),type, fieldWidth, padChar);
      break;

    case 'f': 
    {
      FAIL(INCOMPLETE_CODE);
      /*
      double v =  va_arg(ap,double);
      ByteSink::Print(face,v);
      break;
      */
    }

    /* %Z: Print a null-terminated string INCLUDING a trailing NULL */
    case 'Z': 
    {
      const char * s = va_arg(ap,const char *);
      if (!s) Print("(null)", fieldWidth, padChar);
      else Print(s, fieldWidth, padChar);
    }
    /* FALL THROUGH */
    /* %z: Print a null byte.  Consumes no args */
    case 'z': 
      WriteByte('\0');
      break;

    case 's': {
      const char * s = va_arg(ap,const char *);
      if (!s) Print("(null)", fieldWidth, padChar);
      else Print(s, fieldWidth, padChar);
      break;
    }

    case 'S': {
      const char * s = va_arg(ap,const char *);
      if (!s) Print("(null)", fieldWidth, padChar);
      else PrintDoubleQuotedCStringWithLength(s);
      break;
    }

    case 'p': {
      const void * p = va_arg(ap,void *);
      if (!p) Print("(nullp)");
      else {
        Print("0x");
        Print((uptr) p, Format::HEX);
      }
      break;
    }

    case '%':
      Print(p, Format::BYTE);
      break;

    default:                    // Either I don't know that code, or you're bogus.
      FAIL(BAD_FORMAT_ARG);     // Either way, I die.  You're welcome.
    }
    }
  }
示例#16
0
文件: shell.c 项目: weiyuhan/nachos
int
main()
{
    SpaceId newProc;
    OpenFileId input = ConsoleInput;
    OpenFileId output = ConsoleOutput;
    char prompt[2], ch, buffer[60], cmd[20], arg[40];
    char* quit, ls, exec, path, echo, mkdir, rm, create, open, cd, close, read, write; 
    int bufferSize, bufferIndex, cmdIndex, argIndex;
    OpenFileId fd;


    prompt[0] = '-';
    prompt[1] = '-';

    while( 1 )
    {
    	Print("nachos://  ", 's');

		bufferSize = 0;
		
		do 
		{
		
		    Read(&buffer[bufferSize], 1, input);

		} while( buffer[bufferSize++] != '\n' );

		buffer[--bufferSize] = '\0';


		bufferIndex = 0;
		cmdIndex = 0;
		while(bufferIndex < bufferSize && buffer[bufferIndex] != '\0' 
			&& buffer[bufferIndex] != ' ')
		{
			cmd[cmdIndex++] = buffer[bufferIndex++];
		}
		cmd[cmdIndex] = '\0';

		while(bufferIndex < bufferSize && buffer[bufferIndex] == ' ')
		{
			bufferIndex++;
		}

		argIndex = 0;
		while(bufferIndex < bufferSize && buffer[bufferIndex] != '\0' 
			&& buffer[bufferIndex] != ' ')
		{
			arg[argIndex++] = buffer[bufferIndex++];
		}
		arg[argIndex] = '\0';

		if(cmdIndex > 0) 
		{
			if(argIndex > 0 && strcmp("exec", cmd, 4) == 0)
			{
				newProc = Exec(arg);
				if(newProc < 0)
				{
					Print("unable to run ", 's');
					Println(arg, 's');
					continue;
				}
				Print("SpaceId : ", 's');
				Println(newProc, 'd');
				Join(newProc);
			}
			if(strcmp("join", cmd, 4) == 0)
			{
				if(newProc >= 0)
					Join(newProc);
			}
			if(strcmp("ls", cmd, 2) == 0)
			{
				LS();
			}
			if(strcmp("quit", cmd, 4) == 0)
			{
				Exit(0);
			}
			if(strcmp("halt", cmd, 4) == 0)
			{
				Halt();
			}
			if(strcmp("path", cmd, 4) == 0)
			{
				Path();
			}
			if(strcmp("help", cmd, 4) == 0)
			{
				Println("ls,echo,mkdir,cd,rm is the same as linux", 's');
				Println("create a new file with: create [filename]", 's');
				Println("open a file with: open [filename]", 's');
				Println("close a file with: close [filename]", 's');
				Println("write an opened file with: write [content]", 's');
				Println("read an opened file with: read", 's');
				Println("close an opened file with: close", 's');
				Println("show current path with: path", 's');
				Println("exit system with: exit", 's');
				Println("halt system with: halt", 's');
			}
			if(argIndex > 0 && strcmp("echo", cmd, 4) == 0)
			{
				Println(arg, 's');
			}
			if(argIndex > 0 && strcmp("mkdir", cmd, 5) == 0)
			{
				MKDir(arg);
			}
			if(argIndex > 0 && strcmp("cd", cmd, 2) == 0)
			{
				CDDir(arg);
			}
			if(argIndex > 0 && strcmp("rm", cmd, 2) == 0)
			{
				Remove(arg);
			}
			if(argIndex > 0 && strcmp("create", cmd, 6) == 0)
			{
				Create(arg);
			}
			if(argIndex > 0 && strcmp("open", cmd, 4) == 0)
			{
				fd = Open(arg);
			}
			if(strcmp("close", cmd, 5) == 0)
			{
				Close(fd);
			}
			if(argIndex > 0 && strcmp("write", cmd, 5) == 0)
			{
				Write(arg, argIndex, fd);
			}
			if(strcmp("read", cmd, 4) == 0)
			{
				int readNum = Read(arg, 40, fd);
				arg[readNum] = '\0';
				Println(arg, 's');
			}
			if(strcmp("send", cmd, 4) == 0)
			{
				int num = parseInt(arg, argIndex);
				PutMsg(num, newProc);
			}
			if(strcmp("get", cmd, 3) == 0)
			{
				int num = GetMsg();
				Println(num, 'd');
			}
			if(strcmp("ts", cmd, 2) == 0)
			{
				TS();
			}
		}
    }
}
示例#17
0
void HttpServer::Println(int _integer)
{
        char  tmp[50];
        itoa(_integer, tmp, 50);
        Println(tmp);
}
示例#18
0
/** Print out a matrix to the GUI or command line
*/
void mPrint(Mat* m, char* msg, int inv)
{
#ifndef SIMULATOR
	{
		int i,j;
		
		if(m == NULL || msg == NULL)
			return;// MAT_ERROR_NULL_PTR;

		Println();

		if(msg != NULL)
		{
			Print(msg);
			if(m->cols > 1)
				Println();
		}
		
		
		for(i=0 ; i < m->rows ; i++)
		{
			for(j=0 ; j < m->cols ; j++)
			{
				if(m->type == MAT_32F || m->type == MAT_64F) 
				{
					PrintFloat(mGet(m,i,j));
					Print("\t");
				}
				else
				{
					PrintFloat(mGetu(m,i,j));
					Print("\t");
				}
			}
			if(m->cols > 1)
				Println();
		}
		if(m->cols == 1)
			Println();
	}
#endif
#ifdef SIMULATOR
	{
		int i,j,iend,jend;

		printf("\r\n");
	
		iend = (inv == 0) ? m->rows : m->cols;
		jend = (inv == 0) ? m->cols : m->rows;

		if(msg != NULL)
		{
			printf(msg);
			if(jend > 1)
				printf("\r\n");
		}
		
		for(i = 0 ; i < iend ; i++)
		{
			for(j = 0 ; j < jend ; j++)
			{
				if(inv == 0)
					printf("%16.5f\t",mGet(m,i,j));
				else
					printf("%16.5f\t",mGet(m,j,i));
			}

			if(jend > 1)
				printf("\r\n");
		}

		if(jend == 1)
			printf("\r\n");
	}
#endif
}
示例#19
0
bool GForce::HandleKey( long inChar ) {
	bool handled = true;
	int n;

	// See if this keystroke is to be ignored
	if ( ! mHandleKeys )
		return false;


	if ( inChar >= 'a' && inChar <= 'z' )
		inChar = 'A' + ( inChar - 'a' );

	if ( inChar == '/' || inChar == '?' )
		ShowHelp();
	else if ( inChar >= ' ' && inChar < 129 ) {

		inChar = mKeyMap.FindNextInstanceOf( 0, inChar );

		switch ( inChar ) {

		case cDispTrackTitle:
			StartTrackText();
			break;

		case cGetConfigInfo:
		  {
			Print(_("WaveShape:  "));
			Println( &mWaveShapeName );
			Print(_("ColorMap:   "));
			Println( &mColorMapName );
			Print(_("DeltaField: "));
			Println( mField -> GetName() );
			ParticleGroup* particle = (ParticleGroup*) mRunningParticlePool.GetHead();
			if ( particle ) {
				Print(_("Particles:  "));

				while ( particle ) {
					Print( &particle -> mTitle );
					particle = (ParticleGroup*) particle -> GetNext();
					if ( particle )
						Print( ", " );
				}
				Println( "" );
			}
			break;
		  }
		case cFrameRate:
			mTemp.SetFloatValue( ( (float) mCurFrameRate ) / 10.0 );
			mTemp.Append(_(" frames/sec"));
			Println( &mTemp );
			break;

		case cDecMagScale:
			mMagScale /= 1.2;
			mTemp.SetFloatValue( mMagScale );
			Print(_("Amplitude scale: "));
			Println( &mTemp );
			break;

		case cIncMagScale:
			mMagScale *= 1.2;
			mTemp.SetFloatValue( mMagScale );
			Print(_("Amplitude scale: "));
			Println( &mTemp );
			break;

		case cToggleParticles:
			mParticlesOn = ! mParticlesOn;
			if ( mParticlesOn )
				Println(_("Particles ON"));
			else
				Println(_("Particles OFF"));
			break;

		case cSpawnNewParticle:
			SpawnNewParticle();
			break;

		case cDecNumSSteps:
		case cIncNumSSteps:
			if ( inChar == cDecNumSSteps )
				n = - 4;
			else
				n = + 4;
			SetNumSampleBins( mNum_S_Steps + n );
			mTemp.Assign(_("Number s steps: "));
			mTemp.Append( mNum_S_Steps );
			Println( &mTemp );
			break;

		case cToggleConfigName:
			mNewConfigNotify = ! mNewConfigNotify;
			if ( mNewConfigNotify )
				Println(_("Show names ON"));
			else
				Println(_("Show names OFF"));
			break;

		case cToggleNormalize:
			mNormalizeInput = ! mNormalizeInput;
			if ( mNormalizeInput )
				Println(_("Normalize ON"));
			else
				Println(_("Normalize OFF"));
			break;

		case cPrevDeltaField:
		case cNextDeltaField:
			n = mFieldPlayList.FindIndexOf( mCurFieldNum );
			if ( inChar == cPrevDeltaField )
				n = n + mFieldPlayList.Count() - 2;

			loadDeltaField( mFieldPlayList.Fetch( 1 + n % mFieldPlayList.Count() ) );

			// If the pref says so, display that we're loading a new config
			if ( mNewConfigNotify ) {
				Print(_("Loading DeltaField: "));
				Println( mField -> GetName() );
			}

			// Turn field slide show off when we change deltafields manually
			if ( ! mFieldSlideShow )
				break;
		case cToggleFieldShow:
			mFieldSlideShow = ! mFieldSlideShow;
			mNextFieldChange = mT;
			if ( mFieldSlideShow ) {
				Println(_("DeltaField slideshow ON"));
				mFieldPlayList.Randomize(); }
			else
				Println(_("DeltaField slideshow OFF"));
			break;


		case cStartSlideshowAll:
			mFieldSlideShow = true;		mNextFieldChange = mT;
			mColorSlideShow = true;		mNextColorChange = mT;
			mShapeSlideShow = true;		mNextShapeChange = mT;
			Println(_("All slideshows ON"));
			break;

		case cStopSlideshowAll:
			mFieldSlideShow = false;
			mColorSlideShow = false;
			mShapeSlideShow = false;
			Println(_("All slideshows OFF"));
			break;


		case cPrevColorMap:
		case cNextColorMap:
			n = mColorPlayList.FindIndexOf( mCurColorMapNum );
			if ( inChar == cPrevColorMap )
				n = n + mColorPlayList.Count() - 2;

			loadColorMap( mColorPlayList.Fetch( 1 + n % mColorPlayList.Count() ), false );

			// Turn slide show off when we change colormaps manually
			if ( ! mColorSlideShow )
				break;
		case cToggleColorShow:
			mColorSlideShow = ! mColorSlideShow;
			mNextColorChange = mT;
			if ( mColorSlideShow ) {
				Println(_("ColorMap slideshow ON"));
				mColorPlayList.Randomize(); }
			else
				Println(_("ColorMap slideshow OFF"));
			break;

		case cPrevWaveShape:
		case cNextWaveShape:
			n = mShapePlayList.FindIndexOf( mCurShapeNum );
			if ( inChar == cPrevWaveShape )
				n = n + mShapePlayList.Count() - 2;

			loadWaveShape( mShapePlayList.Fetch( 1 + n % mShapePlayList.Count() ), false );

			// Turn slide show off when we change shapes manually
			if ( ! mShapeSlideShow )
				break;
		case cToggleShapeShow:
			mShapeSlideShow = ! mShapeSlideShow;
			mNextShapeChange = mT;
			if ( mShapeSlideShow ) {
				Println(_("WaveShape slideshow ON"));
				mShapePlayList.Randomize(); }
			else
				Println(_("WaveShape slideshow OFF"));
			break;

		case cSetPreset0:	StoreConfigState( VAL('S','E','T','0') );	break;
		case cSetPreset1:	StoreConfigState( VAL('S','E','T','1') );	break;
		case cSetPreset2:	StoreConfigState( VAL('S','E','T','2') );	break;
		case cSetPreset3:	StoreConfigState( VAL('S','E','T','3') );	break;
		case cSetPreset4:	StoreConfigState( VAL('S','E','T','4') );	break;
		case cSetPreset5:	StoreConfigState( VAL('S','E','T','5') );	break;
		case cSetPreset6:	StoreConfigState( VAL('S','E','T','6') );	break;
		case cSetPreset7:	StoreConfigState( VAL('S','E','T','7') );	break;
		case cSetPreset8:	StoreConfigState( VAL('S','E','T','8') );	break;
		case cSetPreset9:	StoreConfigState( VAL('S','E','T','9') );	break;


		case cPreset0:	handled = RestoreConfigState( VAL('S','E','T','0') );	break;
		case cPreset1:	handled = RestoreConfigState( VAL('S','E','T','1') );	break;
		case cPreset2:	handled = RestoreConfigState( VAL('S','E','T','2') );	break;
		case cPreset3:	handled = RestoreConfigState( VAL('S','E','T','3') );	break;
		case cPreset4:	handled = RestoreConfigState( VAL('S','E','T','4') );	break;
		case cPreset5:	handled = RestoreConfigState( VAL('S','E','T','5') );	break;
		case cPreset6:	handled = RestoreConfigState( VAL('S','E','T','6') );	break;
		case cPreset7:	handled = RestoreConfigState( VAL('S','E','T','7') );	break;
		case cPreset8:	handled = RestoreConfigState( VAL('S','E','T','8') );	break;
		case cPreset9:	handled = RestoreConfigState( VAL('S','E','T','9') );	break;

		default:
			handled = false;
		}	}
	else
		handled = false;

	return handled;
}
示例#20
0
文件: eval.cpp 项目: hyln9/nV
bool SearchDownValues(var &result, var head, var body)
{
	std::map<Var,def_t>::const_iterator
		iter = DownValues.find(head);
	if(iter != DownValues.end())
	{
		const def_t &definitions = iter->second;
		if (Verbose >= 2) {
			wcerr << _W("Search downvalue for ");
			Println(Ex(head, body), wcerr);
		}
		if (definitions.is_vec()) {
			def_t::vec_t::const_iterator
				iter2 = definitions.vec->begin();
			while(iter2 != definitions.vec->end())
			{
				if (Verbose >= 2) {
					wcerr << _W("# Try ");
					Print(iter2->first);
					wcerr << _W(" :> ");
					Print(iter2->second.second);
					wcerr << std::endl;
				}
				map_t m;
				if(MatchQ(m,iter2->second.first,body))
				{
					if (TraceRuleSymbols.count(head) != 0)
					{
						// FIXME: rewrite this after we implement the kernel message infrastructure
						Print(head);
						wcout << _W("::tracer : ");
						Print(Ex(head, body));
						wcout << _W(" :> ");
						Print(iter2->second.second);
						wcout << "\n";
					}
					result = Eval(Subs(m,iter2->second.second));
					if (ExQ(result, TAG(Condition))) {
						++iter2;
						continue;
					}
					if (Verbose >= 2) {
						wcerr << _W("Result is ");
						Println(result, wcerr);
					}
					return true;
				}
				++iter2;
			}
		} else {
			def_t::map_t::const_iterator
				iter2 = definitions.map->begin();
			if (Verbose >= 2) {
				wcerr << _W("Search downvalue for ");
				Println(Ex(head, body), wcerr);
			}
			while(iter2 != definitions.map->end())
			{
				if (Verbose >= 2) {
					wcerr << _W("# Try ");
					Print(iter2->first);
					wcout << _W(" :> ");
					Print(iter2->second.second);
					wcout << std::endl;
				}
				map_t m;
				if(MatchQ(m,iter2->second.first,body))
				{
					if (TraceRuleSymbols.count(head) != 0)
					{
						// FIXME: rewrite this after we implement the kernel message infrastructure
						Print(head);
						wcout << _W("::tracer : ");
						Print(Ex(head, body));
						wcout << _W(" :> ");
						Print(iter2->second.second);
						wcout << "\n";
					}
					result = Eval(Subs(m,iter2->second.second));
					if (ExQ(result, TAG(Condition))) {
						++iter2;
						continue;
					}
					if (Verbose >= 2) {
						wcerr << _W("Result is ");
						Println(result, wcerr);
					}
					return true;
				}
				++iter2;
			}
		}
	}
	return false;
}