Пример #1
0
int KeystrokePaste( PCONSOLE_INFO pdp )
{
    if( OpenClipboard(NULL) )
    {
        uint32_t format;
        // successful open...
        format = EnumClipboardFormats( 0 );
        while( format )
        {
            //DECLTEXT( msg, "                                     " );
            //msg.data.size = sprintf( msg.data.data, "Format: %d", format );
            //EnqueLink( pdp->ps->Command->ppOutput, SegDuplicate( (PTEXT)&msg ) );
#ifndef CF_TEXT
#define CF_TEXT 1
#endif
            if( format == CF_TEXT )
            {
                HANDLE hData = GetClipboardData( CF_TEXT );
                LPVOID pData = GlobalLock( hData );
                PTEXT pStroke = SegCreateFromText( pData );
                int ofs, n;
                GlobalUnlock( hData );
                n = ofs = 0;
                while( pStroke->data.data[n] )
                {
                    pStroke->data.data[ofs] = pStroke->data.data[n];
                    if( pStroke->data.data[n] == '\r' ) // trash extra returns... keep newlines
                    {
                        n++;
                        continue;
                    }
                    else
                    {
                        ofs++;
                        n++;
                    }
                }
                pStroke->data.size = ofs;
                pStroke->data.data[ofs] = pStroke->data.data[n];
                if( PSI_DoStroke( pdp, pStroke ) ) 1;
                //   RenderCommandLine( pdp );
                //EnqueLink( pdp->ps->Command->ppOutput, SegDuplicate(pStroke) );
                LineRelease( pStroke );
                break;
            }
            format = EnumClipboardFormats( format );
        }
        CloseClipboard();
    }
    else
    {
#ifdef __DEKWARE__PLUGIN__
        DECLTEXT( msg, "Clipboard was not available" );
        EnqueLink( &pdp->common.Owner->Command->Output, &msg );
#endif
    }
    return 0;

}
Пример #2
0
void ParseURI( CTEXTSTR string )
{
   int state;
	PTEXT words;
	PTEXT delete_seg = NULL;
	PTEXT line = SegCreateFromText( string );
	PTEXT filename = NULL;
   PTEXT varname = NULL;
	PTEXT varvalue = NULL;
   PTEXT content = NULL;
   int content_length;

	struct {
		uint32_t bInvalid : 1;
		uint32_t bGet : 1;
		uint32_t bPost : 1;
		uint32_t bBinary : 1; // reading the content...
		uint32_t bValue : 1;
	} flags;
// we got a line, therefore we can process it...
	// only thing then is the last line in the block ...

	state = GET_FILENAME;

	words = burst( line );
	delete_seg = words;
	// though...
	LineRelease( line );
	flags.bValue = 0;

	while( words )
	{
		DECLTEXT( page, WIDE("page") );
		DECLTEXT( CGI, WIDE("CGI") );
		//printf( "state:%d word:%s \r\n",state, GetText(words ) );
		// what does stuff have now?  the whole thign?  a line?
		if( !GetTextSize( words ) ) switch( state )
		{
		case GET_HTTP_EOL:
			state = GET_HTTP_METAVAR;
			break;
		case GET_HTTP_METAVAR:
		case GET_CGI:
			goto AddCGIVariable;
			break;
		}
		else switch( state )
		{
		case RESET:
			state = GET_COMMAND;
			continue;  // skip ahead  and try new state;
			break;
		case GET_COMMAND:
			if( TextLike( words, WIDE("GET") ) )
			{
				state = GET_FILENAME;
				//flags.bGet = TRUE;
			}
			else if( TextLike( words, WIDE("POST") ) )
			{
				state = GET_FILENAME;
				//flags.bPost = TRUE;
			}
			else
			{
				flags.bInvalid = TRUE;
			}
			break;
		case GET_FILENAME:
			if( !filename && TextIs( words, WIDE("/") ) )
			{
				// this is rude, and should never be done,
				// however this filter consumes all data anyhow, SO
				// mangling this will not hurt much...
				words->format.position.offset.spaces = 0;
			}
			if( TextIs( words, WIDE("?") ) || words->format.position.offset.spaces )
			{
				if( !words->format.position.offset.spaces )
					state = GET_CGI;
				else
					state = GET_HTTP_VERSION;
				filename = NEXTLINE( filename );
				LineRelease( SegBreak( filename ) );
				HTTPCollapse( &filename );
				//AddVariableExxx( ps, ps->Current, (PTEXT)&page, filename, FALSE,TRUE,TRUE DBG_SRC );
				//AddVariable( ps, ps->Current, (PTEXT)&CGI, TextDuplicate( NEXTLINE( words ), FALSE ) );
				LineRelease( filename );
				filename = NULL;
			}
			else
			{
				filename = SegAppend( filename, SegDuplicate( words ) );
			}
			break;
		case GET_CGI:
			if( words->format.position.offset.spaces )
			{
				state = GET_HTTP_VERSION;
				goto AddCGIVariable;
			}
			else
			{
				if( TextIs( words, WIDE("=") ) )
				{
					HTTPCollapse( &varname );
					flags.bValue = 1;
				}
				else if( TextIs( words, WIDE("&") ) )
				{
				AddCGIVariable:
					HTTPCollapse( &varvalue );
					HTTPCollapse( &varname );
					if( TextLike( varname, WIDE("content-length") ) )
					{
						content_length= IntCreateFromText( GetText( varvalue ) );
					}
					{
						struct VAR *v = New( struct VAR );
						v->varname = varname;
						varname = NULL;
						v->varvalue = varvalue;
						varvalue = NULL;
						AddLink( &l.vars, v );
					}
					//AddVariableExxx( ps, ps->Current, pmdp->varname, pmdp->varvalue, FALSE,TRUE,TRUE DBG_SRC );
					//LineRelease( varname );
					//LineRelease( varvalue );
					//varname = NULL;
					//varvalue = NULL;
					flags.bValue = 0;
				}
				else
				{
					if( flags.bValue )
					{
						varvalue = SegAppend( varvalue, SegDuplicate( words ) );
					}
					else
					{
						//printf( "add var" );
						varname = SegAppend( varname, SegDuplicate( words ) );
					}
				}
			}
			break;
		case GET_HTTP_VERSION:
			if( TextIs( words, WIDE("HTTP") ) )
					{
						// okay - don't really do anything... next word is the version...
					}
					else
					{
                  // TextIs( words, "/" ); // this is a token before the number...
						// Version better be something like 1.1 1.0?
						// well wait for EOL...
						state = GET_HTTP_EOL;
					}
					break;
				case GET_HTTP_EOL:
					if( !GetTextSize( words ) )
					{
						state = GET_HTTP_METAVAR;
					}
					break;
				case GET_HTTP_METAVAR:
					{
						if( !flags.bValue && TextIs( words, WIDE(":") ) )
						{
                     flags.bValue = TRUE;
						}
						else
						{
							if( flags.bValue )
							{
                        varvalue = SegAppend( varvalue, SegDuplicate( words ) );
							}
							else
							{
                        varname = SegAppend( varname, SegDuplicate( words ) );
							}
						}
					}
               break;
				case GET_HTTP_CONTENT:
					if( !content_length )
					{
                  DebugBreak();
                  state = RESET;
					}
					else
					{
						// hmm we've parsed everything up to here, but now we need blocks, binary blocks.
						content = SegAppend( content, words );
						if( LineLength( content ) == content_length )
						{
							//ProcessPostCGI( common.Owner, content );
							//AddVariableExxx( ps, ps->Current, (PTEXT)&CGI, content, FALSE,TRUE,TRUE DBG_SRC );
							//AddVariable( ps, ps->Current, (PTEXT)&CGI, content );
							LineRelease( content );

							//InvokeBehavior( "http.request", common.Owner->Current, common.Owner, NULL );
							//InvokeBehavior( "http_request", common.Owner->Current, common.Owner, NULL );
							state = RESET;
						}
                  words = NULL;
					}
					break;
		}
Пример #3
0
int HandleArgs( int argc, TEXTCHAR **argv )
{

   PVARTEXT pvt = NULL;
	int arg = 1;
	if( argc == 1 )
	{
		MessageBox( NULL, WIDE( "Available Arguments\n" )
					  WIDE( " -back $aarrggbb  : set background color in hex, alpha, red, green, blue [default black]\n" )
					  WIDE( " -text $aarrggbb  : set text color in hex, alpha, red, green, blue [default white]\n" )
					  WIDE( " -lines N  : Set the target number of lines (font height, bigger number is smaller) [default 20]\n" )
					  WIDE( " -cols N  : Set the target number of columns (font width, bigger number is smaller) [default 30]\n" )
					  WIDE( " -file <filename>  : Use contents fo the file specified for text\n" )
					  WIDE( " -alpha : enable alpha transparency display\n" )
					  WIDE( " -dead : disable click and keyboard bypass\n" )
					  WIDE( " -display N : specify which display to show on\n" )
					  WIDE( " -timeout N : default time delay for no action (milliseconds)\n" )
					  WIDE( "\n" )
					  WIDE( " -notop : shows the banner as not topmost (default is top).\n" )
					  WIDE( " -yesno : shows the Yes/No buttons, and returns error level 0 for yes and 1 for no.\n" )
					  WIDE( " -okcancel : shows the Okay/Cancel buttons, and returns error level 0 for yes and 1 for no.\n" )
					  WIDE( " -yesno and -okaycancel : returns error level 0 for yes and 1 for no, 2 for cancel, 3 for ok.\n" )
					  WIDE( " \n" )
					  WIDE( " any other unknown argument or other word will show as text.\n" )
					  WIDE( " banner_command -back $20800010 -text $FF70A080 Show \"This Text On\" Banner\n" )
					  WIDE( "   - the prior command will show 3 lines 'show', 'this text on', 'banner'" )
					  WIDE( " banner_command Show \"\\\"This Text On\\\"\" Banner\n" )
					  WIDE( "   - the prior command shows how to include showing quotes" )
					 , WIDE( "Usage" )
					 , MB_OK );
      return 0;
	}
   // default to topmost.
	l.flags.bTop = 1;

	while( arg < argc )
	{
		if( argv[arg][0]=='-' )
		{
			if( StrCaseCmp( argv[arg]+1, WIDE( "back" ) ) == 0 )
			{
				// blah
				arg++;
				if( arg < argc )
				{
               PTEXT tmp2;
					PTEXT tmp = SegCreateFromText( argv[arg] );
               tmp2 = tmp;
					GetColorVar( &tmp, &l.back_color );
					LineRelease( tmp2 );
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "text" ) ) == 0 )
			{
				arg++;
				if( arg < argc )
				{
               PTEXT tmp2;
					PTEXT tmp = SegCreateFromText( argv[arg] );
               tmp2 = tmp;
					GetColorVar( &tmp, &l.text_color );
					LineRelease( tmp2 );
				}

			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "lines" ) ) == 0 )
			{
				arg++;
				if( arg < argc )
				{
#ifdef UNICODE
					l.lines = _wtoi( argv[arg] );
#else
					l.lines = atoi( argv[arg] );
#endif
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "cols" ) ) == 0 )
			{
				arg++;
				if( arg < argc )
				{
#ifdef UNICODE
               l.columns = _wtoi( argv[arg] );
#else
               l.columns = atoi( argv[arg] );
#endif
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "display" ) ) == 0 )
			{
				arg++;
				if( arg < argc )
				{
#ifdef UNICODE
               l.display = _wtoi( argv[arg] );
#else
               l.display = atoi( argv[arg] );
#endif
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "timeout" ) ) == 0 )
			{
				arg++;
				if( arg < argc )
				{
#ifdef UNICODE
               l.timeout = _wtoi( argv[arg] );
#else
               l.timeout = atoi( argv[arg] );
#endif
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "dead" ) ) == 0 )
			{
            l.flags.bDead = 1;
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "alpha" ) ) == 0 )
			{
            l.flags.bAlpha = 1;
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "file" ) ) == 0 )
			{
				// blah
				arg++;
				if( arg < argc )
				{
               POINTER p;
					l.file = argv[arg];
					p = OpenSpace( NULL, l.file, &l.text_size );
					if( p )
					{
						l.text = NewArray( TEXTCHAR, l.text_size + 1 );
						MemCpy( l.text, p, l.text_size );
						l.text[l.text_size] = 0;
                  Release( p );
					}
				}
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "notop" ) ) == 0 )
			{
            l.flags.bTop = 0;
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "yesno" ) ) == 0 )
			{
            l.flags.bYesNo = 1;
			}
			else if( StrCaseCmp( argv[arg]+1, WIDE( "okcancel" ) ) == 0 )
			{
            l.flags.bOkayCancel = 1;
			}
			else
			{
				if( !pvt )
				{
					pvt = VarTextCreate();
					vtprintf( pvt, WIDE( "%s" ), argv[arg] );
				}
				else
					vtprintf( pvt, WIDE( "\n%s" ), argv[arg] );
			}
		}
		else
		{
			if( !pvt )
			{
				pvt = VarTextCreate();
            vtprintf( pvt, WIDE( "%s" ), argv[arg] );
			}
         else
            vtprintf( pvt, WIDE( "\n%s" ), argv[arg] );
		}
      arg++;
	}
	if( pvt )
	{
      l.text = StrDup( GetText( VarTextPeek( pvt ) ) );
	}

	if( !l.text )
	{
      l.text = WIDE( "INVALID COMMAND LINE\nARGUMENTS" ) ;
	}
	else
	{
		int n = 0;
      int o = 0;
		for( n = 0; l.text[n]; n++ )
		{
			if( l.text[n] < 32 )
			{
				if( l.text[n] == '\n' )
				{
					l.text[o++] = l.text[n];
				}
			}
			else
				l.text[o++] = l.text[n];
		}
		l.text[o++] = l.text[n];

	}
   return 1;
}