X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_properties.c;h=7a7010e7f07748bf8343d5e75f41032e48f00c9c;hb=23571c330fd1644833dcb73661ac987eda177200;hp=2664edd7df60c2b197f5177870e531c930163f76;hpb=23c2a612605501afef9f5c9029145958e6c7fbd8;p=melted diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index 2664edd..7a7010e 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -74,6 +74,45 @@ mlt_properties mlt_properties_new( ) return this; } +/** Load properties from a file. +*/ + +mlt_properties mlt_properties_load( char *filename ) +{ + // Construct a standalone properties object + mlt_properties this = mlt_properties_new( ); + + if ( this != NULL ) + { + // Open the file + FILE *file = fopen( filename, "r" ); + + // Load contents of file + if ( file != NULL ) + { + // Temp string + char temp[ 1024 ]; + + // Read each string from the file + while( fgets( temp, 1024, file ) ) + { + // Chomp the string + temp[ strlen( temp ) - 1 ] = '\0'; + + // Parse and set the property + if ( strcmp( temp, "" ) && temp[ 0 ] != '#' ) + mlt_properties_parse( this, temp ); + } + + // Close the file + fclose( file ); + } + } + + // Return the pointer + return this; +} + static inline int generate_hash( char *name ) { int hash = 0; @@ -91,7 +130,7 @@ static inline int generate_hash( char *name ) static inline void mlt_properties_do_mirror( mlt_properties this, char *name ) { property_list *list = this->private; - if ( list->mirror != NULL && strcmp( name, "in" ) && strcmp( name, "out" ) ) + if ( list->mirror != NULL ) { char *value = mlt_properties_get( this, name ); if ( value != NULL ) @@ -239,6 +278,14 @@ int mlt_properties_set( mlt_properties this, char *name, char *value ) return error; } +/** Set or default the property. +*/ + +int mlt_properties_set_or_default( mlt_properties this, char *name, char *value, char *def ) +{ + return mlt_properties_set( this, name, value == NULL ? def : value ); +} + /** Get a string value by name. */