/*
* 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 Library 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.
*/
#ifndef _NETWORKLIB_
#define _NETWORKLIB_
#ifndef BUF_SIZE
#define BUF_SIZE 1024
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
#if defined __Linux__
#ifndef USE_UNIX_SOCKET
#define USE_UNIX_SOCKET
#endif
#endif
#if defined __FreeBSD__
#ifndef USE_UNIX_SOCKET
#define USE_UNIX_SOCKET
#endif
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stddef.h>
#include "wrapper.h"
/* -----------------------------------------------------------------------------
* I/O Functions
* -------------------------------------------------------------------------- */
int string2int(const char *);
int read_buffer(int, void *, int);
int write_buffer(int, const void *, int);
int xsend(int, int, const char *, ...);
int readline(int, char *, int);
int copy(int, int, unsigned long);
/* -----------------------------------------------------------------------------
* DNS Functions
* -------------------------------------------------------------------------- */
char * getfqdn(const char *);
char * getmyfqdn(void);
char *get_host(const char *);
char *get_ip(const char *);
/* -----------------------------------------------------------------------------
* Network tool functions
* -------------------------------------------------------------------------- */
int isipv4(const char *ip);
unsigned int sockaddr_localinfo(int, struct sockaddr_in *);
short getlocalport(int);
char *getlocaladdr(int);
unsigned int sockaddr_peerinfo(int, struct sockaddr_in *);
short getforeignport(int);
char *getforeignaddr(int);
/* -----------------------------------------------------------------------------
* Network init functions
* -------------------------------------------------------------------------- */
void socketaddr_init(struct sockaddr_in *);
int socketaddr_service(struct sockaddr_in *, const char *, const char *);
int socketaddr_host(struct sockaddr_in *, const char *);
int resolveproto(const char *);
int prototype(const char *);
#ifdef USE_UNIX_SOCKET
int create_unix_socket (const char *);
#endif
int open_unix_fd(const char *);
int client_connect(const char *, const char *, const char *);
int server_init(const char *, const char *);
#endif
syntax highlighted by Code2HTML, v. 0.9.1