Ejemplo n.º 1
0
static gboolean
DoCompressed (struct ras_progressive_state *context,
	      const guchar * buf, guint size,
	      GError **error)
{
	int i;

	for (i = 0; i < size; i++) {
		switch (context->DecoderState) {
		    case 0:
			    if (buf[i] == 0x80)
				    context->DecoderState = 1;
			    else
				    context->LineBuf[context->LineDone++] = buf[i];
			    break;
		    case 1:
			    if (buf[i] == 0) {
				    context->LineBuf[context->LineDone++] = 0x80;
				    context->DecoderState = 0;
			    }
			    else
				    context->DecoderState = buf[i] + 1;
			    break;
		    default:
			    for (; context->DecoderState; context->DecoderState--) {
				    context->LineBuf[context->LineDone++] = buf[i];
				    if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0))
					    OneLine(context);
			    }
		}
		if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0))
			OneLine(context);
	}
	return TRUE;
}
Ejemplo n.º 2
0
bool CComments::PrintSchemaComments(CNcbiOstream& out, int indent, int /*flags*/) const
{
    if ( Empty() ) {
        return false;
    }
    
    out << '>'; // close 'element' tag
#if 0
    PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
    ITERATE ( TComments, i, m_Comments ) {
        out << '\n' << *i;
    }
    PrintASNNewLine(out, indent) << "</xs:documentation></xs:annotation>";
#else
    if ( OneLine() ) {
        PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
        out << NStr::TruncateSpaces(m_Comments.front());
        out << "</xs:documentation></xs:annotation>";
    }
    else {
        PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>";
        ITERATE ( TComments, i, m_Comments ) {
            out << '\n' << *i;
        }
        PrintASNNewLine(out, indent) << "</xs:documentation></xs:annotation>";
    }
#endif
    return true;
}
Ejemplo n.º 3
0
CNcbiOstream& CComments::PrintDTD(CNcbiOstream& out, int flags) const
{
    if ( Empty() ) // no comments
        return out;

    if ( !(flags & eDoNotWriteBlankLine) ) {
        // prepend comments by empty line to separate from previous comments
        out << '\n';
    }

    // comments start
    out <<
        "<!--";

    if ( !(flags & eAlwaysMultiline) && OneLine() ) {
        // one line comment
        out << m_Comments.front() << ' ';
    }
    else {
        // multiline comments
        out << '\n';
        ITERATE ( TComments, i, m_Comments ) {
            out << *i << '\n';
        }
    }

    // comments end
    out << "-->";
    
    if ( !(flags & eNoEOL) )
        out << '\n';

    return out;
}
Ejemplo n.º 4
0
VOID GRAPHBOARD::DisplayLines( const HPS hps )
{
    POINTL P1, P2;
    INT BorderDist;
    INT Row, Col;


    Row = GetBoardRow( DrawPoint.y );
    Col = GetBoardCol( DrawPoint.x );
    if( !Row || !Col ) return; 	// cursor is outside the gameboard

    // left to right line:
    P1.x = LowerLeftPlace.x;			// left edge
    P2.x = LowerLeftPlace.x + (Columns - 3)*dist;	// right edge
    P1.y = P2.y = LowerLeftPlace.y + (Row - 1)*dist;	// same height as DrawPoint
    OneLine( hps, P1, P2 );

    // bottom to top line:
    P1.x = P2.x = LowerLeftPlace.x + (Col - 1)*dist;
    P1.y = LowerLeftPlace.y;
    P2.y = LowerLeftPlace.y + (Rows - 3)*dist;
    OneLine( hps, P1, P2 );

    // left bottom to right top line:
    BorderDist = Row < Col ? Row : Col;
    P1.x = LowerLeftPlace.x + ( Col - BorderDist )*dist;
    P1.y = LowerLeftPlace.y + ( Row - BorderDist )*dist;
    BorderDist = ( Rows - 3 - Row ) < (Columns - 3 - Col ) ?
	( Rows - 3 - Row ) : (Columns - 3 - Col );
    P2.x = LowerLeftPlace.x + ( Col + BorderDist )*dist;
    P2.y = LowerLeftPlace.y + ( Row + BorderDist )*dist;
    OneLine( hps, P1, P2 );

    // right bottom to left top line:
    BorderDist = (Row )  < (Columns - 1 - Col ) ?
	(Row ) : (Columns - 1 - Col );
    P1.x = LowerLeftPlace.x + ( Col + BorderDist - 2 )*dist;
    P1.y = LowerLeftPlace.y + ( Row - BorderDist )*dist;
    BorderDist = ( Rows - 1 - Row ) < (Col )  ?
	( Rows - 1 - Row ) : (Col );
    P2.x = LowerLeftPlace.x + ( Col - BorderDist )*dist;
    P2.y = LowerLeftPlace.y + ( Row + BorderDist - 2 )*dist;
	
    OneLine( hps, P1, P2 );
}
Ejemplo n.º 5
0
/*
 * context - from image_begin_load
 * buf - new image data
 * size - length of new image data
 *
 * append image data onto inrecrementally built output image
 */
