home *** CD-ROM | disk | FTP | other *** search
- /*
- * (c) Copyright 1992 by Panagiotis Tsirigotis
- * All rights reserved. The file named COPYRIGHT specifies the terms
- * and conditions for redistribution.
- */
-
- #ifndef SERVICE_H
- #define SERVICE_H
-
- /*
- * $Id: service.h,v 5.1 1992/10/31 23:59:07 panos Exp $
- */
-
- #ifndef NO_POSIX_TYPES
- #include <sys/types.h> /* for pid_t */
- #else
- typedef int pid_t ;
- #endif
-
- #include "xlog.h"
-
- #include "defs.h"
- #include "sconf.h"
- #include "builtin.h"
-
-
- /*
- * This struct holds data for an active service
- *
- * There are 3 function pointers:
- *
- * post_mortem: invoked when a server exits
- * shutdown: invoked to playback the protocol and get information
- * from the other end. It also sets up the connection
- * for an orderly close.
- */
- struct service_data
- {
- int service_fd ;
- unsigned running_servers ;
- unsigned retry_servers ;
- unsigned attempts ; /* # of attempts to start a server */
- time_t start_time ; /* since this time */
- voidfunc postmortem ; /* ARGS: struct server * */
- voidfunc shutdown ; /* ARGS: int sd, char **msgp */
- status_e (*handler)() ; /* ARGS: service *, connection * */
- pset_h no_access ;
- pset_h only_from ;
- xlog_h log_handle ;
- } ;
-
-
- /*
- * NOTE: A service can be disabled but not deleted if it has any servers
- * running
- */
- typedef enum /* service states */
- {
- SVC_NOT_STARTED = 0, /* no attempt to start it yet */
- SVC_ACTIVE, /* service is available */
- SVC_SUSPENDED, /* service is suspended */
- SVC_DISABLED /* service disabled */
- } state_e ;
-
-
-
- /*
- * NOTE: Clearing the structure will give all its fields their default values
- */
- struct service
- {
- state_e state ;
- int ref_count ; /* number of pointers to this service */
- struct builtin_service *builtin ;
- struct service_config conf ;
- struct service_data sd ;
- } ;
-
- #define IS_ACTIVE( sp ) ( (sp)->state == SVC_ACTIVE )
- #define IS_SUSPENDED( sp ) ( (sp)->state == SVC_SUSPENDED )
- #define IS_AVAILABLE( sp ) ( IS_ACTIVE( sp ) || IS_SUSPENDED( sp ) )
-
- #define SVC_HOLD( sp ) (sp)->ref_count++
- #define SVC_RELE( sp ) \
- ( ( (sp)->ref_count <= 1 ) ? svc_release( sp ) : --(sp)->ref_count )
-
- #define SP( p ) ( (struct service *) (p) )
-
- #define CONF( sp ) ( &(sp)->conf )
- #define SDATA( sp ) ( &(sp)->sd )
- #define SVC_FORKS( sp ) ( ! IS_INTERNAL( CONF( sp ) ) || \
- (sp)->builtin->fork_server == YES )
- #define SVC_IS_LOGGING( sp ) ( SDATA( sp )->log_handle )
- #define SVC_FD( sp ) ( SDATA( sp )->service_fd )
- #define SVC_RETRY( sp ) ( M_IS_CLEAR( CONF(sp)->flags, SF_NORETRY ) )
- #define SVC_HANDLE( sp, cp ) (*SDATA( sp )->handler)( sp, cp )
-
- #define INTERCEPT_SERVICE_NAME "intercept"
-
- status_e svc_init() ;
- struct service *svc_new() ;
- struct service *svc_alloc() ;
- void svc_free() ;
- status_e svc_activate() ;
- void svc_setup_address_control() ;
- void svc_deactivate() ;
- void svc_suspend() ;
- void svc_resume() ;
- int svc_release() ;
- void svc_dump() ;
- void svc_request() ;
- status_e svc_access_control() ;
- void svc_shutdown() ;
-
- #endif /* SERVICE_H */
-