Author: sandervanderburg
Date: Tue Oct 12 20:12:10 2010
New Revision: 24248
URL: https://svn.nixos.org/websvn/nix/?rev=24248&sc=1

Log:
Refactored --set operation into libinterface

Modified:
   disnix/disnix/trunk/src/activate/main.c
   disnix/disnix/trunk/src/libinterface/client-interface.c
   disnix/disnix/trunk/src/libinterface/client-interface.h

Modified: disnix/disnix/trunk/src/activate/main.c
==============================================================================
--- disnix/disnix/trunk/src/activate/main.c     Tue Oct 12 19:44:32 2010        
(r24247)
+++ disnix/disnix/trunk/src/activate/main.c     Tue Oct 12 20:12:10 2010        
(r24248)
@@ -258,24 +258,10 @@
                
        printf("Setting profile: %s on target: %s\n", item->profile, 
item->target);
        
-       status = fork();
+       status = wait_to_finish(exec_set(interface, item->target, profile, 
item->profile));
        
-       if(status == 0)
-       {
-           char *args[] = {interface, "--target", item->target, "--profile", 
profile, "--set", item->profile, NULL};
-           execvp(interface, args);
-           _exit(1);
-       }
-       
-       if(status == -1)
+       if(status != 0)
            return FALSE;
-       else
-       {
-           wait(&status);
-           
-           if(WEXITSTATUS(status) != 0)
-               return FALSE;
-       }
     }
 
     return TRUE;

Modified: disnix/disnix/trunk/src/libinterface/client-interface.c
==============================================================================
--- disnix/disnix/trunk/src/libinterface/client-interface.c     Tue Oct 12 
19:44:32 2010        (r24247)
+++ disnix/disnix/trunk/src/libinterface/client-interface.c     Tue Oct 12 
20:12:10 2010        (r24248)
@@ -127,6 +127,20 @@
        return pid;
 }
 
+pid_t exec_set(gchar *interface, gchar *target, gchar *profile, gchar 
*component)
+{
+    pid_t pid = fork();
+    
+    if(pid == 0)
+    {
+        char *args[] = {interface, "--target", target, "--profile", profile, 
"--set", component, NULL};
+        execvp(interface, args);
+        _exit(1);
+    }
+    else
+       return pid;
+}
+
 pid_t exec_query_installed(gchar *interface, gchar *target, gchar *profile)
 {
     pid_t pid = fork();

Modified: disnix/disnix/trunk/src/libinterface/client-interface.h
==============================================================================
--- disnix/disnix/trunk/src/libinterface/client-interface.h     Tue Oct 12 
19:44:32 2010        (r24247)
+++ disnix/disnix/trunk/src/libinterface/client-interface.h     Tue Oct 12 
20:12:10 2010        (r24248)
@@ -88,7 +88,17 @@
 pid_t exec_collect_garbage(gchar *interface, gchar *target, gboolean 
delete_old);
 
 /**
- * Queries the installed services operation through a Disnix client interface
+ * Invokes the set operation through a Disnix client interface
+ *
+ * @param interface Path to the interface executable
+ * @param target Target Address of the remote interface
+ * @param profile Identifier of the distributed profile
+ * @param component Component which becomes the contents of the profile
+ */
+pid_t exec_set(gchar *interface, gchar *target, gchar *profile, gchar 
*component);
+
+/**
+ * Invokes the the query installed operation through a Disnix client interface
  *
  * @param interface Path to the interface executable
  * @param target Target Address of the remote interface
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to