Add to git.
[pthrlib.git] / doc / pthr_server_main_loop.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>pthr_server_main_loop</title>
6 </head>
7 <body>
8
9 <h1 align=center>pthr_server_main_loop</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#AUTHOR">AUTHOR</a><br>
14 <a href="#LICENSE">LICENSE</a><br>
15 <a href="#VERSION">VERSION</a><br>
16
17 <hr>
18 <!-- Creator     : groff version 1.17.2 -->
19 <!-- CreationDate: Fri Aug 30 16:16:42 2002 -->
20 <a name="NAME"></a>
21 <h2>NAME</h2>
22 <table width="100%" border=0 rules="none" frame="void"
23        cols="2" cellspacing="0" cellpadding="0">
24 <tr valign="top" align="left">
25 <td width="10%"></td><td width="90%">
26 pthr_server_main_loop, pthr_server_default_port, pthr_server_port_option_name, pthr_server_disable_syslog, pthr_server_package_name, pthr_server_disable_fork, pthr_server_disable_chdir, pthr_server_disable_close, pthr_server_chroot, pthr_server_username, pthr_server_stderr_file, pthr_server_startup_fn - Enter server main loop.</td></table>
27 <a name="SYNOPSIS"></a>
28 <h2>SYNOPSIS</h2>
29
30 <table width="100%" border=0 rules="none" frame="void"
31        cols="2" cellspacing="0" cellpadding="0">
32 <tr valign="top" align="left">
33 <td width="10%"></td><td width="90%">
34 <pre><b>#include &lt;pthr_server.h&gt;
35
36 void pthr_server_main_loop (int argc, char *argv[], void (*processor_fn) (int sock, void *));
37 void pthr_server_default_port (int default_port);
38 void pthr_server_port_option_name (char port_option_name);
39 void pthr_server_disable_syslog (void);
40 void pthr_server_package_name (const char *package_name);
41 void pthr_server_disable_fork (void);
42 void pthr_server_disable_chdir (void);
43 void pthr_server_disable_close (void);
44 void pthr_server_chroot (const char *root);
45 void pthr_server_username (const char *username);
46 void pthr_server_stderr_file (const char *pathname);
47 void pthr_server_startup_fn (void (*startup_fn) (int argc, char *argv[]));
48 </b></pre></td></table>
49 <a name="DESCRIPTION"></a>
50 <h2>DESCRIPTION</h2>
51
52 <table width="100%" border=0 rules="none" frame="void"
53        cols="2" cellspacing="0" cellpadding="0">
54 <tr valign="top" align="left">
55 <td width="10%"></td><td width="90%">
56 The function <b>pthr_server_main_loop</b> is a helper
57 function which allows you to write very simple servers
58 quickly using <b>pthrlib</b>. Normally your <b>main</b>
59 should just contain a call to <b>pthr_server_main_loop
60 (argc, argv, processor)</b> and you would include a function
61 called <b>processor</b> which is called on every
62 connection.</td></table>
63
64 <table width="100%" border=0 rules="none" frame="void"
65        cols="2" cellspacing="0" cellpadding="0">
66 <tr valign="top" align="left">
67 <td width="10%"></td><td width="90%">
68 The other functions allow you to customise the behaviour of
69 <b>pthr_server_main_loop</b>. You should call any of these
70 once in your <b>main</b> before calling
71 <b>pthr_server_main_loop</b>.</td></table>
72
73 <table width="100%" border=0 rules="none" frame="void"
74        cols="2" cellspacing="0" cellpadding="0">
75 <tr valign="top" align="left">
76 <td width="10%"></td><td width="90%">
77 By default the server listens on port 80 and allows you to
78 override this on the command line using the <b>-p</b>
79 option. To change this, call <b>pthr_server_default_port</b>
80 and/or <b>pthr_server_port_option_name</b>.</td></table>
81
82 <table width="100%" border=0 rules="none" frame="void"
83        cols="2" cellspacing="0" cellpadding="0">
84 <tr valign="top" align="left">
85 <td width="10%"></td><td width="90%">
86 By default the server writes package and version information
87 to syslog (although it will not be able to correctly
88 determine the package). Use
89 <b>pthr_server_disable_syslog</b> to disable syslogging
90 entirely, or <b>pthr_server_package_name</b> to change the
91 name displayed in the logs.</td></table>
92
93 <table width="100%" border=0 rules="none" frame="void"
94        cols="2" cellspacing="0" cellpadding="0">
95 <tr valign="top" align="left">
96 <td width="10%"></td><td width="90%">
97 By default the server forks into the background, changes to
98 the root directory and disconnects entirely from the
99 terminal. Use <b>pthr_server_disable_fork</b>,
100 <b>pthr_server_disable_chdir</b> and
101 <b>pthr_server_disable_close</b> to change these
102 respectively.</td></table>
103
104 <table width="100%" border=0 rules="none" frame="void"
105        cols="2" cellspacing="0" cellpadding="0">
106 <tr valign="top" align="left">
107 <td width="10%"></td><td width="90%">
108 If you wish to have the server chroot after start up, then
109 call <b>pthr_server_chroot</b>. This is only possible if the
110 server is run as root, otherwise the chroot is silently
111 ignored.</td></table>
112
113 <table width="100%" border=0 rules="none" frame="void"
114        cols="2" cellspacing="0" cellpadding="0">
115 <tr valign="top" align="left">
116 <td width="10%"></td><td width="90%">
117 If you wish to have the server change user and group after
118 start up, then call <b>pthr_server_username</b> (the group
119 is taken from the password file and <b>initgroups(3)</b> is
120 also called). This is only possible if the server is run as
121 root, otherwise the change user is silently
122 ignored.</td></table>
123
124 <table width="100%" border=0 rules="none" frame="void"
125        cols="2" cellspacing="0" cellpadding="0">
126 <tr valign="top" align="left">
127 <td width="10%"></td><td width="90%">
128 If you wish to have <b>stderr</b> connected to a file (this
129 is done after changing user, so make sure the file is
130 accessible or owned by the user, not by root), then call
131 <b>pthr_server_stderr_file</b>. Note that unless you call
132 this function or <b>pthr_server_disable_close</b> then
133 <b>stderr</b> is sent to <b>/dev/null</b>!</td></table>
134
135 <table width="100%" border=0 rules="none" frame="void"
136        cols="2" cellspacing="0" cellpadding="0">
137 <tr valign="top" align="left">
138 <td width="10%"></td><td width="90%">
139 The <b>startup_fn</b> is called after all of the above
140 operations have completed, but before the listener thread is
141 created. You do miscellaneous start-of-day functions from
142 here, in particular starting up other global threads. The
143 command line arguments are also passed to this
144 function.</td></table>
145 <a name="AUTHOR"></a>
146 <h2>AUTHOR</h2>
147
148 <table width="100%" border=0 rules="none" frame="void"
149        cols="2" cellspacing="0" cellpadding="0">
150 <tr valign="top" align="left">
151 <td width="10%"></td><td width="90%">
152 Richard Jones &lt;rich@annexia.org&gt;</td></table>
153 <a name="LICENSE"></a>
154 <h2>LICENSE</h2>
155
156 <table width="100%" border=0 rules="none" frame="void"
157        cols="2" cellspacing="0" cellpadding="0">
158 <tr valign="top" align="left">
159 <td width="10%"></td><td width="90%">
160 GNU LGPL (see http://www.gnu.org/)</td></table>
161 <a name="VERSION"></a>
162 <h2>VERSION</h2>
163
164 <table width="100%" border=0 rules="none" frame="void"
165        cols="2" cellspacing="0" cellpadding="0">
166 <tr valign="top" align="left">
167 <td width="10%"></td><td width="90%">
168 pthrlib-3.0.3</td></table>
169 <hr>
170 </body>
171 </html>