⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daemon.h

📁 一个开源的网络开发库ACE
💻 H
字号:
/*
 * daemon.h,v 1.3 2000/06/04 22:00:03 brunsch Exp
 *
 * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
 * rights reserved.
 *
 * Use of this software is governed by the terms of the license agreement for
 * the Netscape Communications or Netscape Comemrce Server between the
 * parties.
 */


/* ------------------------------------------------------------------------ */


/*
 * daemon.h: Things related to the accepting connections
 *
 * Rob McCool
 */


#ifndef DAEMON_H
#define DAEMON_H

#ifdef XP_WIN32
#include <nt/ntdaemon.h>
#else

#include "net.h"
#include "session.h"

#include <pwd.h>    /* struct passwd */


/* ------------------------------- Defines -------------------------------- */


#define child_exit exit


/* Codes for child_status */
#define CHILD_EMPTY_SLOT 0xfe
#define CHILD_AWAIT_CONNECT 0xff
#define CHILD_PROCESSING 0x00
#define CHILD_READING 0x01
#define CHILD_WRITING 0x02
#define CHILD_RESOLVING 0x03


typedef struct {
    char *ipstr;
    int port;
    struct passwd *pw;
    char *chr;
    char *pidfn;
    void (*rcback)(int);
#if defined(DAEMON_UNIX_POOL) || defined(DAEMON_UNIX_MOBRULE)
    int maxprocs, minprocs, proclife;
#endif
#ifdef NET_SSL
    char *secure_keyfn;
    char *secure_certfn;
    char *secure_dongle;
    int secure_auth;
    int secure_session_timeout;
    int security;
#endif
} daemon_s;


/* ------------------------------ Prototypes ------------------------------ */

#ifdef MCC_PROXY
/* A unique serial number assigned to each child. */
extern int child_serial;
#endif

/*
 * daemon_run accepts whether or not it should detach from its parent process,
 * and a daemon structure as its arguments. The daemon structure contains
 * a port number, a root directory to chroot to (can be NULL), a filename to
 * log the daemon pid to (can be NULL). daemon_run never returns.
 *
 * child_callback is a function which will be called every time a new
 * connection is recieved. Session is a new session ID.
 *
 * rcback is a function which is a restart function: When SIGHUP is received,
 * this function will be called. You may give SIG_DFL if you don't want to
 * support restarting. The rcback will be passed SIGHUP.
 *
 * pw is the passwd entry to run the daemon as. If the effective user id is
 * root, daemon_run will try to set its uid and gid to the user pointed
 * to by this structure. You may pass NULL.
 */

void daemon_run(int det, void (*child_callback)(Session *), daemon_s *d);

/*
 * fork is a wrapper for the system's fork function. This closes the listen
 * socket for the mob. This also makes sure that a threaded daemon only gets
 * the calling thread and not all of them.
 */

pid_t child_fork(void);


/*
 * Set status to the given code for statistics reporting
 */

#ifdef DAEMON_STATS
void child_status(int code);
#else
#define child_status(code) (void)(code)
#endif


#endif
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -