Пример #1
0
tVoid PrintArgs( int argc , char** argv )
{
   int idx ;

   for( idx = 0 ; idx < argc ; idx++ )
   {
      OutInt( idx , sizeof( idx ) ) ;
      OutString( " : " ) ;
      OutString( argv[ idx ] ) ;
      OutLinefeed() ;
   }
}
Пример #2
0
bool Archive::ToVarList(IVarList & args) {
    UI8_TYPE nType = GetNextType();
    if (TYPE_UNKWON == nType) {
        return false;
    }

    args.Clear();

    while (TYPE_UNKWON != nType) {
        switch (nType) {
            case TYPE_INT:
                args << OutI32();
                break;
            case TYPE_INT64:
                args << OutI64();
                break;
            case TYPE_STRING:
                args << OutString();
                break;
            case TYPE_WIDESTR:
                args << OutWideStr();
                break;
            case TYPE_DOUBLE:
                args << OutDouble();
                break;
        }

        nType = GetNextType();
    }
    return true;
}
Пример #3
0
/*
 * EnableModem()
 *
 * This will enable the modem for use.
 */
void EnableModem(char FromNet)
{
    if (FromNet || strLen(cfg.DepData.sEnable) == 0)
	InternalEnDis(TRUE);
    else
	OutString(cfg.DepData.sEnable);
}
Пример #4
0
// Convert number to string (char array)
// Writes to timerOutput char array
SINT32 BinToDec( int seconds ){
    int md = 0;
    int ctr = 0;

    while( seconds ){
        // Take new least significant digit
        md = seconds % 10;
		
		// Convert to char and place in array
        timerOutput[ctr] = md + '0';
       
        // Remove handled digit
        seconds /= 10;

        ctr++;
    }

	// Last increment of ctr is above last index
    ctr--;

	// Output in reverse order
    while( ctr >= 0 ){
        OutChar( timerOutput[ctr] );
        ctr--;
    }

    OutString( (CHAR*)" seconds passed\n\r" ); 

    return RTX_SUCCESS;
}
Пример #5
0
/*
 * ReInitModem()
 *
 * This function will reinitialize the modem at a high speed.
 */
void ReInitModem()
{
    if (strLen(cfg.DepData.HiSpeedInit) != 0 && !gotCarrier()) {
	setNetCallBaud(cfg.sysBaud);
	OutString(cfg.DepData.HiSpeedInit);
    }
}
Пример #6
0
tBoolean CliHelp( int argc , char** argv ) 
{
   int idx ;
   int idxMin ;
   int idxMax ;

   OutLinefeed() ;

   if( argc > 0 )
   {
      idxMin = GetIndex( argv[0] ) ;
      idxMax = idxMin+1 ;
   }
   else
   {
      idxMin = 0 ;
      idxMax = sTableSize ;
   }

   for( idx = idxMin ; idx < idxMax ; idx++ )
   {
      OutString( sCliTable[idx].help ) ;
      OutLinefeed() ;
      OutLinefeed() ;
   }
   OutLinefeed() ;

   return TRUE ;
}
Пример #7
0
/*
 * DisableModem()
 *
 * This function will disable the modem.
 */
