/*
* ----------------------------------------------------------------
* Night Light File Descriptor Debugging Functions Header
* ----------------------------------------------------------------
* Copyright (C) 2003-2007 Jonas Kvinge <jonas@night-light.net>
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Last modified by:
* Jonas Kvinge (02.07.2003)
*
*/
#ifdef FDCALLS_H
#warning "fdcalls.h already included."
#else
#define FDCALLS_H
struct sockaddr;
#if !FDDEBUG
#error "fdcalls.h included, but FDDEBUG not defined TRUE."
#endif
#define FDPTRZSTRLEN 10
#define FDBYTESTRLEN 4
#define FDFILESTRLEN 16
#define FDLINESTRLEN 4
#define FDTIMESTRLEN 10
#define FD_PRINT FALSE
#define SOCKET_PRINT FALSE
#ifndef FDCALLS_C
#define SOCKET_REDEFINE
#undef fopen
#undef fclose
#undef socket
#undef close
#undef accept
#define fopen(p, m) openfd(__FILE__, __LINE__, __FUNCTION__, (p), (m))
#define fclose(s) closefd(__FILE__, __LINE__, __FUNCTION__, (s))
#define socket(d, t, p) opensock(__FILE__, __LINE__, __FUNCTION__, (d), (t), (p))
#define close(s) closesock(__FILE__, __LINE__, __FUNCTION__, (s))
#define accept(s, a, l) acceptsock(__FILE__, __LINE__, __FUNCTION__, s, a, l);
#endif
#ifndef accept_addrlen_type
#if OS_BSD || OS_LINUX || OS_WIN32 || WIN32
#define accept_addrlen_type socklen_t
#define getsockopt_optlen_type socklen_t
#define getsockname_namelen_type socklen_t
#define getpeername_namelen_type socklen_t
#elif OS_SOLARIS
#define accept_addrlen_type socklen_t
#define getsockopt_optlen_type int
#define getsockname_namelen_type socklen_t
#define getpeername_namelen_type socklen_t
#elif OS_AIX
#define accept_addrlen_type int
#define getsockopt_optlen_type int
#define getsockname_namelen_type socklen_t
#define getpeername_namelen_type socklen_t
#elif OS_HPUNIX
#define accept_addrlen_type socklen_t
#define getsockopt_optlen_type socklen_t
#define getsockname_namelen_type socklen_t
#define getpeername_namelen_type socklen_t
#elif OS_OSF1
#define accept_addrlen_type int
#define getsockopt_optlen_type int
#define getsockname_namelen_type int
#define getpeername_namelen_type int
#else
#define accept_addrlen_type socklen_t
#define getsockopt_optlen_type socklen_t
#define getsockname_namelen_type socklen_t
#define getpeername_namelen_type socklen_t
#endif
#endif
/* STRUCTURES - JONAS (21.06.2003) */
struct FDTable_Struct {
FILE *FD;
const char *File;
unsigned short int Line;
const char *Function;
char *Path;
char *Mode;
time_t Time;
struct FDTable_Struct *Prev;
struct FDTable_Struct *Next;
};
struct SockTable_Struct {
signed long int Socket;
const char *File;
unsigned short int Line;
const char *Function;
time_t Time;
struct SockTable_Struct *Prev;
struct SockTable_Struct *Next;
};
/* FUNCTION PROTOTYPES - JONAS (01.07.2003) */
void fdtable_add(FILE *FD, const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, const char *const PathPT, const char *const ModePT);
void fdtable_rem(struct FDTable_Struct *FDTableS);
struct FDTable_Struct *fdtable_get(const FILE *const FD);
void fdtable_clear(void);
FILE *openfd(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, const char *const PathPT, const char *const ModePT);
signed short int closefd(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, FILE *FD);
void socktable_add(signed long int Socket, const char *const FilePT, const unsigned short int Line, const char *const FunctionPT);
void socktable_rem(struct SockTable_Struct *SockTableS);
struct SockTable_Struct *socktable_get(signed long int Socket);
void socktable_clear(void);
#if NEED_SYS_SOCKET_H
signed short int opensock(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, signed short int Domain, signed short int Type, signed short int Protocol);
signed short int acceptsock(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, signed short int ListenSocket, struct sockaddr *SockAddr, accept_addrlen_type *SockAddrLen);
#endif
#if NEED_UNISTD_H
signed short int closesock(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, signed short int Socket);
#endif
void fd_print(void);
#endif
syntax highlighted by Code2HTML, v. 0.9.1