//-----------------------------------------------------------------------------
// Copyright © 2003 - Philip Howard - All rights reserved
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//-----------------------------------------------------------------------------
// package	libh/daemon
// homepage	http://libh.slashusr.org/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 120 columns wide.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// file		daemon_lib.h
//
// purpose	Define resources used by the daemon library.
//-----------------------------------------------------------------------------
#ifndef __DAEMON_LIB_H__
#define __DAEMON_LIB_H__

//-----------------------------------------------------------------------------
// headers
//-----------------------------------------------------------------------------
#define _GNU_SOURCE

//------------------------------------------------
// Linux often returns ERESTARTSYS from accept()
// but won't define it without __KERNEL__ defined.
//------------------------------------------------
#include <alloca.h>

#define __KERNEL__
#include <errno.h>
#undef __KERNEL__

#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <poll.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include "libh_common.h"

#include <libh/daemon.h>
#include <libh/time.h>

//-----------------------------------------------------------------------------
// macros
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// macro	__FUNC_NAME__
//
// purpose	Declare the name of the current function.
//
// note		If the gcc compiler is a version that supports the __func__
//		symbol, this macro expands into an unused struct definition
//		allowing it to be placed before other variable definitions.
//		If the gcc compiler is a version that does not support the
//		__func__ symbol, this macro expands into a static const array
//		initialized with the string name of the function which can be
//		used in the same way as the C99 standard __func__ symbol.
//-----------------------------------------------------------------------------
#if __GNUC__>2 || ( __GNUC__==2 && __GNUC_MINOR__>91 )
#define __FUNC_NAME__(name) struct __dummy____FUNC_NAME__{int __dummy____FUNC_NAME__;}
#else
#define __FUNC_NAME__(name) static const char __func__[] = #name
#endif

//-----------------------------------------------------------------------------
// end header
//-----------------------------------------------------------------------------
#endif /* __DAEMON_LIB_H__ */

