home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / xinetd / xinetd.2.0.6 / flags.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-22  |  1.8 KB  |  85 lines

  1. /*
  2.  * (c) Copyright 1992 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. static char RCSid[] = "$Id: flags.c,v 5.1 1992/11/01 00:01:21 panos Exp $" ;
  8.  
  9. #include "flags.h"
  10. #include "defs.h"
  11. #include "state.h"
  12.  
  13. /*
  14.  * Control flags
  15.  */
  16. #define CF_NONE                        0x0
  17. #define CF_RESTART                    0x1
  18. #define CF_NOENV                        0x2
  19.  
  20. struct flag_action
  21. {
  22.     int flag ;
  23.     voidfunc action ;
  24.     int control_flags ;
  25. } ;
  26.  
  27.  
  28. void soft_reconfig() ;
  29. void hard_reconfig() ;
  30. void dump_internal_state() ;
  31. void consistency_check() ;
  32. void child_exit() ;
  33. void server_retry() ;
  34. void quit_program() ;
  35. void terminate_program() ;
  36.  
  37.  
  38. static struct flag_action flag_actions[] =
  39. {
  40.     { SOFT_RECONFIG_FLAG,        soft_reconfig,                CF_RESTART + CF_NOENV },
  41.     { HARD_RECONFIG_FLAG,        hard_reconfig,                CF_RESTART + CF_NOENV },
  42.     { RETRY_FLAG,                    server_retry,                CF_RESTART                 },
  43.     { DUMP_FLAG,                    dump_internal_state,        CF_NONE                      },
  44.     { TERMINATE_FLAG,                terminate_program,        CF_NONE                     },
  45.     { CONSISTENCY_FLAG,            consistency_check,        CF_NONE                     },
  46.     { CHILD_FLAG,                    child_exit,                    CF_RESTART                 },
  47.     { QUIT_FLAG,                    quit_program,                CF_NONE                     },
  48.     { 0,                                0,                                0        }
  49. } ;
  50.  
  51.  
  52. int check_flags()
  53. {
  54.     bool_int restart_loop = FALSE ;
  55.     bool_int valid_env = ps.rws.env_is_valid ;
  56.  
  57.     while ( ! M_ARE_ALL_CLEAR( ps.flags ) )
  58.     {
  59.         register struct flag_action *fap ;
  60.  
  61.         for ( fap = flag_actions ; fap->flag != 0 ; fap++ )
  62.             if ( M_IS_SET( ps.flags, fap->flag ) )
  63.             {
  64.                 M_CLEAR( ps.flags, fap->flag ) ;
  65.  
  66.                 if ( fap->control_flags & CF_NOENV )
  67.                     ps.rws.env_is_valid = FALSE ;
  68.                 else
  69.                     ps.rws.env_is_valid = valid_env ;
  70.  
  71.                 (*fap->action)() ;
  72.  
  73.                 if ( ! restart_loop )
  74.                     restart_loop = ( fap->control_flags & CF_RESTART ) ;
  75.                 break ;
  76.             }
  77.     }
  78.  
  79.     ps.rws.env_is_valid = valid_env ;
  80.  
  81.     return( restart_loop ) ;
  82. }
  83.  
  84.  
  85.