コード例 #1
0
ファイル: ROMETGraphErrors.cpp プロジェクト: cjpl/rome
//______________________________________________________________________________
void ROMETGraphErrors::SetPoint(Int_t i, Double_t x, Double_t y)
{
    // Set x and y values for point number i.

    if (i < 0) return;
    if (i >= fMaxSize) {
        Double_t **ps = ExpandAndCopy(i+1, fNpoints);
        CopyAndRelease(ps, 0,0,0);
    }
    if (i >= fNpoints) {
        // points above i can be not initialized
        // set zero up to i-th point to avoid redefenition
        // of this method in descendant classes
        FillZero(fNpoints, i + 1);
        fNpoints = i+1;
    }
    fX[i] = x;
    fY[i] = y;
}
void main( int nArgc, char *szArgv[] )
{
	FILE			*WWWFile = NULL;
	unsigned char	*pWWWMem = NULL;
	int				nWWWLen;

	if( nArgc == 2 || nArgc == 3 )
	{
		if( nArgc == 3 )
			OUTFile = fopen( szArgv[2], "wb" );
		else
			OUTFile = fopen( "ENDMARK.C", "wb" );
		if( OUTFile == NULL )
		{
			printf( "failed to open ENDMARK.C !" );
			goto Exit;
		}		

		WWWFile = fopen( szArgv[1], "rb" );
		if( WWWFile == NULL )
		{
			printf( "failed to open %s !", szArgv[1] );
			goto Exit;
		}

		pWWWMem = malloc( MAX_WWW_SIZE );
		if( pWWWMem == NULL )
		{
			printf( "Not enought memory !" );
			goto Exit;
		}
			
   		nWWWLen = fread( pWWWMem, 1, MAX_WWW_SIZE, WWWFile );
		if( nWWWLen <= 0 )
		{
			printf( "Failed to read %s !", szArgv[2] );
			goto Exit;
		}

		fprintf( OUTFile, "const char EndMark[]=\"{EndMark}\";\r\n" );

		fprintf( OUTFile, "const unsigned long EndMark1 = 0x00544F5A;\r\n" );
		
		fprintf( OUTFile, "const unsigned long MyDataSize[4] = { %d, %d, %d, 0 };\r\n", 
				MAX_WWW_SIZE, 0, nWWWLen );

		fprintf( OUTFile, "const unsigned char MyData[%d] = { \r\n", MAX_WWW_SIZE );

		
		ProduceData( pWWWMem, nWWWLen );

		FillZero( ( MAX_WWW_SIZE  ) - nWWWLen );

		fprintf( OUTFile, "};\r\n" );
	}
Exit:
	if( pWWWMem )
		free( pWWWMem );
	
	if( WWWFile )
		fclose( WWWFile );
	
	if( OUTFile )
		fclose( OUTFile );
}