[Initng-svn] r3633 - initng/trunk/plugins/ngc4

svn at initng.thinktux.net svn at initng.thinktux.net
Sun Apr 2 23:05:03 CEST 2006


Author: jimmy
Date: Sun Apr  2 23:05:02 2006
New Revision: 3633

Modified:
   initng/trunk/plugins/ngc4/ngc4.c
Log:
Add an --instant option, to add with ngc, to make int *not* to block.


Modified: initng/trunk/plugins/ngc4/ngc4.c
==============================================================================
--- initng/trunk/plugins/ngc4/ngc4.c	(original)
+++ initng/trunk/plugins/ngc4/ngc4.c	Sun Apr  2 23:05:02 2006
@@ -184,7 +184,7 @@
 }
 #endif
 
-static int send_and_handle(const char c, const char *l, const char *opt)
+static int send_and_handle(const char c, const char *l, const char *opt, int instant)
 {
     char *string = NULL;
     reply *rep = NULL;
@@ -215,6 +215,8 @@
 
 
 #ifdef HAVE_NGE
+    if(instant==FALSE)
+    {
     /*
      * there are special commands, where we wanna 
      * initziate nge, and follow the service.
@@ -223,8 +225,9 @@
     {
         return (start_or_stop_command(rep));
     }
+    }
 #endif
-
+    
     string = ngcclient_reply_to_string(rep, TRUE);
     printf("\n\n%s\n", string);
     free(string);
@@ -236,6 +239,7 @@
 int main(int argc, char *argv[])
 {
     int i;
+    int instant = FALSE;
     int cc = 1;
     char *Argv = NULL;
 
@@ -329,28 +333,28 @@
             {
                 /* check if is a string or char */
                 if (Argv[4])
-                    return (send_and_handle('\0', &Argv[3], argv[1]));
+                    return (send_and_handle('\0', &Argv[3], argv[1], instant));
                 else
-                    return (send_and_handle(Argv[3], NULL, argv[1]));
+                    return (send_and_handle(Argv[3], NULL, argv[1], instant));
             }
             else
             {
                 /* check if its a string or char */
                 if (Argv[3])
-                    return (send_and_handle('\0', &Argv[2], argv[1]));
+                    return (send_and_handle('\0', &Argv[2], argv[1], instant));
                 else
-                    return (send_and_handle(Argv[2], NULL, argv[1]));
+                    return (send_and_handle(Argv[2], NULL, argv[1], instant));
             }
         }
 
         /* else call standard */
-        return (send_and_handle('\0', Argv, argv[1]));
+        return (send_and_handle('\0', Argv, argv[1], instant));
     }
 
     /* make sure there are any arguments at all */
     if (argc <= 1)
     {
-        send_and_handle('h', NULL, NULL);
+        send_and_handle('h', NULL, NULL, instant);
         exit(0);
     }
 
@@ -362,14 +366,14 @@
         /* every fresh start needs a '-' char */
         if (argv[cc][0] != '-')
         {
-            send_and_handle('h', NULL, NULL);
+            send_and_handle('h', NULL, NULL, instant);
             exit(1);
         }
 
         /* check that there is a char after the '-' */
         if (!argv[cc][1])
         {
-            send_and_handle('h', NULL, NULL);
+            send_and_handle('h', NULL, NULL, instant);
             exit(1);
         }
 
@@ -381,12 +385,19 @@
         /* if it is an --option */
         if (argv[cc][1] == '-')
         {
-            if (!send_and_handle('\0', &argv[cc][2], opt))
+	    if(strcmp(&argv[cc][2], "instant")==0)
+	    {
+		instant=TRUE;
+		cc++;
+		continue;
+	    }
+	
+            if (!send_and_handle('\0', &argv[cc][2], opt, instant))
                 exit(1);
         }
         else
         {
-            if (!send_and_handle(argv[cc][1], NULL, opt))
+            if (!send_and_handle(argv[cc][1], NULL, opt, instant))
                 exit(1);
         }
 


More information about the Initng-svn mailing list