home *** CD-ROM | disk | FTP | other *** search
/ Programming with VisualAge for Java / IBMVJAVA.ISO / icswinnt / httpdw32.z / daemon.h < prev    next >
C/C++ Source or Header  |  1997-03-12  |  3KB  |  119 lines

  1. /*
  2.  * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
  3.  * rights reserved.
  4.  *
  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.  */
  9.  
  10.  
  11. /* ------------------------------------------------------------------------ */
  12.  
  13.  
  14. /*
  15.  * daemon.h: Things related to the accepting connections
  16.  *
  17.  * Rob McCoolie
  18.  */
  19.  
  20.  
  21. #ifndef DAEMON_H
  22. #define DAEMON_H
  23.  
  24. #ifdef XP_WIN32
  25. #include <nt/ntdaemon.h>
  26. #else
  27.  
  28. #include "net.h"
  29. #include "session.h"
  30.  
  31. #include <pwd.h>    /* struct passwd */
  32.  
  33.  
  34. /* ------------------------------- Defines -------------------------------- */
  35.  
  36.  
  37. #define child_exit exit
  38.  
  39.  
  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
  47.  
  48.  
  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;
  68.  
  69.  
  70. /* ------------------------------ Prototypes ------------------------------ */
  71.  
  72. #ifdef MCC_PROXY
  73. /* A unique serial number assigned to each child. */
  74. extern int child_serial;
  75. #endif
  76.  
  77. /*
  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.
  82.  *
  83.  * child_callback is a function which will be called every time a new
  84.  * connection is recieved. Session is a new session ID.
  85.  *
  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.
  89.  *
  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.
  93.  */
  94.  
  95. void daemon_run(int det, void (*child_callback)(Session *), daemon_s *d);
  96.  
  97. /*
  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.
  101.  */
  102.  
  103. pid_t child_fork(void);
  104.  
  105.  
  106. /*
  107.  * Set status to the given code for statistics reporting
  108.  */
  109.  
  110. #ifdef DAEMON_STATS
  111. void child_status(int code);
  112. #else
  113. #define child_status(code) (void)(code)
  114. #endif
  115.  
  116.  
  117. #endif
  118. #endif
  119.