Improved push capabilities
[melted] / src / valerie / valerie.c
index 8499f44..c76112d 100644 (file)
@@ -148,6 +148,37 @@ valerie_error_code valerie_execute( valerie this, size_t size, char *format, ...
 /** Execute a command.
 */
 
+valerie_error_code valerie_receive( valerie this, char *doc, size_t size, char *format, ... )
+{
+       valerie_error_code error = valerie_server_unavailable;
+       char *command = malloc( size );
+       if ( this != NULL && command != NULL )
+       {
+               va_list list;
+               va_start( list, format );
+               if ( vsnprintf( command, size, format, list ) != 0 )
+               {
+                       valerie_response response = valerie_parser_received( this->parser, command, doc );
+                       valerie_set_last_response( this, response );
+                       error = valerie_get_error_code( this, response );
+               }
+               else
+               {
+                       error = valerie_invalid_command;
+               }
+               va_end( list );
+       }
+       else
+       {
+               error = valerie_malloc_failed;
+       }
+       free( command );
+       return error;
+}
+
+/** Execute a command.
+*/
+
 valerie_error_code valerie_push( valerie this, mlt_service service, size_t size, char *format, ... )
 {
        valerie_error_code error = valerie_server_unavailable;
@@ -286,6 +317,14 @@ valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int3
 /** Push a service on to a unit.
 */
 
+valerie_error_code valerie_unit_receive( valerie this, int unit, char *command, char *doc )
+{
+       return valerie_receive( this, doc, 10240, "PUSH U%d %s", unit, command );
+}
+
+/** Push a service on to a unit.
+*/
+
 valerie_error_code valerie_unit_push( valerie this, int unit, char *command, mlt_service service )
 {
        return valerie_push( this, service, 10240, "PUSH U%d %s", unit, command );