Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

rcs_exit.cc File Reference

#include "rcs_exit.hh"
#include "rcs_defs.hh"
#include "linklist.hh"
#include "rcs_prnt.hh"
#include "timer.hh"
#include <stdlib.h>
#include <signal.h>

Include dependency graph for rcs_exit.cc:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  RCS_EXIT_LIST_ENTRY

Functions

int RCS_EXPORT attach_rcs_exit_list (void(*fptr)(int))
void RCS_EXPORT rcs_cleanup (int code)
void rcs_exit_signal_handler (int sig)
void RCS_EXPORT rcs_exit (int code)

Variables

RCS_LINKED_LISTexit_list = (RCS_LINKED_LIST *) NULL
int rcs_ready_for_exit = 0
int rcs_exit_sig = 0


Function Documentation

int RCS_EXPORT attach_rcs_exit_list void(*    fptr)(int)
 

Definition at line 56 of file rcs_exit.cc.

00058 {
00059   RCS_EXIT_LIST_ENTRY entry;
00060   if (NULL == exit_list)
00061     {
00062       exit_list = new RCS_LINKED_LIST;
00063     }
00064   if (NULL == exit_list)
00065     {
00066       rcs_print_error ("attach_rcs_exit_list:: Out of Memory.\n");
00067       return -1;
00068     }
00069   entry.process_id = 0;
00070   entry.fptr = fptr;
00071 #ifdef WINDOWS
00072   entry.process_id = ((long) GetCurrentProcessId ());
00073 #endif
00074 #ifdef VXWORKS
00075   entry.process_id = (long) taskIdSelf ();
00076 #endif
00077   return exit_list->store_at_tail (&entry, sizeof (entry), 1);
00078 }

void RCS_EXPORT rcs_cleanup int    code
 

Definition at line 81 of file rcs_exit.cc.

00082 {
00083   RCS_EXIT_LIST_ENTRY *entry;
00084   long process_id = 0;
00085 #ifdef WINDOWS
00086   process_id = ((long) GetCurrentProcessId ());
00087 #endif
00088 #ifdef VXWORKS
00089   process_id = (long) taskIdSelf ();
00090 #endif
00091 
00092   if (NULL == exit_list)
00093     {
00094       return;
00095     }
00096   entry = (RCS_EXIT_LIST_ENTRY *) exit_list->get_head ();
00097   while (NULL != entry)
00098     {
00099       if (entry->process_id == process_id && entry->fptr != NULL)
00100         {
00101           entry->fptr (code);
00102         }
00103       entry = (RCS_EXIT_LIST_ENTRY *) exit_list->get_next ();
00104     }
00105   if (exit_list->list_size == 0)
00106     {
00107       delete exit_list;
00108       exit_list = (RCS_LINKED_LIST *) NULL;
00109     }
00110 }

void rcs_exit_signal_handler int    sig [static]
 

Definition at line 115 of file rcs_exit.cc.

00116 {
00117   rcs_ready_for_exit = 1;
00118   rcs_exit_sig = sig;
00119 }

void RCS_EXPORT rcs_exit int    code
 

Definition at line 122 of file rcs_exit.cc.

00123 {
00124   rcs_cleanup (code);
00125 #ifdef UNDER_CE
00126   ExitThread (code);
00127 #else
00128 #ifndef VXWORKS
00129   if (code == -1)
00130     {
00131       rcs_print_error ("\n Errors Reported!!!\n Press ^C to exit.\n");
00132       signal (SIGINT, rcs_exit_signal_handler);
00133       int secs = 0;
00134       while (!rcs_ready_for_exit && secs < 600)
00135         {
00136           esleep (1.0);
00137           secs++;
00138         }
00139     }
00140 #endif
00141   exit (code);
00142 #endif
00143 }


Variable Documentation

RCS_LINKED_LIST* exit_list = (RCS_LINKED_LIST *) NULL [static]
 

Definition at line 39 of file rcs_exit.cc.

int rcs_ready_for_exit = 0 [static]
 

Definition at line 112 of file rcs_exit.cc.

int rcs_exit_sig = 0 [static]
 

Definition at line 113 of file rcs_exit.cc.


Generated on Sun Dec 2 15:57:48 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001