monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: monit control.c


From: Jan-Henrik Haukeland
Subject: RE: monit control.c
Date: Wed, 9 Oct 2002 02:03:42 +0200

> Modified files:
>       .              : control.c
>
> Log message:
>       Tidy up a bit. Create a function that tests and returns stop/start
>       script.

+/*
+ * Return a pointer to start/stop Command_T object
+ * @param p A Process T object @param action A start/stop action
+ */
+Command_T check_script(Process_T p, char *action) {
+
+  Command_T c = NULL;
+
+  if(is(action, "start")) {
+    c= p->start;
+  }
+  else if(is(action, "stop")) {
+    c= p->stop;
+  }
+
+  return c;
+
 }

This will not work, you cannot return a object from a function unless it's
allocated. A better solution could be something like (untested):

int has_script(Process_T p char *action) {

 if((is(action, "start") && p->start)||(is(action, "stop") && p->stop))
   return TRUE;
 return FALSE;

}

Jan-Henrik





reply via email to

[Prev in Thread] Current Thread [Next in Thread]