Exemplo n.º 1
0
int DaoxFont_Open( DaoxFont *self, const char *file )
{
	FILE *fin = fopen( file, "r" );

	DaoxFont_ResetGlyphs( self );
	DString_Reset( self->buffer, 0 );

	if( fin == NULL ) return 0;

	DaoFile_ReadAll( fin, self->buffer, 1 );
	return DaoxFont_Init( self, self->buffer );
}
Exemplo n.º 2
0
int DaoStream_ReadStdin( DaoStream *self, DString *data, int count )
{
	DString_Reset( data, 0 );
	if( count >= 0 ){
		DString_Reset( data, count );
		DString_Reset( data, fread( data->chars, 1, count, stdin ) );
	}else if( count == -1 ){
		DaoFile_ReadLine( stdin, data );
	}else{
		DaoFile_ReadAll( stdin, data, 0 );
	}
	fseek( stdin, 0, SEEK_END );
	return data->size;
}
Exemplo n.º 3
0
static int DaoFileStream_Read( DaoStream *stream, DString *data, int count )
{
	DaoFileStream *self = (DaoFileStream*) stream;

	DString_Reset( data, 0 );
	if( DaoFileStream_AtEnd( stream ) ) return -1;
	if( count >= 0 ){
		DString_Reset( data, count );
		DString_Reset( data, fread( data->chars, 1, count, self->file ) );
	}else if( count == -1 ){
		DaoFile_ReadLine( self->file, data );
	}else{
		DaoFile_ReadAll( self->file, data, 0 );
	}
	return data->size;
}
Exemplo n.º 4
0
DAO_DLL int DaoOnLoad( DaoVmSpace *vmSpace, DaoNamespace *ns )
{
	FILE *fin = fopen( "test.xml", "r" );
	DString *xml = DString_New();
	DaoXmlDOM *dom = DaoXmlDOM_New();
	DaoXmlParser *parser = DaoXmlParser_New();
	DaoFile_ReadAll( fin, xml, 1 );

	DaoXmlParser_Parse( parser, dom, xml );

	DaoXmlDOM_Traverse( dom, NULL, NULL, DaoXmlNode_TestVisit );

	DString_Delete( xml );
	DaoXmlDOM_Delete( dom );
	DaoXmlParser_Delete( parser );
	return 0;
}