monit-dev
[Top][All Lists]
Advanced

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

RE: configuration patch - final version


From: Jan-Henrik Haukeland
Subject: RE: configuration patch - final version
Date: Tue, 11 Feb 2003 22:35:11 +0100

Elaborations (I'm on windows right now, and cannot try, this is more thinking
aloud)


Write:

  1) first write the timestamp:

  time_t now;

  fwrite(time(&now), 1, sizeof (time_t), binaryfile);

  2) Then the length of the process list

     int length= get_process_list_length();

  fwrite(length, 1, sizeof (int), binaryfile);

  2) Then the list:

  for(p= processlist; p; p= p->next)
        fwrite(p, 1, sizeof *(p), binaryfile);


Read:

1) Get state file timestamp

   time_t stamp;

   fread(now, 1, sizeof (time_t), binaryfile);

2) Get length

   int length;
   fread(length, 1, sizeof (int), binaryfile);

Process_T new;
Process_T temp= NEW(temp);

for(i=0; i<length; i++) {

 if(fread(temp, 1, sizeof *(temp), binaryfile) != sizeof *(temp))
   error_exit;
 }
 if((new= get_process(temp->name))
   copy temp.do_validate to new.do_validate;
}


Simple and effective (if it works that is :)


Jan-Henrik







reply via email to

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