/**
 * @file io.h Common NDO I/O functions
 */
/*
 * Copyright 2009-2014 Nagios Core Development Team and Community Contributors
 * Copyright 2005-2009 Ethan Galstad
 *
 * This file is part of NDOUtils.
 *
 * NDOUtils is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * NDOUtils 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 NDOUtils. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NDO_IO_H_INCLUDED
#define NDO_IO_H_INCLUDED

#include "config.h"


#define NDO_SINK_FILE         0
#define NDO_SINK_FD           1
#define NDO_SINK_UNIXSOCKET   2
#define NDO_SINK_TCPSOCKET    3

#define NDO_DEFAULT_TCP_PORT  @ndo2db_port@	/* default port to use */


/* MMAPFILE structure - used for reading files via mmap() */
typedef struct ndo_mmapfile_struct{
	char *path;
	int mode;
	int fd;
	unsigned long file_size;
	unsigned long current_position;
	unsigned long current_line;
	void *mmap_buf;
        }ndo_mmapfile;


ndo_mmapfile *ndo_mmap_fopen(char *);
int ndo_mmap_fclose(ndo_mmapfile *);
char *ndo_mmap_fgets(ndo_mmapfile *);

int ndo_sink_open(char *,int,int,int,int,int *);
int ndo_sink_write(int,char *,int);
int ndo_sink_write_newline(int);
int ndo_sink_flush(int);
int ndo_sink_close(int);
int ndo_inet_aton(register const char *,struct in_addr *);

void ndo_strip_buffer(char *);
char *ndo_escape_buffer(char *);
char *ndo_unescape_buffer(char *);

#endif