void DisableModem(char FromNet)
{
    if (FromNet || strLen(cfg.DepData.sDisable) == 0)
	InternalEnDis(FALSE);
    else
	OutString(cfg.DepData.sDisable);
}
Пример #8
0
REC_INFO* NewRecEle()
{
    REC_INFO* pRec = NULL;
    pRec = (REC_INFO*)malloc(sizeof(REC_INFO));
    OutString(DBG_RES,"Malloc ELE\n");
    if(pRec == NULL)
    {
        return NULL;
    }
    memset(pRec,0,sizeof(REC_INFO));
    return pRec;
}
Пример #9
0
bool clWAVDataEncoder::ResetEncoder( int NumChannels, int NumSamplesPerSec, int BitsPerSample, float Quality )
{
	m_OutputData.clear();
	m_OutputData.reserve( 1024*1024 );

	OutString( "RIFF----WAVEfmt " );

	// write WAVEfmt header
	OutValue( 16, 4 );
	OutValue( 1, 2 );	// PCM
	OutValue( NumChannels, 2 );
	OutValue( NumSamplesPerSec, 4 );
	OutValue( NumSamplesPerSec * BitsPerSample * NumChannels / 8, 4 );
	OutValue( NumChannels * sizeof( uint16_t ), 2 ); // data block size
	OutValue( 16, 2 );	// bits per sample

	m_DataChunkPos = m_OutputData.size();

	OutString( "data----" );

	return false;
}
Пример #10
0
static tVoid ReplaceLine( int* curr , int* last , char* str ) 
{
   int idx ;
   
   for( idx = 0 ; idx < *curr ; idx++ )
   {
      SerialWrite( SERIAL_PORT_MONITOR , (tUByte*)LeftString , sizeof( LeftString ) ) ;
   }
   
   for( idx = 0 ; idx < *last ; idx++ )
   {
      OutString( " " ) ;
   }
   
   for( idx = 0 ; idx < *last ; idx++ )
   {
      SerialWrite( SERIAL_PORT_MONITOR , (tUByte*)LeftString , sizeof( LeftString ) ) ;
   }
   
   OutString( str ) ;
   *curr = strlen( str ) ;
   *last = *curr ;
}
Пример #11
0
inline int IsSeperator(char ch, enum ELE_SEPERATOR_TYPE *pType)
{
    int i = 0;
    for(i = 0; i < sizeof(seperator)/sizeof(seperator[0]); ++i)
    {
        if(seperator[i] == ch)
        {
            OutString(DBG_IS_SEPERATOR, "FindSeperator[%c]\n",ch);
            *pType = i;
            return 1;
        }
    }
    return 0;
}
Пример #12
0
void SerialPortC::BreakConnection(void)
	{
	FlushOutput();

	DropDtr();
	RaiseDtr();

	pause(50);

	if (cfg.dumbmodem == 6 || cfg.dumbmodem == 7)
		{
		OutString(cfg.hangup);
		OutString(br);

		if (cfg.hangupdelay)
			{
			pause(cfg.hangupdelay * 100);
			}
		else
			{
			pause(50);
			}
		}
	}
