Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / base / daemon.h
blobaeb93a43ffac057ca51e0c88be73a1e50b22b256
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * daemon.h: Things related to the accepting connections
17 * Rob McCool
21 #ifndef DAEMON_H
22 #define DAEMON_H
24 #ifdef XP_WIN32
25 #include <nt/ntdaemon.h>
26 #else
28 #include "net.h"
29 #include "session.h"
31 #include <pwd.h> /* struct passwd */
34 /* ------------------------------- Defines -------------------------------- */
37 #define child_exit exit
40 /* Codes for child_status */
41 #define CHILD_EMPTY_SLOT 0xfe
42 #define CHILD_AWAIT_CONNECT 0xff
43 #define CHILD_PROCESSING 0x00
44 #define CHILD_READING 0x01
45 #define CHILD_WRITING 0x02
46 #define CHILD_RESOLVING 0x03
49 typedef struct {
50 char *ipstr;
51 int port;
52 struct passwd *pw;
53 char *chr;
54 char *pidfn;
55 void (*rcback)(int);
56 #if defined(DAEMON_UNIX_POOL) || defined(DAEMON_UNIX_MOBRULE)
57 int maxprocs, minprocs, proclife;
58 #endif
59 #ifdef NET_SSL
60 char *secure_keyfn;
61 char *secure_certfn;
62 char *secure_dongle;
63 int secure_auth;
64 int secure_session_timeout;
65 int security;
66 #endif
67 } daemon_s;
70 /* ------------------------------ Prototypes ------------------------------ */
72 #ifdef MCC_PROXY
73 /* A unique serial number assigned to each child. */
74 extern int child_serial;
75 #endif
78 * daemon_run accepts whether or not it should detach from its parent process,
79 * and a daemon structure as its arguments. The daemon structure contains
80 * a port number, a root directory to chroot to (can be NULL), a filename to
81 * log the daemon pid to (can be NULL). daemon_run never returns.
83 * child_callback is a function which will be called every time a new
84 * connection is received. Session is a new session ID.
86 * rcback is a function which is a restart function: When SIGHUP is received,
87 * this function will be called. You may give SIG_DFL if you don't want to
88 * support restarting. The rcback will be passed SIGHUP.
90 * pw is the passwd entry to run the daemon as. If the effective user id is
91 * root, daemon_run will try to set its uid and gid to the user pointed
92 * to by this structure. You may pass NULL.
95 void daemon_run(int det, void (*child_callback)(Session *), daemon_s *d);
98 * fork is a wrapper for the system's fork function. This closes the listen
99 * socket for the mob. This also makes sure that a threaded daemon only gets
100 * the calling thread and not all of them.
103 pid_t child_fork();
107 * Set status to the given code for statistics reporting
110 #ifdef DAEMON_STATS
111 void child_status(int code);
112 #else
113 #define child_status(code) (void)(code)
114 #endif
117 #endif
118 #endif