예제 #1
0
파일: musiobin.cpp 프로젝트: DDMAL/aruspix
bool MusBinInput::ReadPage( MusPage *page )
{
	int j;

    if ( !ReadSeparator() )
		return false;

	Read( &int32, 4 );
	page->npage = wxINT32_SWAP_ON_BE( int32 );
	Read( &int16, 2 );
	page->nbrePortees = wxINT16_SWAP_ON_BE( int16 );
    Read( &page->noMasqueFixe, 1 );	
	Read( &page->noMasqueVar, 1 );
	Read( &page->reserve, 1 );
	Read( &page->defin, 1 );
	Read( &int32, 4 );
	page->indent = wxINT32_SWAP_ON_BE( int32 );	
	Read( &int32, 4 );
	page->indentDroite = wxINT32_SWAP_ON_BE( int32 ); 
	Read( &int32, 4 );
	page->lrg_lign = wxINT32_SWAP_ON_BE( int32 );
    for (j = 0; j < page->nbrePortees; j++) 
	{
		MusStaff *staff = new MusStaff();
		ReadStaff( staff );
        staff->voix = (j % 2 == 0) ? 1 : 0; // add voices
		page->m_staves.Add( staff );
	}

	return true;

}
예제 #2
0
파일: musiobin.cpp 프로젝트: DDMAL/aruspix
bool MusBinInput::ImportFile( )
{
	int i;

	if ( !IsOk() )
	{
		wxLogMessage(_("Cannot read file '%s'"), m_file->m_fname.c_str() );
		return false;
	}

    ReadFileHeader( &m_file->m_fheader ); // fileheader
    
	m_file->m_pages.Clear();		
    for (i = 0; i < m_file->m_fheader.nbpage; i++ )
	{
		MusPage *page = new MusPage();
		ReadPage( page );
		m_file->m_pages.Add( page );
    }
    if ( !ReadSeparator() ) 
		return false;
	if ( m_file->m_fheader.param.entetePied & PAGINATION )
		ReadPagination( &m_file->m_pagination );
	if ( m_file->m_fheader.param.entetePied & ENTETE )
		ReadHeaderFooter( &m_file->m_header );
	if ( m_file->m_fheader.param.entetePied & PIEDDEPAGE )
		ReadHeaderFooter( &m_file->m_footer );

	//wxLogMessage("OK %d", m_file->m_pages.GetCount() );
    //m_file->CheckIntegrity();

	return true;
}
예제 #3
0
파일: date.c 프로젝트: GYGit/reactos
static BOOL
ParseDate (LPTSTR s)
{
    SYSTEMTIME d;
    unsigned char leap;
    LPTSTR p = s;

    if (!*s)
        return TRUE;

    GetLocalTime (&d);

    d.wYear = 0;
    d.wDay = 0;
    d.wMonth = 0;

    switch (nDateFormat)
    {
        case 0: /* mmddyy */
        default:
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            break;

        case 1: /* ddmmyy */
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            break;

        case 2: /* yymmdd */
            if (!ReadNumber (&p, &d.wYear))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wMonth))
                return FALSE;
            if (!ReadSeparator (&p))
                return FALSE;
            if (!ReadNumber (&p, &d.wDay))
                return FALSE;
            break;
    }

    /* if only entered two digits: */
    /*   assume 2000's if value less than 80 */
    /*   assume 1900's if value greater or equal 80 */
    if (d.wYear <= 99)
    {
        if (d.wYear >= 80)
            d.wYear = 1900 + d.wYear;
        else
            d.wYear = 2000 + d.wYear;
    }

    leap = (!(d.wYear % 4) && (d.wYear % 100)) || !(d.wYear % 400);

    if ((d.wMonth >= 1 && d.wMonth <= 12) &&
        (d.wDay >= 1 && d.wDay <= awMonths[leap][d.wMonth]) &&
        (d.wYear >= 1980 && d.wYear <= 2099))
    {
        SetLocalTime (&d);
        return TRUE;
    }

    return FALSE;
}
예제 #4
0
파일: cmdUser.c 프로젝트: Moteesh/reactos
static
BOOL
ParseDate(
    PWSTR s,
    PULONG pSeconds)
{
    SYSTEMTIME SystemTime = {0};
    FILETIME LocalFileTime, FileTime;
    LARGE_INTEGER Time;
    INT nDateFormat = 0;
    PWSTR p = s;

    if (!*s)
        return FALSE;

    GetLocaleInfoW(LOCALE_USER_DEFAULT,
                   LOCALE_IDATE,
                   (PWSTR)&nDateFormat,
                   sizeof(INT));

    switch (nDateFormat)
    {
        case 0: /* mmddyy */
        default:
            if (!ReadNumber(&p, &SystemTime.wMonth))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wDay))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wYear))
                return FALSE;
            break;

        case 1: /* ddmmyy */
            if (!ReadNumber(&p, &SystemTime.wDay))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wMonth))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wYear))
                return FALSE;
            break;

        case 2: /* yymmdd */
            if (!ReadNumber(&p, &SystemTime.wYear))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wMonth))
                return FALSE;
            if (!ReadSeparator(&p))
                return FALSE;
            if (!ReadNumber(&p, &SystemTime.wDay))
                return FALSE;
            break;
    }

    /* if only entered two digits: */
    /*   assume 2000's if value less than 80 */
    /*   assume 1900's if value greater or equal 80 */
    if (SystemTime.wYear <= 99)
    {
        if (SystemTime.wYear >= 80)
            SystemTime.wYear += 1900;
        else
            SystemTime.wYear += 2000;
    }

    if (!SystemTimeToFileTime(&SystemTime, &LocalFileTime))
        return FALSE;

    if (!LocalFileTimeToFileTime(&LocalFileTime, &FileTime))
        return FALSE;

    Time.u.LowPart = FileTime.dwLowDateTime;
    Time.u.HighPart = FileTime.dwHighDateTime;

    if (!RtlTimeToSecondsSince1970(&Time, pSeconds))
        return FALSE;

    return TRUE;
}
예제 #5
0
/******************************************************************************
 * read the input file
 * parse each section as it occurs
 * load the data into the coaster variables
 * see COASTER.FORMAT.README.txt for details
 *****************************************************************************/