Пример #13
0
void DelAllEle(REC_INFO* pEle)
{
    REC_INFO* pEleDel;
    REC_INFO* pEleNext;
    pEleDel = pEle;
    while(pEleDel)
    {
        pEleNext = pEleDel->pNext;
        if(pEleDel->pContent)
        {
            free(pEleDel->pContent);
        }
        free(pEleDel);
        OutString(DBG_RES, "FREE ELE\n");
        pEleDel = pEleNext;
    }
    return;
}
Пример #14
0
tBoolean CliProcess()
{
   /* returns TRUE if still processing */
   tBoolean processing = FALSE ;
   int argc ;
   int idx ;

   argc = ParseLine( sLineCurrent ) ;

   if( argc >= 1 && ( idx = GetIndex( argv[ 0 ] ) ) >= 0 )
   {
      sContinue = sCliTable[idx].pfunc( argc-1 , &argv[1] ) ;
   }
   else
   {
      OutLinefeed() ;
      OutString( "Unrecognized command (enter ? for command list)" ) ;
      OutLinefeed() ;
   }

   return processing ;
}
Пример #15
0
tBoolean CliGet()
{
   static int idx = 0 ;
   static int idxMax = 0 ;
   static tBoolean esc = FALSE ; 
   tUByte inbyte ;
   tBoolean enterHit = FALSE ;
   tUByte* ptr ;
   int size ;
   static int lineCurrent = 0 ;
   static int lineBuffer  = 0 ;
   static int lineMax = 0 ;
   static tBoolean prompt = FALSE ;
   int echo = FALSE ;
   
   ptr = &inbyte ;
   size = 1 ;
   
   if( !prompt )
   {
      OutString( ">" ) ;
      prompt = TRUE ;
   }

   if( SerialRead( SERIAL_PORT_MONITOR , &inbyte , 1 ) )
   {
      if( inbyte == ESCAPE_KEY )
      {
         esc = TRUE ;
      }
      else if( esc )
      {
         if( inbyte == ESCAPE2_KEY ) /* ignore after escape */
         {
            inbyte = 0 ;
         }
         else {
            switch( inbyte )
            {
            case UP_KEY :
               inbyte = 0 ;
               lineBuffer-- ;
               if( lineBuffer < 0 )
               {
                  lineBuffer = lineMax-1 ;
               }
               memcpy( sLineCurrent , (char*)sLineBuf[ lineBuffer ] , sizeof( sLineCurrent ) ) ;
               ReplaceLine( &idx , &idxMax , (char*)sLineCurrent ) ;
               break ;
            case DOWN_KEY : 
               inbyte = 0 ;
               lineBuffer++ ;
               if( lineBuffer >= lineMax )
               {
                  lineBuffer = 0 ;
               }
               memcpy( sLineCurrent , (char*)sLineBuf[ lineBuffer ] , sizeof( sLineCurrent ) ) ;
               ReplaceLine( &idx , &idxMax , (char*)sLineCurrent ) ;
               break ;
            case RIGHT_KEY :
               inbyte = MAP_RIGHT ;
               ptr = (tUByte*)RightString ;
               size = sizeof( RightString ) ;
               break ;
            case LEFT_KEY :
               inbyte = MAP_LEFT ;
               ptr = (tUByte*)LeftString ;
               size = sizeof( LeftString ) ;
               break ;
            default :                
               inbyte = 0 ;
               break ;
            }
            esc = FALSE ;
         }
      }
   
      if(   ( inbyte == BACKSPACE_KEY ) 
         || ( inbyte == ENTER_KEY ) 
         || ( inbyte == MAP_LEFT ) 
         || ( inbyte == MAP_RIGHT ) 
         || ( ( inbyte >= ' ' ) && ( inbyte <= '~' ) ) )
      {

         if( inbyte == ENTER_KEY )
         {
            sLineCurrent[ idxMax ] = 0 ; /* null terminate string */
            idx = 0 ;
            idxMax = 0 ;
            enterHit = TRUE ;
            memcpy( sLineBuf[ lineCurrent ] , sLineCurrent , sizeof( sLineCurrent ) ) ;
            lineCurrent++ ;
            if( lineCurrent >= BUFFER_LINES )
            {
               lineCurrent = 0 ; 
            }
            lineBuffer = lineCurrent ;
            if( lineCurrent > lineMax )
            {
               lineMax = lineCurrent ;
            }
            prompt = FALSE ;
            echo = TRUE ;
         }
         else if( inbyte == BACKSPACE_KEY )
         {
            if( idx )
            {
               SerialWrite( SERIAL_PORT_MONITOR , (tUByte*)LeftString , sizeof( LeftString ) ) ;
               OutString( " " ) ;
               SerialWrite( SERIAL_PORT_MONITOR , (tUByte*)LeftString , sizeof( LeftString ) ) ;
               idx-- ;
            }
         }
         else if( inbyte == MAP_LEFT )
         {
            if( idx )
            {
               idx-- ;
               echo = TRUE ;
            }
         }
         else if( ( inbyte == MAP_RIGHT ) )
         {
            if( idx < idxMax )
            {
               idx++ ;
               echo = TRUE ;
            }
         }
         else if( idx < ( LINE_BUF_SIZE - 1 ) ) 
         {
            sLineCurrent[ idx++ ] = inbyte ;
            echo = TRUE ;
         }
      }         
   }
   
   if( echo ) 
   {
      SerialWrite( SERIAL_PORT_MONITOR , ptr , size ) ;
   }
   
   if( idx > idxMax )
   {
      idxMax = idx ;
   }

   return enterHit ;
}
Пример #16
0
tBoolean MemDump( int argc , char** argv )
{
   tByte* ptr ;
   tByte* ptrEnd ;
   int    size ;
   int    linecount = 0 ;
   char   ascii[LINE_LENGTH+1] ;

   ascii[ LINE_LENGTH ] = 0 ; /* Null terminate */
      
   if( argc != 2 )
   {
      return FALSE ;
   }

   size = StringToInt( argv[1] ) ;

   ptr  = (char*)StringToInt( argv[0] ) ;

   ptrEnd = ptr + size ;

   OutLinefeed() ;

   while( ptr < ptrEnd )
   {
      if( linecount == 0 )
      {
         OutHex( (tULong)ptr , 4 ) ;
         OutString( " : " ) ;
      }

      OutHex( *ptr , 1 ) ;

      /* printable characters */
      if( *ptr >= ' ' && *ptr <= '~' )
      {
         ascii[ linecount ] = *ptr ;
      }
      else
      {
         ascii[ linecount ] = '.' ;
      }

      OutString( " " ) ;
      ptr++ ;
      linecount++ ;
      if( linecount == 8 )
      {
         OutString( "  " ) ;
      }
      else if( linecount == 16 ) 
      {
         OutString( "  " ) ;
         OutString( (char*)ascii ) ;

         OutLinefeed() ;
         linecount = 0 ;
      }
   }

   ascii[ linecount ] = 0 ;
   OutString( "  " ) ;
   OutString( (char*)ascii ) ;

   OutLinefeed() ;
   
   return TRUE ;
}
Пример #17
0
int GentConnect::TryRunning(string &outstr2) {
    char *new_rbuf;
    int rbytes = 0;
    int readNum;
    int stop=0;
	while(true) {
	  if(stop==1) break;
        switch(curstatus) {
            case Status::CONN_READ:
                outstr = "";
                readNum = InitRead(rbytes);
                LOG(GentLog::INFO, "init read the number of byte is %d.", readNum);
                if(readNum < 0) {
                    LOG(GentLog::WARN, "init read the number of byte less than zero");
                    outstr2 = "read error\r\n";
                    Reset();
                    return readNum;
                }else if(readNum == 0) {                                
                    return readNum;
                }
                remainsize = comm->Process(rbuf, rbytes, outstr);
                LOG(GentLog::INFO, "curstatus: %d",curstatus);
                 if(!remainsize && outstr != "") {
                     curstatus = Status::CONN_WRITE;
                     gevent->UpdateEvent(fd, this, eventWrite);
                }
                break;
            case Status::CONN_NREAD:
                //OutString("ok\r\n"); 
                //LOG(GentLog::INFO, "start conn_nread remainsize:%d",remainsize);
				if(!content) {
                    new_rbuf = (char *)malloc(remainsize);
                    memset(new_rbuf,0,remainsize);
                    rcont = content = new_rbuf;
                }
                if(NextRead() == -1) {
                    stop = 1;
                    break;		
                }
                break;
            case Status::CONN_DATA:
                outstr = "";
                comm->Complete(outstr,content, actualsize);
                curstatus = Status::CONN_WRITE;
                gevent->UpdateEvent(fd, this, eventWrite);
                
                return 0;
            case Status::CONN_WRITE:
                OutString(outstr);
                break;
            case Status::CONN_WAIT:
				LOG(GentLog::INFO, "the status of %d is connect wait", fd);
                remainsize = 0;
                Reset();
                curstatus = Status::CONN_READ;
                //GentEvent::Instance()->UpdateEvent(fd, this);
                gevent->UpdateEvent(fd, this, eventRead);
                
                return 0;
            case Status::CONN_CLOSE:
                return -1;		
            default:
                return -1;
        }
        
	}
	return 1;
}
Пример #18
0
int ReadInLine(FILE* pFile, REC_INFO* pLineInfo)
{
    char* pLine = NULL;
    int ret = 0;
    unsigned int readPos = 0;
    unsigned int eleLen = 0;
    size_t lineLen = 0;
    REC_INFO* pEleEnd = pLineInfo;
    enum ELE_SEPERATOR_TYPE sepType = SEP_END;

    pLine = (char*)malloc(MAX_LINE_CHAR_COUNT);
    OutString(DBG_RES, "Malloc Local pLine\n");
    if(pLine == NULL)
    {
        return -1;
    }
    memset(pLine, 0, MAX_LINE_CHAR_COUNT);

    ret = -2;
    while(fgets(pLine, MAX_LINE_CHAR_COUNT, pFile) != NULL)
    {
        lineLen = strlen(pLine);
        for(readPos = 0, eleLen = 0; readPos < lineLen; ++readPos)
        {
            if(IsSeperator(pLine[readPos],&sepType))
            {
                if(eleLen > 0)
                {
                    pEleEnd = PushEleEnd(pEleEnd, ELE_TEXT, pLine + readPos - eleLen, eleLen);
                    if(pEleEnd == NULL)
                    {
                        ret = -3;
                        goto FREE_AND_RETURN;
                    }
                    eleLen = 0;
                }

                pEleEnd = PushEleEnd(pEleEnd, ELE_SEPERATOR, &sepType, 0);
                if(pEleEnd == NULL)
                {
                    ret = -3;
                    goto FREE_AND_RETURN;
                }
            }
            else
            {
                ++eleLen;
            }
        } 
        if(eleLen != 0)
        {
            pEleEnd = PushEleEnd(pEleEnd, ELE_TEXT, pLine + readPos - eleLen, eleLen);
            if(pEleEnd == NULL)
            {
                ret = -3;
                goto FREE_AND_RETURN;
            }
            eleLen = 0;
        }
        if(lineLen == 0)
        {
            ret = -4;
            goto FREE_AND_RETURN;
        }
        if(IsLineEnd(pLine[lineLen - 1]))
        {
            ret = 0;
            goto FREE_AND_RETURN;
        }
    }
    
FREE_AND_RETURN:
    free(pLine);
    OutString(DBG_RES, "FREE Local pLine\n");
    return ret;
}