gboolean
gdk_pixbuf__ras_image_load_increment(gpointer data, guchar * buf, guint size)
{
	struct ras_progressive_state *context =
	    (struct ras_progressive_state *) data;

	gint BytesToCopy;

	while (size > 0) {
		if (context->HeaderDone < context->HeaderSize) {	/* We still 
									   have headerbytes to do */
			BytesToCopy =
			    context->HeaderSize - context->HeaderDone;
			if (BytesToCopy > size)
				BytesToCopy = size;

			memmove(context->HeaderBuf + context->HeaderDone,
			       buf, BytesToCopy);

			size -= BytesToCopy;
			buf += BytesToCopy;
			context->HeaderDone += BytesToCopy;

		} else {
			/* Pixeldata only */
			BytesToCopy =
			    context->LineWidth - context->LineDone;
			if (BytesToCopy > size)
				BytesToCopy = size;

			if (BytesToCopy > 0) {
				memmove(context->LineBuf +
				       context->LineDone, buf,
				       BytesToCopy);

				size -= BytesToCopy;
				buf += BytesToCopy;
				context->LineDone += BytesToCopy;
			}
			if ((context->LineDone >= context->LineWidth) &&
			    (context->LineWidth > 0))
				OneLine(context);


		}

		if (context->HeaderDone >= 32)
			RAS2State((struct rasterfile *) context->HeaderBuf,
				  context);


	}

	return TRUE;
}
Ejemplo n.º 6
0
bool PathFind::OneLine(TwoPoint& endPoint)
{
	if(endPoint.Count()!=2)
	{
		return false;
	}
	endPoint.Sort();
	Point first=endPoint.First();
	Point second=endPoint.Second(); 
	return OneLine(first,second);
}
Ejemplo n.º 7
0
bool PathFind::Search(const Point& first,const Point& second)
{ 
	if(A[first.X][first.Y]!=A[second.X][second.Y])
	{
		return false;
	}
	bool isOK=Near(first,second);
	if(!isOK)
	{
		isOK=OneLine(first,second);
	}
	if(!isOK)
	{
		isOK=MoreLine(first,second);
	}
	return isOK;
}
Ejemplo n.º 8
0
VOID GRAPHBOARD::MarkDragLine( const HPS hps,
						const char BeginRow, const char BeginCol )
{
    char EndRow, EndCol;
    INT dx, dy;
    POINTL BeginPoint;

    if( !DrawPoint.x && !DrawPoint.y ) return;
    // pointer out of range -> do nothing
		
    EndRow = GetBoardRow( DrawPoint.y );
    EndCol = GetBoardCol( DrawPoint.x );

    BeginPoint.x = LowerLeftPlace.x + (BeginCol -1)*dist;
    BeginPoint.y = LowerLeftPlace.y + (BeginRow - 1)*dist;

    dx = EndCol - BeginCol;
    if ( dx )
	if ( dx > 0 ) dx = 1;
	else dx = -1;

    dy = EndRow - BeginRow;
    if( dy )
	if( dy > 0 ) dy = 1;
	else dy = -1;

    OneLine( hps, BeginPoint, DrawPoint );
	
    while( EndRow != BeginRow || EndCol != BeginCol ){
	if( !GetMarked( EndRow, EndCol) )
	    DrawPMMark( hps, EndRow, EndCol );
	EndRow -= dy;
	EndCol -= dx;
    }
    if( !GetMarked( EndRow, EndCol) )
	DrawPMMark( hps, EndRow, EndCol );
}
void TForm1::AnalyseOneFunction(int &FunctionCount, int NumberOfCalls, AnsiString FunctionString, std::ofstream &OutFile)
{
AnsiString Prelim = "./";
for(int x=0;x<5000;x++)
    {
    DupNumArray[x] = -1;
    MissingNumArray[x] = -1;
    }
Label1->Caption = "Analysing function:   " + FunctionString + " (" + AnsiString(FunctionCount + 1) + "/" + AnsiString(NumberOfCalls) + ")";
Form1->Repaint();
int DupNumArrayIndex = 0;
for(int x=0;x<NumFiles;x++)
    {
    AnsiString FullFileName = Prelim + FileString[x];
    std::ifstream InFile(FullFileName.c_str());
    if(InFile == 0)
        {
        ShowMessage("Input file failed to open - " + FileString[x]);
        return;
        }
    char Buffer[5000];
    bool EndOfFile = false;
    while(!EndOfFile)
        {
        InFile.getline(Buffer, 5000);
        AnsiString OneLine(Buffer);
        for(int x = 1; x< OneLine.Length() - FunctionString.Length() + 1;x++)
            {
            if(OneLine.SubString(x,FunctionString.Length() + 1) == FunctionString + '(')
            //rule out other functions that contain the sought function name (allow to be preceded by space, !, ., > or (
                {if((x == 1) || (OneLine[x-1] < '"') || (OneLine[x-1] == '.') || (OneLine[x-1] == '>') || (OneLine[x-1] == '('))
                    {
                    AnsiString NumberLineStr = OneLine.SubString(x + FunctionString.Length() + 1,OneLine.Length() - (x + FunctionString.Length() + 1));
                    AnsiString NumberString = "";
                    while((NumberLineStr.Length() > 0) && ((NumberLineStr[1] <= '9') && (NumberLineStr[1] >= '0')))
                        {
                        NumberString+= NumberLineStr[1];
                        NumberLineStr.Delete(1,1);
                        }
                    if(NumberString != "")
                        {
                        int Number = NumberString.ToInt();
                        DupNumArray[DupNumArrayIndex] = Number;
                        DupNumArrayIndex++;
                        }
                    }
                }
            }
        if(InFile.eof())
            {
            EndOfFile = true;
            }
        }
    InFile.close();
    }
//Label1->Caption = "Array analysis started for function " + FunctionString;
//Form1->Repaint();
int MaxIndex = -1;//so first brings it to 0
int MaxNumber = -1;
for(int x=0;x<5000;x++)
    {
    if(DupNumArray[x] > -1)
        {
        MaxIndex++;
        if(DupNumArray[x] > MaxNumber) MaxNumber = DupNumArray[x];
        }
    else break;
    }
for(int x=0;x<MaxIndex+1;x++)
    {
    MissingNumArray[x] = DupNumArray[x];
    }
//check for duplicates
for(int x=0;x<MaxIndex + 1;x++)
    {
    int CheckNumber = DupNumArray[x];
    if(CheckNumber == -1) continue;
    int RepeatCount = 0;
    for(int y=x+1;y<MaxIndex + 1;y++)
        {
        if(DupNumArray[y] == CheckNumber)
            {
            RepeatCount++;
            DupNumArray[y] = -1;//so it isn't counted again if appears more than twice in all
            }
        }
    if(RepeatCount > 0)
        {
        AnsiString MessageString = "Number " + AnsiString(CheckNumber) + " repeated " + AnsiString(RepeatCount) + " times in function " + FunctionString;
        if(Screen)
            {
            int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL);
            if (button == IDCANCEL)
                {
                BreakFlag = true;
                return;
                }
            }
        if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10);
        }
    }