int ReadInputFile()
{
	char SECTION[BUFSIZ/2];
	int i, sectionOK;

	SkipComment();
	while(!feof(file))
	{
		if (!ReadSectionName(SECTION,BUFSIZ/2))
		{
			PrintError("Section SECTION expected");
			return 0;
		}
		// read each section and parse it
		sectionOK = 0;
		if (!strcmp(SECTION,"trackcontrolpoints"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadUnsignedInt(&nbPointControl)) return 0;
			
			pPointControl = (point*)malloc(nbPointControl*2*sizeof(point));
			for(i=0; i<nbPointControl; i++)
			{
				if (!SkipNewline()) return 0;
				if (!ReadPoint(&pPointControl[i*2])) return 0;
				if (!ReadSeparator()) return 0;
				if (!ReadPoint(&pPointControl[i*2+1])) return 0;
			}
		}
		if (!strcmp(SECTION,"supportscoordinate"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadUnsignedInt(&nbColumnCoord)) return 0;
			pColumnCoordinate = (int*)malloc(nbColumnCoord*sizeof(int));
			for(i=0; i<nbColumnCoord; i++)
			{
				if (!SkipNewline()) return 0;
				if (!ReadUnsignedInt(&pColumnCoordinate[i])) return 0;
			}
		}
		if (!strcmp(SECTION,"platform"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadPoint(&metalPosition)) return 0;
			if (!SkipNewline()) return 0;
			if (!ReadFloat(&metalLength))
			{
				PrintError("Number expected");
				return 0;
			}
			if (!SkipNewline()) return 0;
			if (!ReadFloat(&metalAngle))
			{
				PrintError("Number expected");
				return 0;
			}
		}
		if (!strcmp(SECTION,"trees"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadUnsignedInt(&nbTree)) return 0;
			pTree = (point*)malloc(nbTree*sizeof(point));
			for(i=0; i<nbTree; i++)
			{
				if (!SkipNewline()) return 0;
				if (!ReadPoint(&pTree[i])) return 0;
				pTree[i].z = -0.001f;
			}
		}
		if (!strcmp(SECTION,"startsegment"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadSignedInt(&startSegment)) return 0;
		}
		if (!strcmp(SECTION,"brakesegment"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadSignedInt(&brakeSegment)) return 0;
		}
		if (!strcmp(SECTION,"segmentlength"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadFloat(&avgSegmentLength))
			{
				PrintError("Number expected");
				return 0;
			}
		}
		if (!strcmp(SECTION,"bankfactor"))
		{
			sectionOK = 1;
			if (!SkipNewline()) return 0;
			if (!ReadFloat(&twistFactor))
			{
				PrintError("Number expected");
				return 0;
			}
		}
		if (!sectionOK) PrintError("Unknown section \"%s\"",SECTION);
		// don't print an error if there is no new line at the end of the file, 
		// don't directly call skipnewline
		i = line_number;
		SkipComment();
		if ((line_number - i == 0) && !feof(file)) PrintError("Newline expected");
	}
	return 1;
}