void processCommand(std::vector< std::string > &args)
    {
/*      printf("PROCESS: ");
      for(int i = 0; i < args.size(); i ++) {
        printf("[%s] ", args[i].c_str());
      }
      printf("\n");*/
      if(args.empty()) {
        *mAction = BNBActions::ERASE;
      } else if(args[0] == "forward")  {
        *mAction = BNBActions::FORWARD | BNBActions::ERASE;
        eraseCommand();
      } else if(args[0] == "drop")  {
        *mAction = BNBActions::DROP | BNBActions::ERASE;
        eraseCommand();
      } else if(args[0] == "var") {
        BNB_ASSERT(args.size() == 2);
        processVar(args[1]);
      } else if(args[0] == "set") {
        BNB_ASSERT(args.size() == 3);
        processAssign(args[1], args[2]);
      } else if(args[0] == "inc") {
        BNB_ASSERT(args.size() == 3);
        processInc(args[1], args[2]);
      } else if(args[0] == "cat") {
        BNB_ASSERT(args.size() == 3);
        processCat(args[1], args[2]);
      } else if(args[0] == "wait") {
        BNB_ASSERT(args.size() == 4);        
        processWait(args[1], args[2], args[3]);
      } else if(args[0] == "echo") {
        processEcho(args);
      } else if(args[0] == "erase") {
        *mAction = BNBActions::ERASE;
        eraseCommand();        
      } else if(args[0] == "save") {
        processSave(args[1], args[2]);
      } else if(args[0] == "append") {
        processAppend(args[1], args[2]);
      } else if(args[0] == "load") {
        processLoad(args[1], args[2]);
      } else if(args[0] == "mkdir") {
        processMkdir(args[1]);
      } else if(args[0] == "skip") {
        eraseCommand();
      } else if(args[0] == "exec") {
        processExec(args[1]);
      } else if(args[0] == "exit") {
        *mAction = BNBActions::EXIT;
        eraseCommand();
      } else {
        printf("%s\n", args[0].c_str());
        BNB_ERROR_REPORT("Unrecognized command");
      }
    }
Exemple #2
0
int SSIEngine::executeComponent(HttpSession *pSession,
                                SSIComponent *pComponent)
{
    AutoBuf *pBuf;
    int ret;

    LS_DBG_H(pSession->getLogSession(), "SSI Process component: %d",
             pComponent->getType());

    switch (pComponent->getType())
    {
    case SSIComponent::SSI_String:
        pBuf = pComponent->getContentBuf();
        pSession->appendDynBody(pBuf->begin(), pBuf->size());
        break;
    case SSIComponent::SSI_Config:
        updateSSIConfig(pSession, pComponent, pSession->getReq()->getSSIRuntime());
        break;
    case SSIComponent::SSI_Echo:
        processEcho(pSession, pComponent);
        break;
    case SSIComponent::SSI_Exec:
        ret = processExec(pSession, pComponent);
        return ret;
        break;
    case SSIComponent::SSI_FSize:
    case SSIComponent::SSI_Flastmod:
        processFileAttr(pSession, pComponent);
        break;
    case SSIComponent::SSI_Include:
        ret = processInclude(pSession, pComponent);
        return ret;
        break;
    case SSIComponent::SSI_Printenv:
        processPrintEnv(pSession);
        break;
    case SSIComponent::SSI_Set:
        processSet(pSession, pComponent);
        break;
    case SSIComponent::SSI_If:
    case SSIComponent::SSI_Elif:
        processIf(pSession, (SSI_If *)pComponent);
        break;
        //SSI_Else,
        //SSI_Elif,
        //SSI_Endif,

    }
    return 0;
}
Exemple #3
0
void TOutputDevice::encodeCard()
{
	static Boolean resetDone = False;

	if( !resetDone || formDef->oldDevice )
		{
		writeCommand( "@" );
		checkStatus();
		if( !formDef->oldDevice )
			delay( 3000 );
		else
			delay( 1000 );

		resetDone = True;
		}

	filterExtChars( trackBuffer, noTracks * trackLength );

	static Boolean tracksSet = False;

	if( formDef->oldDevice )
		{
		writeCommand( "E" );
		checkStatus();

//		if( !tracksSet )
//			{
			writeCommand( "T2" );
			checkStatus();
			writeCommand( "T3" );
			checkStatus();
			tracksSet = True;
//			}
		}

	char trackCommand[3] = "Ix";

	for( char c = 0; c < noTracks; c++ )
		{
		trackCommand[1] = ((char)(c + '1'));

		int dataLen;

		if( formDef->oldDevice )
			switch( c )
				{
				case 0:
					dataLen = 76;
					break;

				case 1:
					dataLen = 36;
					for( int i = 0; i < dataLen; i++ )
						{
						int index = c * trackLength + i;
						switch( trackBuffer[index] )
							{
							case ' ':
								trackBuffer[index] = '0';
								break;

							case '.':
								trackBuffer[index] = 'D';
								break;
							}
						}

					break;

				case 2:
					dataLen = 104;
					break;
				}
		else
			dataLen = trackLength;

		writeCommand( trackCommand, &trackBuffer[c * trackLength],
					  dataLen );
		if( !formDef->oldDevice )
			checkStatus();
		else
			processEcho();
		}

	if( !formDef->oldDevice )
		{
		filterExtChars( label, noLines * lineLength );

		writeCommand( "N" );
		checkStatus();


		char command[3];
		command[0] = esc;
		command[2] = '\r';


		command[0] = 0x1C;
		command[1] = 'T';
		writeBytes( command, 3 );

		for( c = 0; c < noLines; c++ )
			{
			if( c == 0 )
				{
				command[1] = 'F';
				writeBytes( command, 2 );
				}
			else
				{
				command[1] = 'H';
				writeBytes( command, 2 );
				}

			char indent[2] = { ' ', ' ' };
			writeBytes( indent, sizeof( indent ) );
			writeBytes( &label[c * lineLength], lineLength );
			command[1] = '\r';
			command[2] = '\n';
			writeBytes( &command[1], 2 );
			}

		writeCommand( "O" );
		checkStatus();
		}

	writeCommand( "W" );
	checkStatus();

	if( !formDef->oldDevice )
		writeCommand( "A" );

	if( formDef->oldDevice )
		messageBox( "Bitte Karte einf�hren, warten, bis "
					"der Kodiervorgang beendet ist und "
					"mit Enter best�tigen.", mfInformation | mfOKButton );

	writeCommand( "H" );
	if( formDef->oldDevice )
		checkStatus();
}