//now check for missing numbers
if(CheckBox1->Checked)
    {
    int IncNumber = 0;
    bool FoundFlag=false;
    while(IncNumber <= MaxNumber)
        {
        FoundFlag = false;
        for(int x=0;x<MaxIndex + 1;x++)
            {
            if(MissingNumArray[x] == IncNumber)
                {
                FoundFlag = true;
                break;
                }
            }
        if(!FoundFlag)
            {
            AnsiString MessageString = "Number " + AnsiString(IncNumber) + " missing for function " + FunctionString;
            if(Screen)
                {
                int button = Application->MessageBox(MessageString.c_str(), "", MB_OKCANCEL);
                if (button == IDCANCEL)
                    {
                    BreakFlag = true;
                    return;
                    }
                }
            if(Print) OutFile << MessageString.c_str() << CHAR(13) << CHAR(10);
            }
        IncNumber++;
        }
    }
FunctionCount++;
}
Ejemplo n.º 10
0
/*
 * context - from image_begin_load
 * buf - new image data
 * size - length of new image data
 *
 * append image data onto incrementally built output image
 */
static gboolean
gdk_pixbuf__ras_image_load_increment(gpointer data,
                                     const guchar * buf, guint size,
                                     GError **error)
{
	struct ras_progressive_state *context =
	    (struct ras_progressive_state *) data;

	gint BytesToCopy;

	while (size > 0) {
		if (context->HeaderDone < context->HeaderSize) {	/* We still 
									   have headerbytes to do */
			BytesToCopy =
			    context->HeaderSize - context->HeaderDone;
			if (BytesToCopy > size)
				BytesToCopy = size;

			memmove(context->HeaderBuf + context->HeaderDone,
			       buf, BytesToCopy);

			size -= BytesToCopy;
			buf += BytesToCopy;
			context->HeaderDone += BytesToCopy;

		} else if (context->Header.type == 2) {
			if (!DoCompressed (context, buf, size, error)) {
				return FALSE;
			}
			size = 0;
		}
		else {
			BytesToCopy =
			    context->LineWidth - context->LineDone;
			if (BytesToCopy > size)
				BytesToCopy = size;

			if (BytesToCopy > 0) {
				memmove(context->LineBuf +
				       context->LineDone, buf,
				       BytesToCopy);

				size -= BytesToCopy;
				buf += BytesToCopy;
				context->LineDone += BytesToCopy;
			}
			if ((context->LineDone >= context->LineWidth) &&
			    (context->LineWidth > 0))
				OneLine(context);


		}

		if (context->HeaderDone >= 32)
			if (!RAS2State((struct rasterfile *) context->HeaderBuf,
				       context, error)) {
				return FALSE;
			}


	}

	return TRUE;
}
Ejemplo n.º 11
0
VOID GRAPHBOARD::DrawScanLines( const HPS hps, const INT Row, const INT Col )
{
    POINTL left, right, top, bot, lefttop, leftbot, righttop, rightbot, center;
    INT BorderDist;

    center.x = LowerLeftPlace.x + ( Col - 1) * dist;
    center.y = LowerLeftPlace.y + (Row - 1) * dist;

    // left to right line:
    left.x = LowerLeftPlace.x;			// left edge
    right.x = LowerLeftPlace.x + (Columns - 3)*dist;	// right edge
    left.y = right.y = LowerLeftPlace.y + (Row - 1)*dist;	// same height as DrawPoint
    // bottom to top line:
    bot.x = top.x = LowerLeftPlace.x + (Col - 1)*dist;
    bot.y = LowerLeftPlace.y;
    top.y = LowerLeftPlace.y + (Rows - 3)*dist;
    // left bottom to right top line:
    BorderDist = Row < Col ? Row : Col;
    leftbot.x = LowerLeftPlace.x + ( Col - BorderDist )*dist;
    leftbot.y = LowerLeftPlace.y + ( Row - BorderDist )*dist;
    BorderDist = ( Rows - 3 - Row ) < (Columns - 3 - Col ) ?
	( Rows - 3 - Row ) : (Columns - 3 - Col );
    righttop.x = LowerLeftPlace.x + ( Col + BorderDist )*dist;
    righttop.y = LowerLeftPlace.y + ( Row + BorderDist )*dist;
    // right bottom to left top line:
    BorderDist = (Row )  < (Columns - 1 - Col ) ?
	(Row ) : (Columns - 1 - Col );
    rightbot.x = LowerLeftPlace.x + ( Col + BorderDist - 2 )*dist;
    rightbot.y = LowerLeftPlace.y + ( Row - BorderDist )*dist;
    BorderDist = ( Rows - 1 - Row ) < (Col )  ?
	( Rows - 1 - Row ) : (Col );
    lefttop.x = LowerLeftPlace.x + ( Col - BorderDist )*dist;
    lefttop.y = LowerLeftPlace.y + ( Row + BorderDist - 2 )*dist;
	
    OneLine( hps, center, right );
    DosSleep( 50 );
    OneLine( hps, center, right );
    DosSleep( 50 );
    OneLine( hps, center, righttop );
    DosSleep( 50 );
    OneLine( hps, center, righttop );
    DosSleep( 50 );
    OneLine( hps, center, top );
    DosSleep( 50 );
    OneLine( hps, center, top );
    DosSleep( 50 );
    OneLine( hps, center, lefttop );
    DosSleep( 50 );
    OneLine( hps, center, lefttop );
    DosSleep( 50 );
    OneLine( hps, center, left );
    DosSleep( 50 );
    OneLine( hps, center, left );
    DosSleep( 50 );
    OneLine( hps, center, leftbot );
    DosSleep( 50 );
    OneLine( hps, center, leftbot );
    DosSleep( 50 );
    OneLine( hps, center, bot );
    DosSleep( 50 );
    OneLine( hps, center, bot );
    DosSleep( 50 );
    OneLine( hps, center, rightbot );
    DosSleep( 50 );
    OneLine( hps, center, rightbot );

}
Ejemplo n.º 12
0
VOID GRAPHBOARD::DrawDragLine( const HPS hps, const char BeginRow,
								 const char BeginCol, POINTL ptl )
{
    int NewLengthX = 0, NewLengthY = 0;
    POINTL NewDrawPoint;		// where we want to paint to
    POINTL BeginPoint;	// where we begin to paint

    BeginPoint.x = NewDrawPoint.x = LowerLeftPlace.x + (BeginCol -1)*dist;
    BeginPoint.y = NewDrawPoint.y = LowerLeftPlace.y + (BeginRow - 1)*dist;
    if( FirstDraw ){	// DrawPoint is the point where we drew to the last time
	DrawPoint.x = BeginPoint.x ;
	DrawPoint.y = BeginPoint.y;
	FirstDraw = FALSE;
    }

    int XOffset = ptl.x - BeginPoint.x;
    int YOffset = ptl.y - BeginPoint.y;
    double help = double(XOffset);
    if( help == 0 ) help = 0.001;
    double Quot = YOffset / help;
    if( Quot < 0 ) Quot = -Quot;

    if( Quot < 0.5 )
	NewLengthX = XOffset;
    else 
	if( Quot < 1 )	{
	    NewLengthX = NewLengthY = YOffset;
	    if( (YOffset > 0 && XOffset < 0) || (YOffset < 0 && XOffset > 0) )
		NewLengthX = - NewLengthX;
	}
	else
	    if( Quot < 2 ){
		NewLengthX = NewLengthY = XOffset;
		if( (YOffset > 0 && XOffset < 0) || (YOffset < 0 && XOffset > 0) )
		    NewLengthY = - NewLengthY;
	    }
	    else
		NewLengthY = YOffset;

    if( NewLengthX >= 0 )
	NewLengthX += dist/2;
    else	
	NewLengthX -= dist/2;

    if( NewLengthY >= 0 )
	NewLengthY += dist/2;
    else	
	NewLengthY -= dist/2;

    NewLengthX /= dist;
    NewLengthY /= dist;	

    NewDrawPoint.x += NewLengthX * dist;
    NewDrawPoint.y += NewLengthY * dist;
    // determine where to draw to

    if( NewDrawPoint.x < LowerLeftPlace.x
	|| NewDrawPoint.y < LowerLeftPlace.y 
	|| NewDrawPoint.x > LowerLeftPlace.x + (Columns - 3) * dist 
	|| NewDrawPoint.y > LowerLeftPlace.y + (Rows - 3) * dist )
	// NewDrawPoint is out of range
	{
	    NewDrawPoint.x = NewDrawPoint.y = 0;
	    //	 	NewDrawPoint = BeginPoint;
	}

    if( DrawPoint.y == NewDrawPoint.y && NewDrawPoint.x == DrawPoint.x  ) return;
    // nothing has changed -> no drawing necessary

    if( DrawPoint.x && DrawPoint.y )
	OneLine( hps, BeginPoint, DrawPoint );	// remove old line
    if( NewDrawPoint.x && NewDrawPoint.y )	
	OneLine( hps, BeginPoint, NewDrawPoint );	// draw new line
    DrawPoint = NewDrawPoint;	// adjust the DrawPoint for the next drawing
}