bitz-server  1.0.0
bitz-server.h
1 /*
2  * bitz-server, An ICAP server implementation in C++
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef BITZ_SERVER_H
21 #define BITZ_SERVER_H
22 
23 #include "bitz/manager.h"
24 
25 #include <csignal>
26 
27 
28 namespace bitz {
29 
30  namespace server {
31 
36  struct server_t {
37  int pid_handle;
38  volatile sig_atomic_t terminating;
39  bool daemon;
40 
41  bitz::Manager * manager;
42  };
43 
47  struct options_t {
48  int debug_flag;
49  std::string config_file;
50  };
51 
52  void init();
53  void init_signal_handlers();
54  void init_sigchld_handler();
55  void init_sigterm_handler();
56  void init_sigquit_handler();
57  void init_sigint_handler();
58  void sigchld_handler( int sig, siginfo_t * sig_info, void * context );
59  void sigterm_handler( int sig, siginfo_t * sig_info, void * context );
60  void sigquit_handler( int sig, siginfo_t * sig_info, void * context );
61  void sigint_handler( int sig, siginfo_t * sig_info, void * context );
62 
63  void daemonize( const char * run_dir, const char * pid_file );
64  void shutdown();
65  void termination_handler( int sig, siginfo_t * sig_info, void * context );
66 
79  options_t read_options( int argc, char **argv );
80 
84  void print_version();
85 
89  void print_usage();
90 
100  void start( int port, unsigned int children, int max_requests, int comm_timeout );
101 
107  void run();
108 
109  } /* end of namespace server */
110 
111 } /* end of namespace bitz */
112 
113 #endif /* !BITZ_SERVER_H */
114 
Definition: echo.cpp:23
Definition: bitz-server.h:36
Definition: manager.h:40
Definition: bitz-server.h:47