/***************************************************************************
 *
 * Copyright (c) 2000, 2001 BalaBit IT Ltd, Budapest, Hungary
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: readline.h,v 1.9.4.3 2001/09/19 19:22:17 bazsi Exp $
 *
 ***************************************************************************/

#ifndef ZORP_READLINE_H_INCLUDED
#define ZORP_READLINE_H_INCLUDED

#include <zorp/zorp.h>
#include <zorp/stream.h>

typedef struct _ZReadLine ZReadLine;

#define ZRL_EOL_NL		0x00000001 /* end-of-line is indicated by nl */
#define ZRL_EOL_CRLF		0x00000002 /* end-of-line is indicated by crlf pair */
#define ZRL_EOL_FATAL		0x00000004 /* erroneous eol mark is fatal */
#define ZRL_NUL_NONFATAL        0x00000008 /* embedded NUL character is not fatal */

#define ZRL_TRUNCATE		0x00000010 /* truncate if line longer than buffer */
#define ZRL_SPLIT		0x00000020 /* split line if longer than buffer */
#define ZRL_SINGLE_READ		0x00000040 /* don't issue several read()s when fetching a line */

/* typedef void (*ZReadLineCallback)(ZReadLine *s, gpointer user_data); */

guint z_read_line_get_from_buf(ZReadLine *self, char **line, guint *length);
guint z_read_line_get(ZReadLine *s, char **line, guint *length);
guint z_read_line_get_copy(ZReadLine *s, char *line, guint *length);
void z_read_line_unget(ZReadLine *self, char *line, guint length);
gboolean z_read_line_has_unread_data(ZReadLine *self);
guint z_read_line_get_unread_data(ZReadLine *self, gchar *buf, guint buflen, guint *bytes_read);

/* void z_read_line_set_callback(ZReadLine *self, ZReadLineCallback cb, gpointer user_data); */

ZReadLine *z_read_line_new(ZStream *from, guint bufsize, guint flags);
void z_read_line_destroy(ZReadLine *self);

#endif
